babylon.module.d.ts 6.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496
  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. private _blendMode;
  10216. /**
  10217. * Blend mode use to render the particle, it can be any of
  10218. * the static Constants.ALPHA_x properties provided in this class.
  10219. * Default value is Constants.ALPHA_COMBINE
  10220. */
  10221. get blendMode(): number;
  10222. set blendMode(blendMode: number);
  10223. /**
  10224. * Creates a new sprite manager
  10225. * @param name defines the manager's name
  10226. * @param imgUrl defines the sprite sheet url
  10227. * @param capacity defines the maximum allowed number of sprites
  10228. * @param cellSize defines the size of a sprite cell
  10229. * @param scene defines the hosting scene
  10230. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10231. * @param samplingMode defines the smapling mode to use with spritesheet
  10232. * @param fromPacked set to false; do not alter
  10233. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10234. */
  10235. constructor(
  10236. /** defines the manager's name */
  10237. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10238. private _makePacked;
  10239. private _appendSpriteVertex;
  10240. /**
  10241. * Intersects the sprites with a ray
  10242. * @param ray defines the ray to intersect with
  10243. * @param camera defines the current active camera
  10244. * @param predicate defines a predicate used to select candidate sprites
  10245. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10246. * @returns null if no hit or a PickingInfo
  10247. */
  10248. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10249. /**
  10250. * Intersects the sprites with a ray
  10251. * @param ray defines the ray to intersect with
  10252. * @param camera defines the current active camera
  10253. * @param predicate defines a predicate used to select candidate sprites
  10254. * @returns null if no hit or a PickingInfo array
  10255. */
  10256. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10257. /**
  10258. * Render all child sprites
  10259. */
  10260. render(): void;
  10261. /**
  10262. * Release associated resources
  10263. */
  10264. dispose(): void;
  10265. }
  10266. }
  10267. declare module "babylonjs/Misc/gradients" {
  10268. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  10269. /** Interface used by value gradients (color, factor, ...) */
  10270. export interface IValueGradient {
  10271. /**
  10272. * Gets or sets the gradient value (between 0 and 1)
  10273. */
  10274. gradient: number;
  10275. }
  10276. /** Class used to store color4 gradient */
  10277. export class ColorGradient implements IValueGradient {
  10278. /**
  10279. * Gets or sets the gradient value (between 0 and 1)
  10280. */
  10281. gradient: number;
  10282. /**
  10283. * Gets or sets first associated color
  10284. */
  10285. color1: Color4;
  10286. /**
  10287. * Gets or sets second associated color
  10288. */
  10289. color2?: Color4;
  10290. /**
  10291. * Will get a color picked randomly between color1 and color2.
  10292. * If color2 is undefined then color1 will be used
  10293. * @param result defines the target Color4 to store the result in
  10294. */
  10295. getColorToRef(result: Color4): void;
  10296. }
  10297. /** Class used to store color 3 gradient */
  10298. export class Color3Gradient implements IValueGradient {
  10299. /**
  10300. * Gets or sets the gradient value (between 0 and 1)
  10301. */
  10302. gradient: number;
  10303. /**
  10304. * Gets or sets the associated color
  10305. */
  10306. color: Color3;
  10307. }
  10308. /** Class used to store factor gradient */
  10309. export class FactorGradient implements IValueGradient {
  10310. /**
  10311. * Gets or sets the gradient value (between 0 and 1)
  10312. */
  10313. gradient: number;
  10314. /**
  10315. * Gets or sets first associated factor
  10316. */
  10317. factor1: number;
  10318. /**
  10319. * Gets or sets second associated factor
  10320. */
  10321. factor2?: number;
  10322. /**
  10323. * Will get a number picked randomly between factor1 and factor2.
  10324. * If factor2 is undefined then factor1 will be used
  10325. * @returns the picked number
  10326. */
  10327. getFactor(): number;
  10328. }
  10329. /**
  10330. * Helper used to simplify some generic gradient tasks
  10331. */
  10332. export class GradientHelper {
  10333. /**
  10334. * Gets the current gradient from an array of IValueGradient
  10335. * @param ratio defines the current ratio to get
  10336. * @param gradients defines the array of IValueGradient
  10337. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10338. */
  10339. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10340. }
  10341. }
  10342. declare module "babylonjs/Maths/math.size" {
  10343. /**
  10344. * Interface for the size containing width and height
  10345. */
  10346. export interface ISize {
  10347. /**
  10348. * Width
  10349. */
  10350. width: number;
  10351. /**
  10352. * Heighht
  10353. */
  10354. height: number;
  10355. }
  10356. /**
  10357. * Size containing widht and height
  10358. */
  10359. export class Size implements ISize {
  10360. /**
  10361. * Width
  10362. */
  10363. width: number;
  10364. /**
  10365. * Height
  10366. */
  10367. height: number;
  10368. /**
  10369. * Creates a Size object from the given width and height (floats).
  10370. * @param width width of the new size
  10371. * @param height height of the new size
  10372. */
  10373. constructor(width: number, height: number);
  10374. /**
  10375. * Returns a string with the Size width and height
  10376. * @returns a string with the Size width and height
  10377. */
  10378. toString(): string;
  10379. /**
  10380. * "Size"
  10381. * @returns the string "Size"
  10382. */
  10383. getClassName(): string;
  10384. /**
  10385. * Returns the Size hash code.
  10386. * @returns a hash code for a unique width and height
  10387. */
  10388. getHashCode(): number;
  10389. /**
  10390. * Updates the current size from the given one.
  10391. * @param src the given size
  10392. */
  10393. copyFrom(src: Size): void;
  10394. /**
  10395. * Updates in place the current Size from the given floats.
  10396. * @param width width of the new size
  10397. * @param height height of the new size
  10398. * @returns the updated Size.
  10399. */
  10400. copyFromFloats(width: number, height: number): Size;
  10401. /**
  10402. * Updates in place the current Size from the given floats.
  10403. * @param width width to set
  10404. * @param height height to set
  10405. * @returns the updated Size.
  10406. */
  10407. set(width: number, height: number): Size;
  10408. /**
  10409. * Multiplies the width and height by numbers
  10410. * @param w factor to multiple the width by
  10411. * @param h factor to multiple the height by
  10412. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10413. */
  10414. multiplyByFloats(w: number, h: number): Size;
  10415. /**
  10416. * Clones the size
  10417. * @returns a new Size copied from the given one.
  10418. */
  10419. clone(): Size;
  10420. /**
  10421. * True if the current Size and the given one width and height are strictly equal.
  10422. * @param other the other size to compare against
  10423. * @returns True if the current Size and the given one width and height are strictly equal.
  10424. */
  10425. equals(other: Size): boolean;
  10426. /**
  10427. * The surface of the Size : width * height (float).
  10428. */
  10429. get surface(): number;
  10430. /**
  10431. * Create a new size of zero
  10432. * @returns a new Size set to (0.0, 0.0)
  10433. */
  10434. static Zero(): Size;
  10435. /**
  10436. * Sums the width and height of two sizes
  10437. * @param otherSize size to add to this size
  10438. * @returns a new Size set as the addition result of the current Size and the given one.
  10439. */
  10440. add(otherSize: Size): Size;
  10441. /**
  10442. * Subtracts the width and height of two
  10443. * @param otherSize size to subtract to this size
  10444. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10445. */
  10446. subtract(otherSize: Size): Size;
  10447. /**
  10448. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10449. * @param start starting size to lerp between
  10450. * @param end end size to lerp between
  10451. * @param amount amount to lerp between the start and end values
  10452. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10453. */
  10454. static Lerp(start: Size, end: Size, amount: number): Size;
  10455. }
  10456. }
  10457. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  10458. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10459. import { Nullable } from "babylonjs/types";
  10460. module "babylonjs/Engines/thinEngine" {
  10461. interface ThinEngine {
  10462. /**
  10463. * Creates a dynamic texture
  10464. * @param width defines the width of the texture
  10465. * @param height defines the height of the texture
  10466. * @param generateMipMaps defines if the engine should generate the mip levels
  10467. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10468. * @returns the dynamic texture inside an InternalTexture
  10469. */
  10470. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10471. /**
  10472. * Update the content of a dynamic texture
  10473. * @param texture defines the texture to update
  10474. * @param canvas defines the canvas containing the source
  10475. * @param invertY defines if data must be stored with Y axis inverted
  10476. * @param premulAlpha defines if alpha is stored as premultiplied
  10477. * @param format defines the format of the data
  10478. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10479. */
  10480. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10481. }
  10482. }
  10483. }
  10484. declare module "babylonjs/Misc/canvasGenerator" {
  10485. /**
  10486. * Helper class used to generate a canvas to manipulate images
  10487. */
  10488. export class CanvasGenerator {
  10489. /**
  10490. * Create a new canvas (or offscreen canvas depending on the context)
  10491. * @param width defines the expected width
  10492. * @param height defines the expected height
  10493. * @return a new canvas or offscreen canvas
  10494. */
  10495. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10496. }
  10497. }
  10498. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  10499. import { Scene } from "babylonjs/scene";
  10500. import { Texture } from "babylonjs/Materials/Textures/texture";
  10501. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  10502. /**
  10503. * A class extending Texture allowing drawing on a texture
  10504. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10505. */
  10506. export class DynamicTexture extends Texture {
  10507. private _generateMipMaps;
  10508. private _canvas;
  10509. private _context;
  10510. private _engine;
  10511. /**
  10512. * Creates a DynamicTexture
  10513. * @param name defines the name of the texture
  10514. * @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
  10515. * @param scene defines the scene where you want the texture
  10516. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10517. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10518. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10519. */
  10520. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10521. /**
  10522. * Get the current class name of the texture useful for serialization or dynamic coding.
  10523. * @returns "DynamicTexture"
  10524. */
  10525. getClassName(): string;
  10526. /**
  10527. * Gets the current state of canRescale
  10528. */
  10529. get canRescale(): boolean;
  10530. private _recreate;
  10531. /**
  10532. * Scales the texture
  10533. * @param ratio the scale factor to apply to both width and height
  10534. */
  10535. scale(ratio: number): void;
  10536. /**
  10537. * Resizes the texture
  10538. * @param width the new width
  10539. * @param height the new height
  10540. */
  10541. scaleTo(width: number, height: number): void;
  10542. /**
  10543. * Gets the context of the canvas used by the texture
  10544. * @returns the canvas context of the dynamic texture
  10545. */
  10546. getContext(): CanvasRenderingContext2D;
  10547. /**
  10548. * Clears the texture
  10549. */
  10550. clear(): void;
  10551. /**
  10552. * Updates the texture
  10553. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10554. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10555. */
  10556. update(invertY?: boolean, premulAlpha?: boolean): void;
  10557. /**
  10558. * Draws text onto the texture
  10559. * @param text defines the text to be drawn
  10560. * @param x defines the placement of the text from the left
  10561. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10562. * @param font defines the font to be used with font-style, font-size, font-name
  10563. * @param color defines the color used for the text
  10564. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10565. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10566. * @param update defines whether texture is immediately update (default is true)
  10567. */
  10568. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  10569. /**
  10570. * Clones the texture
  10571. * @returns the clone of the texture.
  10572. */
  10573. clone(): DynamicTexture;
  10574. /**
  10575. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10576. * @returns a serialized dynamic texture object
  10577. */
  10578. serialize(): any;
  10579. /** @hidden */
  10580. _rebuild(): void;
  10581. }
  10582. }
  10583. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  10584. import { Nullable } from "babylonjs/types";
  10585. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10586. import { Scene } from "babylonjs/scene";
  10587. module "babylonjs/Engines/engine" {
  10588. interface Engine {
  10589. /**
  10590. * Creates a raw texture
  10591. * @param data defines the data to store in the texture
  10592. * @param width defines the width of the texture
  10593. * @param height defines the height of the texture
  10594. * @param format defines the format of the data
  10595. * @param generateMipMaps defines if the engine should generate the mip levels
  10596. * @param invertY defines if data must be stored with Y axis inverted
  10597. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10598. * @param compression defines the compression used (null by default)
  10599. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10600. * @returns the raw texture inside an InternalTexture
  10601. */
  10602. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  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. */
  10610. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10611. /**
  10612. * Update a raw texture
  10613. * @param texture defines the texture to update
  10614. * @param data defines the data to store in the texture
  10615. * @param format defines the format of the data
  10616. * @param invertY defines if data must be stored with Y axis inverted
  10617. * @param compression defines the compression used (null by default)
  10618. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10619. */
  10620. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10621. /**
  10622. * Creates a new raw cube texture
  10623. * @param data defines the array of data to use to create each face
  10624. * @param size defines the size of the textures
  10625. * @param format defines the format of the data
  10626. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10627. * @param generateMipMaps defines if the engine should generate the mip levels
  10628. * @param invertY defines if data must be stored with Y axis inverted
  10629. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10630. * @param compression defines the compression used (null by default)
  10631. * @returns the cube texture as an InternalTexture
  10632. */
  10633. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10634. /**
  10635. * Update a raw cube texture
  10636. * @param texture defines the texture to udpdate
  10637. * @param data defines the data to store
  10638. * @param format defines the data format
  10639. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10640. * @param invertY defines if data must be stored with Y axis inverted
  10641. */
  10642. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10643. /**
  10644. * Update a raw cube texture
  10645. * @param texture defines the texture to udpdate
  10646. * @param data defines the data to store
  10647. * @param format defines the data format
  10648. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10649. * @param invertY defines if data must be stored with Y axis inverted
  10650. * @param compression defines the compression used (null by default)
  10651. */
  10652. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10653. /**
  10654. * Update a raw cube texture
  10655. * @param texture defines the texture to udpdate
  10656. * @param data defines the data to store
  10657. * @param format defines the data format
  10658. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10659. * @param invertY defines if data must be stored with Y axis inverted
  10660. * @param compression defines the compression used (null by default)
  10661. * @param level defines which level of the texture to update
  10662. */
  10663. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10664. /**
  10665. * Creates a new raw cube texture from a specified url
  10666. * @param url defines the url where the data is located
  10667. * @param scene defines the current scene
  10668. * @param size defines the size of the textures
  10669. * @param format defines the format of the data
  10670. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10671. * @param noMipmap defines if the engine should avoid generating the mip levels
  10672. * @param callback defines a callback used to extract texture data from loaded data
  10673. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10674. * @param onLoad defines a callback called when texture is loaded
  10675. * @param onError defines a callback called if there is an error
  10676. * @returns the cube texture as an InternalTexture
  10677. */
  10678. 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;
  10679. /**
  10680. * Creates a new raw cube texture from a specified url
  10681. * @param url defines the url where the data is located
  10682. * @param scene defines the current scene
  10683. * @param size defines the size of the textures
  10684. * @param format defines the format of the data
  10685. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10686. * @param noMipmap defines if the engine should avoid generating the mip levels
  10687. * @param callback defines a callback used to extract texture data from loaded data
  10688. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10689. * @param onLoad defines a callback called when texture is loaded
  10690. * @param onError defines a callback called if there is an error
  10691. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10692. * @param invertY defines if data must be stored with Y axis inverted
  10693. * @returns the cube texture as an InternalTexture
  10694. */
  10695. 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;
  10696. /**
  10697. * Creates a new raw 3D texture
  10698. * @param data defines the data used to create the texture
  10699. * @param width defines the width of the texture
  10700. * @param height defines the height of the texture
  10701. * @param depth defines the depth of the texture
  10702. * @param format defines the format of the texture
  10703. * @param generateMipMaps defines if the engine must generate mip levels
  10704. * @param invertY defines if data must be stored with Y axis inverted
  10705. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10706. * @param compression defines the compressed used (can be null)
  10707. * @param textureType defines the compressed used (can be null)
  10708. * @returns a new raw 3D texture (stored in an InternalTexture)
  10709. */
  10710. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  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. */
  10718. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10719. /**
  10720. * Update a raw 3D texture
  10721. * @param texture defines the texture to update
  10722. * @param data defines the data to store
  10723. * @param format defines the data format
  10724. * @param invertY defines if data must be stored with Y axis inverted
  10725. * @param compression defines the used compression (can be null)
  10726. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10727. */
  10728. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10729. /**
  10730. * Creates a new raw 2D array texture
  10731. * @param data defines the data used to create the texture
  10732. * @param width defines the width of the texture
  10733. * @param height defines the height of the texture
  10734. * @param depth defines the number of layers of the texture
  10735. * @param format defines the format of the texture
  10736. * @param generateMipMaps defines if the engine must generate mip levels
  10737. * @param invertY defines if data must be stored with Y axis inverted
  10738. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10739. * @param compression defines the compressed used (can be null)
  10740. * @param textureType defines the compressed used (can be null)
  10741. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10742. */
  10743. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  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. */
  10751. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10752. /**
  10753. * Update a raw 2D array texture
  10754. * @param texture defines the texture to update
  10755. * @param data defines the data to store
  10756. * @param format defines the data format
  10757. * @param invertY defines if data must be stored with Y axis inverted
  10758. * @param compression defines the used compression (can be null)
  10759. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10760. */
  10761. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10762. }
  10763. }
  10764. }
  10765. declare module "babylonjs/Materials/Textures/rawTexture" {
  10766. import { Scene } from "babylonjs/scene";
  10767. import { Texture } from "babylonjs/Materials/Textures/texture";
  10768. import "babylonjs/Engines/Extensions/engine.rawTexture";
  10769. /**
  10770. * Raw texture can help creating a texture directly from an array of data.
  10771. * This can be super useful if you either get the data from an uncompressed source or
  10772. * if you wish to create your texture pixel by pixel.
  10773. */
  10774. export class RawTexture extends Texture {
  10775. /**
  10776. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10777. */
  10778. format: number;
  10779. private _engine;
  10780. /**
  10781. * Instantiates a new RawTexture.
  10782. * Raw texture can help creating a texture directly from an array of data.
  10783. * This can be super useful if you either get the data from an uncompressed source or
  10784. * if you wish to create your texture pixel by pixel.
  10785. * @param data define the array of data to use to create the texture
  10786. * @param width define the width of the texture
  10787. * @param height define the height of the texture
  10788. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10789. * @param scene define the scene the texture belongs to
  10790. * @param generateMipMaps define whether mip maps should be generated or not
  10791. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10792. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10793. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10794. */
  10795. constructor(data: ArrayBufferView, width: number, height: number,
  10796. /**
  10797. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10798. */
  10799. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10800. /**
  10801. * Updates the texture underlying data.
  10802. * @param data Define the new data of the texture
  10803. */
  10804. update(data: ArrayBufferView): void;
  10805. /**
  10806. * Creates a luminance texture from some data.
  10807. * @param data Define the texture data
  10808. * @param width Define the width of the texture
  10809. * @param height Define the height of the texture
  10810. * @param scene Define the scene the texture belongs to
  10811. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10812. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10813. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10814. * @returns the luminance texture
  10815. */
  10816. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10817. /**
  10818. * Creates a luminance alpha texture from some data.
  10819. * @param data Define the texture data
  10820. * @param width Define the width of the texture
  10821. * @param height Define the height of the texture
  10822. * @param scene Define the scene the texture belongs to
  10823. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10824. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10825. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10826. * @returns the luminance alpha texture
  10827. */
  10828. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10829. /**
  10830. * Creates an alpha texture from some data.
  10831. * @param data Define the texture data
  10832. * @param width Define the width of the texture
  10833. * @param height Define the height of the texture
  10834. * @param scene Define the scene the texture belongs to
  10835. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10836. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10837. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10838. * @returns the alpha texture
  10839. */
  10840. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10841. /**
  10842. * Creates a RGB texture from some data.
  10843. * @param data Define the texture data
  10844. * @param width Define the width of the texture
  10845. * @param height Define the height of the texture
  10846. * @param scene Define the scene the texture belongs to
  10847. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10848. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10849. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10850. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10851. * @returns the RGB alpha texture
  10852. */
  10853. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10854. /**
  10855. * Creates a RGBA texture from some data.
  10856. * @param data Define the texture data
  10857. * @param width Define the width of the texture
  10858. * @param height Define the height of the texture
  10859. * @param scene Define the scene the texture belongs to
  10860. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10861. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10862. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10863. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10864. * @returns the RGBA texture
  10865. */
  10866. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10867. /**
  10868. * Creates a R texture from some data.
  10869. * @param data Define the texture data
  10870. * @param width Define the width of the texture
  10871. * @param height Define the height of the texture
  10872. * @param scene Define the scene the texture belongs to
  10873. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10874. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10875. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10876. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10877. * @returns the R texture
  10878. */
  10879. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10880. }
  10881. }
  10882. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  10883. import { Scene } from "babylonjs/scene";
  10884. import { ISceneComponent } from "babylonjs/sceneComponent";
  10885. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  10886. module "babylonjs/abstractScene" {
  10887. interface AbstractScene {
  10888. /**
  10889. * The list of procedural textures added to the scene
  10890. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10891. */
  10892. proceduralTextures: Array<ProceduralTexture>;
  10893. }
  10894. }
  10895. /**
  10896. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10897. * in a given scene.
  10898. */
  10899. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10900. /**
  10901. * The component name helpfull to identify the component in the list of scene components.
  10902. */
  10903. readonly name: string;
  10904. /**
  10905. * The scene the component belongs to.
  10906. */
  10907. scene: Scene;
  10908. /**
  10909. * Creates a new instance of the component for the given scene
  10910. * @param scene Defines the scene to register the component in
  10911. */
  10912. constructor(scene: Scene);
  10913. /**
  10914. * Registers the component in a given scene
  10915. */
  10916. register(): void;
  10917. /**
  10918. * Rebuilds the elements related to this component in case of
  10919. * context lost for instance.
  10920. */
  10921. rebuild(): void;
  10922. /**
  10923. * Disposes the component and the associated ressources.
  10924. */
  10925. dispose(): void;
  10926. private _beforeClear;
  10927. }
  10928. }
  10929. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  10930. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10931. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  10932. module "babylonjs/Engines/thinEngine" {
  10933. interface ThinEngine {
  10934. /**
  10935. * Creates a new render target cube texture
  10936. * @param size defines the size of the texture
  10937. * @param options defines the options used to create the texture
  10938. * @returns a new render target cube texture stored in an InternalTexture
  10939. */
  10940. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10941. }
  10942. }
  10943. }
  10944. declare module "babylonjs/Shaders/procedural.vertex" {
  10945. /** @hidden */
  10946. export var proceduralVertexShader: {
  10947. name: string;
  10948. shader: string;
  10949. };
  10950. }
  10951. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  10952. import { Observable } from "babylonjs/Misc/observable";
  10953. import { Nullable } from "babylonjs/types";
  10954. import { Scene } from "babylonjs/scene";
  10955. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10956. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  10957. import { Effect } from "babylonjs/Materials/effect";
  10958. import { Texture } from "babylonjs/Materials/Textures/texture";
  10959. import "babylonjs/Engines/Extensions/engine.renderTarget";
  10960. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  10961. import "babylonjs/Shaders/procedural.vertex";
  10962. /**
  10963. * 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.
  10964. * This is the base class of any Procedural texture and contains most of the shareable code.
  10965. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10966. */
  10967. export class ProceduralTexture extends Texture {
  10968. isCube: boolean;
  10969. /**
  10970. * Define if the texture is enabled or not (disabled texture will not render)
  10971. */
  10972. isEnabled: boolean;
  10973. /**
  10974. * Define if the texture must be cleared before rendering (default is true)
  10975. */
  10976. autoClear: boolean;
  10977. /**
  10978. * Callback called when the texture is generated
  10979. */
  10980. onGenerated: () => void;
  10981. /**
  10982. * Event raised when the texture is generated
  10983. */
  10984. onGeneratedObservable: Observable<ProceduralTexture>;
  10985. /** @hidden */
  10986. _generateMipMaps: boolean;
  10987. /** @hidden **/
  10988. _effect: Effect;
  10989. /** @hidden */
  10990. _textures: {
  10991. [key: string]: Texture;
  10992. };
  10993. private _size;
  10994. private _currentRefreshId;
  10995. private _frameId;
  10996. private _refreshRate;
  10997. private _vertexBuffers;
  10998. private _indexBuffer;
  10999. private _uniforms;
  11000. private _samplers;
  11001. private _fragment;
  11002. private _floats;
  11003. private _ints;
  11004. private _floatsArrays;
  11005. private _colors3;
  11006. private _colors4;
  11007. private _vectors2;
  11008. private _vectors3;
  11009. private _matrices;
  11010. private _fallbackTexture;
  11011. private _fallbackTextureUsed;
  11012. private _engine;
  11013. private _cachedDefines;
  11014. private _contentUpdateId;
  11015. private _contentData;
  11016. /**
  11017. * Instantiates a new procedural texture.
  11018. * 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.
  11019. * This is the base class of any Procedural texture and contains most of the shareable code.
  11020. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11021. * @param name Define the name of the texture
  11022. * @param size Define the size of the texture to create
  11023. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11024. * @param scene Define the scene the texture belongs to
  11025. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11026. * @param generateMipMaps Define if the texture should creates mip maps or not
  11027. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11028. */
  11029. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11030. /**
  11031. * The effect that is created when initializing the post process.
  11032. * @returns The created effect corresponding the the postprocess.
  11033. */
  11034. getEffect(): Effect;
  11035. /**
  11036. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11037. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11038. */
  11039. getContent(): Nullable<ArrayBufferView>;
  11040. private _createIndexBuffer;
  11041. /** @hidden */
  11042. _rebuild(): void;
  11043. /**
  11044. * Resets the texture in order to recreate its associated resources.
  11045. * This can be called in case of context loss
  11046. */
  11047. reset(): void;
  11048. protected _getDefines(): string;
  11049. /**
  11050. * Is the texture ready to be used ? (rendered at least once)
  11051. * @returns true if ready, otherwise, false.
  11052. */
  11053. isReady(): boolean;
  11054. /**
  11055. * Resets the refresh counter of the texture and start bak from scratch.
  11056. * Could be useful to regenerate the texture if it is setup to render only once.
  11057. */
  11058. resetRefreshCounter(): void;
  11059. /**
  11060. * Set the fragment shader to use in order to render the texture.
  11061. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11062. */
  11063. setFragment(fragment: any): void;
  11064. /**
  11065. * Define the refresh rate of the texture or the rendering frequency.
  11066. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11067. */
  11068. get refreshRate(): number;
  11069. set refreshRate(value: number);
  11070. /** @hidden */
  11071. _shouldRender(): boolean;
  11072. /**
  11073. * Get the size the texture is rendering at.
  11074. * @returns the size (texture is always squared)
  11075. */
  11076. getRenderSize(): number;
  11077. /**
  11078. * Resize the texture to new value.
  11079. * @param size Define the new size the texture should have
  11080. * @param generateMipMaps Define whether the new texture should create mip maps
  11081. */
  11082. resize(size: number, generateMipMaps: boolean): void;
  11083. private _checkUniform;
  11084. /**
  11085. * Set a texture in the shader program used to render.
  11086. * @param name Define the name of the uniform samplers as defined in the shader
  11087. * @param texture Define the texture to bind to this sampler
  11088. * @return the texture itself allowing "fluent" like uniform updates
  11089. */
  11090. setTexture(name: string, texture: Texture): ProceduralTexture;
  11091. /**
  11092. * Set a float in the shader.
  11093. * @param name Define the name of the uniform as defined in the shader
  11094. * @param value Define the value to give to the uniform
  11095. * @return the texture itself allowing "fluent" like uniform updates
  11096. */
  11097. setFloat(name: string, value: number): ProceduralTexture;
  11098. /**
  11099. * Set a int in the shader.
  11100. * @param name Define the name of the uniform as defined in the shader
  11101. * @param value Define the value to give to the uniform
  11102. * @return the texture itself allowing "fluent" like uniform updates
  11103. */
  11104. setInt(name: string, value: number): ProceduralTexture;
  11105. /**
  11106. * Set an array of floats in the shader.
  11107. * @param name Define the name of the uniform as defined in the shader
  11108. * @param value Define the value to give to the uniform
  11109. * @return the texture itself allowing "fluent" like uniform updates
  11110. */
  11111. setFloats(name: string, value: number[]): ProceduralTexture;
  11112. /**
  11113. * Set a vec3 in the shader from a Color3.
  11114. * @param name Define the name of the uniform as defined in the shader
  11115. * @param value Define the value to give to the uniform
  11116. * @return the texture itself allowing "fluent" like uniform updates
  11117. */
  11118. setColor3(name: string, value: Color3): ProceduralTexture;
  11119. /**
  11120. * Set a vec4 in the shader from a Color4.
  11121. * @param name Define the name of the uniform as defined in the shader
  11122. * @param value Define the value to give to the uniform
  11123. * @return the texture itself allowing "fluent" like uniform updates
  11124. */
  11125. setColor4(name: string, value: Color4): ProceduralTexture;
  11126. /**
  11127. * Set a vec2 in the shader from a Vector2.
  11128. * @param name Define the name of the uniform as defined in the shader
  11129. * @param value Define the value to give to the uniform
  11130. * @return the texture itself allowing "fluent" like uniform updates
  11131. */
  11132. setVector2(name: string, value: Vector2): ProceduralTexture;
  11133. /**
  11134. * Set a vec3 in the shader from a Vector3.
  11135. * @param name Define the name of the uniform as defined in the shader
  11136. * @param value Define the value to give to the uniform
  11137. * @return the texture itself allowing "fluent" like uniform updates
  11138. */
  11139. setVector3(name: string, value: Vector3): ProceduralTexture;
  11140. /**
  11141. * Set a mat4 in the shader from a MAtrix.
  11142. * @param name Define the name of the uniform as defined in the shader
  11143. * @param value Define the value to give to the uniform
  11144. * @return the texture itself allowing "fluent" like uniform updates
  11145. */
  11146. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11147. /**
  11148. * Render the texture to its associated render target.
  11149. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11150. */
  11151. render(useCameraPostProcess?: boolean): void;
  11152. /**
  11153. * Clone the texture.
  11154. * @returns the cloned texture
  11155. */
  11156. clone(): ProceduralTexture;
  11157. /**
  11158. * Dispose the texture and release its asoociated resources.
  11159. */
  11160. dispose(): void;
  11161. }
  11162. }
  11163. declare module "babylonjs/Particles/baseParticleSystem" {
  11164. import { Nullable } from "babylonjs/types";
  11165. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  11166. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11167. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  11168. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11169. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  11170. import { Scene } from "babylonjs/scene";
  11171. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  11172. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  11173. import { Texture } from "babylonjs/Materials/Textures/texture";
  11174. import { Color4 } from "babylonjs/Maths/math.color";
  11175. import { Animation } from "babylonjs/Animations/animation";
  11176. /**
  11177. * This represents the base class for particle system in Babylon.
  11178. * 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.
  11179. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11180. * @example https://doc.babylonjs.com/babylon101/particles
  11181. */
  11182. export class BaseParticleSystem {
  11183. /**
  11184. * Source color is added to the destination color without alpha affecting the result
  11185. */
  11186. static BLENDMODE_ONEONE: number;
  11187. /**
  11188. * Blend current color and particle color using particle’s alpha
  11189. */
  11190. static BLENDMODE_STANDARD: number;
  11191. /**
  11192. * Add current color and particle color multiplied by particle’s alpha
  11193. */
  11194. static BLENDMODE_ADD: number;
  11195. /**
  11196. * Multiply current color with particle color
  11197. */
  11198. static BLENDMODE_MULTIPLY: number;
  11199. /**
  11200. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11201. */
  11202. static BLENDMODE_MULTIPLYADD: number;
  11203. /**
  11204. * List of animations used by the particle system.
  11205. */
  11206. animations: Animation[];
  11207. /**
  11208. * The id of the Particle system.
  11209. */
  11210. id: string;
  11211. /**
  11212. * The friendly name of the Particle system.
  11213. */
  11214. name: string;
  11215. /**
  11216. * The rendering group used by the Particle system to chose when to render.
  11217. */
  11218. renderingGroupId: number;
  11219. /**
  11220. * The emitter represents the Mesh or position we are attaching the particle system to.
  11221. */
  11222. emitter: Nullable<AbstractMesh | Vector3>;
  11223. /**
  11224. * The maximum number of particles to emit per frame
  11225. */
  11226. emitRate: number;
  11227. /**
  11228. * If you want to launch only a few particles at once, that can be done, as well.
  11229. */
  11230. manualEmitCount: number;
  11231. /**
  11232. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11233. */
  11234. updateSpeed: number;
  11235. /**
  11236. * The amount of time the particle system is running (depends of the overall update speed).
  11237. */
  11238. targetStopDuration: number;
  11239. /**
  11240. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11241. */
  11242. disposeOnStop: boolean;
  11243. /**
  11244. * Minimum power of emitting particles.
  11245. */
  11246. minEmitPower: number;
  11247. /**
  11248. * Maximum power of emitting particles.
  11249. */
  11250. maxEmitPower: number;
  11251. /**
  11252. * Minimum life time of emitting particles.
  11253. */
  11254. minLifeTime: number;
  11255. /**
  11256. * Maximum life time of emitting particles.
  11257. */
  11258. maxLifeTime: number;
  11259. /**
  11260. * Minimum Size of emitting particles.
  11261. */
  11262. minSize: number;
  11263. /**
  11264. * Maximum Size of emitting particles.
  11265. */
  11266. maxSize: number;
  11267. /**
  11268. * Minimum scale of emitting particles on X axis.
  11269. */
  11270. minScaleX: number;
  11271. /**
  11272. * Maximum scale of emitting particles on X axis.
  11273. */
  11274. maxScaleX: number;
  11275. /**
  11276. * Minimum scale of emitting particles on Y axis.
  11277. */
  11278. minScaleY: number;
  11279. /**
  11280. * Maximum scale of emitting particles on Y axis.
  11281. */
  11282. maxScaleY: number;
  11283. /**
  11284. * Gets or sets the minimal initial rotation in radians.
  11285. */
  11286. minInitialRotation: number;
  11287. /**
  11288. * Gets or sets the maximal initial rotation in radians.
  11289. */
  11290. maxInitialRotation: number;
  11291. /**
  11292. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11293. */
  11294. minAngularSpeed: number;
  11295. /**
  11296. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11297. */
  11298. maxAngularSpeed: number;
  11299. /**
  11300. * The texture used to render each particle. (this can be a spritesheet)
  11301. */
  11302. particleTexture: Nullable<Texture>;
  11303. /**
  11304. * The layer mask we are rendering the particles through.
  11305. */
  11306. layerMask: number;
  11307. /**
  11308. * This can help using your own shader to render the particle system.
  11309. * The according effect will be created
  11310. */
  11311. customShader: any;
  11312. /**
  11313. * By default particle system starts as soon as they are created. This prevents the
  11314. * automatic start to happen and let you decide when to start emitting particles.
  11315. */
  11316. preventAutoStart: boolean;
  11317. private _noiseTexture;
  11318. /**
  11319. * Gets or sets a texture used to add random noise to particle positions
  11320. */
  11321. get noiseTexture(): Nullable<ProceduralTexture>;
  11322. set noiseTexture(value: Nullable<ProceduralTexture>);
  11323. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11324. noiseStrength: Vector3;
  11325. /**
  11326. * Callback triggered when the particle animation is ending.
  11327. */
  11328. onAnimationEnd: Nullable<() => void>;
  11329. /**
  11330. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11331. */
  11332. blendMode: number;
  11333. /**
  11334. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11335. * to override the particles.
  11336. */
  11337. forceDepthWrite: boolean;
  11338. /** 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 */
  11339. preWarmCycles: number;
  11340. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11341. preWarmStepOffset: number;
  11342. /**
  11343. * 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)
  11344. */
  11345. spriteCellChangeSpeed: number;
  11346. /**
  11347. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11348. */
  11349. startSpriteCellID: number;
  11350. /**
  11351. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11352. */
  11353. endSpriteCellID: number;
  11354. /**
  11355. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11356. */
  11357. spriteCellWidth: number;
  11358. /**
  11359. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11360. */
  11361. spriteCellHeight: number;
  11362. /**
  11363. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11364. */
  11365. spriteRandomStartCell: boolean;
  11366. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11367. translationPivot: Vector2;
  11368. /** @hidden */
  11369. protected _isAnimationSheetEnabled: boolean;
  11370. /**
  11371. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11372. */
  11373. beginAnimationOnStart: boolean;
  11374. /**
  11375. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11376. */
  11377. beginAnimationFrom: number;
  11378. /**
  11379. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11380. */
  11381. beginAnimationTo: number;
  11382. /**
  11383. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11384. */
  11385. beginAnimationLoop: boolean;
  11386. /**
  11387. * Gets or sets a world offset applied to all particles
  11388. */
  11389. worldOffset: Vector3;
  11390. /**
  11391. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11392. */
  11393. get isAnimationSheetEnabled(): boolean;
  11394. set isAnimationSheetEnabled(value: boolean);
  11395. /**
  11396. * Get hosting scene
  11397. * @returns the scene
  11398. */
  11399. getScene(): Scene;
  11400. /**
  11401. * You can use gravity if you want to give an orientation to your particles.
  11402. */
  11403. gravity: Vector3;
  11404. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11405. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11406. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11407. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11408. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11409. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11410. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11411. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11412. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11413. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11414. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11415. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11416. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11417. /**
  11418. * Defines the delay in milliseconds before starting the system (0 by default)
  11419. */
  11420. startDelay: number;
  11421. /**
  11422. * Gets the current list of drag gradients.
  11423. * You must use addDragGradient and removeDragGradient to udpate this list
  11424. * @returns the list of drag gradients
  11425. */
  11426. getDragGradients(): Nullable<Array<FactorGradient>>;
  11427. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11428. limitVelocityDamping: number;
  11429. /**
  11430. * Gets the current list of limit velocity gradients.
  11431. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11432. * @returns the list of limit velocity gradients
  11433. */
  11434. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11435. /**
  11436. * Gets the current list of color gradients.
  11437. * You must use addColorGradient and removeColorGradient to udpate this list
  11438. * @returns the list of color gradients
  11439. */
  11440. getColorGradients(): Nullable<Array<ColorGradient>>;
  11441. /**
  11442. * Gets the current list of size gradients.
  11443. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11444. * @returns the list of size gradients
  11445. */
  11446. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11447. /**
  11448. * Gets the current list of color remap gradients.
  11449. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11450. * @returns the list of color remap gradients
  11451. */
  11452. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11453. /**
  11454. * Gets the current list of alpha remap gradients.
  11455. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11456. * @returns the list of alpha remap gradients
  11457. */
  11458. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11459. /**
  11460. * Gets the current list of life time gradients.
  11461. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11462. * @returns the list of life time gradients
  11463. */
  11464. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11465. /**
  11466. * Gets the current list of angular speed gradients.
  11467. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11468. * @returns the list of angular speed gradients
  11469. */
  11470. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11471. /**
  11472. * Gets the current list of velocity gradients.
  11473. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11474. * @returns the list of velocity gradients
  11475. */
  11476. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11477. /**
  11478. * Gets the current list of start size gradients.
  11479. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11480. * @returns the list of start size gradients
  11481. */
  11482. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11483. /**
  11484. * Gets the current list of emit rate gradients.
  11485. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11486. * @returns the list of emit rate gradients
  11487. */
  11488. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11489. /**
  11490. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11491. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11492. */
  11493. get direction1(): Vector3;
  11494. set direction1(value: Vector3);
  11495. /**
  11496. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11497. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11498. */
  11499. get direction2(): Vector3;
  11500. set direction2(value: Vector3);
  11501. /**
  11502. * 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.
  11503. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11504. */
  11505. get minEmitBox(): Vector3;
  11506. set minEmitBox(value: Vector3);
  11507. /**
  11508. * 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.
  11509. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11510. */
  11511. get maxEmitBox(): Vector3;
  11512. set maxEmitBox(value: Vector3);
  11513. /**
  11514. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11515. */
  11516. color1: Color4;
  11517. /**
  11518. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11519. */
  11520. color2: Color4;
  11521. /**
  11522. * Color the particle will have at the end of its lifetime
  11523. */
  11524. colorDead: Color4;
  11525. /**
  11526. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11527. */
  11528. textureMask: Color4;
  11529. /**
  11530. * The particle emitter type defines the emitter used by the particle system.
  11531. * It can be for example box, sphere, or cone...
  11532. */
  11533. particleEmitterType: IParticleEmitterType;
  11534. /** @hidden */
  11535. _isSubEmitter: boolean;
  11536. /**
  11537. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11538. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11539. */
  11540. billboardMode: number;
  11541. protected _isBillboardBased: boolean;
  11542. /**
  11543. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11544. */
  11545. get isBillboardBased(): boolean;
  11546. set isBillboardBased(value: boolean);
  11547. /**
  11548. * The scene the particle system belongs to.
  11549. */
  11550. protected _scene: Scene;
  11551. /**
  11552. * Local cache of defines for image processing.
  11553. */
  11554. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11555. /**
  11556. * Default configuration related to image processing available in the standard Material.
  11557. */
  11558. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11559. /**
  11560. * Gets the image processing configuration used either in this material.
  11561. */
  11562. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11563. /**
  11564. * Sets the Default image processing configuration used either in the this material.
  11565. *
  11566. * If sets to null, the scene one is in use.
  11567. */
  11568. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11569. /**
  11570. * Attaches a new image processing configuration to the Standard Material.
  11571. * @param configuration
  11572. */
  11573. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11574. /** @hidden */
  11575. protected _reset(): void;
  11576. /** @hidden */
  11577. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11578. /**
  11579. * Instantiates a particle system.
  11580. * 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.
  11581. * @param name The name of the particle system
  11582. */
  11583. constructor(name: string);
  11584. /**
  11585. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11586. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11587. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11588. * @returns the emitter
  11589. */
  11590. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11591. /**
  11592. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11593. * @param radius The radius of the hemisphere to emit from
  11594. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11595. * @returns the emitter
  11596. */
  11597. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11598. /**
  11599. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11600. * @param radius The radius of the sphere to emit from
  11601. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11602. * @returns the emitter
  11603. */
  11604. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11605. /**
  11606. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11607. * @param radius The radius of the sphere to emit from
  11608. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11609. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11610. * @returns the emitter
  11611. */
  11612. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11613. /**
  11614. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11615. * @param radius The radius of the emission cylinder
  11616. * @param height The height of the emission cylinder
  11617. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11618. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11619. * @returns the emitter
  11620. */
  11621. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11622. /**
  11623. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11624. * @param radius The radius of the cylinder to emit from
  11625. * @param height The height of the emission cylinder
  11626. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11627. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11628. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11629. * @returns the emitter
  11630. */
  11631. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11632. /**
  11633. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11634. * @param radius The radius of the cone to emit from
  11635. * @param angle The base angle of the cone
  11636. * @returns the emitter
  11637. */
  11638. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11639. /**
  11640. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11641. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11642. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11643. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11644. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11645. * @returns the emitter
  11646. */
  11647. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11648. }
  11649. }
  11650. declare module "babylonjs/Particles/subEmitter" {
  11651. import { Scene } from "babylonjs/scene";
  11652. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  11653. /**
  11654. * Type of sub emitter
  11655. */
  11656. export enum SubEmitterType {
  11657. /**
  11658. * Attached to the particle over it's lifetime
  11659. */
  11660. ATTACHED = 0,
  11661. /**
  11662. * Created when the particle dies
  11663. */
  11664. END = 1
  11665. }
  11666. /**
  11667. * Sub emitter class used to emit particles from an existing particle
  11668. */
  11669. export class SubEmitter {
  11670. /**
  11671. * the particle system to be used by the sub emitter
  11672. */
  11673. particleSystem: ParticleSystem;
  11674. /**
  11675. * Type of the submitter (Default: END)
  11676. */
  11677. type: SubEmitterType;
  11678. /**
  11679. * 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)
  11680. * Note: This only is supported when using an emitter of type Mesh
  11681. */
  11682. inheritDirection: boolean;
  11683. /**
  11684. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11685. */
  11686. inheritedVelocityAmount: number;
  11687. /**
  11688. * Creates a sub emitter
  11689. * @param particleSystem the particle system to be used by the sub emitter
  11690. */
  11691. constructor(
  11692. /**
  11693. * the particle system to be used by the sub emitter
  11694. */
  11695. particleSystem: ParticleSystem);
  11696. /**
  11697. * Clones the sub emitter
  11698. * @returns the cloned sub emitter
  11699. */
  11700. clone(): SubEmitter;
  11701. /**
  11702. * Serialize current object to a JSON object
  11703. * @returns the serialized object
  11704. */
  11705. serialize(): any;
  11706. /** @hidden */
  11707. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11708. /**
  11709. * Creates a new SubEmitter from a serialized JSON version
  11710. * @param serializationObject defines the JSON object to read from
  11711. * @param scene defines the hosting scene
  11712. * @param rootUrl defines the rootUrl for data loading
  11713. * @returns a new SubEmitter
  11714. */
  11715. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11716. /** Release associated resources */
  11717. dispose(): void;
  11718. }
  11719. }
  11720. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  11721. /** @hidden */
  11722. export var imageProcessingDeclaration: {
  11723. name: string;
  11724. shader: string;
  11725. };
  11726. }
  11727. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  11728. /** @hidden */
  11729. export var imageProcessingFunctions: {
  11730. name: string;
  11731. shader: string;
  11732. };
  11733. }
  11734. declare module "babylonjs/Shaders/particles.fragment" {
  11735. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  11736. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  11737. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  11738. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  11739. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  11740. /** @hidden */
  11741. export var particlesPixelShader: {
  11742. name: string;
  11743. shader: string;
  11744. };
  11745. }
  11746. declare module "babylonjs/Shaders/particles.vertex" {
  11747. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  11748. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  11749. /** @hidden */
  11750. export var particlesVertexShader: {
  11751. name: string;
  11752. shader: string;
  11753. };
  11754. }
  11755. declare module "babylonjs/Particles/particleSystem" {
  11756. import { Nullable } from "babylonjs/types";
  11757. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  11758. import { Observable } from "babylonjs/Misc/observable";
  11759. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  11760. import { Effect } from "babylonjs/Materials/effect";
  11761. import { Scene, IDisposable } from "babylonjs/scene";
  11762. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  11763. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  11764. import { Particle } from "babylonjs/Particles/particle";
  11765. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  11766. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  11767. import "babylonjs/Shaders/particles.fragment";
  11768. import "babylonjs/Shaders/particles.vertex";
  11769. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11770. /**
  11771. * This represents a particle system in Babylon.
  11772. * 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.
  11773. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11774. * @example https://doc.babylonjs.com/babylon101/particles
  11775. */
  11776. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11777. /**
  11778. * Billboard mode will only apply to Y axis
  11779. */
  11780. static readonly BILLBOARDMODE_Y: number;
  11781. /**
  11782. * Billboard mode will apply to all axes
  11783. */
  11784. static readonly BILLBOARDMODE_ALL: number;
  11785. /**
  11786. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11787. */
  11788. static readonly BILLBOARDMODE_STRETCHED: number;
  11789. /**
  11790. * This function can be defined to provide custom update for active particles.
  11791. * This function will be called instead of regular update (age, position, color, etc.).
  11792. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11793. */
  11794. updateFunction: (particles: Particle[]) => void;
  11795. private _emitterWorldMatrix;
  11796. /**
  11797. * This function can be defined to specify initial direction for every new particle.
  11798. * It by default use the emitterType defined function
  11799. */
  11800. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  11801. /**
  11802. * This function can be defined to specify initial position for every new particle.
  11803. * It by default use the emitterType defined function
  11804. */
  11805. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  11806. /**
  11807. * @hidden
  11808. */
  11809. _inheritedVelocityOffset: Vector3;
  11810. /**
  11811. * An event triggered when the system is disposed
  11812. */
  11813. onDisposeObservable: Observable<ParticleSystem>;
  11814. private _onDisposeObserver;
  11815. /**
  11816. * Sets a callback that will be triggered when the system is disposed
  11817. */
  11818. set onDispose(callback: () => void);
  11819. private _particles;
  11820. private _epsilon;
  11821. private _capacity;
  11822. private _stockParticles;
  11823. private _newPartsExcess;
  11824. private _vertexData;
  11825. private _vertexBuffer;
  11826. private _vertexBuffers;
  11827. private _spriteBuffer;
  11828. private _indexBuffer;
  11829. private _effect;
  11830. private _customEffect;
  11831. private _cachedDefines;
  11832. private _scaledColorStep;
  11833. private _colorDiff;
  11834. private _scaledDirection;
  11835. private _scaledGravity;
  11836. private _currentRenderId;
  11837. private _alive;
  11838. private _useInstancing;
  11839. private _started;
  11840. private _stopped;
  11841. private _actualFrame;
  11842. private _scaledUpdateSpeed;
  11843. private _vertexBufferSize;
  11844. /** @hidden */
  11845. _currentEmitRateGradient: Nullable<FactorGradient>;
  11846. /** @hidden */
  11847. _currentEmitRate1: number;
  11848. /** @hidden */
  11849. _currentEmitRate2: number;
  11850. /** @hidden */
  11851. _currentStartSizeGradient: Nullable<FactorGradient>;
  11852. /** @hidden */
  11853. _currentStartSize1: number;
  11854. /** @hidden */
  11855. _currentStartSize2: number;
  11856. private readonly _rawTextureWidth;
  11857. private _rampGradientsTexture;
  11858. private _useRampGradients;
  11859. /** Gets or sets a boolean indicating that ramp gradients must be used
  11860. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11861. */
  11862. get useRampGradients(): boolean;
  11863. set useRampGradients(value: boolean);
  11864. /**
  11865. * 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.
  11866. * 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: [])
  11867. */
  11868. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11869. private _subEmitters;
  11870. /**
  11871. * @hidden
  11872. * If the particle systems emitter should be disposed when the particle system is disposed
  11873. */
  11874. _disposeEmitterOnDispose: boolean;
  11875. /**
  11876. * The current active Sub-systems, this property is used by the root particle system only.
  11877. */
  11878. activeSubSystems: Array<ParticleSystem>;
  11879. private _rootParticleSystem;
  11880. /**
  11881. * Gets the current list of active particles
  11882. */
  11883. get particles(): Particle[];
  11884. /**
  11885. * Returns the string "ParticleSystem"
  11886. * @returns a string containing the class name
  11887. */
  11888. getClassName(): string;
  11889. /**
  11890. * Instantiates a particle system.
  11891. * 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.
  11892. * @param name The name of the particle system
  11893. * @param capacity The max number of particles alive at the same time
  11894. * @param scene The scene the particle system belongs to
  11895. * @param customEffect a custom effect used to change the way particles are rendered by default
  11896. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11897. * @param epsilon Offset used to render the particles
  11898. */
  11899. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  11900. private _addFactorGradient;
  11901. private _removeFactorGradient;
  11902. /**
  11903. * Adds a new life time gradient
  11904. * @param gradient defines the gradient to use (between 0 and 1)
  11905. * @param factor defines the life time factor to affect to the specified gradient
  11906. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11907. * @returns the current particle system
  11908. */
  11909. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11910. /**
  11911. * Remove a specific life time gradient
  11912. * @param gradient defines the gradient to remove
  11913. * @returns the current particle system
  11914. */
  11915. removeLifeTimeGradient(gradient: number): IParticleSystem;
  11916. /**
  11917. * Adds a new size gradient
  11918. * @param gradient defines the gradient to use (between 0 and 1)
  11919. * @param factor defines the size factor to affect to the specified gradient
  11920. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11921. * @returns the current particle system
  11922. */
  11923. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11924. /**
  11925. * Remove a specific size gradient
  11926. * @param gradient defines the gradient to remove
  11927. * @returns the current particle system
  11928. */
  11929. removeSizeGradient(gradient: number): IParticleSystem;
  11930. /**
  11931. * Adds a new color remap gradient
  11932. * @param gradient defines the gradient to use (between 0 and 1)
  11933. * @param min defines the color remap minimal range
  11934. * @param max defines the color remap maximal range
  11935. * @returns the current particle system
  11936. */
  11937. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11938. /**
  11939. * Remove a specific color remap gradient
  11940. * @param gradient defines the gradient to remove
  11941. * @returns the current particle system
  11942. */
  11943. removeColorRemapGradient(gradient: number): IParticleSystem;
  11944. /**
  11945. * Adds a new alpha remap gradient
  11946. * @param gradient defines the gradient to use (between 0 and 1)
  11947. * @param min defines the alpha remap minimal range
  11948. * @param max defines the alpha remap maximal range
  11949. * @returns the current particle system
  11950. */
  11951. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11952. /**
  11953. * Remove a specific alpha remap gradient
  11954. * @param gradient defines the gradient to remove
  11955. * @returns the current particle system
  11956. */
  11957. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  11958. /**
  11959. * Adds a new angular speed gradient
  11960. * @param gradient defines the gradient to use (between 0 and 1)
  11961. * @param factor defines the angular speed to affect to the specified gradient
  11962. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11963. * @returns the current particle system
  11964. */
  11965. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11966. /**
  11967. * Remove a specific angular speed gradient
  11968. * @param gradient defines the gradient to remove
  11969. * @returns the current particle system
  11970. */
  11971. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  11972. /**
  11973. * Adds a new velocity gradient
  11974. * @param gradient defines the gradient to use (between 0 and 1)
  11975. * @param factor defines the velocity to affect to the specified gradient
  11976. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11977. * @returns the current particle system
  11978. */
  11979. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11980. /**
  11981. * Remove a specific velocity gradient
  11982. * @param gradient defines the gradient to remove
  11983. * @returns the current particle system
  11984. */
  11985. removeVelocityGradient(gradient: number): IParticleSystem;
  11986. /**
  11987. * Adds a new limit velocity gradient
  11988. * @param gradient defines the gradient to use (between 0 and 1)
  11989. * @param factor defines the limit velocity value to affect to the specified gradient
  11990. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11991. * @returns the current particle system
  11992. */
  11993. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11994. /**
  11995. * Remove a specific limit velocity gradient
  11996. * @param gradient defines the gradient to remove
  11997. * @returns the current particle system
  11998. */
  11999. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12000. /**
  12001. * Adds a new drag gradient
  12002. * @param gradient defines the gradient to use (between 0 and 1)
  12003. * @param factor defines the drag value to affect to the specified gradient
  12004. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12005. * @returns the current particle system
  12006. */
  12007. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12008. /**
  12009. * Remove a specific drag gradient
  12010. * @param gradient defines the gradient to remove
  12011. * @returns the current particle system
  12012. */
  12013. removeDragGradient(gradient: number): IParticleSystem;
  12014. /**
  12015. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12016. * @param gradient defines the gradient to use (between 0 and 1)
  12017. * @param factor defines the emit rate value to affect to the specified gradient
  12018. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12019. * @returns the current particle system
  12020. */
  12021. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12022. /**
  12023. * Remove a specific emit rate gradient
  12024. * @param gradient defines the gradient to remove
  12025. * @returns the current particle system
  12026. */
  12027. removeEmitRateGradient(gradient: number): IParticleSystem;
  12028. /**
  12029. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12030. * @param gradient defines the gradient to use (between 0 and 1)
  12031. * @param factor defines the start size value to affect to the specified gradient
  12032. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12033. * @returns the current particle system
  12034. */
  12035. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12036. /**
  12037. * Remove a specific start size gradient
  12038. * @param gradient defines the gradient to remove
  12039. * @returns the current particle system
  12040. */
  12041. removeStartSizeGradient(gradient: number): IParticleSystem;
  12042. private _createRampGradientTexture;
  12043. /**
  12044. * Gets the current list of ramp gradients.
  12045. * You must use addRampGradient and removeRampGradient to udpate this list
  12046. * @returns the list of ramp gradients
  12047. */
  12048. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12049. /**
  12050. * Adds a new ramp gradient used to remap particle colors
  12051. * @param gradient defines the gradient to use (between 0 and 1)
  12052. * @param color defines the color to affect to the specified gradient
  12053. * @returns the current particle system
  12054. */
  12055. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12056. /**
  12057. * Remove a specific ramp gradient
  12058. * @param gradient defines the gradient to remove
  12059. * @returns the current particle system
  12060. */
  12061. removeRampGradient(gradient: number): ParticleSystem;
  12062. /**
  12063. * Adds a new color gradient
  12064. * @param gradient defines the gradient to use (between 0 and 1)
  12065. * @param color1 defines the color to affect to the specified gradient
  12066. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12067. * @returns this particle system
  12068. */
  12069. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12070. /**
  12071. * Remove a specific color gradient
  12072. * @param gradient defines the gradient to remove
  12073. * @returns this particle system
  12074. */
  12075. removeColorGradient(gradient: number): IParticleSystem;
  12076. private _fetchR;
  12077. protected _reset(): void;
  12078. private _resetEffect;
  12079. private _createVertexBuffers;
  12080. private _createIndexBuffer;
  12081. /**
  12082. * Gets the maximum number of particles active at the same time.
  12083. * @returns The max number of active particles.
  12084. */
  12085. getCapacity(): number;
  12086. /**
  12087. * Gets whether there are still active particles in the system.
  12088. * @returns True if it is alive, otherwise false.
  12089. */
  12090. isAlive(): boolean;
  12091. /**
  12092. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12093. * @returns True if it has been started, otherwise false.
  12094. */
  12095. isStarted(): boolean;
  12096. private _prepareSubEmitterInternalArray;
  12097. /**
  12098. * Starts the particle system and begins to emit
  12099. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12100. */
  12101. start(delay?: number): void;
  12102. /**
  12103. * Stops the particle system.
  12104. * @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.
  12105. */
  12106. stop(stopSubEmitters?: boolean): void;
  12107. /**
  12108. * Remove all active particles
  12109. */
  12110. reset(): void;
  12111. /**
  12112. * @hidden (for internal use only)
  12113. */
  12114. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12115. /**
  12116. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12117. * Its lifetime will start back at 0.
  12118. */
  12119. recycleParticle: (particle: Particle) => void;
  12120. private _stopSubEmitters;
  12121. private _createParticle;
  12122. private _removeFromRoot;
  12123. private _emitFromParticle;
  12124. private _update;
  12125. /** @hidden */
  12126. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12127. /** @hidden */
  12128. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12129. /** @hidden */
  12130. private _getEffect;
  12131. /**
  12132. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12133. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12134. */
  12135. animate(preWarmOnly?: boolean): void;
  12136. private _appendParticleVertices;
  12137. /**
  12138. * Rebuilds the particle system.
  12139. */
  12140. rebuild(): void;
  12141. /**
  12142. * Is this system ready to be used/rendered
  12143. * @return true if the system is ready
  12144. */
  12145. isReady(): boolean;
  12146. private _render;
  12147. /**
  12148. * Renders the particle system in its current state.
  12149. * @returns the current number of particles
  12150. */
  12151. render(): number;
  12152. /**
  12153. * Disposes the particle system and free the associated resources
  12154. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12155. */
  12156. dispose(disposeTexture?: boolean): void;
  12157. /**
  12158. * Clones the particle system.
  12159. * @param name The name of the cloned object
  12160. * @param newEmitter The new emitter to use
  12161. * @returns the cloned particle system
  12162. */
  12163. clone(name: string, newEmitter: any): ParticleSystem;
  12164. /**
  12165. * Serializes the particle system to a JSON object.
  12166. * @returns the JSON object
  12167. */
  12168. serialize(): any;
  12169. /** @hidden */
  12170. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  12171. /** @hidden */
  12172. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12173. /**
  12174. * Parses a JSON object to create a particle system.
  12175. * @param parsedParticleSystem The JSON object to parse
  12176. * @param scene The scene to create the particle system in
  12177. * @param rootUrl The root url to use to load external dependencies like texture
  12178. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12179. * @returns the Parsed particle system
  12180. */
  12181. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12182. }
  12183. }
  12184. declare module "babylonjs/Particles/particle" {
  12185. import { Nullable } from "babylonjs/types";
  12186. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  12187. import { Color4 } from "babylonjs/Maths/math.color";
  12188. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12189. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12190. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  12191. /**
  12192. * A particle represents one of the element emitted by a particle system.
  12193. * This is mainly define by its coordinates, direction, velocity and age.
  12194. */
  12195. export class Particle {
  12196. /**
  12197. * The particle system the particle belongs to.
  12198. */
  12199. particleSystem: ParticleSystem;
  12200. private static _Count;
  12201. /**
  12202. * Unique ID of the particle
  12203. */
  12204. id: number;
  12205. /**
  12206. * The world position of the particle in the scene.
  12207. */
  12208. position: Vector3;
  12209. /**
  12210. * The world direction of the particle in the scene.
  12211. */
  12212. direction: Vector3;
  12213. /**
  12214. * The color of the particle.
  12215. */
  12216. color: Color4;
  12217. /**
  12218. * The color change of the particle per step.
  12219. */
  12220. colorStep: Color4;
  12221. /**
  12222. * Defines how long will the life of the particle be.
  12223. */
  12224. lifeTime: number;
  12225. /**
  12226. * The current age of the particle.
  12227. */
  12228. age: number;
  12229. /**
  12230. * The current size of the particle.
  12231. */
  12232. size: number;
  12233. /**
  12234. * The current scale of the particle.
  12235. */
  12236. scale: Vector2;
  12237. /**
  12238. * The current angle of the particle.
  12239. */
  12240. angle: number;
  12241. /**
  12242. * Defines how fast is the angle changing.
  12243. */
  12244. angularSpeed: number;
  12245. /**
  12246. * Defines the cell index used by the particle to be rendered from a sprite.
  12247. */
  12248. cellIndex: number;
  12249. /**
  12250. * The information required to support color remapping
  12251. */
  12252. remapData: Vector4;
  12253. /** @hidden */
  12254. _randomCellOffset?: number;
  12255. /** @hidden */
  12256. _initialDirection: Nullable<Vector3>;
  12257. /** @hidden */
  12258. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12259. /** @hidden */
  12260. _initialStartSpriteCellID: number;
  12261. /** @hidden */
  12262. _initialEndSpriteCellID: number;
  12263. /** @hidden */
  12264. _currentColorGradient: Nullable<ColorGradient>;
  12265. /** @hidden */
  12266. _currentColor1: Color4;
  12267. /** @hidden */
  12268. _currentColor2: Color4;
  12269. /** @hidden */
  12270. _currentSizeGradient: Nullable<FactorGradient>;
  12271. /** @hidden */
  12272. _currentSize1: number;
  12273. /** @hidden */
  12274. _currentSize2: number;
  12275. /** @hidden */
  12276. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12277. /** @hidden */
  12278. _currentAngularSpeed1: number;
  12279. /** @hidden */
  12280. _currentAngularSpeed2: number;
  12281. /** @hidden */
  12282. _currentVelocityGradient: Nullable<FactorGradient>;
  12283. /** @hidden */
  12284. _currentVelocity1: number;
  12285. /** @hidden */
  12286. _currentVelocity2: number;
  12287. /** @hidden */
  12288. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12289. /** @hidden */
  12290. _currentLimitVelocity1: number;
  12291. /** @hidden */
  12292. _currentLimitVelocity2: number;
  12293. /** @hidden */
  12294. _currentDragGradient: Nullable<FactorGradient>;
  12295. /** @hidden */
  12296. _currentDrag1: number;
  12297. /** @hidden */
  12298. _currentDrag2: number;
  12299. /** @hidden */
  12300. _randomNoiseCoordinates1: Vector3;
  12301. /** @hidden */
  12302. _randomNoiseCoordinates2: Vector3;
  12303. /**
  12304. * Creates a new instance Particle
  12305. * @param particleSystem the particle system the particle belongs to
  12306. */
  12307. constructor(
  12308. /**
  12309. * The particle system the particle belongs to.
  12310. */
  12311. particleSystem: ParticleSystem);
  12312. private updateCellInfoFromSystem;
  12313. /**
  12314. * Defines how the sprite cell index is updated for the particle
  12315. */
  12316. updateCellIndex(): void;
  12317. /** @hidden */
  12318. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12319. /** @hidden */
  12320. _inheritParticleInfoToSubEmitters(): void;
  12321. /** @hidden */
  12322. _reset(): void;
  12323. /**
  12324. * Copy the properties of particle to another one.
  12325. * @param other the particle to copy the information to.
  12326. */
  12327. copyTo(other: Particle): void;
  12328. }
  12329. }
  12330. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  12331. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12332. import { Effect } from "babylonjs/Materials/effect";
  12333. import { Particle } from "babylonjs/Particles/particle";
  12334. import { Scene } from "babylonjs/scene";
  12335. /**
  12336. * Particle emitter represents a volume emitting particles.
  12337. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12338. */
  12339. export interface IParticleEmitterType {
  12340. /**
  12341. * Called by the particle System when the direction is computed for the created particle.
  12342. * @param worldMatrix is the world matrix of the particle system
  12343. * @param directionToUpdate is the direction vector to update with the result
  12344. * @param particle is the particle we are computed the direction for
  12345. */
  12346. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12347. /**
  12348. * Called by the particle System when the position is computed for the created particle.
  12349. * @param worldMatrix is the world matrix of the particle system
  12350. * @param positionToUpdate is the position vector to update with the result
  12351. * @param particle is the particle we are computed the position for
  12352. */
  12353. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12354. /**
  12355. * Clones the current emitter and returns a copy of it
  12356. * @returns the new emitter
  12357. */
  12358. clone(): IParticleEmitterType;
  12359. /**
  12360. * Called by the GPUParticleSystem to setup the update shader
  12361. * @param effect defines the update shader
  12362. */
  12363. applyToShader(effect: Effect): void;
  12364. /**
  12365. * Returns a string to use to update the GPU particles update shader
  12366. * @returns the effect defines string
  12367. */
  12368. getEffectDefines(): string;
  12369. /**
  12370. * Returns a string representing the class name
  12371. * @returns a string containing the class name
  12372. */
  12373. getClassName(): string;
  12374. /**
  12375. * Serializes the particle system to a JSON object.
  12376. * @returns the JSON object
  12377. */
  12378. serialize(): any;
  12379. /**
  12380. * Parse properties from a JSON object
  12381. * @param serializationObject defines the JSON object
  12382. * @param scene defines the hosting scene
  12383. */
  12384. parse(serializationObject: any, scene: Scene): void;
  12385. }
  12386. }
  12387. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  12388. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12389. import { Effect } from "babylonjs/Materials/effect";
  12390. import { Particle } from "babylonjs/Particles/particle";
  12391. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12392. /**
  12393. * Particle emitter emitting particles from the inside of a box.
  12394. * It emits the particles randomly between 2 given directions.
  12395. */
  12396. export class BoxParticleEmitter implements IParticleEmitterType {
  12397. /**
  12398. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12399. */
  12400. direction1: Vector3;
  12401. /**
  12402. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12403. */
  12404. direction2: Vector3;
  12405. /**
  12406. * 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.
  12407. */
  12408. minEmitBox: Vector3;
  12409. /**
  12410. * 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.
  12411. */
  12412. maxEmitBox: Vector3;
  12413. /**
  12414. * Creates a new instance BoxParticleEmitter
  12415. */
  12416. constructor();
  12417. /**
  12418. * Called by the particle System when the direction is computed for the created particle.
  12419. * @param worldMatrix is the world matrix of the particle system
  12420. * @param directionToUpdate is the direction vector to update with the result
  12421. * @param particle is the particle we are computed the direction for
  12422. */
  12423. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12424. /**
  12425. * Called by the particle System when the position is computed for the created particle.
  12426. * @param worldMatrix is the world matrix of the particle system
  12427. * @param positionToUpdate is the position vector to update with the result
  12428. * @param particle is the particle we are computed the position for
  12429. */
  12430. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12431. /**
  12432. * Clones the current emitter and returns a copy of it
  12433. * @returns the new emitter
  12434. */
  12435. clone(): BoxParticleEmitter;
  12436. /**
  12437. * Called by the GPUParticleSystem to setup the update shader
  12438. * @param effect defines the update shader
  12439. */
  12440. applyToShader(effect: Effect): void;
  12441. /**
  12442. * Returns a string to use to update the GPU particles update shader
  12443. * @returns a string containng the defines string
  12444. */
  12445. getEffectDefines(): string;
  12446. /**
  12447. * Returns the string "BoxParticleEmitter"
  12448. * @returns a string containing the class name
  12449. */
  12450. getClassName(): string;
  12451. /**
  12452. * Serializes the particle system to a JSON object.
  12453. * @returns the JSON object
  12454. */
  12455. serialize(): any;
  12456. /**
  12457. * Parse properties from a JSON object
  12458. * @param serializationObject defines the JSON object
  12459. */
  12460. parse(serializationObject: any): void;
  12461. }
  12462. }
  12463. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  12464. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12465. import { Effect } from "babylonjs/Materials/effect";
  12466. import { Particle } from "babylonjs/Particles/particle";
  12467. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12468. /**
  12469. * Particle emitter emitting particles from the inside of a cone.
  12470. * It emits the particles alongside the cone volume from the base to the particle.
  12471. * The emission direction might be randomized.
  12472. */
  12473. export class ConeParticleEmitter implements IParticleEmitterType {
  12474. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12475. directionRandomizer: number;
  12476. private _radius;
  12477. private _angle;
  12478. private _height;
  12479. /**
  12480. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12481. */
  12482. radiusRange: number;
  12483. /**
  12484. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12485. */
  12486. heightRange: number;
  12487. /**
  12488. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12489. */
  12490. emitFromSpawnPointOnly: boolean;
  12491. /**
  12492. * Gets or sets the radius of the emission cone
  12493. */
  12494. get radius(): number;
  12495. set radius(value: number);
  12496. /**
  12497. * Gets or sets the angle of the emission cone
  12498. */
  12499. get angle(): number;
  12500. set angle(value: number);
  12501. private _buildHeight;
  12502. /**
  12503. * Creates a new instance ConeParticleEmitter
  12504. * @param radius the radius of the emission cone (1 by default)
  12505. * @param angle the cone base angle (PI by default)
  12506. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12507. */
  12508. constructor(radius?: number, angle?: number,
  12509. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12510. directionRandomizer?: number);
  12511. /**
  12512. * Called by the particle System when the direction is computed for the created particle.
  12513. * @param worldMatrix is the world matrix of the particle system
  12514. * @param directionToUpdate is the direction vector to update with the result
  12515. * @param particle is the particle we are computed the direction for
  12516. */
  12517. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12518. /**
  12519. * Called by the particle System when the position is computed for the created particle.
  12520. * @param worldMatrix is the world matrix of the particle system
  12521. * @param positionToUpdate is the position vector to update with the result
  12522. * @param particle is the particle we are computed the position for
  12523. */
  12524. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12525. /**
  12526. * Clones the current emitter and returns a copy of it
  12527. * @returns the new emitter
  12528. */
  12529. clone(): ConeParticleEmitter;
  12530. /**
  12531. * Called by the GPUParticleSystem to setup the update shader
  12532. * @param effect defines the update shader
  12533. */
  12534. applyToShader(effect: Effect): void;
  12535. /**
  12536. * Returns a string to use to update the GPU particles update shader
  12537. * @returns a string containng the defines string
  12538. */
  12539. getEffectDefines(): string;
  12540. /**
  12541. * Returns the string "ConeParticleEmitter"
  12542. * @returns a string containing the class name
  12543. */
  12544. getClassName(): string;
  12545. /**
  12546. * Serializes the particle system to a JSON object.
  12547. * @returns the JSON object
  12548. */
  12549. serialize(): any;
  12550. /**
  12551. * Parse properties from a JSON object
  12552. * @param serializationObject defines the JSON object
  12553. */
  12554. parse(serializationObject: any): void;
  12555. }
  12556. }
  12557. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  12558. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12559. import { Effect } from "babylonjs/Materials/effect";
  12560. import { Particle } from "babylonjs/Particles/particle";
  12561. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12562. /**
  12563. * Particle emitter emitting particles from the inside of a cylinder.
  12564. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12565. */
  12566. export class CylinderParticleEmitter implements IParticleEmitterType {
  12567. /**
  12568. * The radius of the emission cylinder.
  12569. */
  12570. radius: number;
  12571. /**
  12572. * The height of the emission cylinder.
  12573. */
  12574. height: number;
  12575. /**
  12576. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12577. */
  12578. radiusRange: number;
  12579. /**
  12580. * How much to randomize the particle direction [0-1].
  12581. */
  12582. directionRandomizer: number;
  12583. /**
  12584. * Creates a new instance CylinderParticleEmitter
  12585. * @param radius the radius of the emission cylinder (1 by default)
  12586. * @param height the height of the emission cylinder (1 by default)
  12587. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12588. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12589. */
  12590. constructor(
  12591. /**
  12592. * The radius of the emission cylinder.
  12593. */
  12594. radius?: number,
  12595. /**
  12596. * The height of the emission cylinder.
  12597. */
  12598. height?: number,
  12599. /**
  12600. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12601. */
  12602. radiusRange?: number,
  12603. /**
  12604. * How much to randomize the particle direction [0-1].
  12605. */
  12606. directionRandomizer?: number);
  12607. /**
  12608. * Called by the particle System when the direction is computed for the created particle.
  12609. * @param worldMatrix is the world matrix of the particle system
  12610. * @param directionToUpdate is the direction vector to update with the result
  12611. * @param particle is the particle we are computed the direction for
  12612. */
  12613. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12614. /**
  12615. * Called by the particle System when the position is computed for the created particle.
  12616. * @param worldMatrix is the world matrix of the particle system
  12617. * @param positionToUpdate is the position vector to update with the result
  12618. * @param particle is the particle we are computed the position for
  12619. */
  12620. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12621. /**
  12622. * Clones the current emitter and returns a copy of it
  12623. * @returns the new emitter
  12624. */
  12625. clone(): CylinderParticleEmitter;
  12626. /**
  12627. * Called by the GPUParticleSystem to setup the update shader
  12628. * @param effect defines the update shader
  12629. */
  12630. applyToShader(effect: Effect): void;
  12631. /**
  12632. * Returns a string to use to update the GPU particles update shader
  12633. * @returns a string containng the defines string
  12634. */
  12635. getEffectDefines(): string;
  12636. /**
  12637. * Returns the string "CylinderParticleEmitter"
  12638. * @returns a string containing the class name
  12639. */
  12640. getClassName(): string;
  12641. /**
  12642. * Serializes the particle system to a JSON object.
  12643. * @returns the JSON object
  12644. */
  12645. serialize(): any;
  12646. /**
  12647. * Parse properties from a JSON object
  12648. * @param serializationObject defines the JSON object
  12649. */
  12650. parse(serializationObject: any): void;
  12651. }
  12652. /**
  12653. * Particle emitter emitting particles from the inside of a cylinder.
  12654. * It emits the particles randomly between two vectors.
  12655. */
  12656. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12657. /**
  12658. * The min limit of the emission direction.
  12659. */
  12660. direction1: Vector3;
  12661. /**
  12662. * The max limit of the emission direction.
  12663. */
  12664. direction2: Vector3;
  12665. /**
  12666. * Creates a new instance CylinderDirectedParticleEmitter
  12667. * @param radius the radius of the emission cylinder (1 by default)
  12668. * @param height the height of the emission cylinder (1 by default)
  12669. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12670. * @param direction1 the min limit of the emission direction (up vector by default)
  12671. * @param direction2 the max limit of the emission direction (up vector by default)
  12672. */
  12673. constructor(radius?: number, height?: number, radiusRange?: number,
  12674. /**
  12675. * The min limit of the emission direction.
  12676. */
  12677. direction1?: Vector3,
  12678. /**
  12679. * The max limit of the emission direction.
  12680. */
  12681. direction2?: Vector3);
  12682. /**
  12683. * Called by the particle System when the direction is computed for the created particle.
  12684. * @param worldMatrix is the world matrix of the particle system
  12685. * @param directionToUpdate is the direction vector to update with the result
  12686. * @param particle is the particle we are computed the direction for
  12687. */
  12688. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12689. /**
  12690. * Clones the current emitter and returns a copy of it
  12691. * @returns the new emitter
  12692. */
  12693. clone(): CylinderDirectedParticleEmitter;
  12694. /**
  12695. * Called by the GPUParticleSystem to setup the update shader
  12696. * @param effect defines the update shader
  12697. */
  12698. applyToShader(effect: Effect): void;
  12699. /**
  12700. * Returns a string to use to update the GPU particles update shader
  12701. * @returns a string containng the defines string
  12702. */
  12703. getEffectDefines(): string;
  12704. /**
  12705. * Returns the string "CylinderDirectedParticleEmitter"
  12706. * @returns a string containing the class name
  12707. */
  12708. getClassName(): string;
  12709. /**
  12710. * Serializes the particle system to a JSON object.
  12711. * @returns the JSON object
  12712. */
  12713. serialize(): any;
  12714. /**
  12715. * Parse properties from a JSON object
  12716. * @param serializationObject defines the JSON object
  12717. */
  12718. parse(serializationObject: any): void;
  12719. }
  12720. }
  12721. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  12722. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12723. import { Effect } from "babylonjs/Materials/effect";
  12724. import { Particle } from "babylonjs/Particles/particle";
  12725. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12726. /**
  12727. * Particle emitter emitting particles from the inside of a hemisphere.
  12728. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12729. */
  12730. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12731. /**
  12732. * The radius of the emission hemisphere.
  12733. */
  12734. radius: number;
  12735. /**
  12736. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12737. */
  12738. radiusRange: number;
  12739. /**
  12740. * How much to randomize the particle direction [0-1].
  12741. */
  12742. directionRandomizer: number;
  12743. /**
  12744. * Creates a new instance HemisphericParticleEmitter
  12745. * @param radius the radius of the emission hemisphere (1 by default)
  12746. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12747. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12748. */
  12749. constructor(
  12750. /**
  12751. * The radius of the emission hemisphere.
  12752. */
  12753. radius?: number,
  12754. /**
  12755. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12756. */
  12757. radiusRange?: number,
  12758. /**
  12759. * How much to randomize the particle direction [0-1].
  12760. */
  12761. directionRandomizer?: number);
  12762. /**
  12763. * Called by the particle System when the direction is computed for the created particle.
  12764. * @param worldMatrix is the world matrix of the particle system
  12765. * @param directionToUpdate is the direction vector to update with the result
  12766. * @param particle is the particle we are computed the direction for
  12767. */
  12768. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12769. /**
  12770. * Called by the particle System when the position is computed for the created particle.
  12771. * @param worldMatrix is the world matrix of the particle system
  12772. * @param positionToUpdate is the position vector to update with the result
  12773. * @param particle is the particle we are computed the position for
  12774. */
  12775. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12776. /**
  12777. * Clones the current emitter and returns a copy of it
  12778. * @returns the new emitter
  12779. */
  12780. clone(): HemisphericParticleEmitter;
  12781. /**
  12782. * Called by the GPUParticleSystem to setup the update shader
  12783. * @param effect defines the update shader
  12784. */
  12785. applyToShader(effect: Effect): void;
  12786. /**
  12787. * Returns a string to use to update the GPU particles update shader
  12788. * @returns a string containng the defines string
  12789. */
  12790. getEffectDefines(): string;
  12791. /**
  12792. * Returns the string "HemisphericParticleEmitter"
  12793. * @returns a string containing the class name
  12794. */
  12795. getClassName(): string;
  12796. /**
  12797. * Serializes the particle system to a JSON object.
  12798. * @returns the JSON object
  12799. */
  12800. serialize(): any;
  12801. /**
  12802. * Parse properties from a JSON object
  12803. * @param serializationObject defines the JSON object
  12804. */
  12805. parse(serializationObject: any): void;
  12806. }
  12807. }
  12808. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  12809. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12810. import { Effect } from "babylonjs/Materials/effect";
  12811. import { Particle } from "babylonjs/Particles/particle";
  12812. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12813. /**
  12814. * Particle emitter emitting particles from a point.
  12815. * It emits the particles randomly between 2 given directions.
  12816. */
  12817. export class PointParticleEmitter implements IParticleEmitterType {
  12818. /**
  12819. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12820. */
  12821. direction1: Vector3;
  12822. /**
  12823. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12824. */
  12825. direction2: Vector3;
  12826. /**
  12827. * Creates a new instance PointParticleEmitter
  12828. */
  12829. constructor();
  12830. /**
  12831. * Called by the particle System when the direction is computed for the created particle.
  12832. * @param worldMatrix is the world matrix of the particle system
  12833. * @param directionToUpdate is the direction vector to update with the result
  12834. * @param particle is the particle we are computed the direction for
  12835. */
  12836. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12837. /**
  12838. * Called by the particle System when the position is computed for the created particle.
  12839. * @param worldMatrix is the world matrix of the particle system
  12840. * @param positionToUpdate is the position vector to update with the result
  12841. * @param particle is the particle we are computed the position for
  12842. */
  12843. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12844. /**
  12845. * Clones the current emitter and returns a copy of it
  12846. * @returns the new emitter
  12847. */
  12848. clone(): PointParticleEmitter;
  12849. /**
  12850. * Called by the GPUParticleSystem to setup the update shader
  12851. * @param effect defines the update shader
  12852. */
  12853. applyToShader(effect: Effect): void;
  12854. /**
  12855. * Returns a string to use to update the GPU particles update shader
  12856. * @returns a string containng the defines string
  12857. */
  12858. getEffectDefines(): string;
  12859. /**
  12860. * Returns the string "PointParticleEmitter"
  12861. * @returns a string containing the class name
  12862. */
  12863. getClassName(): string;
  12864. /**
  12865. * Serializes the particle system to a JSON object.
  12866. * @returns the JSON object
  12867. */
  12868. serialize(): any;
  12869. /**
  12870. * Parse properties from a JSON object
  12871. * @param serializationObject defines the JSON object
  12872. */
  12873. parse(serializationObject: any): void;
  12874. }
  12875. }
  12876. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  12877. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12878. import { Effect } from "babylonjs/Materials/effect";
  12879. import { Particle } from "babylonjs/Particles/particle";
  12880. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12881. /**
  12882. * Particle emitter emitting particles from the inside of a sphere.
  12883. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  12884. */
  12885. export class SphereParticleEmitter implements IParticleEmitterType {
  12886. /**
  12887. * The radius of the emission sphere.
  12888. */
  12889. radius: number;
  12890. /**
  12891. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12892. */
  12893. radiusRange: number;
  12894. /**
  12895. * How much to randomize the particle direction [0-1].
  12896. */
  12897. directionRandomizer: number;
  12898. /**
  12899. * Creates a new instance SphereParticleEmitter
  12900. * @param radius the radius of the emission sphere (1 by default)
  12901. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12902. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12903. */
  12904. constructor(
  12905. /**
  12906. * The radius of the emission sphere.
  12907. */
  12908. radius?: number,
  12909. /**
  12910. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12911. */
  12912. radiusRange?: number,
  12913. /**
  12914. * How much to randomize the particle direction [0-1].
  12915. */
  12916. directionRandomizer?: number);
  12917. /**
  12918. * Called by the particle System when the direction is computed for the created particle.
  12919. * @param worldMatrix is the world matrix of the particle system
  12920. * @param directionToUpdate is the direction vector to update with the result
  12921. * @param particle is the particle we are computed the direction for
  12922. */
  12923. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12924. /**
  12925. * Called by the particle System when the position is computed for the created particle.
  12926. * @param worldMatrix is the world matrix of the particle system
  12927. * @param positionToUpdate is the position vector to update with the result
  12928. * @param particle is the particle we are computed the position for
  12929. */
  12930. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12931. /**
  12932. * Clones the current emitter and returns a copy of it
  12933. * @returns the new emitter
  12934. */
  12935. clone(): SphereParticleEmitter;
  12936. /**
  12937. * Called by the GPUParticleSystem to setup the update shader
  12938. * @param effect defines the update shader
  12939. */
  12940. applyToShader(effect: Effect): void;
  12941. /**
  12942. * Returns a string to use to update the GPU particles update shader
  12943. * @returns a string containng the defines string
  12944. */
  12945. getEffectDefines(): string;
  12946. /**
  12947. * Returns the string "SphereParticleEmitter"
  12948. * @returns a string containing the class name
  12949. */
  12950. getClassName(): string;
  12951. /**
  12952. * Serializes the particle system to a JSON object.
  12953. * @returns the JSON object
  12954. */
  12955. serialize(): any;
  12956. /**
  12957. * Parse properties from a JSON object
  12958. * @param serializationObject defines the JSON object
  12959. */
  12960. parse(serializationObject: any): void;
  12961. }
  12962. /**
  12963. * Particle emitter emitting particles from the inside of a sphere.
  12964. * It emits the particles randomly between two vectors.
  12965. */
  12966. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  12967. /**
  12968. * The min limit of the emission direction.
  12969. */
  12970. direction1: Vector3;
  12971. /**
  12972. * The max limit of the emission direction.
  12973. */
  12974. direction2: Vector3;
  12975. /**
  12976. * Creates a new instance SphereDirectedParticleEmitter
  12977. * @param radius the radius of the emission sphere (1 by default)
  12978. * @param direction1 the min limit of the emission direction (up vector by default)
  12979. * @param direction2 the max limit of the emission direction (up vector by default)
  12980. */
  12981. constructor(radius?: number,
  12982. /**
  12983. * The min limit of the emission direction.
  12984. */
  12985. direction1?: Vector3,
  12986. /**
  12987. * The max limit of the emission direction.
  12988. */
  12989. direction2?: Vector3);
  12990. /**
  12991. * Called by the particle System when the direction is computed for the created particle.
  12992. * @param worldMatrix is the world matrix of the particle system
  12993. * @param directionToUpdate is the direction vector to update with the result
  12994. * @param particle is the particle we are computed the direction for
  12995. */
  12996. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12997. /**
  12998. * Clones the current emitter and returns a copy of it
  12999. * @returns the new emitter
  13000. */
  13001. clone(): SphereDirectedParticleEmitter;
  13002. /**
  13003. * Called by the GPUParticleSystem to setup the update shader
  13004. * @param effect defines the update shader
  13005. */
  13006. applyToShader(effect: Effect): void;
  13007. /**
  13008. * Returns a string to use to update the GPU particles update shader
  13009. * @returns a string containng the defines string
  13010. */
  13011. getEffectDefines(): string;
  13012. /**
  13013. * Returns the string "SphereDirectedParticleEmitter"
  13014. * @returns a string containing the class name
  13015. */
  13016. getClassName(): string;
  13017. /**
  13018. * Serializes the particle system to a JSON object.
  13019. * @returns the JSON object
  13020. */
  13021. serialize(): any;
  13022. /**
  13023. * Parse properties from a JSON object
  13024. * @param serializationObject defines the JSON object
  13025. */
  13026. parse(serializationObject: any): void;
  13027. }
  13028. }
  13029. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  13030. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13031. import { Effect } from "babylonjs/Materials/effect";
  13032. import { Particle } from "babylonjs/Particles/particle";
  13033. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13034. import { Nullable } from "babylonjs/types";
  13035. /**
  13036. * Particle emitter emitting particles from a custom list of positions.
  13037. */
  13038. export class CustomParticleEmitter implements IParticleEmitterType {
  13039. /**
  13040. * Gets or sets the position generator that will create the inital position of each particle.
  13041. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13042. */
  13043. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13044. /**
  13045. * Gets or sets the destination generator that will create the final destination of each particle.
  13046. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13047. */
  13048. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13049. /**
  13050. * Creates a new instance CustomParticleEmitter
  13051. */
  13052. constructor();
  13053. /**
  13054. * Called by the particle System when the direction is computed for the created particle.
  13055. * @param worldMatrix is the world matrix of the particle system
  13056. * @param directionToUpdate is the direction vector to update with the result
  13057. * @param particle is the particle we are computed the direction for
  13058. */
  13059. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13060. /**
  13061. * Called by the particle System when the position is computed for the created particle.
  13062. * @param worldMatrix is the world matrix of the particle system
  13063. * @param positionToUpdate is the position vector to update with the result
  13064. * @param particle is the particle we are computed the position for
  13065. */
  13066. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  13067. /**
  13068. * Clones the current emitter and returns a copy of it
  13069. * @returns the new emitter
  13070. */
  13071. clone(): CustomParticleEmitter;
  13072. /**
  13073. * Called by the GPUParticleSystem to setup the update shader
  13074. * @param effect defines the update shader
  13075. */
  13076. applyToShader(effect: Effect): void;
  13077. /**
  13078. * Returns a string to use to update the GPU particles update shader
  13079. * @returns a string containng the defines string
  13080. */
  13081. getEffectDefines(): string;
  13082. /**
  13083. * Returns the string "PointParticleEmitter"
  13084. * @returns a string containing the class name
  13085. */
  13086. getClassName(): string;
  13087. /**
  13088. * Serializes the particle system to a JSON object.
  13089. * @returns the JSON object
  13090. */
  13091. serialize(): any;
  13092. /**
  13093. * Parse properties from a JSON object
  13094. * @param serializationObject defines the JSON object
  13095. */
  13096. parse(serializationObject: any): void;
  13097. }
  13098. }
  13099. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  13100. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13101. import { Effect } from "babylonjs/Materials/effect";
  13102. import { Particle } from "babylonjs/Particles/particle";
  13103. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13104. import { Scene } from "babylonjs/scene";
  13105. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13106. /**
  13107. * Particle emitter emitting particles from the inside of a box.
  13108. * It emits the particles randomly between 2 given directions.
  13109. */
  13110. export class MeshParticleEmitter implements IParticleEmitterType {
  13111. /** Defines the mesh to use as source */
  13112. mesh?: AbstractMesh | undefined;
  13113. private _indices;
  13114. private _positions;
  13115. private _normals;
  13116. private _storedNormal;
  13117. /**
  13118. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13119. */
  13120. direction1: Vector3;
  13121. /**
  13122. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13123. */
  13124. direction2: Vector3;
  13125. /**
  13126. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13127. */
  13128. useMeshNormalsForDirection: boolean;
  13129. /**
  13130. * Creates a new instance MeshParticleEmitter
  13131. * @param mesh defines the mesh to use as source
  13132. */
  13133. constructor(
  13134. /** Defines the mesh to use as source */
  13135. mesh?: AbstractMesh | undefined);
  13136. /**
  13137. * Called by the particle System when the direction is computed for the created particle.
  13138. * @param worldMatrix is the world matrix of the particle system
  13139. * @param directionToUpdate is the direction vector to update with the result
  13140. * @param particle is the particle we are computed the direction for
  13141. */
  13142. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13143. /**
  13144. * Called by the particle System when the position is computed for the created particle.
  13145. * @param worldMatrix is the world matrix of the particle system
  13146. * @param positionToUpdate is the position vector to update with the result
  13147. * @param particle is the particle we are computed the position for
  13148. */
  13149. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  13150. /**
  13151. * Clones the current emitter and returns a copy of it
  13152. * @returns the new emitter
  13153. */
  13154. clone(): MeshParticleEmitter;
  13155. /**
  13156. * Called by the GPUParticleSystem to setup the update shader
  13157. * @param effect defines the update shader
  13158. */
  13159. applyToShader(effect: Effect): void;
  13160. /**
  13161. * Returns a string to use to update the GPU particles update shader
  13162. * @returns a string containng the defines string
  13163. */
  13164. getEffectDefines(): string;
  13165. /**
  13166. * Returns the string "BoxParticleEmitter"
  13167. * @returns a string containing the class name
  13168. */
  13169. getClassName(): string;
  13170. /**
  13171. * Serializes the particle system to a JSON object.
  13172. * @returns the JSON object
  13173. */
  13174. serialize(): any;
  13175. /**
  13176. * Parse properties from a JSON object
  13177. * @param serializationObject defines the JSON object
  13178. * @param scene defines the hosting scene
  13179. */
  13180. parse(serializationObject: any, scene: Scene): void;
  13181. }
  13182. }
  13183. declare module "babylonjs/Particles/EmitterTypes/index" {
  13184. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  13185. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  13186. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  13187. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  13188. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13189. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  13190. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  13191. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  13192. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  13193. }
  13194. declare module "babylonjs/Particles/IParticleSystem" {
  13195. import { Nullable } from "babylonjs/types";
  13196. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  13197. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  13198. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13199. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  13200. import { Texture } from "babylonjs/Materials/Textures/texture";
  13201. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  13202. import { Scene } from "babylonjs/scene";
  13203. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  13204. import { Animation } from "babylonjs/Animations/animation";
  13205. /**
  13206. * Interface representing a particle system in Babylon.js.
  13207. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13208. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13209. */
  13210. export interface IParticleSystem {
  13211. /**
  13212. * List of animations used by the particle system.
  13213. */
  13214. animations: Animation[];
  13215. /**
  13216. * The id of the Particle system.
  13217. */
  13218. id: string;
  13219. /**
  13220. * The name of the Particle system.
  13221. */
  13222. name: string;
  13223. /**
  13224. * The emitter represents the Mesh or position we are attaching the particle system to.
  13225. */
  13226. emitter: Nullable<AbstractMesh | Vector3>;
  13227. /**
  13228. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13229. */
  13230. isBillboardBased: boolean;
  13231. /**
  13232. * The rendering group used by the Particle system to chose when to render.
  13233. */
  13234. renderingGroupId: number;
  13235. /**
  13236. * The layer mask we are rendering the particles through.
  13237. */
  13238. layerMask: number;
  13239. /**
  13240. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13241. */
  13242. updateSpeed: number;
  13243. /**
  13244. * The amount of time the particle system is running (depends of the overall update speed).
  13245. */
  13246. targetStopDuration: number;
  13247. /**
  13248. * The texture used to render each particle. (this can be a spritesheet)
  13249. */
  13250. particleTexture: Nullable<Texture>;
  13251. /**
  13252. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13253. */
  13254. blendMode: number;
  13255. /**
  13256. * Minimum life time of emitting particles.
  13257. */
  13258. minLifeTime: number;
  13259. /**
  13260. * Maximum life time of emitting particles.
  13261. */
  13262. maxLifeTime: number;
  13263. /**
  13264. * Minimum Size of emitting particles.
  13265. */
  13266. minSize: number;
  13267. /**
  13268. * Maximum Size of emitting particles.
  13269. */
  13270. maxSize: number;
  13271. /**
  13272. * Minimum scale of emitting particles on X axis.
  13273. */
  13274. minScaleX: number;
  13275. /**
  13276. * Maximum scale of emitting particles on X axis.
  13277. */
  13278. maxScaleX: number;
  13279. /**
  13280. * Minimum scale of emitting particles on Y axis.
  13281. */
  13282. minScaleY: number;
  13283. /**
  13284. * Maximum scale of emitting particles on Y axis.
  13285. */
  13286. maxScaleY: number;
  13287. /**
  13288. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13289. */
  13290. color1: Color4;
  13291. /**
  13292. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13293. */
  13294. color2: Color4;
  13295. /**
  13296. * Color the particle will have at the end of its lifetime.
  13297. */
  13298. colorDead: Color4;
  13299. /**
  13300. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13301. */
  13302. emitRate: number;
  13303. /**
  13304. * You can use gravity if you want to give an orientation to your particles.
  13305. */
  13306. gravity: Vector3;
  13307. /**
  13308. * Minimum power of emitting particles.
  13309. */
  13310. minEmitPower: number;
  13311. /**
  13312. * Maximum power of emitting particles.
  13313. */
  13314. maxEmitPower: number;
  13315. /**
  13316. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13317. */
  13318. minAngularSpeed: number;
  13319. /**
  13320. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13321. */
  13322. maxAngularSpeed: number;
  13323. /**
  13324. * Gets or sets the minimal initial rotation in radians.
  13325. */
  13326. minInitialRotation: number;
  13327. /**
  13328. * Gets or sets the maximal initial rotation in radians.
  13329. */
  13330. maxInitialRotation: number;
  13331. /**
  13332. * The particle emitter type defines the emitter used by the particle system.
  13333. * It can be for example box, sphere, or cone...
  13334. */
  13335. particleEmitterType: Nullable<IParticleEmitterType>;
  13336. /**
  13337. * Defines the delay in milliseconds before starting the system (0 by default)
  13338. */
  13339. startDelay: number;
  13340. /**
  13341. * 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
  13342. */
  13343. preWarmCycles: number;
  13344. /**
  13345. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13346. */
  13347. preWarmStepOffset: number;
  13348. /**
  13349. * 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)
  13350. */
  13351. spriteCellChangeSpeed: number;
  13352. /**
  13353. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13354. */
  13355. startSpriteCellID: number;
  13356. /**
  13357. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13358. */
  13359. endSpriteCellID: number;
  13360. /**
  13361. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13362. */
  13363. spriteCellWidth: number;
  13364. /**
  13365. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13366. */
  13367. spriteCellHeight: number;
  13368. /**
  13369. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13370. */
  13371. spriteRandomStartCell: boolean;
  13372. /**
  13373. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13374. */
  13375. isAnimationSheetEnabled: boolean;
  13376. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13377. translationPivot: Vector2;
  13378. /**
  13379. * Gets or sets a texture used to add random noise to particle positions
  13380. */
  13381. noiseTexture: Nullable<BaseTexture>;
  13382. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13383. noiseStrength: Vector3;
  13384. /**
  13385. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13386. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13387. */
  13388. billboardMode: number;
  13389. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13390. limitVelocityDamping: number;
  13391. /**
  13392. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13393. */
  13394. beginAnimationOnStart: boolean;
  13395. /**
  13396. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13397. */
  13398. beginAnimationFrom: number;
  13399. /**
  13400. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13401. */
  13402. beginAnimationTo: number;
  13403. /**
  13404. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13405. */
  13406. beginAnimationLoop: boolean;
  13407. /**
  13408. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13409. */
  13410. disposeOnStop: boolean;
  13411. /**
  13412. * Gets the maximum number of particles active at the same time.
  13413. * @returns The max number of active particles.
  13414. */
  13415. getCapacity(): number;
  13416. /**
  13417. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13418. * @returns True if it has been started, otherwise false.
  13419. */
  13420. isStarted(): boolean;
  13421. /**
  13422. * Animates the particle system for this frame.
  13423. */
  13424. animate(): void;
  13425. /**
  13426. * Renders the particle system in its current state.
  13427. * @returns the current number of particles
  13428. */
  13429. render(): number;
  13430. /**
  13431. * Dispose the particle system and frees its associated resources.
  13432. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13433. */
  13434. dispose(disposeTexture?: boolean): void;
  13435. /**
  13436. * Clones the particle system.
  13437. * @param name The name of the cloned object
  13438. * @param newEmitter The new emitter to use
  13439. * @returns the cloned particle system
  13440. */
  13441. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13442. /**
  13443. * Serializes the particle system to a JSON object.
  13444. * @returns the JSON object
  13445. */
  13446. serialize(): any;
  13447. /**
  13448. * Rebuild the particle system
  13449. */
  13450. rebuild(): void;
  13451. /**
  13452. * Starts the particle system and begins to emit
  13453. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13454. */
  13455. start(delay?: number): void;
  13456. /**
  13457. * Stops the particle system.
  13458. */
  13459. stop(): void;
  13460. /**
  13461. * Remove all active particles
  13462. */
  13463. reset(): void;
  13464. /**
  13465. * Is this system ready to be used/rendered
  13466. * @return true if the system is ready
  13467. */
  13468. isReady(): boolean;
  13469. /**
  13470. * Adds a new color gradient
  13471. * @param gradient defines the gradient to use (between 0 and 1)
  13472. * @param color1 defines the color to affect to the specified gradient
  13473. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13474. * @returns the current particle system
  13475. */
  13476. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13477. /**
  13478. * Remove a specific color gradient
  13479. * @param gradient defines the gradient to remove
  13480. * @returns the current particle system
  13481. */
  13482. removeColorGradient(gradient: number): IParticleSystem;
  13483. /**
  13484. * Adds a new size gradient
  13485. * @param gradient defines the gradient to use (between 0 and 1)
  13486. * @param factor defines the size factor to affect to the specified gradient
  13487. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13488. * @returns the current particle system
  13489. */
  13490. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13491. /**
  13492. * Remove a specific size gradient
  13493. * @param gradient defines the gradient to remove
  13494. * @returns the current particle system
  13495. */
  13496. removeSizeGradient(gradient: number): IParticleSystem;
  13497. /**
  13498. * Gets the current list of color gradients.
  13499. * You must use addColorGradient and removeColorGradient to udpate this list
  13500. * @returns the list of color gradients
  13501. */
  13502. getColorGradients(): Nullable<Array<ColorGradient>>;
  13503. /**
  13504. * Gets the current list of size gradients.
  13505. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13506. * @returns the list of size gradients
  13507. */
  13508. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13509. /**
  13510. * Gets the current list of angular speed gradients.
  13511. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13512. * @returns the list of angular speed gradients
  13513. */
  13514. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13515. /**
  13516. * Adds a new angular speed gradient
  13517. * @param gradient defines the gradient to use (between 0 and 1)
  13518. * @param factor defines the angular speed to affect to the specified gradient
  13519. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13520. * @returns the current particle system
  13521. */
  13522. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13523. /**
  13524. * Remove a specific angular speed gradient
  13525. * @param gradient defines the gradient to remove
  13526. * @returns the current particle system
  13527. */
  13528. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13529. /**
  13530. * Gets the current list of velocity gradients.
  13531. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13532. * @returns the list of velocity gradients
  13533. */
  13534. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13535. /**
  13536. * Adds a new velocity gradient
  13537. * @param gradient defines the gradient to use (between 0 and 1)
  13538. * @param factor defines the velocity to affect to the specified gradient
  13539. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13540. * @returns the current particle system
  13541. */
  13542. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13543. /**
  13544. * Remove a specific velocity gradient
  13545. * @param gradient defines the gradient to remove
  13546. * @returns the current particle system
  13547. */
  13548. removeVelocityGradient(gradient: number): IParticleSystem;
  13549. /**
  13550. * Gets the current list of limit velocity gradients.
  13551. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13552. * @returns the list of limit velocity gradients
  13553. */
  13554. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13555. /**
  13556. * Adds a new limit velocity gradient
  13557. * @param gradient defines the gradient to use (between 0 and 1)
  13558. * @param factor defines the limit velocity to affect to the specified gradient
  13559. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13560. * @returns the current particle system
  13561. */
  13562. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13563. /**
  13564. * Remove a specific limit velocity gradient
  13565. * @param gradient defines the gradient to remove
  13566. * @returns the current particle system
  13567. */
  13568. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13569. /**
  13570. * Adds a new drag gradient
  13571. * @param gradient defines the gradient to use (between 0 and 1)
  13572. * @param factor defines the drag to affect to the specified gradient
  13573. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13574. * @returns the current particle system
  13575. */
  13576. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13577. /**
  13578. * Remove a specific drag gradient
  13579. * @param gradient defines the gradient to remove
  13580. * @returns the current particle system
  13581. */
  13582. removeDragGradient(gradient: number): IParticleSystem;
  13583. /**
  13584. * Gets the current list of drag gradients.
  13585. * You must use addDragGradient and removeDragGradient to udpate this list
  13586. * @returns the list of drag gradients
  13587. */
  13588. getDragGradients(): Nullable<Array<FactorGradient>>;
  13589. /**
  13590. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13591. * @param gradient defines the gradient to use (between 0 and 1)
  13592. * @param factor defines the emit rate to affect to the specified gradient
  13593. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13594. * @returns the current particle system
  13595. */
  13596. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13597. /**
  13598. * Remove a specific emit rate gradient
  13599. * @param gradient defines the gradient to remove
  13600. * @returns the current particle system
  13601. */
  13602. removeEmitRateGradient(gradient: number): IParticleSystem;
  13603. /**
  13604. * Gets the current list of emit rate gradients.
  13605. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13606. * @returns the list of emit rate gradients
  13607. */
  13608. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13609. /**
  13610. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13611. * @param gradient defines the gradient to use (between 0 and 1)
  13612. * @param factor defines the start size to affect to the specified gradient
  13613. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13614. * @returns the current particle system
  13615. */
  13616. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13617. /**
  13618. * Remove a specific start size gradient
  13619. * @param gradient defines the gradient to remove
  13620. * @returns the current particle system
  13621. */
  13622. removeStartSizeGradient(gradient: number): IParticleSystem;
  13623. /**
  13624. * Gets the current list of start size gradients.
  13625. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13626. * @returns the list of start size gradients
  13627. */
  13628. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13629. /**
  13630. * Adds a new life time gradient
  13631. * @param gradient defines the gradient to use (between 0 and 1)
  13632. * @param factor defines the life time factor to affect to the specified gradient
  13633. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13634. * @returns the current particle system
  13635. */
  13636. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13637. /**
  13638. * Remove a specific life time gradient
  13639. * @param gradient defines the gradient to remove
  13640. * @returns the current particle system
  13641. */
  13642. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13643. /**
  13644. * Gets the current list of life time gradients.
  13645. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13646. * @returns the list of life time gradients
  13647. */
  13648. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13649. /**
  13650. * Gets the current list of color gradients.
  13651. * You must use addColorGradient and removeColorGradient to udpate this list
  13652. * @returns the list of color gradients
  13653. */
  13654. getColorGradients(): Nullable<Array<ColorGradient>>;
  13655. /**
  13656. * Adds a new ramp gradient used to remap particle colors
  13657. * @param gradient defines the gradient to use (between 0 and 1)
  13658. * @param color defines the color to affect to the specified gradient
  13659. * @returns the current particle system
  13660. */
  13661. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13662. /**
  13663. * Gets the current list of ramp gradients.
  13664. * You must use addRampGradient and removeRampGradient to udpate this list
  13665. * @returns the list of ramp gradients
  13666. */
  13667. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13668. /** Gets or sets a boolean indicating that ramp gradients must be used
  13669. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13670. */
  13671. useRampGradients: boolean;
  13672. /**
  13673. * Adds a new color remap gradient
  13674. * @param gradient defines the gradient to use (between 0 and 1)
  13675. * @param min defines the color remap minimal range
  13676. * @param max defines the color remap maximal range
  13677. * @returns the current particle system
  13678. */
  13679. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13680. /**
  13681. * Gets the current list of color remap gradients.
  13682. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13683. * @returns the list of color remap gradients
  13684. */
  13685. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13686. /**
  13687. * Adds a new alpha remap gradient
  13688. * @param gradient defines the gradient to use (between 0 and 1)
  13689. * @param min defines the alpha remap minimal range
  13690. * @param max defines the alpha remap maximal range
  13691. * @returns the current particle system
  13692. */
  13693. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13694. /**
  13695. * Gets the current list of alpha remap gradients.
  13696. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13697. * @returns the list of alpha remap gradients
  13698. */
  13699. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13700. /**
  13701. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13702. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13703. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13704. * @returns the emitter
  13705. */
  13706. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13707. /**
  13708. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13709. * @param radius The radius of the hemisphere to emit from
  13710. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13711. * @returns the emitter
  13712. */
  13713. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13714. /**
  13715. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13716. * @param radius The radius of the sphere to emit from
  13717. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13718. * @returns the emitter
  13719. */
  13720. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13721. /**
  13722. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13723. * @param radius The radius of the sphere to emit from
  13724. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13725. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13726. * @returns the emitter
  13727. */
  13728. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13729. /**
  13730. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13731. * @param radius The radius of the emission cylinder
  13732. * @param height The height of the emission cylinder
  13733. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13734. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13735. * @returns the emitter
  13736. */
  13737. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13738. /**
  13739. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13740. * @param radius The radius of the cylinder to emit from
  13741. * @param height The height of the emission cylinder
  13742. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13743. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13744. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13745. * @returns the emitter
  13746. */
  13747. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13748. /**
  13749. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13750. * @param radius The radius of the cone to emit from
  13751. * @param angle The base angle of the cone
  13752. * @returns the emitter
  13753. */
  13754. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13755. /**
  13756. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13757. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13758. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13759. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13760. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13761. * @returns the emitter
  13762. */
  13763. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13764. /**
  13765. * Get hosting scene
  13766. * @returns the scene
  13767. */
  13768. getScene(): Scene;
  13769. }
  13770. }
  13771. declare module "babylonjs/Meshes/transformNode" {
  13772. import { DeepImmutable } from "babylonjs/types";
  13773. import { Observable } from "babylonjs/Misc/observable";
  13774. import { Nullable } from "babylonjs/types";
  13775. import { Camera } from "babylonjs/Cameras/camera";
  13776. import { Scene } from "babylonjs/scene";
  13777. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  13778. import { Node } from "babylonjs/node";
  13779. import { Bone } from "babylonjs/Bones/bone";
  13780. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13781. import { Space } from "babylonjs/Maths/math.axis";
  13782. /**
  13783. * 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.
  13784. * @see https://doc.babylonjs.com/how_to/transformnode
  13785. */
  13786. export class TransformNode extends Node {
  13787. /**
  13788. * Object will not rotate to face the camera
  13789. */
  13790. static BILLBOARDMODE_NONE: number;
  13791. /**
  13792. * Object will rotate to face the camera but only on the x axis
  13793. */
  13794. static BILLBOARDMODE_X: number;
  13795. /**
  13796. * Object will rotate to face the camera but only on the y axis
  13797. */
  13798. static BILLBOARDMODE_Y: number;
  13799. /**
  13800. * Object will rotate to face the camera but only on the z axis
  13801. */
  13802. static BILLBOARDMODE_Z: number;
  13803. /**
  13804. * Object will rotate to face the camera
  13805. */
  13806. static BILLBOARDMODE_ALL: number;
  13807. /**
  13808. * Object will rotate to face the camera's position instead of orientation
  13809. */
  13810. static BILLBOARDMODE_USE_POSITION: number;
  13811. private _forward;
  13812. private _forwardInverted;
  13813. private _up;
  13814. private _right;
  13815. private _rightInverted;
  13816. private _position;
  13817. private _rotation;
  13818. private _rotationQuaternion;
  13819. protected _scaling: Vector3;
  13820. protected _isDirty: boolean;
  13821. private _transformToBoneReferal;
  13822. private _isAbsoluteSynced;
  13823. private _billboardMode;
  13824. /**
  13825. * Gets or sets the billboard mode. Default is 0.
  13826. *
  13827. * | Value | Type | Description |
  13828. * | --- | --- | --- |
  13829. * | 0 | BILLBOARDMODE_NONE | |
  13830. * | 1 | BILLBOARDMODE_X | |
  13831. * | 2 | BILLBOARDMODE_Y | |
  13832. * | 4 | BILLBOARDMODE_Z | |
  13833. * | 7 | BILLBOARDMODE_ALL | |
  13834. *
  13835. */
  13836. get billboardMode(): number;
  13837. set billboardMode(value: number);
  13838. private _preserveParentRotationForBillboard;
  13839. /**
  13840. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13841. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13842. */
  13843. get preserveParentRotationForBillboard(): boolean;
  13844. set preserveParentRotationForBillboard(value: boolean);
  13845. /**
  13846. * 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
  13847. */
  13848. scalingDeterminant: number;
  13849. private _infiniteDistance;
  13850. /**
  13851. * Gets or sets the distance of the object to max, often used by skybox
  13852. */
  13853. get infiniteDistance(): boolean;
  13854. set infiniteDistance(value: boolean);
  13855. /**
  13856. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13857. * By default the system will update normals to compensate
  13858. */
  13859. ignoreNonUniformScaling: boolean;
  13860. /**
  13861. * 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
  13862. */
  13863. reIntegrateRotationIntoRotationQuaternion: boolean;
  13864. /** @hidden */
  13865. _poseMatrix: Nullable<Matrix>;
  13866. /** @hidden */
  13867. _localMatrix: Matrix;
  13868. private _usePivotMatrix;
  13869. private _absolutePosition;
  13870. private _absoluteScaling;
  13871. private _absoluteRotationQuaternion;
  13872. private _pivotMatrix;
  13873. private _pivotMatrixInverse;
  13874. protected _postMultiplyPivotMatrix: boolean;
  13875. protected _isWorldMatrixFrozen: boolean;
  13876. /** @hidden */
  13877. _indexInSceneTransformNodesArray: number;
  13878. /**
  13879. * An event triggered after the world matrix is updated
  13880. */
  13881. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13882. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13883. /**
  13884. * Gets a string identifying the name of the class
  13885. * @returns "TransformNode" string
  13886. */
  13887. getClassName(): string;
  13888. /**
  13889. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13890. */
  13891. get position(): Vector3;
  13892. set position(newPosition: Vector3);
  13893. /**
  13894. * 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)).
  13895. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13896. */
  13897. get rotation(): Vector3;
  13898. set rotation(newRotation: Vector3);
  13899. /**
  13900. * 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)).
  13901. */
  13902. get scaling(): Vector3;
  13903. set scaling(newScaling: Vector3);
  13904. /**
  13905. * 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).
  13906. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13907. */
  13908. get rotationQuaternion(): Nullable<Quaternion>;
  13909. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  13910. /**
  13911. * The forward direction of that transform in world space.
  13912. */
  13913. get forward(): Vector3;
  13914. /**
  13915. * The up direction of that transform in world space.
  13916. */
  13917. get up(): Vector3;
  13918. /**
  13919. * The right direction of that transform in world space.
  13920. */
  13921. get right(): Vector3;
  13922. /**
  13923. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13924. * @param matrix the matrix to copy the pose from
  13925. * @returns this TransformNode.
  13926. */
  13927. updatePoseMatrix(matrix: Matrix): TransformNode;
  13928. /**
  13929. * Returns the mesh Pose matrix.
  13930. * @returns the pose matrix
  13931. */
  13932. getPoseMatrix(): Matrix;
  13933. /** @hidden */
  13934. _isSynchronized(): boolean;
  13935. /** @hidden */
  13936. _initCache(): void;
  13937. /**
  13938. * Flag the transform node as dirty (Forcing it to update everything)
  13939. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13940. * @returns this transform node
  13941. */
  13942. markAsDirty(property: string): TransformNode;
  13943. /**
  13944. * Returns the current mesh absolute position.
  13945. * Returns a Vector3.
  13946. */
  13947. get absolutePosition(): Vector3;
  13948. /**
  13949. * Returns the current mesh absolute scaling.
  13950. * Returns a Vector3.
  13951. */
  13952. get absoluteScaling(): Vector3;
  13953. /**
  13954. * Returns the current mesh absolute rotation.
  13955. * Returns a Quaternion.
  13956. */
  13957. get absoluteRotationQuaternion(): Quaternion;
  13958. /**
  13959. * Sets a new matrix to apply before all other transformation
  13960. * @param matrix defines the transform matrix
  13961. * @returns the current TransformNode
  13962. */
  13963. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13964. /**
  13965. * Sets a new pivot matrix to the current node
  13966. * @param matrix defines the new pivot matrix to use
  13967. * @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
  13968. * @returns the current TransformNode
  13969. */
  13970. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13971. /**
  13972. * Returns the mesh pivot matrix.
  13973. * Default : Identity.
  13974. * @returns the matrix
  13975. */
  13976. getPivotMatrix(): Matrix;
  13977. /**
  13978. * Instantiate (when possible) or clone that node with its hierarchy
  13979. * @param newParent defines the new parent to use for the instance (or clone)
  13980. * @param options defines options to configure how copy is done
  13981. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  13982. * @returns an instance (or a clone) of the current node with its hiearchy
  13983. */
  13984. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  13985. doNotInstantiate: boolean;
  13986. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  13987. /**
  13988. * Prevents the World matrix to be computed any longer
  13989. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13990. * @returns the TransformNode.
  13991. */
  13992. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13993. /**
  13994. * Allows back the World matrix computation.
  13995. * @returns the TransformNode.
  13996. */
  13997. unfreezeWorldMatrix(): this;
  13998. /**
  13999. * True if the World matrix has been frozen.
  14000. */
  14001. get isWorldMatrixFrozen(): boolean;
  14002. /**
  14003. * Retuns the mesh absolute position in the World.
  14004. * @returns a Vector3.
  14005. */
  14006. getAbsolutePosition(): Vector3;
  14007. /**
  14008. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14009. * @param absolutePosition the absolute position to set
  14010. * @returns the TransformNode.
  14011. */
  14012. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14013. /**
  14014. * Sets the mesh position in its local space.
  14015. * @param vector3 the position to set in localspace
  14016. * @returns the TransformNode.
  14017. */
  14018. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14019. /**
  14020. * Returns the mesh position in the local space from the current World matrix values.
  14021. * @returns a new Vector3.
  14022. */
  14023. getPositionExpressedInLocalSpace(): Vector3;
  14024. /**
  14025. * Translates the mesh along the passed Vector3 in its local space.
  14026. * @param vector3 the distance to translate in localspace
  14027. * @returns the TransformNode.
  14028. */
  14029. locallyTranslate(vector3: Vector3): TransformNode;
  14030. private static _lookAtVectorCache;
  14031. /**
  14032. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14033. * @param targetPoint the position (must be in same space as current mesh) to look at
  14034. * @param yawCor optional yaw (y-axis) correction in radians
  14035. * @param pitchCor optional pitch (x-axis) correction in radians
  14036. * @param rollCor optional roll (z-axis) correction in radians
  14037. * @param space the choosen space of the target
  14038. * @returns the TransformNode.
  14039. */
  14040. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14041. /**
  14042. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14043. * This Vector3 is expressed in the World space.
  14044. * @param localAxis axis to rotate
  14045. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14046. */
  14047. getDirection(localAxis: Vector3): Vector3;
  14048. /**
  14049. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14050. * localAxis is expressed in the mesh local space.
  14051. * result is computed in the Wordl space from the mesh World matrix.
  14052. * @param localAxis axis to rotate
  14053. * @param result the resulting transformnode
  14054. * @returns this TransformNode.
  14055. */
  14056. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14057. /**
  14058. * Sets this transform node rotation to the given local axis.
  14059. * @param localAxis the axis in local space
  14060. * @param yawCor optional yaw (y-axis) correction in radians
  14061. * @param pitchCor optional pitch (x-axis) correction in radians
  14062. * @param rollCor optional roll (z-axis) correction in radians
  14063. * @returns this TransformNode
  14064. */
  14065. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14066. /**
  14067. * Sets a new pivot point to the current node
  14068. * @param point defines the new pivot point to use
  14069. * @param space defines if the point is in world or local space (local by default)
  14070. * @returns the current TransformNode
  14071. */
  14072. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14073. /**
  14074. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14075. * @returns the pivot point
  14076. */
  14077. getPivotPoint(): Vector3;
  14078. /**
  14079. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14080. * @param result the vector3 to store the result
  14081. * @returns this TransformNode.
  14082. */
  14083. getPivotPointToRef(result: Vector3): TransformNode;
  14084. /**
  14085. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14086. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14087. */
  14088. getAbsolutePivotPoint(): Vector3;
  14089. /**
  14090. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14091. * @param result vector3 to store the result
  14092. * @returns this TransformNode.
  14093. */
  14094. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14095. /**
  14096. * Defines the passed node as the parent of the current node.
  14097. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14098. * @see https://doc.babylonjs.com/how_to/parenting
  14099. * @param node the node ot set as the parent
  14100. * @returns this TransformNode.
  14101. */
  14102. setParent(node: Nullable<Node>): TransformNode;
  14103. private _nonUniformScaling;
  14104. /**
  14105. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14106. */
  14107. get nonUniformScaling(): boolean;
  14108. /** @hidden */
  14109. _updateNonUniformScalingState(value: boolean): boolean;
  14110. /**
  14111. * Attach the current TransformNode to another TransformNode associated with a bone
  14112. * @param bone Bone affecting the TransformNode
  14113. * @param affectedTransformNode TransformNode associated with the bone
  14114. * @returns this object
  14115. */
  14116. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14117. /**
  14118. * Detach the transform node if its associated with a bone
  14119. * @returns this object
  14120. */
  14121. detachFromBone(): TransformNode;
  14122. private static _rotationAxisCache;
  14123. /**
  14124. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14125. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14126. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14127. * The passed axis is also normalized.
  14128. * @param axis the axis to rotate around
  14129. * @param amount the amount to rotate in radians
  14130. * @param space Space to rotate in (Default: local)
  14131. * @returns the TransformNode.
  14132. */
  14133. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14134. /**
  14135. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14136. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14137. * The passed axis is also normalized. .
  14138. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14139. * @param point the point to rotate around
  14140. * @param axis the axis to rotate around
  14141. * @param amount the amount to rotate in radians
  14142. * @returns the TransformNode
  14143. */
  14144. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14145. /**
  14146. * Translates the mesh along the axis vector for the passed distance in the given space.
  14147. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14148. * @param axis the axis to translate in
  14149. * @param distance the distance to translate
  14150. * @param space Space to rotate in (Default: local)
  14151. * @returns the TransformNode.
  14152. */
  14153. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14154. /**
  14155. * Adds a rotation step to the mesh current rotation.
  14156. * x, y, z are Euler angles expressed in radians.
  14157. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14158. * This means this rotation is made in the mesh local space only.
  14159. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14160. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14161. * ```javascript
  14162. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14163. * ```
  14164. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14165. * 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.
  14166. * @param x Rotation to add
  14167. * @param y Rotation to add
  14168. * @param z Rotation to add
  14169. * @returns the TransformNode.
  14170. */
  14171. addRotation(x: number, y: number, z: number): TransformNode;
  14172. /**
  14173. * @hidden
  14174. */
  14175. protected _getEffectiveParent(): Nullable<Node>;
  14176. /**
  14177. * Computes the world matrix of the node
  14178. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14179. * @returns the world matrix
  14180. */
  14181. computeWorldMatrix(force?: boolean): Matrix;
  14182. /**
  14183. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14184. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14185. */
  14186. resetLocalMatrix(independentOfChildren?: boolean): void;
  14187. protected _afterComputeWorldMatrix(): void;
  14188. /**
  14189. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14190. * @param func callback function to add
  14191. *
  14192. * @returns the TransformNode.
  14193. */
  14194. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14195. /**
  14196. * Removes a registered callback function.
  14197. * @param func callback function to remove
  14198. * @returns the TransformNode.
  14199. */
  14200. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14201. /**
  14202. * Gets the position of the current mesh in camera space
  14203. * @param camera defines the camera to use
  14204. * @returns a position
  14205. */
  14206. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14207. /**
  14208. * Returns the distance from the mesh to the active camera
  14209. * @param camera defines the camera to use
  14210. * @returns the distance
  14211. */
  14212. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14213. /**
  14214. * Clone the current transform node
  14215. * @param name Name of the new clone
  14216. * @param newParent New parent for the clone
  14217. * @param doNotCloneChildren Do not clone children hierarchy
  14218. * @returns the new transform node
  14219. */
  14220. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14221. /**
  14222. * Serializes the objects information.
  14223. * @param currentSerializationObject defines the object to serialize in
  14224. * @returns the serialized object
  14225. */
  14226. serialize(currentSerializationObject?: any): any;
  14227. /**
  14228. * Returns a new TransformNode object parsed from the source provided.
  14229. * @param parsedTransformNode is the source.
  14230. * @param scene the scne the object belongs to
  14231. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14232. * @returns a new TransformNode object parsed from the source provided.
  14233. */
  14234. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14235. /**
  14236. * Get all child-transformNodes of this node
  14237. * @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
  14238. * @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
  14239. * @returns an array of TransformNode
  14240. */
  14241. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14242. /**
  14243. * Releases resources associated with this transform node.
  14244. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14245. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14246. */
  14247. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14248. /**
  14249. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14250. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14251. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14252. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14253. * @returns the current mesh
  14254. */
  14255. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14256. private _syncAbsoluteScalingAndRotation;
  14257. }
  14258. }
  14259. declare module "babylonjs/Animations/animationPropertiesOverride" {
  14260. /**
  14261. * Class used to override all child animations of a given target
  14262. */
  14263. export class AnimationPropertiesOverride {
  14264. /**
  14265. * Gets or sets a value indicating if animation blending must be used
  14266. */
  14267. enableBlending: boolean;
  14268. /**
  14269. * Gets or sets the blending speed to use when enableBlending is true
  14270. */
  14271. blendingSpeed: number;
  14272. /**
  14273. * Gets or sets the default loop mode to use
  14274. */
  14275. loopMode: number;
  14276. }
  14277. }
  14278. declare module "babylonjs/Bones/bone" {
  14279. import { Skeleton } from "babylonjs/Bones/skeleton";
  14280. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  14281. import { Nullable } from "babylonjs/types";
  14282. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14283. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14284. import { Node } from "babylonjs/node";
  14285. import { Space } from "babylonjs/Maths/math.axis";
  14286. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  14287. /**
  14288. * Class used to store bone information
  14289. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14290. */
  14291. export class Bone extends Node {
  14292. /**
  14293. * defines the bone name
  14294. */
  14295. name: string;
  14296. private static _tmpVecs;
  14297. private static _tmpQuat;
  14298. private static _tmpMats;
  14299. /**
  14300. * Gets the list of child bones
  14301. */
  14302. children: Bone[];
  14303. /** Gets the animations associated with this bone */
  14304. animations: import("babylonjs/Animations/animation").Animation[];
  14305. /**
  14306. * Gets or sets bone length
  14307. */
  14308. length: number;
  14309. /**
  14310. * @hidden Internal only
  14311. * Set this value to map this bone to a different index in the transform matrices
  14312. * Set this value to -1 to exclude the bone from the transform matrices
  14313. */
  14314. _index: Nullable<number>;
  14315. private _skeleton;
  14316. private _localMatrix;
  14317. private _restPose;
  14318. private _baseMatrix;
  14319. private _absoluteTransform;
  14320. private _invertedAbsoluteTransform;
  14321. private _parent;
  14322. private _scalingDeterminant;
  14323. private _worldTransform;
  14324. private _localScaling;
  14325. private _localRotation;
  14326. private _localPosition;
  14327. private _needToDecompose;
  14328. private _needToCompose;
  14329. /** @hidden */
  14330. _linkedTransformNode: Nullable<TransformNode>;
  14331. /** @hidden */
  14332. _waitingTransformNodeId: Nullable<string>;
  14333. /** @hidden */
  14334. get _matrix(): Matrix;
  14335. /** @hidden */
  14336. set _matrix(value: Matrix);
  14337. /**
  14338. * Create a new bone
  14339. * @param name defines the bone name
  14340. * @param skeleton defines the parent skeleton
  14341. * @param parentBone defines the parent (can be null if the bone is the root)
  14342. * @param localMatrix defines the local matrix
  14343. * @param restPose defines the rest pose matrix
  14344. * @param baseMatrix defines the base matrix
  14345. * @param index defines index of the bone in the hiearchy
  14346. */
  14347. constructor(
  14348. /**
  14349. * defines the bone name
  14350. */
  14351. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14352. /**
  14353. * Gets the current object class name.
  14354. * @return the class name
  14355. */
  14356. getClassName(): string;
  14357. /**
  14358. * Gets the parent skeleton
  14359. * @returns a skeleton
  14360. */
  14361. getSkeleton(): Skeleton;
  14362. /**
  14363. * Gets parent bone
  14364. * @returns a bone or null if the bone is the root of the bone hierarchy
  14365. */
  14366. getParent(): Nullable<Bone>;
  14367. /**
  14368. * Returns an array containing the root bones
  14369. * @returns an array containing the root bones
  14370. */
  14371. getChildren(): Array<Bone>;
  14372. /**
  14373. * Gets the node index in matrix array generated for rendering
  14374. * @returns the node index
  14375. */
  14376. getIndex(): number;
  14377. /**
  14378. * Sets the parent bone
  14379. * @param parent defines the parent (can be null if the bone is the root)
  14380. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14381. */
  14382. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14383. /**
  14384. * Gets the local matrix
  14385. * @returns a matrix
  14386. */
  14387. getLocalMatrix(): Matrix;
  14388. /**
  14389. * Gets the base matrix (initial matrix which remains unchanged)
  14390. * @returns a matrix
  14391. */
  14392. getBaseMatrix(): Matrix;
  14393. /**
  14394. * Gets the rest pose matrix
  14395. * @returns a matrix
  14396. */
  14397. getRestPose(): Matrix;
  14398. /**
  14399. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14400. */
  14401. getWorldMatrix(): Matrix;
  14402. /**
  14403. * Sets the local matrix to rest pose matrix
  14404. */
  14405. returnToRest(): void;
  14406. /**
  14407. * Gets the inverse of the absolute transform matrix.
  14408. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14409. * @returns a matrix
  14410. */
  14411. getInvertedAbsoluteTransform(): Matrix;
  14412. /**
  14413. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14414. * @returns a matrix
  14415. */
  14416. getAbsoluteTransform(): Matrix;
  14417. /**
  14418. * Links with the given transform node.
  14419. * The local matrix of this bone is copied from the transform node every frame.
  14420. * @param transformNode defines the transform node to link to
  14421. */
  14422. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14423. /**
  14424. * Gets the node used to drive the bone's transformation
  14425. * @returns a transform node or null
  14426. */
  14427. getTransformNode(): Nullable<TransformNode>;
  14428. /** Gets or sets current position (in local space) */
  14429. get position(): Vector3;
  14430. set position(newPosition: Vector3);
  14431. /** Gets or sets current rotation (in local space) */
  14432. get rotation(): Vector3;
  14433. set rotation(newRotation: Vector3);
  14434. /** Gets or sets current rotation quaternion (in local space) */
  14435. get rotationQuaternion(): Quaternion;
  14436. set rotationQuaternion(newRotation: Quaternion);
  14437. /** Gets or sets current scaling (in local space) */
  14438. get scaling(): Vector3;
  14439. set scaling(newScaling: Vector3);
  14440. /**
  14441. * Gets the animation properties override
  14442. */
  14443. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14444. private _decompose;
  14445. private _compose;
  14446. /**
  14447. * Update the base and local matrices
  14448. * @param matrix defines the new base or local matrix
  14449. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14450. * @param updateLocalMatrix defines if the local matrix should be updated
  14451. */
  14452. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14453. /** @hidden */
  14454. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14455. /**
  14456. * Flag the bone as dirty (Forcing it to update everything)
  14457. */
  14458. markAsDirty(): void;
  14459. /** @hidden */
  14460. _markAsDirtyAndCompose(): void;
  14461. private _markAsDirtyAndDecompose;
  14462. /**
  14463. * Translate the bone in local or world space
  14464. * @param vec The amount to translate the bone
  14465. * @param space The space that the translation is in
  14466. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14467. */
  14468. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14469. /**
  14470. * Set the postion of the bone in local or world space
  14471. * @param position The position to set the bone
  14472. * @param space The space that the position is in
  14473. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14474. */
  14475. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14476. /**
  14477. * Set the absolute position of the bone (world space)
  14478. * @param position The position to set the bone
  14479. * @param mesh The mesh that this bone is attached to
  14480. */
  14481. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14482. /**
  14483. * Scale the bone on the x, y and z axes (in local space)
  14484. * @param x The amount to scale the bone on the x axis
  14485. * @param y The amount to scale the bone on the y axis
  14486. * @param z The amount to scale the bone on the z axis
  14487. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14488. */
  14489. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14490. /**
  14491. * Set the bone scaling in local space
  14492. * @param scale defines the scaling vector
  14493. */
  14494. setScale(scale: Vector3): void;
  14495. /**
  14496. * Gets the current scaling in local space
  14497. * @returns the current scaling vector
  14498. */
  14499. getScale(): Vector3;
  14500. /**
  14501. * Gets the current scaling in local space and stores it in a target vector
  14502. * @param result defines the target vector
  14503. */
  14504. getScaleToRef(result: Vector3): void;
  14505. /**
  14506. * Set the yaw, pitch, and roll of the bone in local or world space
  14507. * @param yaw The rotation of the bone on the y axis
  14508. * @param pitch The rotation of the bone on the x axis
  14509. * @param roll The rotation of the bone on the z axis
  14510. * @param space The space that the axes of rotation are in
  14511. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14512. */
  14513. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14514. /**
  14515. * Add a rotation to the bone on an axis in local or world space
  14516. * @param axis The axis to rotate the bone on
  14517. * @param amount The amount to rotate the bone
  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. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14522. /**
  14523. * Set the rotation of the bone to a particular axis angle in local or world space
  14524. * @param axis The axis to rotate the bone on
  14525. * @param angle The angle that the bone should be rotated to
  14526. * @param space The space that the axis is in
  14527. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14528. */
  14529. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14530. /**
  14531. * Set the euler rotation of the bone in local of world space
  14532. * @param rotation The euler rotation that the bone should be set to
  14533. * @param space The space that the rotation is in
  14534. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14535. */
  14536. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14537. /**
  14538. * Set the quaternion rotation of the bone in local of world space
  14539. * @param quat The quaternion rotation that the bone should be set to
  14540. * @param space The space that the rotation is in
  14541. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14542. */
  14543. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14544. /**
  14545. * Set the rotation matrix of the bone in local of world space
  14546. * @param rotMat The rotation matrix that the bone should be set to
  14547. * @param space The space that the rotation is in
  14548. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14549. */
  14550. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14551. private _rotateWithMatrix;
  14552. private _getNegativeRotationToRef;
  14553. /**
  14554. * Get the position of the bone in local or world space
  14555. * @param space The space that the returned position is in
  14556. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14557. * @returns The position of the bone
  14558. */
  14559. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14560. /**
  14561. * Copy the position of the bone to a vector3 in local or world space
  14562. * @param space The space that the returned position is in
  14563. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14564. * @param result The vector3 to copy the position to
  14565. */
  14566. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14567. /**
  14568. * Get the absolute position of the bone (world space)
  14569. * @param mesh The mesh that this bone is attached to
  14570. * @returns The absolute position of the bone
  14571. */
  14572. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14573. /**
  14574. * Copy the absolute position of the bone (world space) to the result param
  14575. * @param mesh The mesh that this bone is attached to
  14576. * @param result The vector3 to copy the absolute position to
  14577. */
  14578. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14579. /**
  14580. * Compute the absolute transforms of this bone and its children
  14581. */
  14582. computeAbsoluteTransforms(): void;
  14583. /**
  14584. * Get the world direction from an axis that is in the local space of the bone
  14585. * @param localAxis The local direction that is used to compute the world direction
  14586. * @param mesh The mesh that this bone is attached to
  14587. * @returns The world direction
  14588. */
  14589. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14590. /**
  14591. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14592. * @param localAxis The local direction that is used to compute the world direction
  14593. * @param mesh The mesh that this bone is attached to
  14594. * @param result The vector3 that the world direction will be copied to
  14595. */
  14596. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14597. /**
  14598. * Get the euler rotation of the bone in local or world space
  14599. * @param space The space that the rotation should be in
  14600. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14601. * @returns The euler rotation
  14602. */
  14603. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14604. /**
  14605. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14606. * @param space The space that the rotation should be in
  14607. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14608. * @param result The vector3 that the rotation should be copied to
  14609. */
  14610. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14611. /**
  14612. * Get the quaternion rotation of the bone in either local or world space
  14613. * @param space The space that the rotation should be in
  14614. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14615. * @returns The quaternion rotation
  14616. */
  14617. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14618. /**
  14619. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14620. * @param space The space that the rotation should be in
  14621. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14622. * @param result The quaternion that the rotation should be copied to
  14623. */
  14624. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14625. /**
  14626. * Get the rotation matrix of the bone in local or world space
  14627. * @param space The space that the rotation should be in
  14628. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14629. * @returns The rotation matrix
  14630. */
  14631. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14632. /**
  14633. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14634. * @param space The space that the rotation should be in
  14635. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14636. * @param result The quaternion that the rotation should be copied to
  14637. */
  14638. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14639. /**
  14640. * Get the world position of a point that is in the local space of the bone
  14641. * @param position The local position
  14642. * @param mesh The mesh that this bone is attached to
  14643. * @returns The world position
  14644. */
  14645. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14646. /**
  14647. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14648. * @param position The local position
  14649. * @param mesh The mesh that this bone is attached to
  14650. * @param result The vector3 that the world position should be copied to
  14651. */
  14652. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14653. /**
  14654. * Get the local position of a point that is in world space
  14655. * @param position The world position
  14656. * @param mesh The mesh that this bone is attached to
  14657. * @returns The local position
  14658. */
  14659. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14660. /**
  14661. * Get the local position of a point that is in world space and copy it to the result param
  14662. * @param position The world position
  14663. * @param mesh The mesh that this bone is attached to
  14664. * @param result The vector3 that the local position should be copied to
  14665. */
  14666. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14667. }
  14668. }
  14669. declare module "babylonjs/Animations/runtimeAnimation" {
  14670. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  14671. import { Animatable } from "babylonjs/Animations/animatable";
  14672. import { Scene } from "babylonjs/scene";
  14673. /**
  14674. * Defines a runtime animation
  14675. */
  14676. export class RuntimeAnimation {
  14677. private _events;
  14678. /**
  14679. * The current frame of the runtime animation
  14680. */
  14681. private _currentFrame;
  14682. /**
  14683. * The animation used by the runtime animation
  14684. */
  14685. private _animation;
  14686. /**
  14687. * The target of the runtime animation
  14688. */
  14689. private _target;
  14690. /**
  14691. * The initiating animatable
  14692. */
  14693. private _host;
  14694. /**
  14695. * The original value of the runtime animation
  14696. */
  14697. private _originalValue;
  14698. /**
  14699. * The original blend value of the runtime animation
  14700. */
  14701. private _originalBlendValue;
  14702. /**
  14703. * The offsets cache of the runtime animation
  14704. */
  14705. private _offsetsCache;
  14706. /**
  14707. * The high limits cache of the runtime animation
  14708. */
  14709. private _highLimitsCache;
  14710. /**
  14711. * Specifies if the runtime animation has been stopped
  14712. */
  14713. private _stopped;
  14714. /**
  14715. * The blending factor of the runtime animation
  14716. */
  14717. private _blendingFactor;
  14718. /**
  14719. * The BabylonJS scene
  14720. */
  14721. private _scene;
  14722. /**
  14723. * The current value of the runtime animation
  14724. */
  14725. private _currentValue;
  14726. /** @hidden */
  14727. _animationState: _IAnimationState;
  14728. /**
  14729. * The active target of the runtime animation
  14730. */
  14731. private _activeTargets;
  14732. private _currentActiveTarget;
  14733. private _directTarget;
  14734. /**
  14735. * The target path of the runtime animation
  14736. */
  14737. private _targetPath;
  14738. /**
  14739. * The weight of the runtime animation
  14740. */
  14741. private _weight;
  14742. /**
  14743. * The ratio offset of the runtime animation
  14744. */
  14745. private _ratioOffset;
  14746. /**
  14747. * The previous delay of the runtime animation
  14748. */
  14749. private _previousDelay;
  14750. /**
  14751. * The previous ratio of the runtime animation
  14752. */
  14753. private _previousRatio;
  14754. private _enableBlending;
  14755. private _keys;
  14756. private _minFrame;
  14757. private _maxFrame;
  14758. private _minValue;
  14759. private _maxValue;
  14760. private _targetIsArray;
  14761. /**
  14762. * Gets the current frame of the runtime animation
  14763. */
  14764. get currentFrame(): number;
  14765. /**
  14766. * Gets the weight of the runtime animation
  14767. */
  14768. get weight(): number;
  14769. /**
  14770. * Gets the current value of the runtime animation
  14771. */
  14772. get currentValue(): any;
  14773. /**
  14774. * Gets the target path of the runtime animation
  14775. */
  14776. get targetPath(): string;
  14777. /**
  14778. * Gets the actual target of the runtime animation
  14779. */
  14780. get target(): any;
  14781. /** @hidden */
  14782. _onLoop: () => void;
  14783. /**
  14784. * Create a new RuntimeAnimation object
  14785. * @param target defines the target of the animation
  14786. * @param animation defines the source animation object
  14787. * @param scene defines the hosting scene
  14788. * @param host defines the initiating Animatable
  14789. */
  14790. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14791. private _preparePath;
  14792. /**
  14793. * Gets the animation from the runtime animation
  14794. */
  14795. get animation(): Animation;
  14796. /**
  14797. * Resets the runtime animation to the beginning
  14798. * @param restoreOriginal defines whether to restore the target property to the original value
  14799. */
  14800. reset(restoreOriginal?: boolean): void;
  14801. /**
  14802. * Specifies if the runtime animation is stopped
  14803. * @returns Boolean specifying if the runtime animation is stopped
  14804. */
  14805. isStopped(): boolean;
  14806. /**
  14807. * Disposes of the runtime animation
  14808. */
  14809. dispose(): void;
  14810. /**
  14811. * Apply the interpolated value to the target
  14812. * @param currentValue defines the value computed by the animation
  14813. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14814. */
  14815. setValue(currentValue: any, weight: number): void;
  14816. private _getOriginalValues;
  14817. private _setValue;
  14818. /**
  14819. * Gets the loop pmode of the runtime animation
  14820. * @returns Loop Mode
  14821. */
  14822. private _getCorrectLoopMode;
  14823. /**
  14824. * Move the current animation to a given frame
  14825. * @param frame defines the frame to move to
  14826. */
  14827. goToFrame(frame: number): void;
  14828. /**
  14829. * @hidden Internal use only
  14830. */
  14831. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14832. /**
  14833. * Execute the current animation
  14834. * @param delay defines the delay to add to the current frame
  14835. * @param from defines the lower bound of the animation range
  14836. * @param to defines the upper bound of the animation range
  14837. * @param loop defines if the current animation must loop
  14838. * @param speedRatio defines the current speed ratio
  14839. * @param weight defines the weight of the animation (default is -1 so no weight)
  14840. * @param onLoop optional callback called when animation loops
  14841. * @returns a boolean indicating if the animation is running
  14842. */
  14843. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14844. }
  14845. }
  14846. declare module "babylonjs/Animations/animatable" {
  14847. import { Animation } from "babylonjs/Animations/animation";
  14848. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  14849. import { Nullable } from "babylonjs/types";
  14850. import { Observable } from "babylonjs/Misc/observable";
  14851. import { Scene } from "babylonjs/scene";
  14852. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  14853. import { Node } from "babylonjs/node";
  14854. /**
  14855. * Class used to store an actual running animation
  14856. */
  14857. export class Animatable {
  14858. /** defines the target object */
  14859. target: any;
  14860. /** defines the starting frame number (default is 0) */
  14861. fromFrame: number;
  14862. /** defines the ending frame number (default is 100) */
  14863. toFrame: number;
  14864. /** defines if the animation must loop (default is false) */
  14865. loopAnimation: boolean;
  14866. /** defines a callback to call when animation ends if it is not looping */
  14867. onAnimationEnd?: (() => void) | null | undefined;
  14868. /** defines a callback to call when animation loops */
  14869. onAnimationLoop?: (() => void) | null | undefined;
  14870. private _localDelayOffset;
  14871. private _pausedDelay;
  14872. private _runtimeAnimations;
  14873. private _paused;
  14874. private _scene;
  14875. private _speedRatio;
  14876. private _weight;
  14877. private _syncRoot;
  14878. /**
  14879. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  14880. * This will only apply for non looping animation (default is true)
  14881. */
  14882. disposeOnEnd: boolean;
  14883. /**
  14884. * Gets a boolean indicating if the animation has started
  14885. */
  14886. animationStarted: boolean;
  14887. /**
  14888. * Observer raised when the animation ends
  14889. */
  14890. onAnimationEndObservable: Observable<Animatable>;
  14891. /**
  14892. * Observer raised when the animation loops
  14893. */
  14894. onAnimationLoopObservable: Observable<Animatable>;
  14895. /**
  14896. * Gets the root Animatable used to synchronize and normalize animations
  14897. */
  14898. get syncRoot(): Nullable<Animatable>;
  14899. /**
  14900. * Gets the current frame of the first RuntimeAnimation
  14901. * Used to synchronize Animatables
  14902. */
  14903. get masterFrame(): number;
  14904. /**
  14905. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  14906. */
  14907. get weight(): number;
  14908. set weight(value: number);
  14909. /**
  14910. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  14911. */
  14912. get speedRatio(): number;
  14913. set speedRatio(value: number);
  14914. /**
  14915. * Creates a new Animatable
  14916. * @param scene defines the hosting scene
  14917. * @param target defines the target object
  14918. * @param fromFrame defines the starting frame number (default is 0)
  14919. * @param toFrame defines the ending frame number (default is 100)
  14920. * @param loopAnimation defines if the animation must loop (default is false)
  14921. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  14922. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  14923. * @param animations defines a group of animation to add to the new Animatable
  14924. * @param onAnimationLoop defines a callback to call when animation loops
  14925. */
  14926. constructor(scene: Scene,
  14927. /** defines the target object */
  14928. target: any,
  14929. /** defines the starting frame number (default is 0) */
  14930. fromFrame?: number,
  14931. /** defines the ending frame number (default is 100) */
  14932. toFrame?: number,
  14933. /** defines if the animation must loop (default is false) */
  14934. loopAnimation?: boolean, speedRatio?: number,
  14935. /** defines a callback to call when animation ends if it is not looping */
  14936. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  14937. /** defines a callback to call when animation loops */
  14938. onAnimationLoop?: (() => void) | null | undefined);
  14939. /**
  14940. * Synchronize and normalize current Animatable with a source Animatable
  14941. * This is useful when using animation weights and when animations are not of the same length
  14942. * @param root defines the root Animatable to synchronize with
  14943. * @returns the current Animatable
  14944. */
  14945. syncWith(root: Animatable): Animatable;
  14946. /**
  14947. * Gets the list of runtime animations
  14948. * @returns an array of RuntimeAnimation
  14949. */
  14950. getAnimations(): RuntimeAnimation[];
  14951. /**
  14952. * Adds more animations to the current animatable
  14953. * @param target defines the target of the animations
  14954. * @param animations defines the new animations to add
  14955. */
  14956. appendAnimations(target: any, animations: Animation[]): void;
  14957. /**
  14958. * Gets the source animation for a specific property
  14959. * @param property defines the propertyu to look for
  14960. * @returns null or the source animation for the given property
  14961. */
  14962. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  14963. /**
  14964. * Gets the runtime animation for a specific property
  14965. * @param property defines the propertyu to look for
  14966. * @returns null or the runtime animation for the given property
  14967. */
  14968. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  14969. /**
  14970. * Resets the animatable to its original state
  14971. */
  14972. reset(): void;
  14973. /**
  14974. * Allows the animatable to blend with current running animations
  14975. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14976. * @param blendingSpeed defines the blending speed to use
  14977. */
  14978. enableBlending(blendingSpeed: number): void;
  14979. /**
  14980. * Disable animation blending
  14981. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14982. */
  14983. disableBlending(): void;
  14984. /**
  14985. * Jump directly to a given frame
  14986. * @param frame defines the frame to jump to
  14987. */
  14988. goToFrame(frame: number): void;
  14989. /**
  14990. * Pause the animation
  14991. */
  14992. pause(): void;
  14993. /**
  14994. * Restart the animation
  14995. */
  14996. restart(): void;
  14997. private _raiseOnAnimationEnd;
  14998. /**
  14999. * Stop and delete the current animation
  15000. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15001. * @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)
  15002. */
  15003. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15004. /**
  15005. * Wait asynchronously for the animation to end
  15006. * @returns a promise which will be fullfilled when the animation ends
  15007. */
  15008. waitAsync(): Promise<Animatable>;
  15009. /** @hidden */
  15010. _animate(delay: number): boolean;
  15011. }
  15012. module "babylonjs/scene" {
  15013. interface Scene {
  15014. /** @hidden */
  15015. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15016. /** @hidden */
  15017. _processLateAnimationBindingsForMatrices(holder: {
  15018. totalWeight: number;
  15019. animations: RuntimeAnimation[];
  15020. originalValue: Matrix;
  15021. }): any;
  15022. /** @hidden */
  15023. _processLateAnimationBindingsForQuaternions(holder: {
  15024. totalWeight: number;
  15025. animations: RuntimeAnimation[];
  15026. originalValue: Quaternion;
  15027. }, refQuaternion: Quaternion): Quaternion;
  15028. /** @hidden */
  15029. _processLateAnimationBindings(): void;
  15030. /**
  15031. * Will start the animation sequence of a given target
  15032. * @param target defines the target
  15033. * @param from defines from which frame should animation start
  15034. * @param to defines until which frame should animation run.
  15035. * @param weight defines the weight to apply to the animation (1.0 by default)
  15036. * @param loop defines if the animation loops
  15037. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15038. * @param onAnimationEnd defines the function to be executed when the animation ends
  15039. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15040. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15041. * @param onAnimationLoop defines the callback to call when an animation loops
  15042. * @returns the animatable object created for this animation
  15043. */
  15044. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  15045. /**
  15046. * Will start the animation sequence of a given target
  15047. * @param target defines the target
  15048. * @param from defines from which frame should animation start
  15049. * @param to defines until which frame should animation run.
  15050. * @param loop defines if the animation loops
  15051. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15052. * @param onAnimationEnd defines the function to be executed when the animation ends
  15053. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15054. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15055. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15056. * @param onAnimationLoop defines the callback to call when an animation loops
  15057. * @returns the animatable object created for this animation
  15058. */
  15059. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  15060. /**
  15061. * Will start the animation sequence of a given target and its hierarchy
  15062. * @param target defines the target
  15063. * @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.
  15064. * @param from defines from which frame should animation start
  15065. * @param to defines until which frame should animation run.
  15066. * @param loop defines if the animation loops
  15067. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15068. * @param onAnimationEnd defines the function to be executed when the animation ends
  15069. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15070. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15071. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15072. * @param onAnimationLoop defines the callback to call when an animation loops
  15073. * @returns the list of created animatables
  15074. */
  15075. 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[];
  15076. /**
  15077. * Begin a new animation on a given node
  15078. * @param target defines the target where the animation will take place
  15079. * @param animations defines the list of animations to start
  15080. * @param from defines the initial value
  15081. * @param to defines the final value
  15082. * @param loop defines if you want animation to loop (off by default)
  15083. * @param speedRatio defines the speed ratio to apply to all animations
  15084. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15085. * @param onAnimationLoop defines the callback to call when an animation loops
  15086. * @returns the list of created animatables
  15087. */
  15088. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  15089. /**
  15090. * Begin a new animation on a given node and its hierarchy
  15091. * @param target defines the root node where the animation will take place
  15092. * @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.
  15093. * @param animations defines the list of animations to start
  15094. * @param from defines the initial value
  15095. * @param to defines the final value
  15096. * @param loop defines if you want animation to loop (off by default)
  15097. * @param speedRatio defines the speed ratio to apply to all animations
  15098. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15099. * @param onAnimationLoop defines the callback to call when an animation loops
  15100. * @returns the list of animatables created for all nodes
  15101. */
  15102. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  15103. /**
  15104. * Gets the animatable associated with a specific target
  15105. * @param target defines the target of the animatable
  15106. * @returns the required animatable if found
  15107. */
  15108. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15109. /**
  15110. * Gets all animatables associated with a given target
  15111. * @param target defines the target to look animatables for
  15112. * @returns an array of Animatables
  15113. */
  15114. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15115. /**
  15116. * Stops and removes all animations that have been applied to the scene
  15117. */
  15118. stopAllAnimations(): void;
  15119. /**
  15120. * Gets the current delta time used by animation engine
  15121. */
  15122. deltaTime: number;
  15123. }
  15124. }
  15125. module "babylonjs/Bones/bone" {
  15126. interface Bone {
  15127. /**
  15128. * Copy an animation range from another bone
  15129. * @param source defines the source bone
  15130. * @param rangeName defines the range name to copy
  15131. * @param frameOffset defines the frame offset
  15132. * @param rescaleAsRequired defines if rescaling must be applied if required
  15133. * @param skelDimensionsRatio defines the scaling ratio
  15134. * @returns true if operation was successful
  15135. */
  15136. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15137. }
  15138. }
  15139. }
  15140. declare module "babylonjs/Bones/skeleton" {
  15141. import { Bone } from "babylonjs/Bones/bone";
  15142. import { Observable } from "babylonjs/Misc/observable";
  15143. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15144. import { Scene } from "babylonjs/scene";
  15145. import { Nullable } from "babylonjs/types";
  15146. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15147. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  15148. import { Animatable } from "babylonjs/Animations/animatable";
  15149. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15150. import { Animation } from "babylonjs/Animations/animation";
  15151. import { AnimationRange } from "babylonjs/Animations/animationRange";
  15152. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15153. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  15154. /**
  15155. * Class used to handle skinning animations
  15156. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15157. */
  15158. export class Skeleton implements IAnimatable {
  15159. /** defines the skeleton name */
  15160. name: string;
  15161. /** defines the skeleton Id */
  15162. id: string;
  15163. /**
  15164. * Defines the list of child bones
  15165. */
  15166. bones: Bone[];
  15167. /**
  15168. * Defines an estimate of the dimension of the skeleton at rest
  15169. */
  15170. dimensionsAtRest: Vector3;
  15171. /**
  15172. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15173. */
  15174. needInitialSkinMatrix: boolean;
  15175. /**
  15176. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15177. */
  15178. overrideMesh: Nullable<AbstractMesh>;
  15179. /**
  15180. * Gets the list of animations attached to this skeleton
  15181. */
  15182. animations: Array<Animation>;
  15183. private _scene;
  15184. private _isDirty;
  15185. private _transformMatrices;
  15186. private _transformMatrixTexture;
  15187. private _meshesWithPoseMatrix;
  15188. private _animatables;
  15189. private _identity;
  15190. private _synchronizedWithMesh;
  15191. private _ranges;
  15192. private _lastAbsoluteTransformsUpdateId;
  15193. private _canUseTextureForBones;
  15194. private _uniqueId;
  15195. /** @hidden */
  15196. _numBonesWithLinkedTransformNode: number;
  15197. /** @hidden */
  15198. _hasWaitingData: Nullable<boolean>;
  15199. /**
  15200. * Specifies if the skeleton should be serialized
  15201. */
  15202. doNotSerialize: boolean;
  15203. private _useTextureToStoreBoneMatrices;
  15204. /**
  15205. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15206. * Please note that this option is not available if the hardware does not support it
  15207. */
  15208. get useTextureToStoreBoneMatrices(): boolean;
  15209. set useTextureToStoreBoneMatrices(value: boolean);
  15210. private _animationPropertiesOverride;
  15211. /**
  15212. * Gets or sets the animation properties override
  15213. */
  15214. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15215. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15216. /**
  15217. * List of inspectable custom properties (used by the Inspector)
  15218. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15219. */
  15220. inspectableCustomProperties: IInspectable[];
  15221. /**
  15222. * An observable triggered before computing the skeleton's matrices
  15223. */
  15224. onBeforeComputeObservable: Observable<Skeleton>;
  15225. /**
  15226. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15227. */
  15228. get isUsingTextureForMatrices(): boolean;
  15229. /**
  15230. * Gets the unique ID of this skeleton
  15231. */
  15232. get uniqueId(): number;
  15233. /**
  15234. * Creates a new skeleton
  15235. * @param name defines the skeleton name
  15236. * @param id defines the skeleton Id
  15237. * @param scene defines the hosting scene
  15238. */
  15239. constructor(
  15240. /** defines the skeleton name */
  15241. name: string,
  15242. /** defines the skeleton Id */
  15243. id: string, scene: Scene);
  15244. /**
  15245. * Gets the current object class name.
  15246. * @return the class name
  15247. */
  15248. getClassName(): string;
  15249. /**
  15250. * Returns an array containing the root bones
  15251. * @returns an array containing the root bones
  15252. */
  15253. getChildren(): Array<Bone>;
  15254. /**
  15255. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15256. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15257. * @returns a Float32Array containing matrices data
  15258. */
  15259. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15260. /**
  15261. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15262. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15263. * @returns a raw texture containing the data
  15264. */
  15265. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15266. /**
  15267. * Gets the current hosting scene
  15268. * @returns a scene object
  15269. */
  15270. getScene(): Scene;
  15271. /**
  15272. * Gets a string representing the current skeleton data
  15273. * @param fullDetails defines a boolean indicating if we want a verbose version
  15274. * @returns a string representing the current skeleton data
  15275. */
  15276. toString(fullDetails?: boolean): string;
  15277. /**
  15278. * Get bone's index searching by name
  15279. * @param name defines bone's name to search for
  15280. * @return the indice of the bone. Returns -1 if not found
  15281. */
  15282. getBoneIndexByName(name: string): number;
  15283. /**
  15284. * Creater a new animation range
  15285. * @param name defines the name of the range
  15286. * @param from defines the start key
  15287. * @param to defines the end key
  15288. */
  15289. createAnimationRange(name: string, from: number, to: number): void;
  15290. /**
  15291. * Delete a specific animation range
  15292. * @param name defines the name of the range
  15293. * @param deleteFrames defines if frames must be removed as well
  15294. */
  15295. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15296. /**
  15297. * Gets a specific animation range
  15298. * @param name defines the name of the range to look for
  15299. * @returns the requested animation range or null if not found
  15300. */
  15301. getAnimationRange(name: string): Nullable<AnimationRange>;
  15302. /**
  15303. * Gets the list of all animation ranges defined on this skeleton
  15304. * @returns an array
  15305. */
  15306. getAnimationRanges(): Nullable<AnimationRange>[];
  15307. /**
  15308. * Copy animation range from a source skeleton.
  15309. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15310. * @param source defines the source skeleton
  15311. * @param name defines the name of the range to copy
  15312. * @param rescaleAsRequired defines if rescaling must be applied if required
  15313. * @returns true if operation was successful
  15314. */
  15315. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15316. /**
  15317. * Forces the skeleton to go to rest pose
  15318. */
  15319. returnToRest(): void;
  15320. private _getHighestAnimationFrame;
  15321. /**
  15322. * Begin a specific animation range
  15323. * @param name defines the name of the range to start
  15324. * @param loop defines if looping must be turned on (false by default)
  15325. * @param speedRatio defines the speed ratio to apply (1 by default)
  15326. * @param onAnimationEnd defines a callback which will be called when animation will end
  15327. * @returns a new animatable
  15328. */
  15329. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15330. /** @hidden */
  15331. _markAsDirty(): void;
  15332. /** @hidden */
  15333. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15334. /** @hidden */
  15335. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15336. private _computeTransformMatrices;
  15337. /**
  15338. * Build all resources required to render a skeleton
  15339. */
  15340. prepare(): void;
  15341. /**
  15342. * Gets the list of animatables currently running for this skeleton
  15343. * @returns an array of animatables
  15344. */
  15345. getAnimatables(): IAnimatable[];
  15346. /**
  15347. * Clone the current skeleton
  15348. * @param name defines the name of the new skeleton
  15349. * @param id defines the id of the new skeleton
  15350. * @returns the new skeleton
  15351. */
  15352. clone(name: string, id?: string): Skeleton;
  15353. /**
  15354. * Enable animation blending for this skeleton
  15355. * @param blendingSpeed defines the blending speed to apply
  15356. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15357. */
  15358. enableBlending(blendingSpeed?: number): void;
  15359. /**
  15360. * Releases all resources associated with the current skeleton
  15361. */
  15362. dispose(): void;
  15363. /**
  15364. * Serialize the skeleton in a JSON object
  15365. * @returns a JSON object
  15366. */
  15367. serialize(): any;
  15368. /**
  15369. * Creates a new skeleton from serialized data
  15370. * @param parsedSkeleton defines the serialized data
  15371. * @param scene defines the hosting scene
  15372. * @returns a new skeleton
  15373. */
  15374. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15375. /**
  15376. * Compute all node absolute transforms
  15377. * @param forceUpdate defines if computation must be done even if cache is up to date
  15378. */
  15379. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15380. /**
  15381. * Gets the root pose matrix
  15382. * @returns a matrix
  15383. */
  15384. getPoseMatrix(): Nullable<Matrix>;
  15385. /**
  15386. * Sorts bones per internal index
  15387. */
  15388. sortBones(): void;
  15389. private _sortBones;
  15390. }
  15391. }
  15392. declare module "babylonjs/Meshes/instancedMesh" {
  15393. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  15394. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15395. import { Camera } from "babylonjs/Cameras/camera";
  15396. import { Node } from "babylonjs/node";
  15397. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15398. import { Mesh } from "babylonjs/Meshes/mesh";
  15399. import { Material } from "babylonjs/Materials/material";
  15400. import { Skeleton } from "babylonjs/Bones/skeleton";
  15401. import { Light } from "babylonjs/Lights/light";
  15402. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  15403. /**
  15404. * Creates an instance based on a source mesh.
  15405. */
  15406. export class InstancedMesh extends AbstractMesh {
  15407. private _sourceMesh;
  15408. private _currentLOD;
  15409. /** @hidden */
  15410. _indexInSourceMeshInstanceArray: number;
  15411. constructor(name: string, source: Mesh);
  15412. /**
  15413. * Returns the string "InstancedMesh".
  15414. */
  15415. getClassName(): string;
  15416. /** Gets the list of lights affecting that mesh */
  15417. get lightSources(): Light[];
  15418. _resyncLightSources(): void;
  15419. _resyncLightSource(light: Light): void;
  15420. _removeLightSource(light: Light, dispose: boolean): void;
  15421. /**
  15422. * If the source mesh receives shadows
  15423. */
  15424. get receiveShadows(): boolean;
  15425. /**
  15426. * The material of the source mesh
  15427. */
  15428. get material(): Nullable<Material>;
  15429. /**
  15430. * Visibility of the source mesh
  15431. */
  15432. get visibility(): number;
  15433. /**
  15434. * Skeleton of the source mesh
  15435. */
  15436. get skeleton(): Nullable<Skeleton>;
  15437. /**
  15438. * Rendering ground id of the source mesh
  15439. */
  15440. get renderingGroupId(): number;
  15441. set renderingGroupId(value: number);
  15442. /**
  15443. * Returns the total number of vertices (integer).
  15444. */
  15445. getTotalVertices(): number;
  15446. /**
  15447. * Returns a positive integer : the total number of indices in this mesh geometry.
  15448. * @returns the numner of indices or zero if the mesh has no geometry.
  15449. */
  15450. getTotalIndices(): number;
  15451. /**
  15452. * The source mesh of the instance
  15453. */
  15454. get sourceMesh(): Mesh;
  15455. /**
  15456. * Is this node ready to be used/rendered
  15457. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15458. * @return {boolean} is it ready
  15459. */
  15460. isReady(completeCheck?: boolean): boolean;
  15461. /**
  15462. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15463. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15464. * @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.
  15465. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15466. */
  15467. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15468. /**
  15469. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15470. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15471. * The `data` are either a numeric array either a Float32Array.
  15472. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15473. * 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).
  15474. * Note that a new underlying VertexBuffer object is created each call.
  15475. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15476. *
  15477. * Possible `kind` values :
  15478. * - VertexBuffer.PositionKind
  15479. * - VertexBuffer.UVKind
  15480. * - VertexBuffer.UV2Kind
  15481. * - VertexBuffer.UV3Kind
  15482. * - VertexBuffer.UV4Kind
  15483. * - VertexBuffer.UV5Kind
  15484. * - VertexBuffer.UV6Kind
  15485. * - VertexBuffer.ColorKind
  15486. * - VertexBuffer.MatricesIndicesKind
  15487. * - VertexBuffer.MatricesIndicesExtraKind
  15488. * - VertexBuffer.MatricesWeightsKind
  15489. * - VertexBuffer.MatricesWeightsExtraKind
  15490. *
  15491. * Returns the Mesh.
  15492. */
  15493. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15494. /**
  15495. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15496. * If the mesh has no geometry, it is simply returned as it is.
  15497. * The `data` are either a numeric array either a Float32Array.
  15498. * No new underlying VertexBuffer object is created.
  15499. * 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.
  15500. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15501. *
  15502. * Possible `kind` values :
  15503. * - VertexBuffer.PositionKind
  15504. * - VertexBuffer.UVKind
  15505. * - VertexBuffer.UV2Kind
  15506. * - VertexBuffer.UV3Kind
  15507. * - VertexBuffer.UV4Kind
  15508. * - VertexBuffer.UV5Kind
  15509. * - VertexBuffer.UV6Kind
  15510. * - VertexBuffer.ColorKind
  15511. * - VertexBuffer.MatricesIndicesKind
  15512. * - VertexBuffer.MatricesIndicesExtraKind
  15513. * - VertexBuffer.MatricesWeightsKind
  15514. * - VertexBuffer.MatricesWeightsExtraKind
  15515. *
  15516. * Returns the Mesh.
  15517. */
  15518. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15519. /**
  15520. * Sets the mesh indices.
  15521. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15522. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15523. * This method creates a new index buffer each call.
  15524. * Returns the Mesh.
  15525. */
  15526. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15527. /**
  15528. * Boolean : True if the mesh owns the requested kind of data.
  15529. */
  15530. isVerticesDataPresent(kind: string): boolean;
  15531. /**
  15532. * Returns an array of indices (IndicesArray).
  15533. */
  15534. getIndices(): Nullable<IndicesArray>;
  15535. get _positions(): Nullable<Vector3[]>;
  15536. /**
  15537. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15538. * This means the mesh underlying bounding box and sphere are recomputed.
  15539. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15540. * @returns the current mesh
  15541. */
  15542. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15543. /** @hidden */
  15544. _preActivate(): InstancedMesh;
  15545. /** @hidden */
  15546. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15547. /** @hidden */
  15548. _postActivate(): void;
  15549. getWorldMatrix(): Matrix;
  15550. get isAnInstance(): boolean;
  15551. /**
  15552. * Returns the current associated LOD AbstractMesh.
  15553. */
  15554. getLOD(camera: Camera): AbstractMesh;
  15555. /** @hidden */
  15556. _syncSubMeshes(): InstancedMesh;
  15557. /** @hidden */
  15558. _generatePointsArray(): boolean;
  15559. /**
  15560. * Creates a new InstancedMesh from the current mesh.
  15561. * - name (string) : the cloned mesh name
  15562. * - newParent (optional Node) : the optional Node to parent the clone to.
  15563. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15564. *
  15565. * Returns the clone.
  15566. */
  15567. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15568. /**
  15569. * Disposes the InstancedMesh.
  15570. * Returns nothing.
  15571. */
  15572. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15573. }
  15574. module "babylonjs/Meshes/mesh" {
  15575. interface Mesh {
  15576. /**
  15577. * Register a custom buffer that will be instanced
  15578. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15579. * @param kind defines the buffer kind
  15580. * @param stride defines the stride in floats
  15581. */
  15582. registerInstancedBuffer(kind: string, stride: number): void;
  15583. /** @hidden */
  15584. _userInstancedBuffersStorage: {
  15585. data: {
  15586. [key: string]: Float32Array;
  15587. };
  15588. sizes: {
  15589. [key: string]: number;
  15590. };
  15591. vertexBuffers: {
  15592. [key: string]: Nullable<VertexBuffer>;
  15593. };
  15594. strides: {
  15595. [key: string]: number;
  15596. };
  15597. };
  15598. }
  15599. }
  15600. module "babylonjs/Meshes/abstractMesh" {
  15601. interface AbstractMesh {
  15602. /**
  15603. * Object used to store instanced buffers defined by user
  15604. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15605. */
  15606. instancedBuffers: {
  15607. [key: string]: any;
  15608. };
  15609. }
  15610. }
  15611. }
  15612. declare module "babylonjs/Materials/shaderMaterial" {
  15613. import { Scene } from "babylonjs/scene";
  15614. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  15615. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15616. import { Mesh } from "babylonjs/Meshes/mesh";
  15617. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  15618. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15619. import { Texture } from "babylonjs/Materials/Textures/texture";
  15620. import { Material } from "babylonjs/Materials/material";
  15621. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  15622. /**
  15623. * Defines the options associated with the creation of a shader material.
  15624. */
  15625. export interface IShaderMaterialOptions {
  15626. /**
  15627. * Does the material work in alpha blend mode
  15628. */
  15629. needAlphaBlending: boolean;
  15630. /**
  15631. * Does the material work in alpha test mode
  15632. */
  15633. needAlphaTesting: boolean;
  15634. /**
  15635. * The list of attribute names used in the shader
  15636. */
  15637. attributes: string[];
  15638. /**
  15639. * The list of unifrom names used in the shader
  15640. */
  15641. uniforms: string[];
  15642. /**
  15643. * The list of UBO names used in the shader
  15644. */
  15645. uniformBuffers: string[];
  15646. /**
  15647. * The list of sampler names used in the shader
  15648. */
  15649. samplers: string[];
  15650. /**
  15651. * The list of defines used in the shader
  15652. */
  15653. defines: string[];
  15654. }
  15655. /**
  15656. * 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.
  15657. *
  15658. * This returned material effects how the mesh will look based on the code in the shaders.
  15659. *
  15660. * @see http://doc.babylonjs.com/how_to/shader_material
  15661. */
  15662. export class ShaderMaterial extends Material {
  15663. private _shaderPath;
  15664. private _options;
  15665. private _textures;
  15666. private _textureArrays;
  15667. private _floats;
  15668. private _ints;
  15669. private _floatsArrays;
  15670. private _colors3;
  15671. private _colors3Arrays;
  15672. private _colors4;
  15673. private _colors4Arrays;
  15674. private _vectors2;
  15675. private _vectors3;
  15676. private _vectors4;
  15677. private _matrices;
  15678. private _matrixArrays;
  15679. private _matrices3x3;
  15680. private _matrices2x2;
  15681. private _vectors2Arrays;
  15682. private _vectors3Arrays;
  15683. private _vectors4Arrays;
  15684. private _cachedWorldViewMatrix;
  15685. private _cachedWorldViewProjectionMatrix;
  15686. private _renderId;
  15687. private _multiview;
  15688. /**
  15689. * Instantiate a new shader material.
  15690. * 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.
  15691. * This returned material effects how the mesh will look based on the code in the shaders.
  15692. * @see http://doc.babylonjs.com/how_to/shader_material
  15693. * @param name Define the name of the material in the scene
  15694. * @param scene Define the scene the material belongs to
  15695. * @param shaderPath Defines the route to the shader code in one of three ways:
  15696. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15697. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15698. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15699. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15700. * @param options Define the options used to create the shader
  15701. */
  15702. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15703. /**
  15704. * Gets the shader path used to define the shader code
  15705. * It can be modified to trigger a new compilation
  15706. */
  15707. get shaderPath(): any;
  15708. /**
  15709. * Sets the shader path used to define the shader code
  15710. * It can be modified to trigger a new compilation
  15711. */
  15712. set shaderPath(shaderPath: any);
  15713. /**
  15714. * Gets the options used to compile the shader.
  15715. * They can be modified to trigger a new compilation
  15716. */
  15717. get options(): IShaderMaterialOptions;
  15718. /**
  15719. * Gets the current class name of the material e.g. "ShaderMaterial"
  15720. * Mainly use in serialization.
  15721. * @returns the class name
  15722. */
  15723. getClassName(): string;
  15724. /**
  15725. * Specifies if the material will require alpha blending
  15726. * @returns a boolean specifying if alpha blending is needed
  15727. */
  15728. needAlphaBlending(): boolean;
  15729. /**
  15730. * Specifies if this material should be rendered in alpha test mode
  15731. * @returns a boolean specifying if an alpha test is needed.
  15732. */
  15733. needAlphaTesting(): boolean;
  15734. private _checkUniform;
  15735. /**
  15736. * Set a texture in the shader.
  15737. * @param name Define the name of the uniform samplers as defined in the shader
  15738. * @param texture Define the texture to bind to this sampler
  15739. * @return the material itself allowing "fluent" like uniform updates
  15740. */
  15741. setTexture(name: string, texture: Texture): ShaderMaterial;
  15742. /**
  15743. * Set a texture array in the shader.
  15744. * @param name Define the name of the uniform sampler array as defined in the shader
  15745. * @param textures Define the list of textures to bind to this sampler
  15746. * @return the material itself allowing "fluent" like uniform updates
  15747. */
  15748. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  15749. /**
  15750. * Set a float in the shader.
  15751. * @param name Define the name of the uniform as defined in the shader
  15752. * @param value Define the value to give to the uniform
  15753. * @return the material itself allowing "fluent" like uniform updates
  15754. */
  15755. setFloat(name: string, value: number): ShaderMaterial;
  15756. /**
  15757. * Set a int in the shader.
  15758. * @param name Define the name of the uniform as defined in the shader
  15759. * @param value Define the value to give to the uniform
  15760. * @return the material itself allowing "fluent" like uniform updates
  15761. */
  15762. setInt(name: string, value: number): ShaderMaterial;
  15763. /**
  15764. * Set an array of floats in the shader.
  15765. * @param name Define the name of the uniform as defined in the shader
  15766. * @param value Define the value to give to the uniform
  15767. * @return the material itself allowing "fluent" like uniform updates
  15768. */
  15769. setFloats(name: string, value: number[]): ShaderMaterial;
  15770. /**
  15771. * Set a vec3 in the shader from a Color3.
  15772. * @param name Define the name of the uniform as defined in the shader
  15773. * @param value Define the value to give to the uniform
  15774. * @return the material itself allowing "fluent" like uniform updates
  15775. */
  15776. setColor3(name: string, value: Color3): ShaderMaterial;
  15777. /**
  15778. * Set a vec3 array in the shader from a Color3 array.
  15779. * @param name Define the name of the uniform as defined in the shader
  15780. * @param value Define the value to give to the uniform
  15781. * @return the material itself allowing "fluent" like uniform updates
  15782. */
  15783. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15784. /**
  15785. * Set a vec4 in the shader from a Color4.
  15786. * @param name Define the name of the uniform as defined in the shader
  15787. * @param value Define the value to give to the uniform
  15788. * @return the material itself allowing "fluent" like uniform updates
  15789. */
  15790. setColor4(name: string, value: Color4): ShaderMaterial;
  15791. /**
  15792. * Set a vec4 array in the shader from a Color4 array.
  15793. * @param name Define the name of the uniform as defined in the shader
  15794. * @param value Define the value to give to the uniform
  15795. * @return the material itself allowing "fluent" like uniform updates
  15796. */
  15797. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15798. /**
  15799. * Set a vec2 in the shader from a Vector2.
  15800. * @param name Define the name of the uniform as defined in the shader
  15801. * @param value Define the value to give to the uniform
  15802. * @return the material itself allowing "fluent" like uniform updates
  15803. */
  15804. setVector2(name: string, value: Vector2): ShaderMaterial;
  15805. /**
  15806. * Set a vec3 in the shader from a Vector3.
  15807. * @param name Define the name of the uniform as defined in the shader
  15808. * @param value Define the value to give to the uniform
  15809. * @return the material itself allowing "fluent" like uniform updates
  15810. */
  15811. setVector3(name: string, value: Vector3): ShaderMaterial;
  15812. /**
  15813. * Set a vec4 in the shader from a Vector4.
  15814. * @param name Define the name of the uniform as defined in the shader
  15815. * @param value Define the value to give to the uniform
  15816. * @return the material itself allowing "fluent" like uniform updates
  15817. */
  15818. setVector4(name: string, value: Vector4): ShaderMaterial;
  15819. /**
  15820. * Set a mat4 in the shader from a Matrix.
  15821. * @param name Define the name of the uniform as defined in the shader
  15822. * @param value Define the value to give to the uniform
  15823. * @return the material itself allowing "fluent" like uniform updates
  15824. */
  15825. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15826. /**
  15827. * Set a float32Array in the shader from a matrix array.
  15828. * @param name Define the name of the uniform as defined in the shader
  15829. * @param value Define the value to give to the uniform
  15830. * @return the material itself allowing "fluent" like uniform updates
  15831. */
  15832. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  15833. /**
  15834. * Set a mat3 in the shader from a Float32Array.
  15835. * @param name Define the name of the uniform as defined in the shader
  15836. * @param value Define the value to give to the uniform
  15837. * @return the material itself allowing "fluent" like uniform updates
  15838. */
  15839. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15840. /**
  15841. * Set a mat2 in the shader from a Float32Array.
  15842. * @param name Define the name of the uniform as defined in the shader
  15843. * @param value Define the value to give to the uniform
  15844. * @return the material itself allowing "fluent" like uniform updates
  15845. */
  15846. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15847. /**
  15848. * Set a vec2 array in the shader from a number array.
  15849. * @param name Define the name of the uniform as defined in the shader
  15850. * @param value Define the value to give to the uniform
  15851. * @return the material itself allowing "fluent" like uniform updates
  15852. */
  15853. setArray2(name: string, value: number[]): ShaderMaterial;
  15854. /**
  15855. * Set a vec3 array in the shader from a number array.
  15856. * @param name Define the name of the uniform as defined in the shader
  15857. * @param value Define the value to give to the uniform
  15858. * @return the material itself allowing "fluent" like uniform updates
  15859. */
  15860. setArray3(name: string, value: number[]): ShaderMaterial;
  15861. /**
  15862. * Set a vec4 array in the shader from a number array.
  15863. * @param name Define the name of the uniform as defined in the shader
  15864. * @param value Define the value to give to the uniform
  15865. * @return the material itself allowing "fluent" like uniform updates
  15866. */
  15867. setArray4(name: string, value: number[]): ShaderMaterial;
  15868. private _checkCache;
  15869. /**
  15870. * Specifies that the submesh is ready to be used
  15871. * @param mesh defines the mesh to check
  15872. * @param subMesh defines which submesh to check
  15873. * @param useInstances specifies that instances should be used
  15874. * @returns a boolean indicating that the submesh is ready or not
  15875. */
  15876. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15877. /**
  15878. * Checks if the material is ready to render the requested mesh
  15879. * @param mesh Define the mesh to render
  15880. * @param useInstances Define whether or not the material is used with instances
  15881. * @returns true if ready, otherwise false
  15882. */
  15883. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15884. /**
  15885. * Binds the world matrix to the material
  15886. * @param world defines the world transformation matrix
  15887. */
  15888. bindOnlyWorldMatrix(world: Matrix): void;
  15889. /**
  15890. * Binds the material to the mesh
  15891. * @param world defines the world transformation matrix
  15892. * @param mesh defines the mesh to bind the material to
  15893. */
  15894. bind(world: Matrix, mesh?: Mesh): void;
  15895. /**
  15896. * Gets the active textures from the material
  15897. * @returns an array of textures
  15898. */
  15899. getActiveTextures(): BaseTexture[];
  15900. /**
  15901. * Specifies if the material uses a texture
  15902. * @param texture defines the texture to check against the material
  15903. * @returns a boolean specifying if the material uses the texture
  15904. */
  15905. hasTexture(texture: BaseTexture): boolean;
  15906. /**
  15907. * Makes a duplicate of the material, and gives it a new name
  15908. * @param name defines the new name for the duplicated material
  15909. * @returns the cloned material
  15910. */
  15911. clone(name: string): ShaderMaterial;
  15912. /**
  15913. * Disposes the material
  15914. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  15915. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  15916. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  15917. */
  15918. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  15919. /**
  15920. * Serializes this material in a JSON representation
  15921. * @returns the serialized material object
  15922. */
  15923. serialize(): any;
  15924. /**
  15925. * Creates a shader material from parsed shader material data
  15926. * @param source defines the JSON represnetation of the material
  15927. * @param scene defines the hosting scene
  15928. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  15929. * @returns a new material
  15930. */
  15931. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15932. }
  15933. }
  15934. declare module "babylonjs/Shaders/color.fragment" {
  15935. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  15936. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  15937. /** @hidden */
  15938. export var colorPixelShader: {
  15939. name: string;
  15940. shader: string;
  15941. };
  15942. }
  15943. declare module "babylonjs/Shaders/color.vertex" {
  15944. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  15945. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15946. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  15947. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  15948. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  15949. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  15950. /** @hidden */
  15951. export var colorVertexShader: {
  15952. name: string;
  15953. shader: string;
  15954. };
  15955. }
  15956. declare module "babylonjs/Meshes/linesMesh" {
  15957. import { Nullable } from "babylonjs/types";
  15958. import { Scene } from "babylonjs/scene";
  15959. import { Color3 } from "babylonjs/Maths/math.color";
  15960. import { Node } from "babylonjs/node";
  15961. import { SubMesh } from "babylonjs/Meshes/subMesh";
  15962. import { Mesh } from "babylonjs/Meshes/mesh";
  15963. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  15964. import { Effect } from "babylonjs/Materials/effect";
  15965. import { Material } from "babylonjs/Materials/material";
  15966. import "babylonjs/Shaders/color.fragment";
  15967. import "babylonjs/Shaders/color.vertex";
  15968. /**
  15969. * Line mesh
  15970. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  15971. */
  15972. export class LinesMesh extends Mesh {
  15973. /**
  15974. * If vertex color should be applied to the mesh
  15975. */
  15976. readonly useVertexColor?: boolean | undefined;
  15977. /**
  15978. * If vertex alpha should be applied to the mesh
  15979. */
  15980. readonly useVertexAlpha?: boolean | undefined;
  15981. /**
  15982. * Color of the line (Default: White)
  15983. */
  15984. color: Color3;
  15985. /**
  15986. * Alpha of the line (Default: 1)
  15987. */
  15988. alpha: number;
  15989. /**
  15990. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15991. * This margin is expressed in world space coordinates, so its value may vary.
  15992. * Default value is 0.1
  15993. */
  15994. intersectionThreshold: number;
  15995. private _colorShader;
  15996. private color4;
  15997. /**
  15998. * Creates a new LinesMesh
  15999. * @param name defines the name
  16000. * @param scene defines the hosting scene
  16001. * @param parent defines the parent mesh if any
  16002. * @param source defines the optional source LinesMesh used to clone data from
  16003. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16004. * When false, achieved by calling a clone(), also passing False.
  16005. * This will make creation of children, recursive.
  16006. * @param useVertexColor defines if this LinesMesh supports vertex color
  16007. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16008. */
  16009. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16010. /**
  16011. * If vertex color should be applied to the mesh
  16012. */
  16013. useVertexColor?: boolean | undefined,
  16014. /**
  16015. * If vertex alpha should be applied to the mesh
  16016. */
  16017. useVertexAlpha?: boolean | undefined);
  16018. private _addClipPlaneDefine;
  16019. private _removeClipPlaneDefine;
  16020. isReady(): boolean;
  16021. /**
  16022. * Returns the string "LineMesh"
  16023. */
  16024. getClassName(): string;
  16025. /**
  16026. * @hidden
  16027. */
  16028. get material(): Material;
  16029. /**
  16030. * @hidden
  16031. */
  16032. set material(value: Material);
  16033. /**
  16034. * @hidden
  16035. */
  16036. get checkCollisions(): boolean;
  16037. /** @hidden */
  16038. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16039. /** @hidden */
  16040. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16041. /**
  16042. * Disposes of the line mesh
  16043. * @param doNotRecurse If children should be disposed
  16044. */
  16045. dispose(doNotRecurse?: boolean): void;
  16046. /**
  16047. * Returns a new LineMesh object cloned from the current one.
  16048. */
  16049. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16050. /**
  16051. * Creates a new InstancedLinesMesh object from the mesh model.
  16052. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16053. * @param name defines the name of the new instance
  16054. * @returns a new InstancedLinesMesh
  16055. */
  16056. createInstance(name: string): InstancedLinesMesh;
  16057. }
  16058. /**
  16059. * Creates an instance based on a source LinesMesh
  16060. */
  16061. export class InstancedLinesMesh extends InstancedMesh {
  16062. /**
  16063. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16064. * This margin is expressed in world space coordinates, so its value may vary.
  16065. * Initilized with the intersectionThreshold value of the source LinesMesh
  16066. */
  16067. intersectionThreshold: number;
  16068. constructor(name: string, source: LinesMesh);
  16069. /**
  16070. * Returns the string "InstancedLinesMesh".
  16071. */
  16072. getClassName(): string;
  16073. }
  16074. }
  16075. declare module "babylonjs/Shaders/line.fragment" {
  16076. /** @hidden */
  16077. export var linePixelShader: {
  16078. name: string;
  16079. shader: string;
  16080. };
  16081. }
  16082. declare module "babylonjs/Shaders/line.vertex" {
  16083. /** @hidden */
  16084. export var lineVertexShader: {
  16085. name: string;
  16086. shader: string;
  16087. };
  16088. }
  16089. declare module "babylonjs/Rendering/edgesRenderer" {
  16090. import { Nullable } from "babylonjs/types";
  16091. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16092. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16093. import { Vector3 } from "babylonjs/Maths/math.vector";
  16094. import { IDisposable } from "babylonjs/scene";
  16095. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  16096. import "babylonjs/Shaders/line.fragment";
  16097. import "babylonjs/Shaders/line.vertex";
  16098. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  16099. module "babylonjs/Meshes/abstractMesh" {
  16100. interface AbstractMesh {
  16101. /**
  16102. * Gets the edgesRenderer associated with the mesh
  16103. */
  16104. edgesRenderer: Nullable<EdgesRenderer>;
  16105. }
  16106. }
  16107. module "babylonjs/Meshes/linesMesh" {
  16108. interface LinesMesh {
  16109. /**
  16110. * Enables the edge rendering mode on the mesh.
  16111. * This mode makes the mesh edges visible
  16112. * @param epsilon defines the maximal distance between two angles to detect a face
  16113. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16114. * @returns the currentAbstractMesh
  16115. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16116. */
  16117. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16118. }
  16119. }
  16120. module "babylonjs/Meshes/linesMesh" {
  16121. interface InstancedLinesMesh {
  16122. /**
  16123. * Enables the edge rendering mode on the mesh.
  16124. * This mode makes the mesh edges visible
  16125. * @param epsilon defines the maximal distance between two angles to detect a face
  16126. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16127. * @returns the current InstancedLinesMesh
  16128. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16129. */
  16130. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16131. }
  16132. }
  16133. /**
  16134. * Defines the minimum contract an Edges renderer should follow.
  16135. */
  16136. export interface IEdgesRenderer extends IDisposable {
  16137. /**
  16138. * Gets or sets a boolean indicating if the edgesRenderer is active
  16139. */
  16140. isEnabled: boolean;
  16141. /**
  16142. * Renders the edges of the attached mesh,
  16143. */
  16144. render(): void;
  16145. /**
  16146. * Checks wether or not the edges renderer is ready to render.
  16147. * @return true if ready, otherwise false.
  16148. */
  16149. isReady(): boolean;
  16150. }
  16151. /**
  16152. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16153. */
  16154. export class EdgesRenderer implements IEdgesRenderer {
  16155. /**
  16156. * Define the size of the edges with an orthographic camera
  16157. */
  16158. edgesWidthScalerForOrthographic: number;
  16159. /**
  16160. * Define the size of the edges with a perspective camera
  16161. */
  16162. edgesWidthScalerForPerspective: number;
  16163. protected _source: AbstractMesh;
  16164. protected _linesPositions: number[];
  16165. protected _linesNormals: number[];
  16166. protected _linesIndices: number[];
  16167. protected _epsilon: number;
  16168. protected _indicesCount: number;
  16169. protected _lineShader: ShaderMaterial;
  16170. protected _ib: DataBuffer;
  16171. protected _buffers: {
  16172. [key: string]: Nullable<VertexBuffer>;
  16173. };
  16174. protected _checkVerticesInsteadOfIndices: boolean;
  16175. private _meshRebuildObserver;
  16176. private _meshDisposeObserver;
  16177. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16178. isEnabled: boolean;
  16179. /**
  16180. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16181. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16182. * @param source Mesh used to create edges
  16183. * @param epsilon sum of angles in adjacency to check for edge
  16184. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16185. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16186. */
  16187. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16188. protected _prepareRessources(): void;
  16189. /** @hidden */
  16190. _rebuild(): void;
  16191. /**
  16192. * Releases the required resources for the edges renderer
  16193. */
  16194. dispose(): void;
  16195. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16196. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16197. /**
  16198. * Checks if the pair of p0 and p1 is en edge
  16199. * @param faceIndex
  16200. * @param edge
  16201. * @param faceNormals
  16202. * @param p0
  16203. * @param p1
  16204. * @private
  16205. */
  16206. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16207. /**
  16208. * push line into the position, normal and index buffer
  16209. * @protected
  16210. */
  16211. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16212. /**
  16213. * Generates lines edges from adjacencjes
  16214. * @private
  16215. */
  16216. _generateEdgesLines(): void;
  16217. /**
  16218. * Checks wether or not the edges renderer is ready to render.
  16219. * @return true if ready, otherwise false.
  16220. */
  16221. isReady(): boolean;
  16222. /**
  16223. * Renders the edges of the attached mesh,
  16224. */
  16225. render(): void;
  16226. }
  16227. /**
  16228. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16229. */
  16230. export class LineEdgesRenderer extends EdgesRenderer {
  16231. /**
  16232. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16233. * @param source LineMesh used to generate edges
  16234. * @param epsilon not important (specified angle for edge detection)
  16235. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16236. */
  16237. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16238. /**
  16239. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16240. */
  16241. _generateEdgesLines(): void;
  16242. }
  16243. }
  16244. declare module "babylonjs/Rendering/renderingGroup" {
  16245. import { SmartArray } from "babylonjs/Misc/smartArray";
  16246. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16247. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16248. import { Nullable } from "babylonjs/types";
  16249. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16250. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  16251. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16252. import { Material } from "babylonjs/Materials/material";
  16253. import { Scene } from "babylonjs/scene";
  16254. /**
  16255. * This represents the object necessary to create a rendering group.
  16256. * This is exclusively used and created by the rendering manager.
  16257. * To modify the behavior, you use the available helpers in your scene or meshes.
  16258. * @hidden
  16259. */
  16260. export class RenderingGroup {
  16261. index: number;
  16262. private static _zeroVector;
  16263. private _scene;
  16264. private _opaqueSubMeshes;
  16265. private _transparentSubMeshes;
  16266. private _alphaTestSubMeshes;
  16267. private _depthOnlySubMeshes;
  16268. private _particleSystems;
  16269. private _spriteManagers;
  16270. private _opaqueSortCompareFn;
  16271. private _alphaTestSortCompareFn;
  16272. private _transparentSortCompareFn;
  16273. private _renderOpaque;
  16274. private _renderAlphaTest;
  16275. private _renderTransparent;
  16276. /** @hidden */
  16277. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16278. onBeforeTransparentRendering: () => void;
  16279. /**
  16280. * Set the opaque sort comparison function.
  16281. * If null the sub meshes will be render in the order they were created
  16282. */
  16283. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16284. /**
  16285. * Set the alpha test sort comparison function.
  16286. * If null the sub meshes will be render in the order they were created
  16287. */
  16288. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16289. /**
  16290. * Set the transparent sort comparison function.
  16291. * If null the sub meshes will be render in the order they were created
  16292. */
  16293. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16294. /**
  16295. * Creates a new rendering group.
  16296. * @param index The rendering group index
  16297. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16298. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16299. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16300. */
  16301. 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>);
  16302. /**
  16303. * Render all the sub meshes contained in the group.
  16304. * @param customRenderFunction Used to override the default render behaviour of the group.
  16305. * @returns true if rendered some submeshes.
  16306. */
  16307. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16308. /**
  16309. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16310. * @param subMeshes The submeshes to render
  16311. */
  16312. private renderOpaqueSorted;
  16313. /**
  16314. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16315. * @param subMeshes The submeshes to render
  16316. */
  16317. private renderAlphaTestSorted;
  16318. /**
  16319. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16320. * @param subMeshes The submeshes to render
  16321. */
  16322. private renderTransparentSorted;
  16323. /**
  16324. * Renders the submeshes in a specified order.
  16325. * @param subMeshes The submeshes to sort before render
  16326. * @param sortCompareFn The comparison function use to sort
  16327. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16328. * @param transparent Specifies to activate blending if true
  16329. */
  16330. private static renderSorted;
  16331. /**
  16332. * Renders the submeshes in the order they were dispatched (no sort applied).
  16333. * @param subMeshes The submeshes to render
  16334. */
  16335. private static renderUnsorted;
  16336. /**
  16337. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16338. * are rendered back to front if in the same alpha index.
  16339. *
  16340. * @param a The first submesh
  16341. * @param b The second submesh
  16342. * @returns The result of the comparison
  16343. */
  16344. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16345. /**
  16346. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16347. * are rendered back to front.
  16348. *
  16349. * @param a The first submesh
  16350. * @param b The second submesh
  16351. * @returns The result of the comparison
  16352. */
  16353. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16354. /**
  16355. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16356. * are rendered front to back (prevent overdraw).
  16357. *
  16358. * @param a The first submesh
  16359. * @param b The second submesh
  16360. * @returns The result of the comparison
  16361. */
  16362. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16363. /**
  16364. * Resets the different lists of submeshes to prepare a new frame.
  16365. */
  16366. prepare(): void;
  16367. dispose(): void;
  16368. /**
  16369. * Inserts the submesh in its correct queue depending on its material.
  16370. * @param subMesh The submesh to dispatch
  16371. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16372. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16373. */
  16374. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16375. dispatchSprites(spriteManager: ISpriteManager): void;
  16376. dispatchParticles(particleSystem: IParticleSystem): void;
  16377. private _renderParticles;
  16378. private _renderSprites;
  16379. }
  16380. }
  16381. declare module "babylonjs/Rendering/renderingManager" {
  16382. import { Nullable } from "babylonjs/types";
  16383. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16384. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16385. import { SmartArray } from "babylonjs/Misc/smartArray";
  16386. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16387. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16388. import { Material } from "babylonjs/Materials/material";
  16389. import { Scene } from "babylonjs/scene";
  16390. import { Camera } from "babylonjs/Cameras/camera";
  16391. /**
  16392. * Interface describing the different options available in the rendering manager
  16393. * regarding Auto Clear between groups.
  16394. */
  16395. export interface IRenderingManagerAutoClearSetup {
  16396. /**
  16397. * Defines whether or not autoclear is enable.
  16398. */
  16399. autoClear: boolean;
  16400. /**
  16401. * Defines whether or not to autoclear the depth buffer.
  16402. */
  16403. depth: boolean;
  16404. /**
  16405. * Defines whether or not to autoclear the stencil buffer.
  16406. */
  16407. stencil: boolean;
  16408. }
  16409. /**
  16410. * This class is used by the onRenderingGroupObservable
  16411. */
  16412. export class RenderingGroupInfo {
  16413. /**
  16414. * The Scene that being rendered
  16415. */
  16416. scene: Scene;
  16417. /**
  16418. * The camera currently used for the rendering pass
  16419. */
  16420. camera: Nullable<Camera>;
  16421. /**
  16422. * The ID of the renderingGroup being processed
  16423. */
  16424. renderingGroupId: number;
  16425. }
  16426. /**
  16427. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16428. * It is enable to manage the different groups as well as the different necessary sort functions.
  16429. * This should not be used directly aside of the few static configurations
  16430. */
  16431. export class RenderingManager {
  16432. /**
  16433. * The max id used for rendering groups (not included)
  16434. */
  16435. static MAX_RENDERINGGROUPS: number;
  16436. /**
  16437. * The min id used for rendering groups (included)
  16438. */
  16439. static MIN_RENDERINGGROUPS: number;
  16440. /**
  16441. * Used to globally prevent autoclearing scenes.
  16442. */
  16443. static AUTOCLEAR: boolean;
  16444. /**
  16445. * @hidden
  16446. */
  16447. _useSceneAutoClearSetup: boolean;
  16448. private _scene;
  16449. private _renderingGroups;
  16450. private _depthStencilBufferAlreadyCleaned;
  16451. private _autoClearDepthStencil;
  16452. private _customOpaqueSortCompareFn;
  16453. private _customAlphaTestSortCompareFn;
  16454. private _customTransparentSortCompareFn;
  16455. private _renderingGroupInfo;
  16456. /**
  16457. * Instantiates a new rendering group for a particular scene
  16458. * @param scene Defines the scene the groups belongs to
  16459. */
  16460. constructor(scene: Scene);
  16461. private _clearDepthStencilBuffer;
  16462. /**
  16463. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16464. * @hidden
  16465. */
  16466. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16467. /**
  16468. * Resets the different information of the group to prepare a new frame
  16469. * @hidden
  16470. */
  16471. reset(): void;
  16472. /**
  16473. * Dispose and release the group and its associated resources.
  16474. * @hidden
  16475. */
  16476. dispose(): void;
  16477. /**
  16478. * Clear the info related to rendering groups preventing retention points during dispose.
  16479. */
  16480. freeRenderingGroups(): void;
  16481. private _prepareRenderingGroup;
  16482. /**
  16483. * Add a sprite manager to the rendering manager in order to render it this frame.
  16484. * @param spriteManager Define the sprite manager to render
  16485. */
  16486. dispatchSprites(spriteManager: ISpriteManager): void;
  16487. /**
  16488. * Add a particle system to the rendering manager in order to render it this frame.
  16489. * @param particleSystem Define the particle system to render
  16490. */
  16491. dispatchParticles(particleSystem: IParticleSystem): void;
  16492. /**
  16493. * Add a submesh to the manager in order to render it this frame
  16494. * @param subMesh The submesh to dispatch
  16495. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16496. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16497. */
  16498. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16499. /**
  16500. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16501. * This allowed control for front to back rendering or reversly depending of the special needs.
  16502. *
  16503. * @param renderingGroupId The rendering group id corresponding to its index
  16504. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16505. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16506. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16507. */
  16508. 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;
  16509. /**
  16510. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16511. *
  16512. * @param renderingGroupId The rendering group id corresponding to its index
  16513. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16514. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16515. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16516. */
  16517. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16518. /**
  16519. * Gets the current auto clear configuration for one rendering group of the rendering
  16520. * manager.
  16521. * @param index the rendering group index to get the information for
  16522. * @returns The auto clear setup for the requested rendering group
  16523. */
  16524. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16525. }
  16526. }
  16527. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  16528. import { SmartArray } from "babylonjs/Misc/smartArray";
  16529. import { Nullable } from "babylonjs/types";
  16530. import { Scene } from "babylonjs/scene";
  16531. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  16532. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16533. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16534. import { Mesh } from "babylonjs/Meshes/mesh";
  16535. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  16536. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  16537. import { Effect } from "babylonjs/Materials/effect";
  16538. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16539. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16540. import "babylonjs/Shaders/shadowMap.fragment";
  16541. import "babylonjs/Shaders/shadowMap.vertex";
  16542. import "babylonjs/Shaders/depthBoxBlur.fragment";
  16543. import { Observable } from "babylonjs/Misc/observable";
  16544. /**
  16545. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16546. */
  16547. export interface ICustomShaderOptions {
  16548. /**
  16549. * Gets or sets the custom shader name to use
  16550. */
  16551. shaderName: string;
  16552. /**
  16553. * The list of attribute names used in the shader
  16554. */
  16555. attributes?: string[];
  16556. /**
  16557. * The list of unifrom names used in the shader
  16558. */
  16559. uniforms?: string[];
  16560. /**
  16561. * The list of sampler names used in the shader
  16562. */
  16563. samplers?: string[];
  16564. /**
  16565. * The list of defines used in the shader
  16566. */
  16567. defines?: string[];
  16568. }
  16569. /**
  16570. * Interface to implement to create a shadow generator compatible with BJS.
  16571. */
  16572. export interface IShadowGenerator {
  16573. /**
  16574. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16575. * @returns The render target texture if present otherwise, null
  16576. */
  16577. getShadowMap(): Nullable<RenderTargetTexture>;
  16578. /**
  16579. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16580. * @param subMesh The submesh we want to render in the shadow map
  16581. * @param useInstances Defines wether will draw in the map using instances
  16582. * @returns true if ready otherwise, false
  16583. */
  16584. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16585. /**
  16586. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16587. * @param defines Defines of the material we want to update
  16588. * @param lightIndex Index of the light in the enabled light list of the material
  16589. */
  16590. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16591. /**
  16592. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16593. * defined in the generator but impacting the effect).
  16594. * It implies the unifroms available on the materials are the standard BJS ones.
  16595. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16596. * @param effect The effect we are binfing the information for
  16597. */
  16598. bindShadowLight(lightIndex: string, effect: Effect): void;
  16599. /**
  16600. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16601. * (eq to shadow prjection matrix * light transform matrix)
  16602. * @returns The transform matrix used to create the shadow map
  16603. */
  16604. getTransformMatrix(): Matrix;
  16605. /**
  16606. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16607. * Cube and 2D textures for instance.
  16608. */
  16609. recreateShadowMap(): void;
  16610. /**
  16611. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16612. * @param onCompiled Callback triggered at the and of the effects compilation
  16613. * @param options Sets of optional options forcing the compilation with different modes
  16614. */
  16615. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16616. useInstances: boolean;
  16617. }>): void;
  16618. /**
  16619. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16620. * @param options Sets of optional options forcing the compilation with different modes
  16621. * @returns A promise that resolves when the compilation completes
  16622. */
  16623. forceCompilationAsync(options?: Partial<{
  16624. useInstances: boolean;
  16625. }>): Promise<void>;
  16626. /**
  16627. * Serializes the shadow generator setup to a json object.
  16628. * @returns The serialized JSON object
  16629. */
  16630. serialize(): any;
  16631. /**
  16632. * Disposes the Shadow map and related Textures and effects.
  16633. */
  16634. dispose(): void;
  16635. }
  16636. /**
  16637. * Default implementation IShadowGenerator.
  16638. * This is the main object responsible of generating shadows in the framework.
  16639. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16640. */
  16641. export class ShadowGenerator implements IShadowGenerator {
  16642. /**
  16643. * Name of the shadow generator class
  16644. */
  16645. static CLASSNAME: string;
  16646. /**
  16647. * Shadow generator mode None: no filtering applied.
  16648. */
  16649. static readonly FILTER_NONE: number;
  16650. /**
  16651. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16652. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16653. */
  16654. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16655. /**
  16656. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16657. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16658. */
  16659. static readonly FILTER_POISSONSAMPLING: number;
  16660. /**
  16661. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16662. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16663. */
  16664. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16665. /**
  16666. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16667. * edge artifacts on steep falloff.
  16668. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16669. */
  16670. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16671. /**
  16672. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16673. * edge artifacts on steep falloff.
  16674. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16675. */
  16676. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16677. /**
  16678. * Shadow generator mode PCF: Percentage Closer Filtering
  16679. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16680. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16681. */
  16682. static readonly FILTER_PCF: number;
  16683. /**
  16684. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16685. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16686. * Contact Hardening
  16687. */
  16688. static readonly FILTER_PCSS: number;
  16689. /**
  16690. * Reserved for PCF and PCSS
  16691. * Highest Quality.
  16692. *
  16693. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16694. *
  16695. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16696. */
  16697. static readonly QUALITY_HIGH: number;
  16698. /**
  16699. * Reserved for PCF and PCSS
  16700. * Good tradeoff for quality/perf cross devices
  16701. *
  16702. * Execute PCF on a 3*3 kernel.
  16703. *
  16704. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16705. */
  16706. static readonly QUALITY_MEDIUM: number;
  16707. /**
  16708. * Reserved for PCF and PCSS
  16709. * The lowest quality but the fastest.
  16710. *
  16711. * Execute PCF on a 1*1 kernel.
  16712. *
  16713. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16714. */
  16715. static readonly QUALITY_LOW: number;
  16716. /** Gets or sets the custom shader name to use */
  16717. customShaderOptions: ICustomShaderOptions;
  16718. /**
  16719. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16720. */
  16721. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16722. /**
  16723. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16724. */
  16725. onAfterShadowMapRenderObservable: Observable<Effect>;
  16726. /**
  16727. * Observable triggered before a mesh is rendered in the shadow map.
  16728. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16729. */
  16730. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16731. /**
  16732. * Observable triggered after a mesh is rendered in the shadow map.
  16733. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16734. */
  16735. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16736. protected _bias: number;
  16737. /**
  16738. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16739. */
  16740. get bias(): number;
  16741. /**
  16742. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16743. */
  16744. set bias(bias: number);
  16745. protected _normalBias: number;
  16746. /**
  16747. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16748. */
  16749. get normalBias(): number;
  16750. /**
  16751. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16752. */
  16753. set normalBias(normalBias: number);
  16754. protected _blurBoxOffset: number;
  16755. /**
  16756. * Gets the blur box offset: offset applied during the blur pass.
  16757. * Only useful if useKernelBlur = false
  16758. */
  16759. get blurBoxOffset(): number;
  16760. /**
  16761. * Sets the blur box offset: offset applied during the blur pass.
  16762. * Only useful if useKernelBlur = false
  16763. */
  16764. set blurBoxOffset(value: number);
  16765. protected _blurScale: number;
  16766. /**
  16767. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16768. * 2 means half of the size.
  16769. */
  16770. get blurScale(): number;
  16771. /**
  16772. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16773. * 2 means half of the size.
  16774. */
  16775. set blurScale(value: number);
  16776. protected _blurKernel: number;
  16777. /**
  16778. * Gets the blur kernel: kernel size of the blur pass.
  16779. * Only useful if useKernelBlur = true
  16780. */
  16781. get blurKernel(): number;
  16782. /**
  16783. * Sets the blur kernel: kernel size of the blur pass.
  16784. * Only useful if useKernelBlur = true
  16785. */
  16786. set blurKernel(value: number);
  16787. protected _useKernelBlur: boolean;
  16788. /**
  16789. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16790. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16791. */
  16792. get useKernelBlur(): boolean;
  16793. /**
  16794. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16795. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16796. */
  16797. set useKernelBlur(value: boolean);
  16798. protected _depthScale: number;
  16799. /**
  16800. * Gets the depth scale used in ESM mode.
  16801. */
  16802. get depthScale(): number;
  16803. /**
  16804. * Sets the depth scale used in ESM mode.
  16805. * This can override the scale stored on the light.
  16806. */
  16807. set depthScale(value: number);
  16808. protected _validateFilter(filter: number): number;
  16809. protected _filter: number;
  16810. /**
  16811. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16812. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16813. */
  16814. get filter(): number;
  16815. /**
  16816. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  16817. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16818. */
  16819. set filter(value: number);
  16820. /**
  16821. * Gets if the current filter is set to Poisson Sampling.
  16822. */
  16823. get usePoissonSampling(): boolean;
  16824. /**
  16825. * Sets the current filter to Poisson Sampling.
  16826. */
  16827. set usePoissonSampling(value: boolean);
  16828. /**
  16829. * Gets if the current filter is set to ESM.
  16830. */
  16831. get useExponentialShadowMap(): boolean;
  16832. /**
  16833. * Sets the current filter is to ESM.
  16834. */
  16835. set useExponentialShadowMap(value: boolean);
  16836. /**
  16837. * Gets if the current filter is set to filtered ESM.
  16838. */
  16839. get useBlurExponentialShadowMap(): boolean;
  16840. /**
  16841. * Gets if the current filter is set to filtered ESM.
  16842. */
  16843. set useBlurExponentialShadowMap(value: boolean);
  16844. /**
  16845. * Gets if the current filter is set to "close ESM" (using the inverse of the
  16846. * exponential to prevent steep falloff artifacts).
  16847. */
  16848. get useCloseExponentialShadowMap(): boolean;
  16849. /**
  16850. * Sets the current filter to "close ESM" (using the inverse of the
  16851. * exponential to prevent steep falloff artifacts).
  16852. */
  16853. set useCloseExponentialShadowMap(value: boolean);
  16854. /**
  16855. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  16856. * exponential to prevent steep falloff artifacts).
  16857. */
  16858. get useBlurCloseExponentialShadowMap(): boolean;
  16859. /**
  16860. * Sets the current filter to filtered "close ESM" (using the inverse of the
  16861. * exponential to prevent steep falloff artifacts).
  16862. */
  16863. set useBlurCloseExponentialShadowMap(value: boolean);
  16864. /**
  16865. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  16866. */
  16867. get usePercentageCloserFiltering(): boolean;
  16868. /**
  16869. * Sets the current filter to "PCF" (percentage closer filtering).
  16870. */
  16871. set usePercentageCloserFiltering(value: boolean);
  16872. protected _filteringQuality: number;
  16873. /**
  16874. * Gets the PCF or PCSS Quality.
  16875. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16876. */
  16877. get filteringQuality(): number;
  16878. /**
  16879. * Sets the PCF or PCSS Quality.
  16880. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16881. */
  16882. set filteringQuality(filteringQuality: number);
  16883. /**
  16884. * Gets if the current filter is set to "PCSS" (contact hardening).
  16885. */
  16886. get useContactHardeningShadow(): boolean;
  16887. /**
  16888. * Sets the current filter to "PCSS" (contact hardening).
  16889. */
  16890. set useContactHardeningShadow(value: boolean);
  16891. protected _contactHardeningLightSizeUVRatio: number;
  16892. /**
  16893. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16894. * Using a ratio helps keeping shape stability independently of the map size.
  16895. *
  16896. * It does not account for the light projection as it was having too much
  16897. * instability during the light setup or during light position changes.
  16898. *
  16899. * Only valid if useContactHardeningShadow is true.
  16900. */
  16901. get contactHardeningLightSizeUVRatio(): number;
  16902. /**
  16903. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16904. * Using a ratio helps keeping shape stability independently of the map size.
  16905. *
  16906. * It does not account for the light projection as it was having too much
  16907. * instability during the light setup or during light position changes.
  16908. *
  16909. * Only valid if useContactHardeningShadow is true.
  16910. */
  16911. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  16912. protected _darkness: number;
  16913. /** Gets or sets the actual darkness of a shadow */
  16914. get darkness(): number;
  16915. set darkness(value: number);
  16916. /**
  16917. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  16918. * 0 means strongest and 1 would means no shadow.
  16919. * @returns the darkness.
  16920. */
  16921. getDarkness(): number;
  16922. /**
  16923. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  16924. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  16925. * @returns the shadow generator allowing fluent coding.
  16926. */
  16927. setDarkness(darkness: number): ShadowGenerator;
  16928. protected _transparencyShadow: boolean;
  16929. /** Gets or sets the ability to have transparent shadow */
  16930. get transparencyShadow(): boolean;
  16931. set transparencyShadow(value: boolean);
  16932. /**
  16933. * Sets the ability to have transparent shadow (boolean).
  16934. * @param transparent True if transparent else False
  16935. * @returns the shadow generator allowing fluent coding
  16936. */
  16937. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  16938. protected _shadowMap: Nullable<RenderTargetTexture>;
  16939. protected _shadowMap2: Nullable<RenderTargetTexture>;
  16940. /**
  16941. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16942. * @returns The render target texture if present otherwise, null
  16943. */
  16944. getShadowMap(): Nullable<RenderTargetTexture>;
  16945. /**
  16946. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  16947. * @returns The render target texture if the shadow map is present otherwise, null
  16948. */
  16949. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  16950. /**
  16951. * Gets the class name of that object
  16952. * @returns "ShadowGenerator"
  16953. */
  16954. getClassName(): string;
  16955. /**
  16956. * Helper function to add a mesh and its descendants to the list of shadow casters.
  16957. * @param mesh Mesh to add
  16958. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  16959. * @returns the Shadow Generator itself
  16960. */
  16961. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16962. /**
  16963. * Helper function to remove a mesh and its descendants from the list of shadow casters
  16964. * @param mesh Mesh to remove
  16965. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  16966. * @returns the Shadow Generator itself
  16967. */
  16968. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16969. /**
  16970. * Controls the extent to which the shadows fade out at the edge of the frustum
  16971. */
  16972. frustumEdgeFalloff: number;
  16973. protected _light: IShadowLight;
  16974. /**
  16975. * Returns the associated light object.
  16976. * @returns the light generating the shadow
  16977. */
  16978. getLight(): IShadowLight;
  16979. /**
  16980. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  16981. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  16982. * It might on the other hand introduce peter panning.
  16983. */
  16984. forceBackFacesOnly: boolean;
  16985. protected _scene: Scene;
  16986. protected _lightDirection: Vector3;
  16987. protected _effect: Effect;
  16988. protected _viewMatrix: Matrix;
  16989. protected _projectionMatrix: Matrix;
  16990. protected _transformMatrix: Matrix;
  16991. protected _cachedPosition: Vector3;
  16992. protected _cachedDirection: Vector3;
  16993. protected _cachedDefines: string;
  16994. protected _currentRenderID: number;
  16995. protected _boxBlurPostprocess: Nullable<PostProcess>;
  16996. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  16997. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  16998. protected _blurPostProcesses: PostProcess[];
  16999. protected _mapSize: number;
  17000. protected _currentFaceIndex: number;
  17001. protected _currentFaceIndexCache: number;
  17002. protected _textureType: number;
  17003. protected _defaultTextureMatrix: Matrix;
  17004. protected _storedUniqueId: Nullable<number>;
  17005. /** @hidden */
  17006. static _SceneComponentInitialization: (scene: Scene) => void;
  17007. /**
  17008. * Creates a ShadowGenerator object.
  17009. * A ShadowGenerator is the required tool to use the shadows.
  17010. * Each light casting shadows needs to use its own ShadowGenerator.
  17011. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17012. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17013. * @param light The light object generating the shadows.
  17014. * @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.
  17015. */
  17016. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17017. protected _initializeGenerator(): void;
  17018. protected _createTargetRenderTexture(): void;
  17019. protected _initializeShadowMap(): void;
  17020. protected _initializeBlurRTTAndPostProcesses(): void;
  17021. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17022. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  17023. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  17024. protected _applyFilterValues(): void;
  17025. /**
  17026. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17027. * @param onCompiled Callback triggered at the and of the effects compilation
  17028. * @param options Sets of optional options forcing the compilation with different modes
  17029. */
  17030. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17031. useInstances: boolean;
  17032. }>): void;
  17033. /**
  17034. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17035. * @param options Sets of optional options forcing the compilation with different modes
  17036. * @returns A promise that resolves when the compilation completes
  17037. */
  17038. forceCompilationAsync(options?: Partial<{
  17039. useInstances: boolean;
  17040. }>): Promise<void>;
  17041. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17042. /**
  17043. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17044. * @param subMesh The submesh we want to render in the shadow map
  17045. * @param useInstances Defines wether will draw in the map using instances
  17046. * @returns true if ready otherwise, false
  17047. */
  17048. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  17049. /**
  17050. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17051. * @param defines Defines of the material we want to update
  17052. * @param lightIndex Index of the light in the enabled light list of the material
  17053. */
  17054. prepareDefines(defines: any, lightIndex: number): void;
  17055. /**
  17056. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17057. * defined in the generator but impacting the effect).
  17058. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17059. * @param effect The effect we are binfing the information for
  17060. */
  17061. bindShadowLight(lightIndex: string, effect: Effect): void;
  17062. /**
  17063. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17064. * (eq to shadow prjection matrix * light transform matrix)
  17065. * @returns The transform matrix used to create the shadow map
  17066. */
  17067. getTransformMatrix(): Matrix;
  17068. /**
  17069. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17070. * Cube and 2D textures for instance.
  17071. */
  17072. recreateShadowMap(): void;
  17073. protected _disposeBlurPostProcesses(): void;
  17074. protected _disposeRTTandPostProcesses(): void;
  17075. /**
  17076. * Disposes the ShadowGenerator.
  17077. * Returns nothing.
  17078. */
  17079. dispose(): void;
  17080. /**
  17081. * Serializes the shadow generator setup to a json object.
  17082. * @returns The serialized JSON object
  17083. */
  17084. serialize(): any;
  17085. /**
  17086. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17087. * @param parsedShadowGenerator The JSON object to parse
  17088. * @param scene The scene to create the shadow map for
  17089. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17090. * @returns The parsed shadow generator
  17091. */
  17092. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17093. }
  17094. }
  17095. declare module "babylonjs/Lights/light" {
  17096. import { Nullable } from "babylonjs/types";
  17097. import { Scene } from "babylonjs/scene";
  17098. import { Vector3 } from "babylonjs/Maths/math.vector";
  17099. import { Color3 } from "babylonjs/Maths/math.color";
  17100. import { Node } from "babylonjs/node";
  17101. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17102. import { Effect } from "babylonjs/Materials/effect";
  17103. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  17104. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  17105. /**
  17106. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17107. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17108. * 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.
  17109. */
  17110. export abstract class Light extends Node {
  17111. /**
  17112. * Falloff Default: light is falling off following the material specification:
  17113. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17114. */
  17115. static readonly FALLOFF_DEFAULT: number;
  17116. /**
  17117. * Falloff Physical: light is falling off following the inverse squared distance law.
  17118. */
  17119. static readonly FALLOFF_PHYSICAL: number;
  17120. /**
  17121. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17122. * to enhance interoperability with other engines.
  17123. */
  17124. static readonly FALLOFF_GLTF: number;
  17125. /**
  17126. * Falloff Standard: light is falling off like in the standard material
  17127. * to enhance interoperability with other materials.
  17128. */
  17129. static readonly FALLOFF_STANDARD: number;
  17130. /**
  17131. * If every light affecting the material is in this lightmapMode,
  17132. * material.lightmapTexture adds or multiplies
  17133. * (depends on material.useLightmapAsShadowmap)
  17134. * after every other light calculations.
  17135. */
  17136. static readonly LIGHTMAP_DEFAULT: number;
  17137. /**
  17138. * material.lightmapTexture as only diffuse lighting from this light
  17139. * adds only specular lighting from this light
  17140. * adds dynamic shadows
  17141. */
  17142. static readonly LIGHTMAP_SPECULAR: number;
  17143. /**
  17144. * material.lightmapTexture as only lighting
  17145. * no light calculation from this light
  17146. * only adds dynamic shadows from this light
  17147. */
  17148. static readonly LIGHTMAP_SHADOWSONLY: number;
  17149. /**
  17150. * Each light type uses the default quantity according to its type:
  17151. * point/spot lights use luminous intensity
  17152. * directional lights use illuminance
  17153. */
  17154. static readonly INTENSITYMODE_AUTOMATIC: number;
  17155. /**
  17156. * lumen (lm)
  17157. */
  17158. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17159. /**
  17160. * candela (lm/sr)
  17161. */
  17162. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17163. /**
  17164. * lux (lm/m^2)
  17165. */
  17166. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17167. /**
  17168. * nit (cd/m^2)
  17169. */
  17170. static readonly INTENSITYMODE_LUMINANCE: number;
  17171. /**
  17172. * Light type const id of the point light.
  17173. */
  17174. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17175. /**
  17176. * Light type const id of the directional light.
  17177. */
  17178. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17179. /**
  17180. * Light type const id of the spot light.
  17181. */
  17182. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17183. /**
  17184. * Light type const id of the hemispheric light.
  17185. */
  17186. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17187. /**
  17188. * Diffuse gives the basic color to an object.
  17189. */
  17190. diffuse: Color3;
  17191. /**
  17192. * Specular produces a highlight color on an object.
  17193. * Note: This is note affecting PBR materials.
  17194. */
  17195. specular: Color3;
  17196. /**
  17197. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17198. * falling off base on range or angle.
  17199. * This can be set to any values in Light.FALLOFF_x.
  17200. *
  17201. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17202. * other types of materials.
  17203. */
  17204. falloffType: number;
  17205. /**
  17206. * Strength of the light.
  17207. * Note: By default it is define in the framework own unit.
  17208. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17209. */
  17210. intensity: number;
  17211. private _range;
  17212. protected _inverseSquaredRange: number;
  17213. /**
  17214. * Defines how far from the source the light is impacting in scene units.
  17215. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17216. */
  17217. get range(): number;
  17218. /**
  17219. * Defines how far from the source the light is impacting in scene units.
  17220. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17221. */
  17222. set range(value: number);
  17223. /**
  17224. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17225. * of light.
  17226. */
  17227. private _photometricScale;
  17228. private _intensityMode;
  17229. /**
  17230. * Gets the photometric scale used to interpret the intensity.
  17231. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17232. */
  17233. get intensityMode(): number;
  17234. /**
  17235. * Sets the photometric scale used to interpret the intensity.
  17236. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17237. */
  17238. set intensityMode(value: number);
  17239. private _radius;
  17240. /**
  17241. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17242. */
  17243. get radius(): number;
  17244. /**
  17245. * sets the light radius used by PBR Materials to simulate soft area lights.
  17246. */
  17247. set radius(value: number);
  17248. private _renderPriority;
  17249. /**
  17250. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17251. * exceeding the number allowed of the materials.
  17252. */
  17253. renderPriority: number;
  17254. private _shadowEnabled;
  17255. /**
  17256. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17257. * the current shadow generator.
  17258. */
  17259. get shadowEnabled(): boolean;
  17260. /**
  17261. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17262. * the current shadow generator.
  17263. */
  17264. set shadowEnabled(value: boolean);
  17265. private _includedOnlyMeshes;
  17266. /**
  17267. * Gets the only meshes impacted by this light.
  17268. */
  17269. get includedOnlyMeshes(): AbstractMesh[];
  17270. /**
  17271. * Sets the only meshes impacted by this light.
  17272. */
  17273. set includedOnlyMeshes(value: AbstractMesh[]);
  17274. private _excludedMeshes;
  17275. /**
  17276. * Gets the meshes not impacted by this light.
  17277. */
  17278. get excludedMeshes(): AbstractMesh[];
  17279. /**
  17280. * Sets the meshes not impacted by this light.
  17281. */
  17282. set excludedMeshes(value: AbstractMesh[]);
  17283. private _excludeWithLayerMask;
  17284. /**
  17285. * Gets the layer id use to find what meshes are not impacted by the light.
  17286. * Inactive if 0
  17287. */
  17288. get excludeWithLayerMask(): number;
  17289. /**
  17290. * Sets the layer id use to find what meshes are not impacted by the light.
  17291. * Inactive if 0
  17292. */
  17293. set excludeWithLayerMask(value: number);
  17294. private _includeOnlyWithLayerMask;
  17295. /**
  17296. * Gets the layer id use to find what meshes are impacted by the light.
  17297. * Inactive if 0
  17298. */
  17299. get includeOnlyWithLayerMask(): number;
  17300. /**
  17301. * Sets the layer id use to find what meshes are impacted by the light.
  17302. * Inactive if 0
  17303. */
  17304. set includeOnlyWithLayerMask(value: number);
  17305. private _lightmapMode;
  17306. /**
  17307. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17308. */
  17309. get lightmapMode(): number;
  17310. /**
  17311. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17312. */
  17313. set lightmapMode(value: number);
  17314. /**
  17315. * Shadow generator associted to the light.
  17316. * @hidden Internal use only.
  17317. */
  17318. _shadowGenerator: Nullable<IShadowGenerator>;
  17319. /**
  17320. * @hidden Internal use only.
  17321. */
  17322. _excludedMeshesIds: string[];
  17323. /**
  17324. * @hidden Internal use only.
  17325. */
  17326. _includedOnlyMeshesIds: string[];
  17327. /**
  17328. * The current light unifom buffer.
  17329. * @hidden Internal use only.
  17330. */
  17331. _uniformBuffer: UniformBuffer;
  17332. /** @hidden */
  17333. _renderId: number;
  17334. /**
  17335. * Creates a Light object in the scene.
  17336. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17337. * @param name The firendly name of the light
  17338. * @param scene The scene the light belongs too
  17339. */
  17340. constructor(name: string, scene: Scene);
  17341. protected abstract _buildUniformLayout(): void;
  17342. /**
  17343. * Sets the passed Effect "effect" with the Light information.
  17344. * @param effect The effect to update
  17345. * @param lightIndex The index of the light in the effect to update
  17346. * @returns The light
  17347. */
  17348. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17349. /**
  17350. * Sets the passed Effect "effect" with the Light textures.
  17351. * @param effect The effect to update
  17352. * @param lightIndex The index of the light in the effect to update
  17353. * @returns The light
  17354. */
  17355. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17356. /**
  17357. * Binds the lights information from the scene to the effect for the given mesh.
  17358. * @param lightIndex Light index
  17359. * @param scene The scene where the light belongs to
  17360. * @param effect The effect we are binding the data to
  17361. * @param useSpecular Defines if specular is supported
  17362. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17363. */
  17364. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17365. /**
  17366. * Sets the passed Effect "effect" with the Light information.
  17367. * @param effect The effect to update
  17368. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17369. * @returns The light
  17370. */
  17371. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17372. /**
  17373. * Returns the string "Light".
  17374. * @returns the class name
  17375. */
  17376. getClassName(): string;
  17377. /** @hidden */
  17378. readonly _isLight: boolean;
  17379. /**
  17380. * Converts the light information to a readable string for debug purpose.
  17381. * @param fullDetails Supports for multiple levels of logging within scene loading
  17382. * @returns the human readable light info
  17383. */
  17384. toString(fullDetails?: boolean): string;
  17385. /** @hidden */
  17386. protected _syncParentEnabledState(): void;
  17387. /**
  17388. * Set the enabled state of this node.
  17389. * @param value - the new enabled state
  17390. */
  17391. setEnabled(value: boolean): void;
  17392. /**
  17393. * Returns the Light associated shadow generator if any.
  17394. * @return the associated shadow generator.
  17395. */
  17396. getShadowGenerator(): Nullable<IShadowGenerator>;
  17397. /**
  17398. * Returns a Vector3, the absolute light position in the World.
  17399. * @returns the world space position of the light
  17400. */
  17401. getAbsolutePosition(): Vector3;
  17402. /**
  17403. * Specifies if the light will affect the passed mesh.
  17404. * @param mesh The mesh to test against the light
  17405. * @return true the mesh is affected otherwise, false.
  17406. */
  17407. canAffectMesh(mesh: AbstractMesh): boolean;
  17408. /**
  17409. * Sort function to order lights for rendering.
  17410. * @param a First Light object to compare to second.
  17411. * @param b Second Light object to compare first.
  17412. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  17413. */
  17414. static CompareLightsPriority(a: Light, b: Light): number;
  17415. /**
  17416. * Releases resources associated with this node.
  17417. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17418. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17419. */
  17420. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17421. /**
  17422. * Returns the light type ID (integer).
  17423. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17424. */
  17425. getTypeID(): number;
  17426. /**
  17427. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17428. * @returns the scaled intensity in intensity mode unit
  17429. */
  17430. getScaledIntensity(): number;
  17431. /**
  17432. * Returns a new Light object, named "name", from the current one.
  17433. * @param name The name of the cloned light
  17434. * @returns the new created light
  17435. */
  17436. clone(name: string): Nullable<Light>;
  17437. /**
  17438. * Serializes the current light into a Serialization object.
  17439. * @returns the serialized object.
  17440. */
  17441. serialize(): any;
  17442. /**
  17443. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17444. * This new light is named "name" and added to the passed scene.
  17445. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17446. * @param name The friendly name of the light
  17447. * @param scene The scene the new light will belong to
  17448. * @returns the constructor function
  17449. */
  17450. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17451. /**
  17452. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17453. * @param parsedLight The JSON representation of the light
  17454. * @param scene The scene to create the parsed light in
  17455. * @returns the created light after parsing
  17456. */
  17457. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17458. private _hookArrayForExcluded;
  17459. private _hookArrayForIncludedOnly;
  17460. private _resyncMeshes;
  17461. /**
  17462. * Forces the meshes to update their light related information in their rendering used effects
  17463. * @hidden Internal Use Only
  17464. */
  17465. _markMeshesAsLightDirty(): void;
  17466. /**
  17467. * Recomputes the cached photometric scale if needed.
  17468. */
  17469. private _computePhotometricScale;
  17470. /**
  17471. * Returns the Photometric Scale according to the light type and intensity mode.
  17472. */
  17473. private _getPhotometricScale;
  17474. /**
  17475. * Reorder the light in the scene according to their defined priority.
  17476. * @hidden Internal Use Only
  17477. */
  17478. _reorderLightsInScene(): void;
  17479. /**
  17480. * Prepares the list of defines specific to the light type.
  17481. * @param defines the list of defines
  17482. * @param lightIndex defines the index of the light for the effect
  17483. */
  17484. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17485. }
  17486. }
  17487. declare module "babylonjs/Actions/action" {
  17488. import { Observable } from "babylonjs/Misc/observable";
  17489. import { Condition } from "babylonjs/Actions/condition";
  17490. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  17491. import { ActionManager } from "babylonjs/Actions/actionManager";
  17492. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  17493. /**
  17494. * Interface used to define Action
  17495. */
  17496. export interface IAction {
  17497. /**
  17498. * Trigger for the action
  17499. */
  17500. trigger: number;
  17501. /** Options of the trigger */
  17502. triggerOptions: any;
  17503. /**
  17504. * Gets the trigger parameters
  17505. * @returns the trigger parameters
  17506. */
  17507. getTriggerParameter(): any;
  17508. /**
  17509. * Internal only - executes current action event
  17510. * @hidden
  17511. */
  17512. _executeCurrent(evt?: ActionEvent): void;
  17513. /**
  17514. * Serialize placeholder for child classes
  17515. * @param parent of child
  17516. * @returns the serialized object
  17517. */
  17518. serialize(parent: any): any;
  17519. /**
  17520. * Internal only
  17521. * @hidden
  17522. */
  17523. _prepare(): void;
  17524. /**
  17525. * Internal only - manager for action
  17526. * @hidden
  17527. */
  17528. _actionManager: AbstractActionManager;
  17529. /**
  17530. * Adds action to chain of actions, may be a DoNothingAction
  17531. * @param action defines the next action to execute
  17532. * @returns The action passed in
  17533. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17534. */
  17535. then(action: IAction): IAction;
  17536. }
  17537. /**
  17538. * The action to be carried out following a trigger
  17539. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17540. */
  17541. export class Action implements IAction {
  17542. /** the trigger, with or without parameters, for the action */
  17543. triggerOptions: any;
  17544. /**
  17545. * Trigger for the action
  17546. */
  17547. trigger: number;
  17548. /**
  17549. * Internal only - manager for action
  17550. * @hidden
  17551. */
  17552. _actionManager: ActionManager;
  17553. private _nextActiveAction;
  17554. private _child;
  17555. private _condition?;
  17556. private _triggerParameter;
  17557. /**
  17558. * An event triggered prior to action being executed.
  17559. */
  17560. onBeforeExecuteObservable: Observable<Action>;
  17561. /**
  17562. * Creates a new Action
  17563. * @param triggerOptions the trigger, with or without parameters, for the action
  17564. * @param condition an optional determinant of action
  17565. */
  17566. constructor(
  17567. /** the trigger, with or without parameters, for the action */
  17568. triggerOptions: any, condition?: Condition);
  17569. /**
  17570. * Internal only
  17571. * @hidden
  17572. */
  17573. _prepare(): void;
  17574. /**
  17575. * Gets the trigger parameters
  17576. * @returns the trigger parameters
  17577. */
  17578. getTriggerParameter(): any;
  17579. /**
  17580. * Internal only - executes current action event
  17581. * @hidden
  17582. */
  17583. _executeCurrent(evt?: ActionEvent): void;
  17584. /**
  17585. * Execute placeholder for child classes
  17586. * @param evt optional action event
  17587. */
  17588. execute(evt?: ActionEvent): void;
  17589. /**
  17590. * Skips to next active action
  17591. */
  17592. skipToNextActiveAction(): void;
  17593. /**
  17594. * Adds action to chain of actions, may be a DoNothingAction
  17595. * @param action defines the next action to execute
  17596. * @returns The action passed in
  17597. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17598. */
  17599. then(action: Action): Action;
  17600. /**
  17601. * Internal only
  17602. * @hidden
  17603. */
  17604. _getProperty(propertyPath: string): string;
  17605. /**
  17606. * Internal only
  17607. * @hidden
  17608. */
  17609. _getEffectiveTarget(target: any, propertyPath: string): any;
  17610. /**
  17611. * Serialize placeholder for child classes
  17612. * @param parent of child
  17613. * @returns the serialized object
  17614. */
  17615. serialize(parent: any): any;
  17616. /**
  17617. * Internal only called by serialize
  17618. * @hidden
  17619. */
  17620. protected _serialize(serializedAction: any, parent?: any): any;
  17621. /**
  17622. * Internal only
  17623. * @hidden
  17624. */
  17625. static _SerializeValueAsString: (value: any) => string;
  17626. /**
  17627. * Internal only
  17628. * @hidden
  17629. */
  17630. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  17631. name: string;
  17632. targetType: string;
  17633. value: string;
  17634. };
  17635. }
  17636. }
  17637. declare module "babylonjs/Actions/condition" {
  17638. import { ActionManager } from "babylonjs/Actions/actionManager";
  17639. /**
  17640. * A Condition applied to an Action
  17641. */
  17642. export class Condition {
  17643. /**
  17644. * Internal only - manager for action
  17645. * @hidden
  17646. */
  17647. _actionManager: ActionManager;
  17648. /**
  17649. * Internal only
  17650. * @hidden
  17651. */
  17652. _evaluationId: number;
  17653. /**
  17654. * Internal only
  17655. * @hidden
  17656. */
  17657. _currentResult: boolean;
  17658. /**
  17659. * Creates a new Condition
  17660. * @param actionManager the manager of the action the condition is applied to
  17661. */
  17662. constructor(actionManager: ActionManager);
  17663. /**
  17664. * Check if the current condition is valid
  17665. * @returns a boolean
  17666. */
  17667. isValid(): boolean;
  17668. /**
  17669. * Internal only
  17670. * @hidden
  17671. */
  17672. _getProperty(propertyPath: string): string;
  17673. /**
  17674. * Internal only
  17675. * @hidden
  17676. */
  17677. _getEffectiveTarget(target: any, propertyPath: string): any;
  17678. /**
  17679. * Serialize placeholder for child classes
  17680. * @returns the serialized object
  17681. */
  17682. serialize(): any;
  17683. /**
  17684. * Internal only
  17685. * @hidden
  17686. */
  17687. protected _serialize(serializedCondition: any): any;
  17688. }
  17689. /**
  17690. * Defines specific conditional operators as extensions of Condition
  17691. */
  17692. export class ValueCondition extends Condition {
  17693. /** path to specify the property of the target the conditional operator uses */
  17694. propertyPath: string;
  17695. /** the value compared by the conditional operator against the current value of the property */
  17696. value: any;
  17697. /** the conditional operator, default ValueCondition.IsEqual */
  17698. operator: number;
  17699. /**
  17700. * Internal only
  17701. * @hidden
  17702. */
  17703. private static _IsEqual;
  17704. /**
  17705. * Internal only
  17706. * @hidden
  17707. */
  17708. private static _IsDifferent;
  17709. /**
  17710. * Internal only
  17711. * @hidden
  17712. */
  17713. private static _IsGreater;
  17714. /**
  17715. * Internal only
  17716. * @hidden
  17717. */
  17718. private static _IsLesser;
  17719. /**
  17720. * returns the number for IsEqual
  17721. */
  17722. static get IsEqual(): number;
  17723. /**
  17724. * Returns the number for IsDifferent
  17725. */
  17726. static get IsDifferent(): number;
  17727. /**
  17728. * Returns the number for IsGreater
  17729. */
  17730. static get IsGreater(): number;
  17731. /**
  17732. * Returns the number for IsLesser
  17733. */
  17734. static get IsLesser(): number;
  17735. /**
  17736. * Internal only The action manager for the condition
  17737. * @hidden
  17738. */
  17739. _actionManager: ActionManager;
  17740. /**
  17741. * Internal only
  17742. * @hidden
  17743. */
  17744. private _target;
  17745. /**
  17746. * Internal only
  17747. * @hidden
  17748. */
  17749. private _effectiveTarget;
  17750. /**
  17751. * Internal only
  17752. * @hidden
  17753. */
  17754. private _property;
  17755. /**
  17756. * Creates a new ValueCondition
  17757. * @param actionManager manager for the action the condition applies to
  17758. * @param target for the action
  17759. * @param propertyPath path to specify the property of the target the conditional operator uses
  17760. * @param value the value compared by the conditional operator against the current value of the property
  17761. * @param operator the conditional operator, default ValueCondition.IsEqual
  17762. */
  17763. constructor(actionManager: ActionManager, target: any,
  17764. /** path to specify the property of the target the conditional operator uses */
  17765. propertyPath: string,
  17766. /** the value compared by the conditional operator against the current value of the property */
  17767. value: any,
  17768. /** the conditional operator, default ValueCondition.IsEqual */
  17769. operator?: number);
  17770. /**
  17771. * Compares the given value with the property value for the specified conditional operator
  17772. * @returns the result of the comparison
  17773. */
  17774. isValid(): boolean;
  17775. /**
  17776. * Serialize the ValueCondition into a JSON compatible object
  17777. * @returns serialization object
  17778. */
  17779. serialize(): any;
  17780. /**
  17781. * Gets the name of the conditional operator for the ValueCondition
  17782. * @param operator the conditional operator
  17783. * @returns the name
  17784. */
  17785. static GetOperatorName(operator: number): string;
  17786. }
  17787. /**
  17788. * Defines a predicate condition as an extension of Condition
  17789. */
  17790. export class PredicateCondition extends Condition {
  17791. /** defines the predicate function used to validate the condition */
  17792. predicate: () => boolean;
  17793. /**
  17794. * Internal only - manager for action
  17795. * @hidden
  17796. */
  17797. _actionManager: ActionManager;
  17798. /**
  17799. * Creates a new PredicateCondition
  17800. * @param actionManager manager for the action the condition applies to
  17801. * @param predicate defines the predicate function used to validate the condition
  17802. */
  17803. constructor(actionManager: ActionManager,
  17804. /** defines the predicate function used to validate the condition */
  17805. predicate: () => boolean);
  17806. /**
  17807. * @returns the validity of the predicate condition
  17808. */
  17809. isValid(): boolean;
  17810. }
  17811. /**
  17812. * Defines a state condition as an extension of Condition
  17813. */
  17814. export class StateCondition extends Condition {
  17815. /** Value to compare with target state */
  17816. value: string;
  17817. /**
  17818. * Internal only - manager for action
  17819. * @hidden
  17820. */
  17821. _actionManager: ActionManager;
  17822. /**
  17823. * Internal only
  17824. * @hidden
  17825. */
  17826. private _target;
  17827. /**
  17828. * Creates a new StateCondition
  17829. * @param actionManager manager for the action the condition applies to
  17830. * @param target of the condition
  17831. * @param value to compare with target state
  17832. */
  17833. constructor(actionManager: ActionManager, target: any,
  17834. /** Value to compare with target state */
  17835. value: string);
  17836. /**
  17837. * Gets a boolean indicating if the current condition is met
  17838. * @returns the validity of the state
  17839. */
  17840. isValid(): boolean;
  17841. /**
  17842. * Serialize the StateCondition into a JSON compatible object
  17843. * @returns serialization object
  17844. */
  17845. serialize(): any;
  17846. }
  17847. }
  17848. declare module "babylonjs/Actions/directActions" {
  17849. import { Action } from "babylonjs/Actions/action";
  17850. import { Condition } from "babylonjs/Actions/condition";
  17851. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  17852. /**
  17853. * This defines an action responsible to toggle a boolean once triggered.
  17854. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17855. */
  17856. export class SwitchBooleanAction extends Action {
  17857. /**
  17858. * The path to the boolean property in the target object
  17859. */
  17860. propertyPath: string;
  17861. private _target;
  17862. private _effectiveTarget;
  17863. private _property;
  17864. /**
  17865. * Instantiate the action
  17866. * @param triggerOptions defines the trigger options
  17867. * @param target defines the object containing the boolean
  17868. * @param propertyPath defines the path to the boolean property in the target object
  17869. * @param condition defines the trigger related conditions
  17870. */
  17871. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  17872. /** @hidden */
  17873. _prepare(): void;
  17874. /**
  17875. * Execute the action toggle the boolean value.
  17876. */
  17877. execute(): void;
  17878. /**
  17879. * Serializes the actions and its related information.
  17880. * @param parent defines the object to serialize in
  17881. * @returns the serialized object
  17882. */
  17883. serialize(parent: any): any;
  17884. }
  17885. /**
  17886. * This defines an action responsible to set a the state field of the target
  17887. * to a desired value once triggered.
  17888. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17889. */
  17890. export class SetStateAction extends Action {
  17891. /**
  17892. * The value to store in the state field.
  17893. */
  17894. value: string;
  17895. private _target;
  17896. /**
  17897. * Instantiate the action
  17898. * @param triggerOptions defines the trigger options
  17899. * @param target defines the object containing the state property
  17900. * @param value defines the value to store in the state field
  17901. * @param condition defines the trigger related conditions
  17902. */
  17903. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  17904. /**
  17905. * Execute the action and store the value on the target state property.
  17906. */
  17907. execute(): void;
  17908. /**
  17909. * Serializes the actions and its related information.
  17910. * @param parent defines the object to serialize in
  17911. * @returns the serialized object
  17912. */
  17913. serialize(parent: any): any;
  17914. }
  17915. /**
  17916. * This defines an action responsible to set a property of the target
  17917. * to a desired value once triggered.
  17918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17919. */
  17920. export class SetValueAction extends Action {
  17921. /**
  17922. * The path of the property to set in the target.
  17923. */
  17924. propertyPath: string;
  17925. /**
  17926. * The value to set in the property
  17927. */
  17928. value: any;
  17929. private _target;
  17930. private _effectiveTarget;
  17931. private _property;
  17932. /**
  17933. * Instantiate the action
  17934. * @param triggerOptions defines the trigger options
  17935. * @param target defines the object containing the property
  17936. * @param propertyPath defines the path of the property to set in the target
  17937. * @param value defines the value to set in the property
  17938. * @param condition defines the trigger related conditions
  17939. */
  17940. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17941. /** @hidden */
  17942. _prepare(): void;
  17943. /**
  17944. * Execute the action and set the targetted property to the desired value.
  17945. */
  17946. execute(): void;
  17947. /**
  17948. * Serializes the actions and its related information.
  17949. * @param parent defines the object to serialize in
  17950. * @returns the serialized object
  17951. */
  17952. serialize(parent: any): any;
  17953. }
  17954. /**
  17955. * This defines an action responsible to increment the target value
  17956. * to a desired value once triggered.
  17957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17958. */
  17959. export class IncrementValueAction extends Action {
  17960. /**
  17961. * The path of the property to increment in the target.
  17962. */
  17963. propertyPath: string;
  17964. /**
  17965. * The value we should increment the property by.
  17966. */
  17967. value: any;
  17968. private _target;
  17969. private _effectiveTarget;
  17970. private _property;
  17971. /**
  17972. * Instantiate the action
  17973. * @param triggerOptions defines the trigger options
  17974. * @param target defines the object containing the property
  17975. * @param propertyPath defines the path of the property to increment in the target
  17976. * @param value defines the value value we should increment the property by
  17977. * @param condition defines the trigger related conditions
  17978. */
  17979. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17980. /** @hidden */
  17981. _prepare(): void;
  17982. /**
  17983. * Execute the action and increment the target of the value amount.
  17984. */
  17985. execute(): void;
  17986. /**
  17987. * Serializes the actions and its related information.
  17988. * @param parent defines the object to serialize in
  17989. * @returns the serialized object
  17990. */
  17991. serialize(parent: any): any;
  17992. }
  17993. /**
  17994. * This defines an action responsible to start an animation once triggered.
  17995. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17996. */
  17997. export class PlayAnimationAction extends Action {
  17998. /**
  17999. * Where the animation should start (animation frame)
  18000. */
  18001. from: number;
  18002. /**
  18003. * Where the animation should stop (animation frame)
  18004. */
  18005. to: number;
  18006. /**
  18007. * Define if the animation should loop or stop after the first play.
  18008. */
  18009. loop?: boolean;
  18010. private _target;
  18011. /**
  18012. * Instantiate the action
  18013. * @param triggerOptions defines the trigger options
  18014. * @param target defines the target animation or animation name
  18015. * @param from defines from where the animation should start (animation frame)
  18016. * @param end defines where the animation should stop (animation frame)
  18017. * @param loop defines if the animation should loop or stop after the first play
  18018. * @param condition defines the trigger related conditions
  18019. */
  18020. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  18021. /** @hidden */
  18022. _prepare(): void;
  18023. /**
  18024. * Execute the action and play the animation.
  18025. */
  18026. execute(): void;
  18027. /**
  18028. * Serializes the actions and its related information.
  18029. * @param parent defines the object to serialize in
  18030. * @returns the serialized object
  18031. */
  18032. serialize(parent: any): any;
  18033. }
  18034. /**
  18035. * This defines an action responsible to stop an animation once triggered.
  18036. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18037. */
  18038. export class StopAnimationAction extends Action {
  18039. private _target;
  18040. /**
  18041. * Instantiate the action
  18042. * @param triggerOptions defines the trigger options
  18043. * @param target defines the target animation or animation name
  18044. * @param condition defines the trigger related conditions
  18045. */
  18046. constructor(triggerOptions: any, target: any, condition?: Condition);
  18047. /** @hidden */
  18048. _prepare(): void;
  18049. /**
  18050. * Execute the action and stop the animation.
  18051. */
  18052. execute(): void;
  18053. /**
  18054. * Serializes the actions and its related information.
  18055. * @param parent defines the object to serialize in
  18056. * @returns the serialized object
  18057. */
  18058. serialize(parent: any): any;
  18059. }
  18060. /**
  18061. * This defines an action responsible that does nothing once triggered.
  18062. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18063. */
  18064. export class DoNothingAction extends Action {
  18065. /**
  18066. * Instantiate the action
  18067. * @param triggerOptions defines the trigger options
  18068. * @param condition defines the trigger related conditions
  18069. */
  18070. constructor(triggerOptions?: any, condition?: Condition);
  18071. /**
  18072. * Execute the action and do nothing.
  18073. */
  18074. execute(): void;
  18075. /**
  18076. * Serializes the actions and its related information.
  18077. * @param parent defines the object to serialize in
  18078. * @returns the serialized object
  18079. */
  18080. serialize(parent: any): any;
  18081. }
  18082. /**
  18083. * This defines an action responsible to trigger several actions once triggered.
  18084. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18085. */
  18086. export class CombineAction extends Action {
  18087. /**
  18088. * The list of aggregated animations to run.
  18089. */
  18090. children: Action[];
  18091. /**
  18092. * Instantiate the action
  18093. * @param triggerOptions defines the trigger options
  18094. * @param children defines the list of aggregated animations to run
  18095. * @param condition defines the trigger related conditions
  18096. */
  18097. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  18098. /** @hidden */
  18099. _prepare(): void;
  18100. /**
  18101. * Execute the action and executes all the aggregated actions.
  18102. */
  18103. execute(evt: ActionEvent): void;
  18104. /**
  18105. * Serializes the actions and its related information.
  18106. * @param parent defines the object to serialize in
  18107. * @returns the serialized object
  18108. */
  18109. serialize(parent: any): any;
  18110. }
  18111. /**
  18112. * This defines an action responsible to run code (external event) once triggered.
  18113. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18114. */
  18115. export class ExecuteCodeAction extends Action {
  18116. /**
  18117. * The callback function to run.
  18118. */
  18119. func: (evt: ActionEvent) => void;
  18120. /**
  18121. * Instantiate the action
  18122. * @param triggerOptions defines the trigger options
  18123. * @param func defines the callback function to run
  18124. * @param condition defines the trigger related conditions
  18125. */
  18126. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  18127. /**
  18128. * Execute the action and run the attached code.
  18129. */
  18130. execute(evt: ActionEvent): void;
  18131. }
  18132. /**
  18133. * This defines an action responsible to set the parent property of the target once triggered.
  18134. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18135. */
  18136. export class SetParentAction extends Action {
  18137. private _parent;
  18138. private _target;
  18139. /**
  18140. * Instantiate the action
  18141. * @param triggerOptions defines the trigger options
  18142. * @param target defines the target containing the parent property
  18143. * @param parent defines from where the animation should start (animation frame)
  18144. * @param condition defines the trigger related conditions
  18145. */
  18146. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  18147. /** @hidden */
  18148. _prepare(): void;
  18149. /**
  18150. * Execute the action and set the parent property.
  18151. */
  18152. execute(): void;
  18153. /**
  18154. * Serializes the actions and its related information.
  18155. * @param parent defines the object to serialize in
  18156. * @returns the serialized object
  18157. */
  18158. serialize(parent: any): any;
  18159. }
  18160. }
  18161. declare module "babylonjs/Actions/actionManager" {
  18162. import { Nullable } from "babylonjs/types";
  18163. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18164. import { Scene } from "babylonjs/scene";
  18165. import { IAction } from "babylonjs/Actions/action";
  18166. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  18167. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  18168. /**
  18169. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  18170. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  18171. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18172. */
  18173. export class ActionManager extends AbstractActionManager {
  18174. /**
  18175. * Nothing
  18176. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18177. */
  18178. static readonly NothingTrigger: number;
  18179. /**
  18180. * On pick
  18181. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18182. */
  18183. static readonly OnPickTrigger: number;
  18184. /**
  18185. * On left pick
  18186. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18187. */
  18188. static readonly OnLeftPickTrigger: number;
  18189. /**
  18190. * On right pick
  18191. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18192. */
  18193. static readonly OnRightPickTrigger: number;
  18194. /**
  18195. * On center pick
  18196. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18197. */
  18198. static readonly OnCenterPickTrigger: number;
  18199. /**
  18200. * On pick down
  18201. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18202. */
  18203. static readonly OnPickDownTrigger: number;
  18204. /**
  18205. * On double pick
  18206. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18207. */
  18208. static readonly OnDoublePickTrigger: number;
  18209. /**
  18210. * On pick up
  18211. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18212. */
  18213. static readonly OnPickUpTrigger: number;
  18214. /**
  18215. * On pick out.
  18216. * This trigger will only be raised if you also declared a OnPickDown
  18217. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18218. */
  18219. static readonly OnPickOutTrigger: number;
  18220. /**
  18221. * On long press
  18222. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18223. */
  18224. static readonly OnLongPressTrigger: number;
  18225. /**
  18226. * On pointer over
  18227. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18228. */
  18229. static readonly OnPointerOverTrigger: number;
  18230. /**
  18231. * On pointer out
  18232. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18233. */
  18234. static readonly OnPointerOutTrigger: number;
  18235. /**
  18236. * On every frame
  18237. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18238. */
  18239. static readonly OnEveryFrameTrigger: number;
  18240. /**
  18241. * On intersection enter
  18242. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18243. */
  18244. static readonly OnIntersectionEnterTrigger: number;
  18245. /**
  18246. * On intersection exit
  18247. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18248. */
  18249. static readonly OnIntersectionExitTrigger: number;
  18250. /**
  18251. * On key down
  18252. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18253. */
  18254. static readonly OnKeyDownTrigger: number;
  18255. /**
  18256. * On key up
  18257. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18258. */
  18259. static readonly OnKeyUpTrigger: number;
  18260. private _scene;
  18261. /**
  18262. * Creates a new action manager
  18263. * @param scene defines the hosting scene
  18264. */
  18265. constructor(scene: Scene);
  18266. /**
  18267. * Releases all associated resources
  18268. */
  18269. dispose(): void;
  18270. /**
  18271. * Gets hosting scene
  18272. * @returns the hosting scene
  18273. */
  18274. getScene(): Scene;
  18275. /**
  18276. * Does this action manager handles actions of any of the given triggers
  18277. * @param triggers defines the triggers to be tested
  18278. * @return a boolean indicating whether one (or more) of the triggers is handled
  18279. */
  18280. hasSpecificTriggers(triggers: number[]): boolean;
  18281. /**
  18282. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  18283. * speed.
  18284. * @param triggerA defines the trigger to be tested
  18285. * @param triggerB defines the trigger to be tested
  18286. * @return a boolean indicating whether one (or more) of the triggers is handled
  18287. */
  18288. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  18289. /**
  18290. * Does this action manager handles actions of a given trigger
  18291. * @param trigger defines the trigger to be tested
  18292. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  18293. * @return whether the trigger is handled
  18294. */
  18295. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  18296. /**
  18297. * Does this action manager has pointer triggers
  18298. */
  18299. get hasPointerTriggers(): boolean;
  18300. /**
  18301. * Does this action manager has pick triggers
  18302. */
  18303. get hasPickTriggers(): boolean;
  18304. /**
  18305. * Registers an action to this action manager
  18306. * @param action defines the action to be registered
  18307. * @return the action amended (prepared) after registration
  18308. */
  18309. registerAction(action: IAction): Nullable<IAction>;
  18310. /**
  18311. * Unregisters an action to this action manager
  18312. * @param action defines the action to be unregistered
  18313. * @return a boolean indicating whether the action has been unregistered
  18314. */
  18315. unregisterAction(action: IAction): Boolean;
  18316. /**
  18317. * Process a specific trigger
  18318. * @param trigger defines the trigger to process
  18319. * @param evt defines the event details to be processed
  18320. */
  18321. processTrigger(trigger: number, evt?: IActionEvent): void;
  18322. /** @hidden */
  18323. _getEffectiveTarget(target: any, propertyPath: string): any;
  18324. /** @hidden */
  18325. _getProperty(propertyPath: string): string;
  18326. /**
  18327. * Serialize this manager to a JSON object
  18328. * @param name defines the property name to store this manager
  18329. * @returns a JSON representation of this manager
  18330. */
  18331. serialize(name: string): any;
  18332. /**
  18333. * Creates a new ActionManager from a JSON data
  18334. * @param parsedActions defines the JSON data to read from
  18335. * @param object defines the hosting mesh
  18336. * @param scene defines the hosting scene
  18337. */
  18338. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  18339. /**
  18340. * Get a trigger name by index
  18341. * @param trigger defines the trigger index
  18342. * @returns a trigger name
  18343. */
  18344. static GetTriggerName(trigger: number): string;
  18345. }
  18346. }
  18347. declare module "babylonjs/Sprites/sprite" {
  18348. import { Vector3 } from "babylonjs/Maths/math.vector";
  18349. import { Nullable } from "babylonjs/types";
  18350. import { ActionManager } from "babylonjs/Actions/actionManager";
  18351. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  18352. import { Color4 } from "babylonjs/Maths/math.color";
  18353. /**
  18354. * Class used to represent a sprite
  18355. * @see http://doc.babylonjs.com/babylon101/sprites
  18356. */
  18357. export class Sprite {
  18358. /** defines the name */
  18359. name: string;
  18360. /** Gets or sets the current world position */
  18361. position: Vector3;
  18362. /** Gets or sets the main color */
  18363. color: Color4;
  18364. /** Gets or sets the width */
  18365. width: number;
  18366. /** Gets or sets the height */
  18367. height: number;
  18368. /** Gets or sets rotation angle */
  18369. angle: number;
  18370. /** Gets or sets the cell index in the sprite sheet */
  18371. cellIndex: number;
  18372. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  18373. cellRef: string;
  18374. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  18375. invertU: number;
  18376. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  18377. invertV: number;
  18378. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  18379. disposeWhenFinishedAnimating: boolean;
  18380. /** Gets the list of attached animations */
  18381. animations: Animation[];
  18382. /** Gets or sets a boolean indicating if the sprite can be picked */
  18383. isPickable: boolean;
  18384. /**
  18385. * Gets or sets the associated action manager
  18386. */
  18387. actionManager: Nullable<ActionManager>;
  18388. private _animationStarted;
  18389. private _loopAnimation;
  18390. private _fromIndex;
  18391. private _toIndex;
  18392. private _delay;
  18393. private _direction;
  18394. private _manager;
  18395. private _time;
  18396. private _onAnimationEnd;
  18397. /**
  18398. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  18399. */
  18400. isVisible: boolean;
  18401. /**
  18402. * Gets or sets the sprite size
  18403. */
  18404. get size(): number;
  18405. set size(value: number);
  18406. /**
  18407. * Creates a new Sprite
  18408. * @param name defines the name
  18409. * @param manager defines the manager
  18410. */
  18411. constructor(
  18412. /** defines the name */
  18413. name: string, manager: ISpriteManager);
  18414. /**
  18415. * Starts an animation
  18416. * @param from defines the initial key
  18417. * @param to defines the end key
  18418. * @param loop defines if the animation must loop
  18419. * @param delay defines the start delay (in ms)
  18420. * @param onAnimationEnd defines a callback to call when animation ends
  18421. */
  18422. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  18423. /** Stops current animation (if any) */
  18424. stopAnimation(): void;
  18425. /** @hidden */
  18426. _animate(deltaTime: number): void;
  18427. /** Release associated resources */
  18428. dispose(): void;
  18429. }
  18430. }
  18431. declare module "babylonjs/Collisions/pickingInfo" {
  18432. import { Nullable } from "babylonjs/types";
  18433. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18434. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18435. import { Sprite } from "babylonjs/Sprites/sprite";
  18436. import { Ray } from "babylonjs/Culling/ray";
  18437. /**
  18438. * Information about the result of picking within a scene
  18439. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  18440. */
  18441. export class PickingInfo {
  18442. /** @hidden */
  18443. _pickingUnavailable: boolean;
  18444. /**
  18445. * If the pick collided with an object
  18446. */
  18447. hit: boolean;
  18448. /**
  18449. * Distance away where the pick collided
  18450. */
  18451. distance: number;
  18452. /**
  18453. * The location of pick collision
  18454. */
  18455. pickedPoint: Nullable<Vector3>;
  18456. /**
  18457. * The mesh corresponding the the pick collision
  18458. */
  18459. pickedMesh: Nullable<AbstractMesh>;
  18460. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18461. bu: number;
  18462. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18463. bv: number;
  18464. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18465. faceId: number;
  18466. /** Id of the the submesh that was picked */
  18467. subMeshId: number;
  18468. /** If a sprite was picked, this will be the sprite the pick collided with */
  18469. pickedSprite: Nullable<Sprite>;
  18470. /**
  18471. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18472. */
  18473. originMesh: Nullable<AbstractMesh>;
  18474. /**
  18475. * The ray that was used to perform the picking.
  18476. */
  18477. ray: Nullable<Ray>;
  18478. /**
  18479. * Gets the normal correspodning to the face the pick collided with
  18480. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18481. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18482. * @returns The normal correspodning to the face the pick collided with
  18483. */
  18484. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18485. /**
  18486. * Gets the texture coordinates of where the pick occured
  18487. * @returns the vector containing the coordnates of the texture
  18488. */
  18489. getTextureCoordinates(): Nullable<Vector2>;
  18490. }
  18491. }
  18492. declare module "babylonjs/Events/pointerEvents" {
  18493. import { Nullable } from "babylonjs/types";
  18494. import { Vector2 } from "babylonjs/Maths/math.vector";
  18495. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  18496. import { Ray } from "babylonjs/Culling/ray";
  18497. /**
  18498. * Gather the list of pointer event types as constants.
  18499. */
  18500. export class PointerEventTypes {
  18501. /**
  18502. * 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.
  18503. */
  18504. static readonly POINTERDOWN: number;
  18505. /**
  18506. * The pointerup event is fired when a pointer is no longer active.
  18507. */
  18508. static readonly POINTERUP: number;
  18509. /**
  18510. * The pointermove event is fired when a pointer changes coordinates.
  18511. */
  18512. static readonly POINTERMOVE: number;
  18513. /**
  18514. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18515. */
  18516. static readonly POINTERWHEEL: number;
  18517. /**
  18518. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18519. */
  18520. static readonly POINTERPICK: number;
  18521. /**
  18522. * The pointertap event is fired when a the object has been touched and released without drag.
  18523. */
  18524. static readonly POINTERTAP: number;
  18525. /**
  18526. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18527. */
  18528. static readonly POINTERDOUBLETAP: number;
  18529. }
  18530. /**
  18531. * Base class of pointer info types.
  18532. */
  18533. export class PointerInfoBase {
  18534. /**
  18535. * Defines the type of event (PointerEventTypes)
  18536. */
  18537. type: number;
  18538. /**
  18539. * Defines the related dom event
  18540. */
  18541. event: PointerEvent | MouseWheelEvent;
  18542. /**
  18543. * Instantiates the base class of pointers info.
  18544. * @param type Defines the type of event (PointerEventTypes)
  18545. * @param event Defines the related dom event
  18546. */
  18547. constructor(
  18548. /**
  18549. * Defines the type of event (PointerEventTypes)
  18550. */
  18551. type: number,
  18552. /**
  18553. * Defines the related dom event
  18554. */
  18555. event: PointerEvent | MouseWheelEvent);
  18556. }
  18557. /**
  18558. * This class is used to store pointer related info for the onPrePointerObservable event.
  18559. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18560. */
  18561. export class PointerInfoPre extends PointerInfoBase {
  18562. /**
  18563. * Ray from a pointer if availible (eg. 6dof controller)
  18564. */
  18565. ray: Nullable<Ray>;
  18566. /**
  18567. * Defines the local position of the pointer on the canvas.
  18568. */
  18569. localPosition: Vector2;
  18570. /**
  18571. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18572. */
  18573. skipOnPointerObservable: boolean;
  18574. /**
  18575. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18576. * @param type Defines the type of event (PointerEventTypes)
  18577. * @param event Defines the related dom event
  18578. * @param localX Defines the local x coordinates of the pointer when the event occured
  18579. * @param localY Defines the local y coordinates of the pointer when the event occured
  18580. */
  18581. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18582. }
  18583. /**
  18584. * This type contains all the data related to a pointer event in Babylon.js.
  18585. * 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.
  18586. */
  18587. export class PointerInfo extends PointerInfoBase {
  18588. /**
  18589. * Defines the picking info associated to the info (if any)\
  18590. */
  18591. pickInfo: Nullable<PickingInfo>;
  18592. /**
  18593. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18594. * @param type Defines the type of event (PointerEventTypes)
  18595. * @param event Defines the related dom event
  18596. * @param pickInfo Defines the picking info associated to the info (if any)\
  18597. */
  18598. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18599. /**
  18600. * Defines the picking info associated to the info (if any)\
  18601. */
  18602. pickInfo: Nullable<PickingInfo>);
  18603. }
  18604. /**
  18605. * Data relating to a touch event on the screen.
  18606. */
  18607. export interface PointerTouch {
  18608. /**
  18609. * X coordinate of touch.
  18610. */
  18611. x: number;
  18612. /**
  18613. * Y coordinate of touch.
  18614. */
  18615. y: number;
  18616. /**
  18617. * Id of touch. Unique for each finger.
  18618. */
  18619. pointerId: number;
  18620. /**
  18621. * Event type passed from DOM.
  18622. */
  18623. type: any;
  18624. }
  18625. }
  18626. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  18627. import { Observable } from "babylonjs/Misc/observable";
  18628. import { Nullable } from "babylonjs/types";
  18629. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18630. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18631. /**
  18632. * Manage the mouse inputs to control the movement of a free camera.
  18633. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18634. */
  18635. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18636. /**
  18637. * Define if touch is enabled in the mouse input
  18638. */
  18639. touchEnabled: boolean;
  18640. /**
  18641. * Defines the camera the input is attached to.
  18642. */
  18643. camera: FreeCamera;
  18644. /**
  18645. * Defines the buttons associated with the input to handle camera move.
  18646. */
  18647. buttons: number[];
  18648. /**
  18649. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18650. */
  18651. angularSensibility: number;
  18652. private _pointerInput;
  18653. private _onMouseMove;
  18654. private _observer;
  18655. private previousPosition;
  18656. /**
  18657. * Observable for when a pointer move event occurs containing the move offset
  18658. */
  18659. onPointerMovedObservable: Observable<{
  18660. offsetX: number;
  18661. offsetY: number;
  18662. }>;
  18663. /**
  18664. * @hidden
  18665. * If the camera should be rotated automatically based on pointer movement
  18666. */
  18667. _allowCameraRotation: boolean;
  18668. /**
  18669. * Manage the mouse inputs to control the movement of a free camera.
  18670. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18671. * @param touchEnabled Defines if touch is enabled or not
  18672. */
  18673. constructor(
  18674. /**
  18675. * Define if touch is enabled in the mouse input
  18676. */
  18677. touchEnabled?: boolean);
  18678. /**
  18679. * Attach the input controls to a specific dom element to get the input from.
  18680. * @param element Defines the element the controls should be listened from
  18681. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18682. */
  18683. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18684. /**
  18685. * Called on JS contextmenu event.
  18686. * Override this method to provide functionality.
  18687. */
  18688. protected onContextMenu(evt: PointerEvent): void;
  18689. /**
  18690. * Detach the current controls from the specified dom element.
  18691. * @param element Defines the element to stop listening the inputs from
  18692. */
  18693. detachControl(element: Nullable<HTMLElement>): void;
  18694. /**
  18695. * Gets the class name of the current intput.
  18696. * @returns the class name
  18697. */
  18698. getClassName(): string;
  18699. /**
  18700. * Get the friendly name associated with the input class.
  18701. * @returns the input friendly name
  18702. */
  18703. getSimpleName(): string;
  18704. }
  18705. }
  18706. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  18707. import { Nullable } from "babylonjs/types";
  18708. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18709. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18710. /**
  18711. * Manage the touch inputs to control the movement of a free camera.
  18712. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18713. */
  18714. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18715. /**
  18716. * Defines the camera the input is attached to.
  18717. */
  18718. camera: FreeCamera;
  18719. /**
  18720. * Defines the touch sensibility for rotation.
  18721. * The higher the faster.
  18722. */
  18723. touchAngularSensibility: number;
  18724. /**
  18725. * Defines the touch sensibility for move.
  18726. * The higher the faster.
  18727. */
  18728. touchMoveSensibility: number;
  18729. private _offsetX;
  18730. private _offsetY;
  18731. private _pointerPressed;
  18732. private _pointerInput;
  18733. private _observer;
  18734. private _onLostFocus;
  18735. /**
  18736. * Attach the input controls to a specific dom element to get the input from.
  18737. * @param element Defines the element the controls should be listened from
  18738. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18739. */
  18740. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18741. /**
  18742. * Detach the current controls from the specified dom element.
  18743. * @param element Defines the element to stop listening the inputs from
  18744. */
  18745. detachControl(element: Nullable<HTMLElement>): void;
  18746. /**
  18747. * Update the current camera state depending on the inputs that have been used this frame.
  18748. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18749. */
  18750. checkInputs(): void;
  18751. /**
  18752. * Gets the class name of the current intput.
  18753. * @returns the class name
  18754. */
  18755. getClassName(): string;
  18756. /**
  18757. * Get the friendly name associated with the input class.
  18758. * @returns the input friendly name
  18759. */
  18760. getSimpleName(): string;
  18761. }
  18762. }
  18763. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  18764. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18765. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  18766. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  18767. import { Nullable } from "babylonjs/types";
  18768. /**
  18769. * Default Inputs manager for the FreeCamera.
  18770. * It groups all the default supported inputs for ease of use.
  18771. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18772. */
  18773. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18774. /**
  18775. * @hidden
  18776. */
  18777. _mouseInput: Nullable<FreeCameraMouseInput>;
  18778. /**
  18779. * Instantiates a new FreeCameraInputsManager.
  18780. * @param camera Defines the camera the inputs belong to
  18781. */
  18782. constructor(camera: FreeCamera);
  18783. /**
  18784. * Add keyboard input support to the input manager.
  18785. * @returns the current input manager
  18786. */
  18787. addKeyboard(): FreeCameraInputsManager;
  18788. /**
  18789. * Add mouse input support to the input manager.
  18790. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18791. * @returns the current input manager
  18792. */
  18793. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18794. /**
  18795. * Removes the mouse input support from the manager
  18796. * @returns the current input manager
  18797. */
  18798. removeMouse(): FreeCameraInputsManager;
  18799. /**
  18800. * Add touch input support to the input manager.
  18801. * @returns the current input manager
  18802. */
  18803. addTouch(): FreeCameraInputsManager;
  18804. /**
  18805. * Remove all attached input methods from a camera
  18806. */
  18807. clear(): void;
  18808. }
  18809. }
  18810. declare module "babylonjs/Cameras/freeCamera" {
  18811. import { Vector3 } from "babylonjs/Maths/math.vector";
  18812. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18813. import { Scene } from "babylonjs/scene";
  18814. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  18815. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  18816. /**
  18817. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18818. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18819. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18820. */
  18821. export class FreeCamera extends TargetCamera {
  18822. /**
  18823. * Define the collision ellipsoid of the camera.
  18824. * This is helpful to simulate a camera body like the player body around the camera
  18825. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18826. */
  18827. ellipsoid: Vector3;
  18828. /**
  18829. * Define an offset for the position of the ellipsoid around the camera.
  18830. * This can be helpful to determine the center of the body near the gravity center of the body
  18831. * instead of its head.
  18832. */
  18833. ellipsoidOffset: Vector3;
  18834. /**
  18835. * Enable or disable collisions of the camera with the rest of the scene objects.
  18836. */
  18837. checkCollisions: boolean;
  18838. /**
  18839. * Enable or disable gravity on the camera.
  18840. */
  18841. applyGravity: boolean;
  18842. /**
  18843. * Define the input manager associated to the camera.
  18844. */
  18845. inputs: FreeCameraInputsManager;
  18846. /**
  18847. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18848. * Higher values reduce sensitivity.
  18849. */
  18850. get angularSensibility(): number;
  18851. /**
  18852. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18853. * Higher values reduce sensitivity.
  18854. */
  18855. set angularSensibility(value: number);
  18856. /**
  18857. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18858. */
  18859. get keysUp(): number[];
  18860. set keysUp(value: number[]);
  18861. /**
  18862. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18863. */
  18864. get keysDown(): number[];
  18865. set keysDown(value: number[]);
  18866. /**
  18867. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18868. */
  18869. get keysLeft(): number[];
  18870. set keysLeft(value: number[]);
  18871. /**
  18872. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18873. */
  18874. get keysRight(): number[];
  18875. set keysRight(value: number[]);
  18876. /**
  18877. * Event raised when the camera collide with a mesh in the scene.
  18878. */
  18879. onCollide: (collidedMesh: AbstractMesh) => void;
  18880. private _collider;
  18881. private _needMoveForGravity;
  18882. private _oldPosition;
  18883. private _diffPosition;
  18884. private _newPosition;
  18885. /** @hidden */
  18886. _localDirection: Vector3;
  18887. /** @hidden */
  18888. _transformedDirection: Vector3;
  18889. /**
  18890. * Instantiates a Free Camera.
  18891. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18892. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18893. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18894. * @param name Define the name of the camera in the scene
  18895. * @param position Define the start position of the camera in the scene
  18896. * @param scene Define the scene the camera belongs to
  18897. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18898. */
  18899. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18900. /**
  18901. * Attached controls to the current camera.
  18902. * @param element Defines the element the controls should be listened from
  18903. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18904. */
  18905. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18906. /**
  18907. * Detach the current controls from the camera.
  18908. * The camera will stop reacting to inputs.
  18909. * @param element Defines the element to stop listening the inputs from
  18910. */
  18911. detachControl(element: HTMLElement): void;
  18912. private _collisionMask;
  18913. /**
  18914. * Define a collision mask to limit the list of object the camera can collide with
  18915. */
  18916. get collisionMask(): number;
  18917. set collisionMask(mask: number);
  18918. /** @hidden */
  18919. _collideWithWorld(displacement: Vector3): void;
  18920. private _onCollisionPositionChange;
  18921. /** @hidden */
  18922. _checkInputs(): void;
  18923. /** @hidden */
  18924. _decideIfNeedsToMove(): boolean;
  18925. /** @hidden */
  18926. _updatePosition(): void;
  18927. /**
  18928. * Destroy the camera and release the current resources hold by it.
  18929. */
  18930. dispose(): void;
  18931. /**
  18932. * Gets the current object class name.
  18933. * @return the class name
  18934. */
  18935. getClassName(): string;
  18936. }
  18937. }
  18938. declare module "babylonjs/Gamepads/gamepad" {
  18939. import { Observable } from "babylonjs/Misc/observable";
  18940. /**
  18941. * Represents a gamepad control stick position
  18942. */
  18943. export class StickValues {
  18944. /**
  18945. * The x component of the control stick
  18946. */
  18947. x: number;
  18948. /**
  18949. * The y component of the control stick
  18950. */
  18951. y: number;
  18952. /**
  18953. * Initializes the gamepad x and y control stick values
  18954. * @param x The x component of the gamepad control stick value
  18955. * @param y The y component of the gamepad control stick value
  18956. */
  18957. constructor(
  18958. /**
  18959. * The x component of the control stick
  18960. */
  18961. x: number,
  18962. /**
  18963. * The y component of the control stick
  18964. */
  18965. y: number);
  18966. }
  18967. /**
  18968. * An interface which manages callbacks for gamepad button changes
  18969. */
  18970. export interface GamepadButtonChanges {
  18971. /**
  18972. * Called when a gamepad has been changed
  18973. */
  18974. changed: boolean;
  18975. /**
  18976. * Called when a gamepad press event has been triggered
  18977. */
  18978. pressChanged: boolean;
  18979. /**
  18980. * Called when a touch event has been triggered
  18981. */
  18982. touchChanged: boolean;
  18983. /**
  18984. * Called when a value has changed
  18985. */
  18986. valueChanged: boolean;
  18987. }
  18988. /**
  18989. * Represents a gamepad
  18990. */
  18991. export class Gamepad {
  18992. /**
  18993. * The id of the gamepad
  18994. */
  18995. id: string;
  18996. /**
  18997. * The index of the gamepad
  18998. */
  18999. index: number;
  19000. /**
  19001. * The browser gamepad
  19002. */
  19003. browserGamepad: any;
  19004. /**
  19005. * Specifies what type of gamepad this represents
  19006. */
  19007. type: number;
  19008. private _leftStick;
  19009. private _rightStick;
  19010. /** @hidden */
  19011. _isConnected: boolean;
  19012. private _leftStickAxisX;
  19013. private _leftStickAxisY;
  19014. private _rightStickAxisX;
  19015. private _rightStickAxisY;
  19016. /**
  19017. * Triggered when the left control stick has been changed
  19018. */
  19019. private _onleftstickchanged;
  19020. /**
  19021. * Triggered when the right control stick has been changed
  19022. */
  19023. private _onrightstickchanged;
  19024. /**
  19025. * Represents a gamepad controller
  19026. */
  19027. static GAMEPAD: number;
  19028. /**
  19029. * Represents a generic controller
  19030. */
  19031. static GENERIC: number;
  19032. /**
  19033. * Represents an XBox controller
  19034. */
  19035. static XBOX: number;
  19036. /**
  19037. * Represents a pose-enabled controller
  19038. */
  19039. static POSE_ENABLED: number;
  19040. /**
  19041. * Represents an Dual Shock controller
  19042. */
  19043. static DUALSHOCK: number;
  19044. /**
  19045. * Specifies whether the left control stick should be Y-inverted
  19046. */
  19047. protected _invertLeftStickY: boolean;
  19048. /**
  19049. * Specifies if the gamepad has been connected
  19050. */
  19051. get isConnected(): boolean;
  19052. /**
  19053. * Initializes the gamepad
  19054. * @param id The id of the gamepad
  19055. * @param index The index of the gamepad
  19056. * @param browserGamepad The browser gamepad
  19057. * @param leftStickX The x component of the left joystick
  19058. * @param leftStickY The y component of the left joystick
  19059. * @param rightStickX The x component of the right joystick
  19060. * @param rightStickY The y component of the right joystick
  19061. */
  19062. constructor(
  19063. /**
  19064. * The id of the gamepad
  19065. */
  19066. id: string,
  19067. /**
  19068. * The index of the gamepad
  19069. */
  19070. index: number,
  19071. /**
  19072. * The browser gamepad
  19073. */
  19074. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19075. /**
  19076. * Callback triggered when the left joystick has changed
  19077. * @param callback
  19078. */
  19079. onleftstickchanged(callback: (values: StickValues) => void): void;
  19080. /**
  19081. * Callback triggered when the right joystick has changed
  19082. * @param callback
  19083. */
  19084. onrightstickchanged(callback: (values: StickValues) => void): void;
  19085. /**
  19086. * Gets the left joystick
  19087. */
  19088. get leftStick(): StickValues;
  19089. /**
  19090. * Sets the left joystick values
  19091. */
  19092. set leftStick(newValues: StickValues);
  19093. /**
  19094. * Gets the right joystick
  19095. */
  19096. get rightStick(): StickValues;
  19097. /**
  19098. * Sets the right joystick value
  19099. */
  19100. set rightStick(newValues: StickValues);
  19101. /**
  19102. * Updates the gamepad joystick positions
  19103. */
  19104. update(): void;
  19105. /**
  19106. * Disposes the gamepad
  19107. */
  19108. dispose(): void;
  19109. }
  19110. /**
  19111. * Represents a generic gamepad
  19112. */
  19113. export class GenericPad extends Gamepad {
  19114. private _buttons;
  19115. private _onbuttondown;
  19116. private _onbuttonup;
  19117. /**
  19118. * Observable triggered when a button has been pressed
  19119. */
  19120. onButtonDownObservable: Observable<number>;
  19121. /**
  19122. * Observable triggered when a button has been released
  19123. */
  19124. onButtonUpObservable: Observable<number>;
  19125. /**
  19126. * Callback triggered when a button has been pressed
  19127. * @param callback Called when a button has been pressed
  19128. */
  19129. onbuttondown(callback: (buttonPressed: number) => void): void;
  19130. /**
  19131. * Callback triggered when a button has been released
  19132. * @param callback Called when a button has been released
  19133. */
  19134. onbuttonup(callback: (buttonReleased: number) => void): void;
  19135. /**
  19136. * Initializes the generic gamepad
  19137. * @param id The id of the generic gamepad
  19138. * @param index The index of the generic gamepad
  19139. * @param browserGamepad The browser gamepad
  19140. */
  19141. constructor(id: string, index: number, browserGamepad: any);
  19142. private _setButtonValue;
  19143. /**
  19144. * Updates the generic gamepad
  19145. */
  19146. update(): void;
  19147. /**
  19148. * Disposes the generic gamepad
  19149. */
  19150. dispose(): void;
  19151. }
  19152. }
  19153. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19154. import { Observable } from "babylonjs/Misc/observable";
  19155. import { Nullable } from "babylonjs/types";
  19156. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19157. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19158. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19159. import { Ray } from "babylonjs/Culling/ray";
  19160. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19161. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19162. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19163. /**
  19164. * Defines the types of pose enabled controllers that are supported
  19165. */
  19166. export enum PoseEnabledControllerType {
  19167. /**
  19168. * HTC Vive
  19169. */
  19170. VIVE = 0,
  19171. /**
  19172. * Oculus Rift
  19173. */
  19174. OCULUS = 1,
  19175. /**
  19176. * Windows mixed reality
  19177. */
  19178. WINDOWS = 2,
  19179. /**
  19180. * Samsung gear VR
  19181. */
  19182. GEAR_VR = 3,
  19183. /**
  19184. * Google Daydream
  19185. */
  19186. DAYDREAM = 4,
  19187. /**
  19188. * Generic
  19189. */
  19190. GENERIC = 5
  19191. }
  19192. /**
  19193. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19194. */
  19195. export interface MutableGamepadButton {
  19196. /**
  19197. * Value of the button/trigger
  19198. */
  19199. value: number;
  19200. /**
  19201. * If the button/trigger is currently touched
  19202. */
  19203. touched: boolean;
  19204. /**
  19205. * If the button/trigger is currently pressed
  19206. */
  19207. pressed: boolean;
  19208. }
  19209. /**
  19210. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19211. * @hidden
  19212. */
  19213. export interface ExtendedGamepadButton extends GamepadButton {
  19214. /**
  19215. * If the button/trigger is currently pressed
  19216. */
  19217. readonly pressed: boolean;
  19218. /**
  19219. * If the button/trigger is currently touched
  19220. */
  19221. readonly touched: boolean;
  19222. /**
  19223. * Value of the button/trigger
  19224. */
  19225. readonly value: number;
  19226. }
  19227. /** @hidden */
  19228. export interface _GamePadFactory {
  19229. /**
  19230. * Returns whether or not the current gamepad can be created for this type of controller.
  19231. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19232. * @returns true if it can be created, otherwise false
  19233. */
  19234. canCreate(gamepadInfo: any): boolean;
  19235. /**
  19236. * Creates a new instance of the Gamepad.
  19237. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19238. * @returns the new gamepad instance
  19239. */
  19240. create(gamepadInfo: any): Gamepad;
  19241. }
  19242. /**
  19243. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19244. */
  19245. export class PoseEnabledControllerHelper {
  19246. /** @hidden */
  19247. static _ControllerFactories: _GamePadFactory[];
  19248. /** @hidden */
  19249. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19250. /**
  19251. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19252. * @param vrGamepad the gamepad to initialized
  19253. * @returns a vr controller of the type the gamepad identified as
  19254. */
  19255. static InitiateController(vrGamepad: any): Gamepad;
  19256. }
  19257. /**
  19258. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19259. */
  19260. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19261. /**
  19262. * If the controller is used in a webXR session
  19263. */
  19264. isXR: boolean;
  19265. private _deviceRoomPosition;
  19266. private _deviceRoomRotationQuaternion;
  19267. /**
  19268. * The device position in babylon space
  19269. */
  19270. devicePosition: Vector3;
  19271. /**
  19272. * The device rotation in babylon space
  19273. */
  19274. deviceRotationQuaternion: Quaternion;
  19275. /**
  19276. * The scale factor of the device in babylon space
  19277. */
  19278. deviceScaleFactor: number;
  19279. /**
  19280. * (Likely devicePosition should be used instead) The device position in its room space
  19281. */
  19282. position: Vector3;
  19283. /**
  19284. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19285. */
  19286. rotationQuaternion: Quaternion;
  19287. /**
  19288. * The type of controller (Eg. Windows mixed reality)
  19289. */
  19290. controllerType: PoseEnabledControllerType;
  19291. protected _calculatedPosition: Vector3;
  19292. private _calculatedRotation;
  19293. /**
  19294. * The raw pose from the device
  19295. */
  19296. rawPose: DevicePose;
  19297. private _trackPosition;
  19298. private _maxRotationDistFromHeadset;
  19299. private _draggedRoomRotation;
  19300. /**
  19301. * @hidden
  19302. */
  19303. _disableTrackPosition(fixedPosition: Vector3): void;
  19304. /**
  19305. * Internal, the mesh attached to the controller
  19306. * @hidden
  19307. */
  19308. _mesh: Nullable<AbstractMesh>;
  19309. private _poseControlledCamera;
  19310. private _leftHandSystemQuaternion;
  19311. /**
  19312. * Internal, matrix used to convert room space to babylon space
  19313. * @hidden
  19314. */
  19315. _deviceToWorld: Matrix;
  19316. /**
  19317. * Node to be used when casting a ray from the controller
  19318. * @hidden
  19319. */
  19320. _pointingPoseNode: Nullable<TransformNode>;
  19321. /**
  19322. * Name of the child mesh that can be used to cast a ray from the controller
  19323. */
  19324. static readonly POINTING_POSE: string;
  19325. /**
  19326. * Creates a new PoseEnabledController from a gamepad
  19327. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19328. */
  19329. constructor(browserGamepad: any);
  19330. private _workingMatrix;
  19331. /**
  19332. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19333. */
  19334. update(): void;
  19335. /**
  19336. * Updates only the pose device and mesh without doing any button event checking
  19337. */
  19338. protected _updatePoseAndMesh(): void;
  19339. /**
  19340. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19341. * @param poseData raw pose fromthe device
  19342. */
  19343. updateFromDevice(poseData: DevicePose): void;
  19344. /**
  19345. * @hidden
  19346. */
  19347. _meshAttachedObservable: Observable<AbstractMesh>;
  19348. /**
  19349. * Attaches a mesh to the controller
  19350. * @param mesh the mesh to be attached
  19351. */
  19352. attachToMesh(mesh: AbstractMesh): void;
  19353. /**
  19354. * Attaches the controllers mesh to a camera
  19355. * @param camera the camera the mesh should be attached to
  19356. */
  19357. attachToPoseControlledCamera(camera: TargetCamera): void;
  19358. /**
  19359. * Disposes of the controller
  19360. */
  19361. dispose(): void;
  19362. /**
  19363. * The mesh that is attached to the controller
  19364. */
  19365. get mesh(): Nullable<AbstractMesh>;
  19366. /**
  19367. * Gets the ray of the controller in the direction the controller is pointing
  19368. * @param length the length the resulting ray should be
  19369. * @returns a ray in the direction the controller is pointing
  19370. */
  19371. getForwardRay(length?: number): Ray;
  19372. }
  19373. }
  19374. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  19375. import { Observable } from "babylonjs/Misc/observable";
  19376. import { Scene } from "babylonjs/scene";
  19377. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19378. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  19379. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  19380. import { Nullable } from "babylonjs/types";
  19381. /**
  19382. * Defines the WebVRController object that represents controllers tracked in 3D space
  19383. */
  19384. export abstract class WebVRController extends PoseEnabledController {
  19385. /**
  19386. * Internal, the default controller model for the controller
  19387. */
  19388. protected _defaultModel: Nullable<AbstractMesh>;
  19389. /**
  19390. * Fired when the trigger state has changed
  19391. */
  19392. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19393. /**
  19394. * Fired when the main button state has changed
  19395. */
  19396. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19397. /**
  19398. * Fired when the secondary button state has changed
  19399. */
  19400. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19401. /**
  19402. * Fired when the pad state has changed
  19403. */
  19404. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19405. /**
  19406. * Fired when controllers stick values have changed
  19407. */
  19408. onPadValuesChangedObservable: Observable<StickValues>;
  19409. /**
  19410. * Array of button availible on the controller
  19411. */
  19412. protected _buttons: Array<MutableGamepadButton>;
  19413. private _onButtonStateChange;
  19414. /**
  19415. * Fired when a controller button's state has changed
  19416. * @param callback the callback containing the button that was modified
  19417. */
  19418. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19419. /**
  19420. * X and Y axis corresponding to the controllers joystick
  19421. */
  19422. pad: StickValues;
  19423. /**
  19424. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19425. */
  19426. hand: string;
  19427. /**
  19428. * The default controller model for the controller
  19429. */
  19430. get defaultModel(): Nullable<AbstractMesh>;
  19431. /**
  19432. * Creates a new WebVRController from a gamepad
  19433. * @param vrGamepad the gamepad that the WebVRController should be created from
  19434. */
  19435. constructor(vrGamepad: any);
  19436. /**
  19437. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19438. */
  19439. update(): void;
  19440. /**
  19441. * Function to be called when a button is modified
  19442. */
  19443. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19444. /**
  19445. * Loads a mesh and attaches it to the controller
  19446. * @param scene the scene the mesh should be added to
  19447. * @param meshLoaded callback for when the mesh has been loaded
  19448. */
  19449. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19450. private _setButtonValue;
  19451. private _changes;
  19452. private _checkChanges;
  19453. /**
  19454. * Disposes of th webVRCOntroller
  19455. */
  19456. dispose(): void;
  19457. }
  19458. }
  19459. declare module "babylonjs/Lights/hemisphericLight" {
  19460. import { Nullable } from "babylonjs/types";
  19461. import { Scene } from "babylonjs/scene";
  19462. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19463. import { Color3 } from "babylonjs/Maths/math.color";
  19464. import { Effect } from "babylonjs/Materials/effect";
  19465. import { Light } from "babylonjs/Lights/light";
  19466. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  19467. /**
  19468. * The HemisphericLight simulates the ambient environment light,
  19469. * so the passed direction is the light reflection direction, not the incoming direction.
  19470. */
  19471. export class HemisphericLight extends Light {
  19472. /**
  19473. * The groundColor is the light in the opposite direction to the one specified during creation.
  19474. * 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.
  19475. */
  19476. groundColor: Color3;
  19477. /**
  19478. * The light reflection direction, not the incoming direction.
  19479. */
  19480. direction: Vector3;
  19481. /**
  19482. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19483. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19484. * The HemisphericLight can't cast shadows.
  19485. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19486. * @param name The friendly name of the light
  19487. * @param direction The direction of the light reflection
  19488. * @param scene The scene the light belongs to
  19489. */
  19490. constructor(name: string, direction: Vector3, scene: Scene);
  19491. protected _buildUniformLayout(): void;
  19492. /**
  19493. * Returns the string "HemisphericLight".
  19494. * @return The class name
  19495. */
  19496. getClassName(): string;
  19497. /**
  19498. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19499. * Returns the updated direction.
  19500. * @param target The target the direction should point to
  19501. * @return The computed direction
  19502. */
  19503. setDirectionToTarget(target: Vector3): Vector3;
  19504. /**
  19505. * Returns the shadow generator associated to the light.
  19506. * @returns Always null for hemispheric lights because it does not support shadows.
  19507. */
  19508. getShadowGenerator(): Nullable<IShadowGenerator>;
  19509. /**
  19510. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19511. * @param effect The effect to update
  19512. * @param lightIndex The index of the light in the effect to update
  19513. * @returns The hemispheric light
  19514. */
  19515. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19516. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19517. /**
  19518. * Computes the world matrix of the node
  19519. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19520. * @param useWasUpdatedFlag defines a reserved property
  19521. * @returns the world matrix
  19522. */
  19523. computeWorldMatrix(): Matrix;
  19524. /**
  19525. * Returns the integer 3.
  19526. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19527. */
  19528. getTypeID(): number;
  19529. /**
  19530. * Prepares the list of defines specific to the light type.
  19531. * @param defines the list of defines
  19532. * @param lightIndex defines the index of the light for the effect
  19533. */
  19534. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19535. }
  19536. }
  19537. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  19538. /** @hidden */
  19539. export var vrMultiviewToSingleviewPixelShader: {
  19540. name: string;
  19541. shader: string;
  19542. };
  19543. }
  19544. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  19545. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19546. import { Scene } from "babylonjs/scene";
  19547. /**
  19548. * Renders to multiple views with a single draw call
  19549. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19550. */
  19551. export class MultiviewRenderTarget extends RenderTargetTexture {
  19552. /**
  19553. * Creates a multiview render target
  19554. * @param scene scene used with the render target
  19555. * @param size the size of the render target (used for each view)
  19556. */
  19557. constructor(scene: Scene, size?: number | {
  19558. width: number;
  19559. height: number;
  19560. } | {
  19561. ratio: number;
  19562. });
  19563. /**
  19564. * @hidden
  19565. * @param faceIndex the face index, if its a cube texture
  19566. */
  19567. _bindFrameBuffer(faceIndex?: number): void;
  19568. /**
  19569. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19570. * @returns the view count
  19571. */
  19572. getViewCount(): number;
  19573. }
  19574. }
  19575. declare module "babylonjs/Maths/math.frustum" {
  19576. import { Matrix } from "babylonjs/Maths/math.vector";
  19577. import { DeepImmutable } from "babylonjs/types";
  19578. import { Plane } from "babylonjs/Maths/math.plane";
  19579. /**
  19580. * Represents a camera frustum
  19581. */
  19582. export class Frustum {
  19583. /**
  19584. * Gets the planes representing the frustum
  19585. * @param transform matrix to be applied to the returned planes
  19586. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19587. */
  19588. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19589. /**
  19590. * Gets the near frustum plane transformed by the transform matrix
  19591. * @param transform transformation matrix to be applied to the resulting frustum plane
  19592. * @param frustumPlane the resuling frustum plane
  19593. */
  19594. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19595. /**
  19596. * Gets the far frustum plane transformed by the transform matrix
  19597. * @param transform transformation matrix to be applied to the resulting frustum plane
  19598. * @param frustumPlane the resuling frustum plane
  19599. */
  19600. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19601. /**
  19602. * Gets the left frustum plane transformed by the transform matrix
  19603. * @param transform transformation matrix to be applied to the resulting frustum plane
  19604. * @param frustumPlane the resuling frustum plane
  19605. */
  19606. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19607. /**
  19608. * Gets the right frustum plane transformed by the transform matrix
  19609. * @param transform transformation matrix to be applied to the resulting frustum plane
  19610. * @param frustumPlane the resuling frustum plane
  19611. */
  19612. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19613. /**
  19614. * Gets the top frustum plane transformed by the transform matrix
  19615. * @param transform transformation matrix to be applied to the resulting frustum plane
  19616. * @param frustumPlane the resuling frustum plane
  19617. */
  19618. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19619. /**
  19620. * Gets the bottom frustum plane transformed by the transform matrix
  19621. * @param transform transformation matrix to be applied to the resulting frustum plane
  19622. * @param frustumPlane the resuling frustum plane
  19623. */
  19624. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19625. /**
  19626. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19627. * @param transform transformation matrix to be applied to the resulting frustum planes
  19628. * @param frustumPlanes the resuling frustum planes
  19629. */
  19630. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19631. }
  19632. }
  19633. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  19634. import { Camera } from "babylonjs/Cameras/camera";
  19635. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19636. import { Nullable } from "babylonjs/types";
  19637. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19638. import { Matrix } from "babylonjs/Maths/math.vector";
  19639. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  19640. module "babylonjs/Engines/engine" {
  19641. interface Engine {
  19642. /**
  19643. * Creates a new multiview render target
  19644. * @param width defines the width of the texture
  19645. * @param height defines the height of the texture
  19646. * @returns the created multiview texture
  19647. */
  19648. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19649. /**
  19650. * Binds a multiview framebuffer to be drawn to
  19651. * @param multiviewTexture texture to bind
  19652. */
  19653. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19654. }
  19655. }
  19656. module "babylonjs/Cameras/camera" {
  19657. interface Camera {
  19658. /**
  19659. * @hidden
  19660. * 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)
  19661. */
  19662. _useMultiviewToSingleView: boolean;
  19663. /**
  19664. * @hidden
  19665. * 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)
  19666. */
  19667. _multiviewTexture: Nullable<RenderTargetTexture>;
  19668. /**
  19669. * @hidden
  19670. * ensures the multiview texture of the camera exists and has the specified width/height
  19671. * @param width height to set on the multiview texture
  19672. * @param height width to set on the multiview texture
  19673. */
  19674. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19675. }
  19676. }
  19677. module "babylonjs/scene" {
  19678. interface Scene {
  19679. /** @hidden */
  19680. _transformMatrixR: Matrix;
  19681. /** @hidden */
  19682. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19683. /** @hidden */
  19684. _createMultiviewUbo(): void;
  19685. /** @hidden */
  19686. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19687. /** @hidden */
  19688. _renderMultiviewToSingleView(camera: Camera): void;
  19689. }
  19690. }
  19691. }
  19692. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  19693. import { Camera } from "babylonjs/Cameras/camera";
  19694. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  19695. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  19696. import "babylonjs/Engines/Extensions/engine.multiview";
  19697. /**
  19698. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19699. * This will not be used for webXR as it supports displaying texture arrays directly
  19700. */
  19701. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19702. /**
  19703. * Initializes a VRMultiviewToSingleview
  19704. * @param name name of the post process
  19705. * @param camera camera to be applied to
  19706. * @param scaleFactor scaling factor to the size of the output texture
  19707. */
  19708. constructor(name: string, camera: Camera, scaleFactor: number);
  19709. }
  19710. }
  19711. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  19712. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  19713. import { Nullable } from "babylonjs/types";
  19714. import { Size } from "babylonjs/Maths/math.size";
  19715. import { Observable } from "babylonjs/Misc/observable";
  19716. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  19717. /**
  19718. * Interface used to define additional presentation attributes
  19719. */
  19720. export interface IVRPresentationAttributes {
  19721. /**
  19722. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19723. */
  19724. highRefreshRate: boolean;
  19725. /**
  19726. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19727. */
  19728. foveationLevel: number;
  19729. }
  19730. module "babylonjs/Engines/engine" {
  19731. interface Engine {
  19732. /** @hidden */
  19733. _vrDisplay: any;
  19734. /** @hidden */
  19735. _vrSupported: boolean;
  19736. /** @hidden */
  19737. _oldSize: Size;
  19738. /** @hidden */
  19739. _oldHardwareScaleFactor: number;
  19740. /** @hidden */
  19741. _vrExclusivePointerMode: boolean;
  19742. /** @hidden */
  19743. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19744. /** @hidden */
  19745. _onVRDisplayPointerRestricted: () => void;
  19746. /** @hidden */
  19747. _onVRDisplayPointerUnrestricted: () => void;
  19748. /** @hidden */
  19749. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19750. /** @hidden */
  19751. _onVrDisplayDisconnect: Nullable<() => void>;
  19752. /** @hidden */
  19753. _onVrDisplayPresentChange: Nullable<() => void>;
  19754. /**
  19755. * Observable signaled when VR display mode changes
  19756. */
  19757. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19758. /**
  19759. * Observable signaled when VR request present is complete
  19760. */
  19761. onVRRequestPresentComplete: Observable<boolean>;
  19762. /**
  19763. * Observable signaled when VR request present starts
  19764. */
  19765. onVRRequestPresentStart: Observable<Engine>;
  19766. /**
  19767. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19768. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19769. */
  19770. isInVRExclusivePointerMode: boolean;
  19771. /**
  19772. * Gets a boolean indicating if a webVR device was detected
  19773. * @returns true if a webVR device was detected
  19774. */
  19775. isVRDevicePresent(): boolean;
  19776. /**
  19777. * Gets the current webVR device
  19778. * @returns the current webVR device (or null)
  19779. */
  19780. getVRDevice(): any;
  19781. /**
  19782. * Initializes a webVR display and starts listening to display change events
  19783. * The onVRDisplayChangedObservable will be notified upon these changes
  19784. * @returns A promise containing a VRDisplay and if vr is supported
  19785. */
  19786. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19787. /** @hidden */
  19788. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19789. /**
  19790. * Gets or sets the presentation attributes used to configure VR rendering
  19791. */
  19792. vrPresentationAttributes?: IVRPresentationAttributes;
  19793. /**
  19794. * Call this function to switch to webVR mode
  19795. * Will do nothing if webVR is not supported or if there is no webVR device
  19796. * @param options the webvr options provided to the camera. mainly used for multiview
  19797. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19798. */
  19799. enableVR(options: WebVROptions): void;
  19800. /** @hidden */
  19801. _onVRFullScreenTriggered(): void;
  19802. }
  19803. }
  19804. }
  19805. declare module "babylonjs/Cameras/VR/webVRCamera" {
  19806. import { Nullable } from "babylonjs/types";
  19807. import { Observable } from "babylonjs/Misc/observable";
  19808. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19809. import { Scene } from "babylonjs/scene";
  19810. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19811. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  19812. import { Node } from "babylonjs/node";
  19813. import { Ray } from "babylonjs/Culling/ray";
  19814. import "babylonjs/Cameras/RigModes/webVRRigMode";
  19815. import "babylonjs/Engines/Extensions/engine.webVR";
  19816. /**
  19817. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19818. * IMPORTANT!! The data is right-hand data.
  19819. * @export
  19820. * @interface DevicePose
  19821. */
  19822. export interface DevicePose {
  19823. /**
  19824. * The position of the device, values in array are [x,y,z].
  19825. */
  19826. readonly position: Nullable<Float32Array>;
  19827. /**
  19828. * The linearVelocity of the device, values in array are [x,y,z].
  19829. */
  19830. readonly linearVelocity: Nullable<Float32Array>;
  19831. /**
  19832. * The linearAcceleration of the device, values in array are [x,y,z].
  19833. */
  19834. readonly linearAcceleration: Nullable<Float32Array>;
  19835. /**
  19836. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19837. */
  19838. readonly orientation: Nullable<Float32Array>;
  19839. /**
  19840. * The angularVelocity of the device, values in array are [x,y,z].
  19841. */
  19842. readonly angularVelocity: Nullable<Float32Array>;
  19843. /**
  19844. * The angularAcceleration of the device, values in array are [x,y,z].
  19845. */
  19846. readonly angularAcceleration: Nullable<Float32Array>;
  19847. }
  19848. /**
  19849. * Interface representing a pose controlled object in Babylon.
  19850. * A pose controlled object has both regular pose values as well as pose values
  19851. * from an external device such as a VR head mounted display
  19852. */
  19853. export interface PoseControlled {
  19854. /**
  19855. * The position of the object in babylon space.
  19856. */
  19857. position: Vector3;
  19858. /**
  19859. * The rotation quaternion of the object in babylon space.
  19860. */
  19861. rotationQuaternion: Quaternion;
  19862. /**
  19863. * The position of the device in babylon space.
  19864. */
  19865. devicePosition?: Vector3;
  19866. /**
  19867. * The rotation quaternion of the device in babylon space.
  19868. */
  19869. deviceRotationQuaternion: Quaternion;
  19870. /**
  19871. * The raw pose coming from the device.
  19872. */
  19873. rawPose: Nullable<DevicePose>;
  19874. /**
  19875. * The scale of the device to be used when translating from device space to babylon space.
  19876. */
  19877. deviceScaleFactor: number;
  19878. /**
  19879. * Updates the poseControlled values based on the input device pose.
  19880. * @param poseData the pose data to update the object with
  19881. */
  19882. updateFromDevice(poseData: DevicePose): void;
  19883. }
  19884. /**
  19885. * Set of options to customize the webVRCamera
  19886. */
  19887. export interface WebVROptions {
  19888. /**
  19889. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19890. */
  19891. trackPosition?: boolean;
  19892. /**
  19893. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19894. */
  19895. positionScale?: number;
  19896. /**
  19897. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19898. */
  19899. displayName?: string;
  19900. /**
  19901. * Should the native controller meshes be initialized. (default: true)
  19902. */
  19903. controllerMeshes?: boolean;
  19904. /**
  19905. * Creating a default HemiLight only on controllers. (default: true)
  19906. */
  19907. defaultLightingOnControllers?: boolean;
  19908. /**
  19909. * If you don't want to use the default VR button of the helper. (default: false)
  19910. */
  19911. useCustomVRButton?: boolean;
  19912. /**
  19913. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19914. */
  19915. customVRButton?: HTMLButtonElement;
  19916. /**
  19917. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19918. */
  19919. rayLength?: number;
  19920. /**
  19921. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19922. */
  19923. defaultHeight?: number;
  19924. /**
  19925. * If multiview should be used if availible (default: false)
  19926. */
  19927. useMultiview?: boolean;
  19928. }
  19929. /**
  19930. * This represents a WebVR camera.
  19931. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19932. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19933. */
  19934. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19935. private webVROptions;
  19936. /**
  19937. * @hidden
  19938. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19939. */
  19940. _vrDevice: any;
  19941. /**
  19942. * The rawPose of the vrDevice.
  19943. */
  19944. rawPose: Nullable<DevicePose>;
  19945. private _onVREnabled;
  19946. private _specsVersion;
  19947. private _attached;
  19948. private _frameData;
  19949. protected _descendants: Array<Node>;
  19950. private _deviceRoomPosition;
  19951. /** @hidden */
  19952. _deviceRoomRotationQuaternion: Quaternion;
  19953. private _standingMatrix;
  19954. /**
  19955. * Represents device position in babylon space.
  19956. */
  19957. devicePosition: Vector3;
  19958. /**
  19959. * Represents device rotation in babylon space.
  19960. */
  19961. deviceRotationQuaternion: Quaternion;
  19962. /**
  19963. * The scale of the device to be used when translating from device space to babylon space.
  19964. */
  19965. deviceScaleFactor: number;
  19966. private _deviceToWorld;
  19967. private _worldToDevice;
  19968. /**
  19969. * References to the webVR controllers for the vrDevice.
  19970. */
  19971. controllers: Array<WebVRController>;
  19972. /**
  19973. * Emits an event when a controller is attached.
  19974. */
  19975. onControllersAttachedObservable: Observable<WebVRController[]>;
  19976. /**
  19977. * Emits an event when a controller's mesh has been loaded;
  19978. */
  19979. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19980. /**
  19981. * Emits an event when the HMD's pose has been updated.
  19982. */
  19983. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19984. private _poseSet;
  19985. /**
  19986. * If the rig cameras be used as parent instead of this camera.
  19987. */
  19988. rigParenting: boolean;
  19989. private _lightOnControllers;
  19990. private _defaultHeight?;
  19991. /**
  19992. * Instantiates a WebVRFreeCamera.
  19993. * @param name The name of the WebVRFreeCamera
  19994. * @param position The starting anchor position for the camera
  19995. * @param scene The scene the camera belongs to
  19996. * @param webVROptions a set of customizable options for the webVRCamera
  19997. */
  19998. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19999. /**
  20000. * Gets the device distance from the ground in meters.
  20001. * @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.
  20002. */
  20003. deviceDistanceToRoomGround(): number;
  20004. /**
  20005. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20006. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20007. */
  20008. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20009. /**
  20010. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20011. * @returns A promise with a boolean set to if the standing matrix is supported.
  20012. */
  20013. useStandingMatrixAsync(): Promise<boolean>;
  20014. /**
  20015. * Disposes the camera
  20016. */
  20017. dispose(): void;
  20018. /**
  20019. * Gets a vrController by name.
  20020. * @param name The name of the controller to retreive
  20021. * @returns the controller matching the name specified or null if not found
  20022. */
  20023. getControllerByName(name: string): Nullable<WebVRController>;
  20024. private _leftController;
  20025. /**
  20026. * The controller corresponding to the users left hand.
  20027. */
  20028. get leftController(): Nullable<WebVRController>;
  20029. private _rightController;
  20030. /**
  20031. * The controller corresponding to the users right hand.
  20032. */
  20033. get rightController(): Nullable<WebVRController>;
  20034. /**
  20035. * Casts a ray forward from the vrCamera's gaze.
  20036. * @param length Length of the ray (default: 100)
  20037. * @returns the ray corresponding to the gaze
  20038. */
  20039. getForwardRay(length?: number): Ray;
  20040. /**
  20041. * @hidden
  20042. * Updates the camera based on device's frame data
  20043. */
  20044. _checkInputs(): void;
  20045. /**
  20046. * Updates the poseControlled values based on the input device pose.
  20047. * @param poseData Pose coming from the device
  20048. */
  20049. updateFromDevice(poseData: DevicePose): void;
  20050. private _htmlElementAttached;
  20051. private _detachIfAttached;
  20052. /**
  20053. * WebVR's attach control will start broadcasting frames to the device.
  20054. * Note that in certain browsers (chrome for example) this function must be called
  20055. * within a user-interaction callback. Example:
  20056. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20057. *
  20058. * @param element html element to attach the vrDevice to
  20059. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20060. */
  20061. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20062. /**
  20063. * Detaches the camera from the html element and disables VR
  20064. *
  20065. * @param element html element to detach from
  20066. */
  20067. detachControl(element: HTMLElement): void;
  20068. /**
  20069. * @returns the name of this class
  20070. */
  20071. getClassName(): string;
  20072. /**
  20073. * Calls resetPose on the vrDisplay
  20074. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20075. */
  20076. resetToCurrentRotation(): void;
  20077. /**
  20078. * @hidden
  20079. * Updates the rig cameras (left and right eye)
  20080. */
  20081. _updateRigCameras(): void;
  20082. private _workingVector;
  20083. private _oneVector;
  20084. private _workingMatrix;
  20085. private updateCacheCalled;
  20086. private _correctPositionIfNotTrackPosition;
  20087. /**
  20088. * @hidden
  20089. * Updates the cached values of the camera
  20090. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20091. */
  20092. _updateCache(ignoreParentClass?: boolean): void;
  20093. /**
  20094. * @hidden
  20095. * Get current device position in babylon world
  20096. */
  20097. _computeDevicePosition(): void;
  20098. /**
  20099. * Updates the current device position and rotation in the babylon world
  20100. */
  20101. update(): void;
  20102. /**
  20103. * @hidden
  20104. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20105. * @returns an identity matrix
  20106. */
  20107. _getViewMatrix(): Matrix;
  20108. private _tmpMatrix;
  20109. /**
  20110. * This function is called by the two RIG cameras.
  20111. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20112. * @hidden
  20113. */
  20114. _getWebVRViewMatrix(): Matrix;
  20115. /** @hidden */
  20116. _getWebVRProjectionMatrix(): Matrix;
  20117. private _onGamepadConnectedObserver;
  20118. private _onGamepadDisconnectedObserver;
  20119. private _updateCacheWhenTrackingDisabledObserver;
  20120. /**
  20121. * Initializes the controllers and their meshes
  20122. */
  20123. initControllers(): void;
  20124. }
  20125. }
  20126. declare module "babylonjs/PostProcesses/postProcess" {
  20127. import { Nullable } from "babylonjs/types";
  20128. import { SmartArray } from "babylonjs/Misc/smartArray";
  20129. import { Observable } from "babylonjs/Misc/observable";
  20130. import { Vector2 } from "babylonjs/Maths/math.vector";
  20131. import { Camera } from "babylonjs/Cameras/camera";
  20132. import { Effect } from "babylonjs/Materials/effect";
  20133. import "babylonjs/Shaders/postprocess.vertex";
  20134. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20135. import { Engine } from "babylonjs/Engines/engine";
  20136. import { Color4 } from "babylonjs/Maths/math.color";
  20137. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20138. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20139. /**
  20140. * Size options for a post process
  20141. */
  20142. export type PostProcessOptions = {
  20143. width: number;
  20144. height: number;
  20145. };
  20146. /**
  20147. * PostProcess can be used to apply a shader to a texture after it has been rendered
  20148. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20149. */
  20150. export class PostProcess {
  20151. /** Name of the PostProcess. */
  20152. name: string;
  20153. /**
  20154. * Gets or sets the unique id of the post process
  20155. */
  20156. uniqueId: number;
  20157. /**
  20158. * Width of the texture to apply the post process on
  20159. */
  20160. width: number;
  20161. /**
  20162. * Height of the texture to apply the post process on
  20163. */
  20164. height: number;
  20165. /**
  20166. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  20167. * @hidden
  20168. */
  20169. _outputTexture: Nullable<InternalTexture>;
  20170. /**
  20171. * Sampling mode used by the shader
  20172. * See https://doc.babylonjs.com/classes/3.1/texture
  20173. */
  20174. renderTargetSamplingMode: number;
  20175. /**
  20176. * Clear color to use when screen clearing
  20177. */
  20178. clearColor: Color4;
  20179. /**
  20180. * If the buffer needs to be cleared before applying the post process. (default: true)
  20181. * Should be set to false if shader will overwrite all previous pixels.
  20182. */
  20183. autoClear: boolean;
  20184. /**
  20185. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  20186. */
  20187. alphaMode: number;
  20188. /**
  20189. * Sets the setAlphaBlendConstants of the babylon engine
  20190. */
  20191. alphaConstants: Color4;
  20192. /**
  20193. * Animations to be used for the post processing
  20194. */
  20195. animations: import("babylonjs/Animations/animation").Animation[];
  20196. /**
  20197. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  20198. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  20199. */
  20200. enablePixelPerfectMode: boolean;
  20201. /**
  20202. * Force the postprocess to be applied without taking in account viewport
  20203. */
  20204. forceFullscreenViewport: boolean;
  20205. /**
  20206. * List of inspectable custom properties (used by the Inspector)
  20207. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20208. */
  20209. inspectableCustomProperties: IInspectable[];
  20210. /**
  20211. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  20212. *
  20213. * | Value | Type | Description |
  20214. * | ----- | ----------------------------------- | ----------- |
  20215. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  20216. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  20217. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  20218. *
  20219. */
  20220. scaleMode: number;
  20221. /**
  20222. * Force textures to be a power of two (default: false)
  20223. */
  20224. alwaysForcePOT: boolean;
  20225. private _samples;
  20226. /**
  20227. * Number of sample textures (default: 1)
  20228. */
  20229. get samples(): number;
  20230. set samples(n: number);
  20231. /**
  20232. * Modify the scale of the post process to be the same as the viewport (default: false)
  20233. */
  20234. adaptScaleToCurrentViewport: boolean;
  20235. private _camera;
  20236. private _scene;
  20237. private _engine;
  20238. private _options;
  20239. private _reusable;
  20240. private _textureType;
  20241. private _textureFormat;
  20242. /**
  20243. * Smart array of input and output textures for the post process.
  20244. * @hidden
  20245. */
  20246. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  20247. /**
  20248. * The index in _textures that corresponds to the output texture.
  20249. * @hidden
  20250. */
  20251. _currentRenderTextureInd: number;
  20252. private _effect;
  20253. private _samplers;
  20254. private _fragmentUrl;
  20255. private _vertexUrl;
  20256. private _parameters;
  20257. private _scaleRatio;
  20258. protected _indexParameters: any;
  20259. private _shareOutputWithPostProcess;
  20260. private _texelSize;
  20261. private _forcedOutputTexture;
  20262. /**
  20263. * Returns the fragment url or shader name used in the post process.
  20264. * @returns the fragment url or name in the shader store.
  20265. */
  20266. getEffectName(): string;
  20267. /**
  20268. * An event triggered when the postprocess is activated.
  20269. */
  20270. onActivateObservable: Observable<Camera>;
  20271. private _onActivateObserver;
  20272. /**
  20273. * A function that is added to the onActivateObservable
  20274. */
  20275. set onActivate(callback: Nullable<(camera: Camera) => void>);
  20276. /**
  20277. * An event triggered when the postprocess changes its size.
  20278. */
  20279. onSizeChangedObservable: Observable<PostProcess>;
  20280. private _onSizeChangedObserver;
  20281. /**
  20282. * A function that is added to the onSizeChangedObservable
  20283. */
  20284. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  20285. /**
  20286. * An event triggered when the postprocess applies its effect.
  20287. */
  20288. onApplyObservable: Observable<Effect>;
  20289. private _onApplyObserver;
  20290. /**
  20291. * A function that is added to the onApplyObservable
  20292. */
  20293. set onApply(callback: (effect: Effect) => void);
  20294. /**
  20295. * An event triggered before rendering the postprocess
  20296. */
  20297. onBeforeRenderObservable: Observable<Effect>;
  20298. private _onBeforeRenderObserver;
  20299. /**
  20300. * A function that is added to the onBeforeRenderObservable
  20301. */
  20302. set onBeforeRender(callback: (effect: Effect) => void);
  20303. /**
  20304. * An event triggered after rendering the postprocess
  20305. */
  20306. onAfterRenderObservable: Observable<Effect>;
  20307. private _onAfterRenderObserver;
  20308. /**
  20309. * A function that is added to the onAfterRenderObservable
  20310. */
  20311. set onAfterRender(callback: (efect: Effect) => void);
  20312. /**
  20313. * 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
  20314. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  20315. */
  20316. get inputTexture(): InternalTexture;
  20317. set inputTexture(value: InternalTexture);
  20318. /**
  20319. * Gets the camera which post process is applied to.
  20320. * @returns The camera the post process is applied to.
  20321. */
  20322. getCamera(): Camera;
  20323. /**
  20324. * Gets the texel size of the postprocess.
  20325. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  20326. */
  20327. get texelSize(): Vector2;
  20328. /**
  20329. * Creates a new instance PostProcess
  20330. * @param name The name of the PostProcess.
  20331. * @param fragmentUrl The url of the fragment shader to be used.
  20332. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  20333. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  20334. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20335. * @param camera The camera to apply the render pass to.
  20336. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20337. * @param engine The engine which the post process will be applied. (default: current engine)
  20338. * @param reusable If the post process can be reused on the same frame. (default: false)
  20339. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  20340. * @param textureType Type of textures used when performing the post process. (default: 0)
  20341. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  20342. * @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
  20343. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  20344. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  20345. */
  20346. constructor(
  20347. /** Name of the PostProcess. */
  20348. 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);
  20349. /**
  20350. * Gets a string idenfifying the name of the class
  20351. * @returns "PostProcess" string
  20352. */
  20353. getClassName(): string;
  20354. /**
  20355. * Gets the engine which this post process belongs to.
  20356. * @returns The engine the post process was enabled with.
  20357. */
  20358. getEngine(): Engine;
  20359. /**
  20360. * The effect that is created when initializing the post process.
  20361. * @returns The created effect corresponding the the postprocess.
  20362. */
  20363. getEffect(): Effect;
  20364. /**
  20365. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  20366. * @param postProcess The post process to share the output with.
  20367. * @returns This post process.
  20368. */
  20369. shareOutputWith(postProcess: PostProcess): PostProcess;
  20370. /**
  20371. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  20372. * This should be called if the post process that shares output with this post process is disabled/disposed.
  20373. */
  20374. useOwnOutput(): void;
  20375. /**
  20376. * Updates the effect with the current post process compile time values and recompiles the shader.
  20377. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20378. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20379. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20380. * @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
  20381. * @param onCompiled Called when the shader has been compiled.
  20382. * @param onError Called if there is an error when compiling a shader.
  20383. */
  20384. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20385. /**
  20386. * The post process is reusable if it can be used multiple times within one frame.
  20387. * @returns If the post process is reusable
  20388. */
  20389. isReusable(): boolean;
  20390. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  20391. markTextureDirty(): void;
  20392. /**
  20393. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  20394. * 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.
  20395. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  20396. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  20397. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  20398. * @returns The target texture that was bound to be written to.
  20399. */
  20400. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  20401. /**
  20402. * If the post process is supported.
  20403. */
  20404. get isSupported(): boolean;
  20405. /**
  20406. * The aspect ratio of the output texture.
  20407. */
  20408. get aspectRatio(): number;
  20409. /**
  20410. * Get a value indicating if the post-process is ready to be used
  20411. * @returns true if the post-process is ready (shader is compiled)
  20412. */
  20413. isReady(): boolean;
  20414. /**
  20415. * Binds all textures and uniforms to the shader, this will be run on every pass.
  20416. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  20417. */
  20418. apply(): Nullable<Effect>;
  20419. private _disposeTextures;
  20420. /**
  20421. * Disposes the post process.
  20422. * @param camera The camera to dispose the post process on.
  20423. */
  20424. dispose(camera?: Camera): void;
  20425. }
  20426. }
  20427. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  20428. /** @hidden */
  20429. export var kernelBlurVaryingDeclaration: {
  20430. name: string;
  20431. shader: string;
  20432. };
  20433. }
  20434. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  20435. /** @hidden */
  20436. export var kernelBlurFragment: {
  20437. name: string;
  20438. shader: string;
  20439. };
  20440. }
  20441. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  20442. /** @hidden */
  20443. export var kernelBlurFragment2: {
  20444. name: string;
  20445. shader: string;
  20446. };
  20447. }
  20448. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  20449. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20450. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  20451. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  20452. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  20453. /** @hidden */
  20454. export var kernelBlurPixelShader: {
  20455. name: string;
  20456. shader: string;
  20457. };
  20458. }
  20459. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  20460. /** @hidden */
  20461. export var kernelBlurVertex: {
  20462. name: string;
  20463. shader: string;
  20464. };
  20465. }
  20466. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  20467. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20468. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  20469. /** @hidden */
  20470. export var kernelBlurVertexShader: {
  20471. name: string;
  20472. shader: string;
  20473. };
  20474. }
  20475. declare module "babylonjs/PostProcesses/blurPostProcess" {
  20476. import { Vector2 } from "babylonjs/Maths/math.vector";
  20477. import { Nullable } from "babylonjs/types";
  20478. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  20479. import { Camera } from "babylonjs/Cameras/camera";
  20480. import { Effect } from "babylonjs/Materials/effect";
  20481. import { Engine } from "babylonjs/Engines/engine";
  20482. import "babylonjs/Shaders/kernelBlur.fragment";
  20483. import "babylonjs/Shaders/kernelBlur.vertex";
  20484. /**
  20485. * The Blur Post Process which blurs an image based on a kernel and direction.
  20486. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  20487. */
  20488. export class BlurPostProcess extends PostProcess {
  20489. /** The direction in which to blur the image. */
  20490. direction: Vector2;
  20491. private blockCompilation;
  20492. protected _kernel: number;
  20493. protected _idealKernel: number;
  20494. protected _packedFloat: boolean;
  20495. private _staticDefines;
  20496. /**
  20497. * Sets the length in pixels of the blur sample region
  20498. */
  20499. set kernel(v: number);
  20500. /**
  20501. * Gets the length in pixels of the blur sample region
  20502. */
  20503. get kernel(): number;
  20504. /**
  20505. * Sets wether or not the blur needs to unpack/repack floats
  20506. */
  20507. set packedFloat(v: boolean);
  20508. /**
  20509. * Gets wether or not the blur is unpacking/repacking floats
  20510. */
  20511. get packedFloat(): boolean;
  20512. /**
  20513. * Creates a new instance BlurPostProcess
  20514. * @param name The name of the effect.
  20515. * @param direction The direction in which to blur the image.
  20516. * @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.
  20517. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20518. * @param camera The camera to apply the render pass to.
  20519. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20520. * @param engine The engine which the post process will be applied. (default: current engine)
  20521. * @param reusable If the post process can be reused on the same frame. (default: false)
  20522. * @param textureType Type of textures used when performing the post process. (default: 0)
  20523. * @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)
  20524. */
  20525. constructor(name: string,
  20526. /** The direction in which to blur the image. */
  20527. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  20528. /**
  20529. * Updates the effect with the current post process compile time values and recompiles the shader.
  20530. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20531. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20532. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20533. * @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
  20534. * @param onCompiled Called when the shader has been compiled.
  20535. * @param onError Called if there is an error when compiling a shader.
  20536. */
  20537. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20538. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20539. /**
  20540. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20541. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20542. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20543. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20544. * The gaps between physical kernels are compensated for in the weighting of the samples
  20545. * @param idealKernel Ideal blur kernel.
  20546. * @return Nearest best kernel.
  20547. */
  20548. protected _nearestBestKernel(idealKernel: number): number;
  20549. /**
  20550. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20551. * @param x The point on the Gaussian distribution to sample.
  20552. * @return the value of the Gaussian function at x.
  20553. */
  20554. protected _gaussianWeight(x: number): number;
  20555. /**
  20556. * Generates a string that can be used as a floating point number in GLSL.
  20557. * @param x Value to print.
  20558. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20559. * @return GLSL float string.
  20560. */
  20561. protected _glslFloat(x: number, decimalFigures?: number): string;
  20562. }
  20563. }
  20564. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  20565. import { Scene } from "babylonjs/scene";
  20566. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20567. import { Plane } from "babylonjs/Maths/math.plane";
  20568. /**
  20569. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20570. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20571. * You can then easily use it as a reflectionTexture on a flat surface.
  20572. * In case the surface is not a plane, please consider relying on reflection probes.
  20573. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20574. */
  20575. export class MirrorTexture extends RenderTargetTexture {
  20576. private scene;
  20577. /**
  20578. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20579. * 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.
  20580. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20581. */
  20582. mirrorPlane: Plane;
  20583. /**
  20584. * Define the blur ratio used to blur the reflection if needed.
  20585. */
  20586. set blurRatio(value: number);
  20587. get blurRatio(): number;
  20588. /**
  20589. * Define the adaptive blur kernel used to blur the reflection if needed.
  20590. * This will autocompute the closest best match for the `blurKernel`
  20591. */
  20592. set adaptiveBlurKernel(value: number);
  20593. /**
  20594. * Define the blur kernel used to blur the reflection if needed.
  20595. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20596. */
  20597. set blurKernel(value: number);
  20598. /**
  20599. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20600. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20601. */
  20602. set blurKernelX(value: number);
  20603. get blurKernelX(): number;
  20604. /**
  20605. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20606. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20607. */
  20608. set blurKernelY(value: number);
  20609. get blurKernelY(): number;
  20610. private _autoComputeBlurKernel;
  20611. protected _onRatioRescale(): void;
  20612. private _updateGammaSpace;
  20613. private _imageProcessingConfigChangeObserver;
  20614. private _transformMatrix;
  20615. private _mirrorMatrix;
  20616. private _savedViewMatrix;
  20617. private _blurX;
  20618. private _blurY;
  20619. private _adaptiveBlurKernel;
  20620. private _blurKernelX;
  20621. private _blurKernelY;
  20622. private _blurRatio;
  20623. /**
  20624. * Instantiates a Mirror Texture.
  20625. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20626. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20627. * You can then easily use it as a reflectionTexture on a flat surface.
  20628. * In case the surface is not a plane, please consider relying on reflection probes.
  20629. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20630. * @param name
  20631. * @param size
  20632. * @param scene
  20633. * @param generateMipMaps
  20634. * @param type
  20635. * @param samplingMode
  20636. * @param generateDepthBuffer
  20637. */
  20638. constructor(name: string, size: number | {
  20639. width: number;
  20640. height: number;
  20641. } | {
  20642. ratio: number;
  20643. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20644. private _preparePostProcesses;
  20645. /**
  20646. * Clone the mirror texture.
  20647. * @returns the cloned texture
  20648. */
  20649. clone(): MirrorTexture;
  20650. /**
  20651. * Serialize the texture to a JSON representation you could use in Parse later on
  20652. * @returns the serialized JSON representation
  20653. */
  20654. serialize(): any;
  20655. /**
  20656. * Dispose the texture and release its associated resources.
  20657. */
  20658. dispose(): void;
  20659. }
  20660. }
  20661. declare module "babylonjs/Materials/Textures/texture" {
  20662. import { Observable } from "babylonjs/Misc/observable";
  20663. import { Nullable } from "babylonjs/types";
  20664. import { Matrix } from "babylonjs/Maths/math.vector";
  20665. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20666. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20667. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  20668. import { Scene } from "babylonjs/scene";
  20669. /**
  20670. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20671. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20672. */
  20673. export class Texture extends BaseTexture {
  20674. /**
  20675. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20676. */
  20677. static SerializeBuffers: boolean;
  20678. /** @hidden */
  20679. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  20680. /** @hidden */
  20681. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  20682. /** @hidden */
  20683. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  20684. /** nearest is mag = nearest and min = nearest and mip = linear */
  20685. static readonly NEAREST_SAMPLINGMODE: number;
  20686. /** nearest is mag = nearest and min = nearest and mip = linear */
  20687. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20688. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20689. static readonly BILINEAR_SAMPLINGMODE: number;
  20690. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20691. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20692. /** Trilinear is mag = linear and min = linear and mip = linear */
  20693. static readonly TRILINEAR_SAMPLINGMODE: number;
  20694. /** Trilinear is mag = linear and min = linear and mip = linear */
  20695. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20696. /** mag = nearest and min = nearest and mip = nearest */
  20697. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20698. /** mag = nearest and min = linear and mip = nearest */
  20699. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20700. /** mag = nearest and min = linear and mip = linear */
  20701. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20702. /** mag = nearest and min = linear and mip = none */
  20703. static readonly NEAREST_LINEAR: number;
  20704. /** mag = nearest and min = nearest and mip = none */
  20705. static readonly NEAREST_NEAREST: number;
  20706. /** mag = linear and min = nearest and mip = nearest */
  20707. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20708. /** mag = linear and min = nearest and mip = linear */
  20709. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20710. /** mag = linear and min = linear and mip = none */
  20711. static readonly LINEAR_LINEAR: number;
  20712. /** mag = linear and min = nearest and mip = none */
  20713. static readonly LINEAR_NEAREST: number;
  20714. /** Explicit coordinates mode */
  20715. static readonly EXPLICIT_MODE: number;
  20716. /** Spherical coordinates mode */
  20717. static readonly SPHERICAL_MODE: number;
  20718. /** Planar coordinates mode */
  20719. static readonly PLANAR_MODE: number;
  20720. /** Cubic coordinates mode */
  20721. static readonly CUBIC_MODE: number;
  20722. /** Projection coordinates mode */
  20723. static readonly PROJECTION_MODE: number;
  20724. /** Inverse Cubic coordinates mode */
  20725. static readonly SKYBOX_MODE: number;
  20726. /** Inverse Cubic coordinates mode */
  20727. static readonly INVCUBIC_MODE: number;
  20728. /** Equirectangular coordinates mode */
  20729. static readonly EQUIRECTANGULAR_MODE: number;
  20730. /** Equirectangular Fixed coordinates mode */
  20731. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20732. /** Equirectangular Fixed Mirrored coordinates mode */
  20733. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20734. /** Texture is not repeating outside of 0..1 UVs */
  20735. static readonly CLAMP_ADDRESSMODE: number;
  20736. /** Texture is repeating outside of 0..1 UVs */
  20737. static readonly WRAP_ADDRESSMODE: number;
  20738. /** Texture is repeating and mirrored */
  20739. static readonly MIRROR_ADDRESSMODE: number;
  20740. /**
  20741. * 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
  20742. */
  20743. static UseSerializedUrlIfAny: boolean;
  20744. /**
  20745. * Define the url of the texture.
  20746. */
  20747. url: Nullable<string>;
  20748. /**
  20749. * Define an offset on the texture to offset the u coordinates of the UVs
  20750. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20751. */
  20752. uOffset: number;
  20753. /**
  20754. * Define an offset on the texture to offset the v coordinates of the UVs
  20755. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20756. */
  20757. vOffset: number;
  20758. /**
  20759. * Define an offset on the texture to scale the u coordinates of the UVs
  20760. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20761. */
  20762. uScale: number;
  20763. /**
  20764. * Define an offset on the texture to scale the v coordinates of the UVs
  20765. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20766. */
  20767. vScale: number;
  20768. /**
  20769. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20770. * @see http://doc.babylonjs.com/how_to/more_materials
  20771. */
  20772. uAng: number;
  20773. /**
  20774. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20775. * @see http://doc.babylonjs.com/how_to/more_materials
  20776. */
  20777. vAng: number;
  20778. /**
  20779. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20780. * @see http://doc.babylonjs.com/how_to/more_materials
  20781. */
  20782. wAng: number;
  20783. /**
  20784. * Defines the center of rotation (U)
  20785. */
  20786. uRotationCenter: number;
  20787. /**
  20788. * Defines the center of rotation (V)
  20789. */
  20790. vRotationCenter: number;
  20791. /**
  20792. * Defines the center of rotation (W)
  20793. */
  20794. wRotationCenter: number;
  20795. /**
  20796. * Are mip maps generated for this texture or not.
  20797. */
  20798. get noMipmap(): boolean;
  20799. /**
  20800. * List of inspectable custom properties (used by the Inspector)
  20801. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20802. */
  20803. inspectableCustomProperties: Nullable<IInspectable[]>;
  20804. private _noMipmap;
  20805. /** @hidden */
  20806. _invertY: boolean;
  20807. private _rowGenerationMatrix;
  20808. private _cachedTextureMatrix;
  20809. private _projectionModeMatrix;
  20810. private _t0;
  20811. private _t1;
  20812. private _t2;
  20813. private _cachedUOffset;
  20814. private _cachedVOffset;
  20815. private _cachedUScale;
  20816. private _cachedVScale;
  20817. private _cachedUAng;
  20818. private _cachedVAng;
  20819. private _cachedWAng;
  20820. private _cachedProjectionMatrixId;
  20821. private _cachedCoordinatesMode;
  20822. /** @hidden */
  20823. protected _initialSamplingMode: number;
  20824. /** @hidden */
  20825. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  20826. private _deleteBuffer;
  20827. protected _format: Nullable<number>;
  20828. private _delayedOnLoad;
  20829. private _delayedOnError;
  20830. private _mimeType?;
  20831. /**
  20832. * Observable triggered once the texture has been loaded.
  20833. */
  20834. onLoadObservable: Observable<Texture>;
  20835. protected _isBlocking: boolean;
  20836. /**
  20837. * Is the texture preventing material to render while loading.
  20838. * If false, a default texture will be used instead of the loading one during the preparation step.
  20839. */
  20840. set isBlocking(value: boolean);
  20841. get isBlocking(): boolean;
  20842. /**
  20843. * Get the current sampling mode associated with the texture.
  20844. */
  20845. get samplingMode(): number;
  20846. /**
  20847. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  20848. */
  20849. get invertY(): boolean;
  20850. /**
  20851. * Instantiates a new texture.
  20852. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20853. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20854. * @param url defines the url of the picture to load as a texture
  20855. * @param scene defines the scene or engine the texture will belong to
  20856. * @param noMipmap defines if the texture will require mip maps or not
  20857. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  20858. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20859. * @param onLoad defines a callback triggered when the texture has been loaded
  20860. * @param onError defines a callback triggered when an error occurred during the loading session
  20861. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  20862. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  20863. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20864. * @param mimeType defines an optional mime type information
  20865. */
  20866. 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);
  20867. /**
  20868. * Update the url (and optional buffer) of this texture if url was null during construction.
  20869. * @param url the url of the texture
  20870. * @param buffer the buffer of the texture (defaults to null)
  20871. * @param onLoad callback called when the texture is loaded (defaults to null)
  20872. */
  20873. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  20874. /**
  20875. * Finish the loading sequence of a texture flagged as delayed load.
  20876. * @hidden
  20877. */
  20878. delayLoad(): void;
  20879. private _prepareRowForTextureGeneration;
  20880. /**
  20881. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  20882. * @returns the transform matrix of the texture.
  20883. */
  20884. getTextureMatrix(uBase?: number): Matrix;
  20885. /**
  20886. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  20887. * @returns The reflection texture transform
  20888. */
  20889. getReflectionTextureMatrix(): Matrix;
  20890. /**
  20891. * Clones the texture.
  20892. * @returns the cloned texture
  20893. */
  20894. clone(): Texture;
  20895. /**
  20896. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20897. * @returns The JSON representation of the texture
  20898. */
  20899. serialize(): any;
  20900. /**
  20901. * Get the current class name of the texture useful for serialization or dynamic coding.
  20902. * @returns "Texture"
  20903. */
  20904. getClassName(): string;
  20905. /**
  20906. * Dispose the texture and release its associated resources.
  20907. */
  20908. dispose(): void;
  20909. /**
  20910. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  20911. * @param parsedTexture Define the JSON representation of the texture
  20912. * @param scene Define the scene the parsed texture should be instantiated in
  20913. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  20914. * @returns The parsed texture if successful
  20915. */
  20916. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  20917. /**
  20918. * Creates a texture from its base 64 representation.
  20919. * @param data Define the base64 payload without the data: prefix
  20920. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20921. * @param scene Define the scene the texture should belong to
  20922. * @param noMipmap Forces the texture to not create mip map information if true
  20923. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20924. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20925. * @param onLoad define a callback triggered when the texture has been loaded
  20926. * @param onError define a callback triggered when an error occurred during the loading session
  20927. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20928. * @returns the created texture
  20929. */
  20930. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  20931. /**
  20932. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  20933. * @param data Define the base64 payload without the data: prefix
  20934. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20935. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  20936. * @param scene Define the scene the texture should belong to
  20937. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  20938. * @param noMipmap Forces the texture to not create mip map information if true
  20939. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20940. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20941. * @param onLoad define a callback triggered when the texture has been loaded
  20942. * @param onError define a callback triggered when an error occurred during the loading session
  20943. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20944. * @returns the created texture
  20945. */
  20946. 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;
  20947. }
  20948. }
  20949. declare module "babylonjs/PostProcesses/postProcessManager" {
  20950. import { Nullable } from "babylonjs/types";
  20951. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20952. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20953. import { Scene } from "babylonjs/scene";
  20954. /**
  20955. * PostProcessManager is used to manage one or more post processes or post process pipelines
  20956. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20957. */
  20958. export class PostProcessManager {
  20959. private _scene;
  20960. private _indexBuffer;
  20961. private _vertexBuffers;
  20962. /**
  20963. * Creates a new instance PostProcess
  20964. * @param scene The scene that the post process is associated with.
  20965. */
  20966. constructor(scene: Scene);
  20967. private _prepareBuffers;
  20968. private _buildIndexBuffer;
  20969. /**
  20970. * Rebuilds the vertex buffers of the manager.
  20971. * @hidden
  20972. */
  20973. _rebuild(): void;
  20974. /**
  20975. * Prepares a frame to be run through a post process.
  20976. * @param sourceTexture The input texture to the post procesess. (default: null)
  20977. * @param postProcesses An array of post processes to be run. (default: null)
  20978. * @returns True if the post processes were able to be run.
  20979. * @hidden
  20980. */
  20981. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  20982. /**
  20983. * Manually render a set of post processes to a texture.
  20984. * @param postProcesses An array of post processes to be run.
  20985. * @param targetTexture The target texture to render to.
  20986. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  20987. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  20988. * @param lodLevel defines which lod of the texture to render to
  20989. */
  20990. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  20991. /**
  20992. * Finalize the result of the output of the postprocesses.
  20993. * @param doNotPresent If true the result will not be displayed to the screen.
  20994. * @param targetTexture The target texture to render to.
  20995. * @param faceIndex The index of the face to bind the target texture to.
  20996. * @param postProcesses The array of post processes to render.
  20997. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  20998. * @hidden
  20999. */
  21000. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  21001. /**
  21002. * Disposes of the post process manager.
  21003. */
  21004. dispose(): void;
  21005. }
  21006. }
  21007. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  21008. import { Observable } from "babylonjs/Misc/observable";
  21009. import { SmartArray } from "babylonjs/Misc/smartArray";
  21010. import { Nullable, Immutable } from "babylonjs/types";
  21011. import { Camera } from "babylonjs/Cameras/camera";
  21012. import { Scene } from "babylonjs/scene";
  21013. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21014. import { Color4 } from "babylonjs/Maths/math.color";
  21015. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  21016. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21017. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21018. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  21019. import { Texture } from "babylonjs/Materials/Textures/texture";
  21020. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  21021. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  21022. import "babylonjs/Engines/Extensions/engine.renderTarget";
  21023. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  21024. import { Engine } from "babylonjs/Engines/engine";
  21025. /**
  21026. * This Helps creating a texture that will be created from a camera in your scene.
  21027. * It is basically a dynamic texture that could be used to create special effects for instance.
  21028. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  21029. */
  21030. export class RenderTargetTexture extends Texture {
  21031. isCube: boolean;
  21032. /**
  21033. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  21034. */
  21035. static readonly REFRESHRATE_RENDER_ONCE: number;
  21036. /**
  21037. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  21038. */
  21039. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  21040. /**
  21041. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  21042. * the central point of your effect and can save a lot of performances.
  21043. */
  21044. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  21045. /**
  21046. * Use this predicate to dynamically define the list of mesh you want to render.
  21047. * If set, the renderList property will be overwritten.
  21048. */
  21049. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  21050. private _renderList;
  21051. /**
  21052. * Use this list to define the list of mesh you want to render.
  21053. */
  21054. get renderList(): Nullable<Array<AbstractMesh>>;
  21055. set renderList(value: Nullable<Array<AbstractMesh>>);
  21056. /**
  21057. * Use this function to overload the renderList array at rendering time.
  21058. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  21059. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  21060. * the cube (if the RTT is a cube, else layerOrFace=0).
  21061. * The renderList passed to the function is the current render list (the one that will be used if the function returns null)
  21062. */
  21063. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>) => Nullable<Array<AbstractMesh>>;
  21064. private _hookArray;
  21065. /**
  21066. * Define if particles should be rendered in your texture.
  21067. */
  21068. renderParticles: boolean;
  21069. /**
  21070. * Define if sprites should be rendered in your texture.
  21071. */
  21072. renderSprites: boolean;
  21073. /**
  21074. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  21075. */
  21076. coordinatesMode: number;
  21077. /**
  21078. * Define the camera used to render the texture.
  21079. */
  21080. activeCamera: Nullable<Camera>;
  21081. /**
  21082. * Override the render function of the texture with your own one.
  21083. */
  21084. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  21085. /**
  21086. * Define if camera post processes should be use while rendering the texture.
  21087. */
  21088. useCameraPostProcesses: boolean;
  21089. /**
  21090. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  21091. */
  21092. ignoreCameraViewport: boolean;
  21093. private _postProcessManager;
  21094. private _postProcesses;
  21095. private _resizeObserver;
  21096. /**
  21097. * An event triggered when the texture is unbind.
  21098. */
  21099. onBeforeBindObservable: Observable<RenderTargetTexture>;
  21100. /**
  21101. * An event triggered when the texture is unbind.
  21102. */
  21103. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  21104. private _onAfterUnbindObserver;
  21105. /**
  21106. * Set a after unbind callback in the texture.
  21107. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  21108. */
  21109. set onAfterUnbind(callback: () => void);
  21110. /**
  21111. * An event triggered before rendering the texture
  21112. */
  21113. onBeforeRenderObservable: Observable<number>;
  21114. private _onBeforeRenderObserver;
  21115. /**
  21116. * Set a before render callback in the texture.
  21117. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  21118. */
  21119. set onBeforeRender(callback: (faceIndex: number) => void);
  21120. /**
  21121. * An event triggered after rendering the texture
  21122. */
  21123. onAfterRenderObservable: Observable<number>;
  21124. private _onAfterRenderObserver;
  21125. /**
  21126. * Set a after render callback in the texture.
  21127. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  21128. */
  21129. set onAfterRender(callback: (faceIndex: number) => void);
  21130. /**
  21131. * An event triggered after the texture clear
  21132. */
  21133. onClearObservable: Observable<Engine>;
  21134. private _onClearObserver;
  21135. /**
  21136. * Set a clear callback in the texture.
  21137. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  21138. */
  21139. set onClear(callback: (Engine: Engine) => void);
  21140. /**
  21141. * An event triggered when the texture is resized.
  21142. */
  21143. onResizeObservable: Observable<RenderTargetTexture>;
  21144. /**
  21145. * Define the clear color of the Render Target if it should be different from the scene.
  21146. */
  21147. clearColor: Color4;
  21148. protected _size: number | {
  21149. width: number;
  21150. height: number;
  21151. layers?: number;
  21152. };
  21153. protected _initialSizeParameter: number | {
  21154. width: number;
  21155. height: number;
  21156. } | {
  21157. ratio: number;
  21158. };
  21159. protected _sizeRatio: Nullable<number>;
  21160. /** @hidden */
  21161. _generateMipMaps: boolean;
  21162. protected _renderingManager: RenderingManager;
  21163. /** @hidden */
  21164. _waitingRenderList: string[];
  21165. protected _doNotChangeAspectRatio: boolean;
  21166. protected _currentRefreshId: number;
  21167. protected _refreshRate: number;
  21168. protected _textureMatrix: Matrix;
  21169. protected _samples: number;
  21170. protected _renderTargetOptions: RenderTargetCreationOptions;
  21171. /**
  21172. * Gets render target creation options that were used.
  21173. */
  21174. get renderTargetOptions(): RenderTargetCreationOptions;
  21175. protected _engine: Engine;
  21176. protected _onRatioRescale(): void;
  21177. /**
  21178. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  21179. * It must define where the camera used to render the texture is set
  21180. */
  21181. boundingBoxPosition: Vector3;
  21182. private _boundingBoxSize;
  21183. /**
  21184. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  21185. * When defined, the cubemap will switch to local mode
  21186. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  21187. * @example https://www.babylonjs-playground.com/#RNASML
  21188. */
  21189. set boundingBoxSize(value: Vector3);
  21190. get boundingBoxSize(): Vector3;
  21191. /**
  21192. * In case the RTT has been created with a depth texture, get the associated
  21193. * depth texture.
  21194. * Otherwise, return null.
  21195. */
  21196. get depthStencilTexture(): Nullable<InternalTexture>;
  21197. /**
  21198. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  21199. * or used a shadow, depth texture...
  21200. * @param name The friendly name of the texture
  21201. * @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)
  21202. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  21203. * @param generateMipMaps True if mip maps need to be generated after render.
  21204. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  21205. * @param type The type of the buffer in the RTT (int, half float, float...)
  21206. * @param isCube True if a cube texture needs to be created
  21207. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  21208. * @param generateDepthBuffer True to generate a depth buffer
  21209. * @param generateStencilBuffer True to generate a stencil buffer
  21210. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  21211. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  21212. * @param delayAllocation if the texture allocation should be delayed (default: false)
  21213. */
  21214. constructor(name: string, size: number | {
  21215. width: number;
  21216. height: number;
  21217. layers?: number;
  21218. } | {
  21219. ratio: number;
  21220. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  21221. /**
  21222. * Creates a depth stencil texture.
  21223. * This is only available in WebGL 2 or with the depth texture extension available.
  21224. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  21225. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  21226. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  21227. */
  21228. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  21229. private _processSizeParameter;
  21230. /**
  21231. * Define the number of samples to use in case of MSAA.
  21232. * It defaults to one meaning no MSAA has been enabled.
  21233. */
  21234. get samples(): number;
  21235. set samples(value: number);
  21236. /**
  21237. * Resets the refresh counter of the texture and start bak from scratch.
  21238. * Could be useful to regenerate the texture if it is setup to render only once.
  21239. */
  21240. resetRefreshCounter(): void;
  21241. /**
  21242. * Define the refresh rate of the texture or the rendering frequency.
  21243. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  21244. */
  21245. get refreshRate(): number;
  21246. set refreshRate(value: number);
  21247. /**
  21248. * Adds a post process to the render target rendering passes.
  21249. * @param postProcess define the post process to add
  21250. */
  21251. addPostProcess(postProcess: PostProcess): void;
  21252. /**
  21253. * Clear all the post processes attached to the render target
  21254. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  21255. */
  21256. clearPostProcesses(dispose?: boolean): void;
  21257. /**
  21258. * Remove one of the post process from the list of attached post processes to the texture
  21259. * @param postProcess define the post process to remove from the list
  21260. */
  21261. removePostProcess(postProcess: PostProcess): void;
  21262. /** @hidden */
  21263. _shouldRender(): boolean;
  21264. /**
  21265. * Gets the actual render size of the texture.
  21266. * @returns the width of the render size
  21267. */
  21268. getRenderSize(): number;
  21269. /**
  21270. * Gets the actual render width of the texture.
  21271. * @returns the width of the render size
  21272. */
  21273. getRenderWidth(): number;
  21274. /**
  21275. * Gets the actual render height of the texture.
  21276. * @returns the height of the render size
  21277. */
  21278. getRenderHeight(): number;
  21279. /**
  21280. * Gets the actual number of layers of the texture.
  21281. * @returns the number of layers
  21282. */
  21283. getRenderLayers(): number;
  21284. /**
  21285. * Get if the texture can be rescaled or not.
  21286. */
  21287. get canRescale(): boolean;
  21288. /**
  21289. * Resize the texture using a ratio.
  21290. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  21291. */
  21292. scale(ratio: number): void;
  21293. /**
  21294. * Get the texture reflection matrix used to rotate/transform the reflection.
  21295. * @returns the reflection matrix
  21296. */
  21297. getReflectionTextureMatrix(): Matrix;
  21298. /**
  21299. * Resize the texture to a new desired size.
  21300. * Be carrefull as it will recreate all the data in the new texture.
  21301. * @param size Define the new size. It can be:
  21302. * - a number for squared texture,
  21303. * - an object containing { width: number, height: number }
  21304. * - or an object containing a ratio { ratio: number }
  21305. */
  21306. resize(size: number | {
  21307. width: number;
  21308. height: number;
  21309. } | {
  21310. ratio: number;
  21311. }): void;
  21312. private _defaultRenderListPrepared;
  21313. /**
  21314. * Renders all the objects from the render list into the texture.
  21315. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  21316. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  21317. */
  21318. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  21319. private _bestReflectionRenderTargetDimension;
  21320. private _prepareRenderingManager;
  21321. /**
  21322. * @hidden
  21323. * @param faceIndex face index to bind to if this is a cubetexture
  21324. * @param layer defines the index of the texture to bind in the array
  21325. */
  21326. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  21327. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  21328. private renderToTarget;
  21329. /**
  21330. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21331. * This allowed control for front to back rendering or reversly depending of the special needs.
  21332. *
  21333. * @param renderingGroupId The rendering group id corresponding to its index
  21334. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21335. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21336. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21337. */
  21338. 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;
  21339. /**
  21340. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21341. *
  21342. * @param renderingGroupId The rendering group id corresponding to its index
  21343. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21344. */
  21345. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  21346. /**
  21347. * Clones the texture.
  21348. * @returns the cloned texture
  21349. */
  21350. clone(): RenderTargetTexture;
  21351. /**
  21352. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21353. * @returns The JSON representation of the texture
  21354. */
  21355. serialize(): any;
  21356. /**
  21357. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21358. */
  21359. disposeFramebufferObjects(): void;
  21360. /**
  21361. * Dispose the texture and release its associated resources.
  21362. */
  21363. dispose(): void;
  21364. /** @hidden */
  21365. _rebuild(): void;
  21366. /**
  21367. * Clear the info related to rendering groups preventing retention point in material dispose.
  21368. */
  21369. freeRenderingGroups(): void;
  21370. /**
  21371. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21372. * @returns the view count
  21373. */
  21374. getViewCount(): number;
  21375. }
  21376. }
  21377. declare module "babylonjs/Materials/material" {
  21378. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21379. import { SmartArray } from "babylonjs/Misc/smartArray";
  21380. import { Observable } from "babylonjs/Misc/observable";
  21381. import { Nullable } from "babylonjs/types";
  21382. import { Scene } from "babylonjs/scene";
  21383. import { Matrix } from "babylonjs/Maths/math.vector";
  21384. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21385. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21386. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21387. import { Effect } from "babylonjs/Materials/effect";
  21388. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21389. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21390. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21391. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21392. import { Mesh } from "babylonjs/Meshes/mesh";
  21393. import { Animation } from "babylonjs/Animations/animation";
  21394. /**
  21395. * Options for compiling materials.
  21396. */
  21397. export interface IMaterialCompilationOptions {
  21398. /**
  21399. * Defines whether clip planes are enabled.
  21400. */
  21401. clipPlane: boolean;
  21402. /**
  21403. * Defines whether instances are enabled.
  21404. */
  21405. useInstances: boolean;
  21406. }
  21407. /**
  21408. * Base class for the main features of a material in Babylon.js
  21409. */
  21410. export class Material implements IAnimatable {
  21411. /**
  21412. * Returns the triangle fill mode
  21413. */
  21414. static readonly TriangleFillMode: number;
  21415. /**
  21416. * Returns the wireframe mode
  21417. */
  21418. static readonly WireFrameFillMode: number;
  21419. /**
  21420. * Returns the point fill mode
  21421. */
  21422. static readonly PointFillMode: number;
  21423. /**
  21424. * Returns the point list draw mode
  21425. */
  21426. static readonly PointListDrawMode: number;
  21427. /**
  21428. * Returns the line list draw mode
  21429. */
  21430. static readonly LineListDrawMode: number;
  21431. /**
  21432. * Returns the line loop draw mode
  21433. */
  21434. static readonly LineLoopDrawMode: number;
  21435. /**
  21436. * Returns the line strip draw mode
  21437. */
  21438. static readonly LineStripDrawMode: number;
  21439. /**
  21440. * Returns the triangle strip draw mode
  21441. */
  21442. static readonly TriangleStripDrawMode: number;
  21443. /**
  21444. * Returns the triangle fan draw mode
  21445. */
  21446. static readonly TriangleFanDrawMode: number;
  21447. /**
  21448. * Stores the clock-wise side orientation
  21449. */
  21450. static readonly ClockWiseSideOrientation: number;
  21451. /**
  21452. * Stores the counter clock-wise side orientation
  21453. */
  21454. static readonly CounterClockWiseSideOrientation: number;
  21455. /**
  21456. * The dirty texture flag value
  21457. */
  21458. static readonly TextureDirtyFlag: number;
  21459. /**
  21460. * The dirty light flag value
  21461. */
  21462. static readonly LightDirtyFlag: number;
  21463. /**
  21464. * The dirty fresnel flag value
  21465. */
  21466. static readonly FresnelDirtyFlag: number;
  21467. /**
  21468. * The dirty attribute flag value
  21469. */
  21470. static readonly AttributesDirtyFlag: number;
  21471. /**
  21472. * The dirty misc flag value
  21473. */
  21474. static readonly MiscDirtyFlag: number;
  21475. /**
  21476. * The all dirty flag value
  21477. */
  21478. static readonly AllDirtyFlag: number;
  21479. /**
  21480. * The ID of the material
  21481. */
  21482. id: string;
  21483. /**
  21484. * Gets or sets the unique id of the material
  21485. */
  21486. uniqueId: number;
  21487. /**
  21488. * The name of the material
  21489. */
  21490. name: string;
  21491. /**
  21492. * Gets or sets user defined metadata
  21493. */
  21494. metadata: any;
  21495. /**
  21496. * For internal use only. Please do not use.
  21497. */
  21498. reservedDataStore: any;
  21499. /**
  21500. * Specifies if the ready state should be checked on each call
  21501. */
  21502. checkReadyOnEveryCall: boolean;
  21503. /**
  21504. * Specifies if the ready state should be checked once
  21505. */
  21506. checkReadyOnlyOnce: boolean;
  21507. /**
  21508. * The state of the material
  21509. */
  21510. state: string;
  21511. /**
  21512. * The alpha value of the material
  21513. */
  21514. protected _alpha: number;
  21515. /**
  21516. * List of inspectable custom properties (used by the Inspector)
  21517. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21518. */
  21519. inspectableCustomProperties: IInspectable[];
  21520. /**
  21521. * Sets the alpha value of the material
  21522. */
  21523. set alpha(value: number);
  21524. /**
  21525. * Gets the alpha value of the material
  21526. */
  21527. get alpha(): number;
  21528. /**
  21529. * Specifies if back face culling is enabled
  21530. */
  21531. protected _backFaceCulling: boolean;
  21532. /**
  21533. * Sets the back-face culling state
  21534. */
  21535. set backFaceCulling(value: boolean);
  21536. /**
  21537. * Gets the back-face culling state
  21538. */
  21539. get backFaceCulling(): boolean;
  21540. /**
  21541. * Stores the value for side orientation
  21542. */
  21543. sideOrientation: number;
  21544. /**
  21545. * Callback triggered when the material is compiled
  21546. */
  21547. onCompiled: Nullable<(effect: Effect) => void>;
  21548. /**
  21549. * Callback triggered when an error occurs
  21550. */
  21551. onError: Nullable<(effect: Effect, errors: string) => void>;
  21552. /**
  21553. * Callback triggered to get the render target textures
  21554. */
  21555. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21556. /**
  21557. * Gets a boolean indicating that current material needs to register RTT
  21558. */
  21559. get hasRenderTargetTextures(): boolean;
  21560. /**
  21561. * Specifies if the material should be serialized
  21562. */
  21563. doNotSerialize: boolean;
  21564. /**
  21565. * @hidden
  21566. */
  21567. _storeEffectOnSubMeshes: boolean;
  21568. /**
  21569. * Stores the animations for the material
  21570. */
  21571. animations: Nullable<Array<Animation>>;
  21572. /**
  21573. * An event triggered when the material is disposed
  21574. */
  21575. onDisposeObservable: Observable<Material>;
  21576. /**
  21577. * An observer which watches for dispose events
  21578. */
  21579. private _onDisposeObserver;
  21580. private _onUnBindObservable;
  21581. /**
  21582. * Called during a dispose event
  21583. */
  21584. set onDispose(callback: () => void);
  21585. private _onBindObservable;
  21586. /**
  21587. * An event triggered when the material is bound
  21588. */
  21589. get onBindObservable(): Observable<AbstractMesh>;
  21590. /**
  21591. * An observer which watches for bind events
  21592. */
  21593. private _onBindObserver;
  21594. /**
  21595. * Called during a bind event
  21596. */
  21597. set onBind(callback: (Mesh: AbstractMesh) => void);
  21598. /**
  21599. * An event triggered when the material is unbound
  21600. */
  21601. get onUnBindObservable(): Observable<Material>;
  21602. /**
  21603. * Stores the value of the alpha mode
  21604. */
  21605. private _alphaMode;
  21606. /**
  21607. * Sets the value of the alpha mode.
  21608. *
  21609. * | Value | Type | Description |
  21610. * | --- | --- | --- |
  21611. * | 0 | ALPHA_DISABLE | |
  21612. * | 1 | ALPHA_ADD | |
  21613. * | 2 | ALPHA_COMBINE | |
  21614. * | 3 | ALPHA_SUBTRACT | |
  21615. * | 4 | ALPHA_MULTIPLY | |
  21616. * | 5 | ALPHA_MAXIMIZED | |
  21617. * | 6 | ALPHA_ONEONE | |
  21618. * | 7 | ALPHA_PREMULTIPLIED | |
  21619. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21620. * | 9 | ALPHA_INTERPOLATE | |
  21621. * | 10 | ALPHA_SCREENMODE | |
  21622. *
  21623. */
  21624. set alphaMode(value: number);
  21625. /**
  21626. * Gets the value of the alpha mode
  21627. */
  21628. get alphaMode(): number;
  21629. /**
  21630. * Stores the state of the need depth pre-pass value
  21631. */
  21632. private _needDepthPrePass;
  21633. /**
  21634. * Sets the need depth pre-pass value
  21635. */
  21636. set needDepthPrePass(value: boolean);
  21637. /**
  21638. * Gets the depth pre-pass value
  21639. */
  21640. get needDepthPrePass(): boolean;
  21641. /**
  21642. * Specifies if depth writing should be disabled
  21643. */
  21644. disableDepthWrite: boolean;
  21645. /**
  21646. * Specifies if depth writing should be forced
  21647. */
  21648. forceDepthWrite: boolean;
  21649. /**
  21650. * Specifies the depth function that should be used. 0 means the default engine function
  21651. */
  21652. depthFunction: number;
  21653. /**
  21654. * Specifies if there should be a separate pass for culling
  21655. */
  21656. separateCullingPass: boolean;
  21657. /**
  21658. * Stores the state specifing if fog should be enabled
  21659. */
  21660. private _fogEnabled;
  21661. /**
  21662. * Sets the state for enabling fog
  21663. */
  21664. set fogEnabled(value: boolean);
  21665. /**
  21666. * Gets the value of the fog enabled state
  21667. */
  21668. get fogEnabled(): boolean;
  21669. /**
  21670. * Stores the size of points
  21671. */
  21672. pointSize: number;
  21673. /**
  21674. * Stores the z offset value
  21675. */
  21676. zOffset: number;
  21677. /**
  21678. * Gets a value specifying if wireframe mode is enabled
  21679. */
  21680. get wireframe(): boolean;
  21681. /**
  21682. * Sets the state of wireframe mode
  21683. */
  21684. set wireframe(value: boolean);
  21685. /**
  21686. * Gets the value specifying if point clouds are enabled
  21687. */
  21688. get pointsCloud(): boolean;
  21689. /**
  21690. * Sets the state of point cloud mode
  21691. */
  21692. set pointsCloud(value: boolean);
  21693. /**
  21694. * Gets the material fill mode
  21695. */
  21696. get fillMode(): number;
  21697. /**
  21698. * Sets the material fill mode
  21699. */
  21700. set fillMode(value: number);
  21701. /**
  21702. * @hidden
  21703. * Stores the effects for the material
  21704. */
  21705. _effect: Nullable<Effect>;
  21706. /**
  21707. * Specifies if uniform buffers should be used
  21708. */
  21709. private _useUBO;
  21710. /**
  21711. * Stores a reference to the scene
  21712. */
  21713. private _scene;
  21714. /**
  21715. * Stores the fill mode state
  21716. */
  21717. private _fillMode;
  21718. /**
  21719. * Specifies if the depth write state should be cached
  21720. */
  21721. private _cachedDepthWriteState;
  21722. /**
  21723. * Specifies if the depth function state should be cached
  21724. */
  21725. private _cachedDepthFunctionState;
  21726. /**
  21727. * Stores the uniform buffer
  21728. */
  21729. protected _uniformBuffer: UniformBuffer;
  21730. /** @hidden */
  21731. _indexInSceneMaterialArray: number;
  21732. /** @hidden */
  21733. meshMap: Nullable<{
  21734. [id: string]: AbstractMesh | undefined;
  21735. }>;
  21736. /**
  21737. * Creates a material instance
  21738. * @param name defines the name of the material
  21739. * @param scene defines the scene to reference
  21740. * @param doNotAdd specifies if the material should be added to the scene
  21741. */
  21742. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21743. /**
  21744. * Returns a string representation of the current material
  21745. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21746. * @returns a string with material information
  21747. */
  21748. toString(fullDetails?: boolean): string;
  21749. /**
  21750. * Gets the class name of the material
  21751. * @returns a string with the class name of the material
  21752. */
  21753. getClassName(): string;
  21754. /**
  21755. * Specifies if updates for the material been locked
  21756. */
  21757. get isFrozen(): boolean;
  21758. /**
  21759. * Locks updates for the material
  21760. */
  21761. freeze(): void;
  21762. /**
  21763. * Unlocks updates for the material
  21764. */
  21765. unfreeze(): void;
  21766. /**
  21767. * Specifies if the material is ready to be used
  21768. * @param mesh defines the mesh to check
  21769. * @param useInstances specifies if instances should be used
  21770. * @returns a boolean indicating if the material is ready to be used
  21771. */
  21772. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21773. /**
  21774. * Specifies that the submesh is ready to be used
  21775. * @param mesh defines the mesh to check
  21776. * @param subMesh defines which submesh to check
  21777. * @param useInstances specifies that instances should be used
  21778. * @returns a boolean indicating that the submesh is ready or not
  21779. */
  21780. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21781. /**
  21782. * Returns the material effect
  21783. * @returns the effect associated with the material
  21784. */
  21785. getEffect(): Nullable<Effect>;
  21786. /**
  21787. * Returns the current scene
  21788. * @returns a Scene
  21789. */
  21790. getScene(): Scene;
  21791. /**
  21792. * Specifies if the material will require alpha blending
  21793. * @returns a boolean specifying if alpha blending is needed
  21794. */
  21795. needAlphaBlending(): boolean;
  21796. /**
  21797. * Specifies if the mesh will require alpha blending
  21798. * @param mesh defines the mesh to check
  21799. * @returns a boolean specifying if alpha blending is needed for the mesh
  21800. */
  21801. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21802. /**
  21803. * Specifies if this material should be rendered in alpha test mode
  21804. * @returns a boolean specifying if an alpha test is needed.
  21805. */
  21806. needAlphaTesting(): boolean;
  21807. /**
  21808. * Gets the texture used for the alpha test
  21809. * @returns the texture to use for alpha testing
  21810. */
  21811. getAlphaTestTexture(): Nullable<BaseTexture>;
  21812. /**
  21813. * Marks the material to indicate that it needs to be re-calculated
  21814. */
  21815. markDirty(): void;
  21816. /** @hidden */
  21817. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21818. /**
  21819. * Binds the material to the mesh
  21820. * @param world defines the world transformation matrix
  21821. * @param mesh defines the mesh to bind the material to
  21822. */
  21823. bind(world: Matrix, mesh?: Mesh): void;
  21824. /**
  21825. * Binds the submesh to the material
  21826. * @param world defines the world transformation matrix
  21827. * @param mesh defines the mesh containing the submesh
  21828. * @param subMesh defines the submesh to bind the material to
  21829. */
  21830. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21831. /**
  21832. * Binds the world matrix to the material
  21833. * @param world defines the world transformation matrix
  21834. */
  21835. bindOnlyWorldMatrix(world: Matrix): void;
  21836. /**
  21837. * Binds the scene's uniform buffer to the effect.
  21838. * @param effect defines the effect to bind to the scene uniform buffer
  21839. * @param sceneUbo defines the uniform buffer storing scene data
  21840. */
  21841. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21842. /**
  21843. * Binds the view matrix to the effect
  21844. * @param effect defines the effect to bind the view matrix to
  21845. */
  21846. bindView(effect: Effect): void;
  21847. /**
  21848. * Binds the view projection matrix to the effect
  21849. * @param effect defines the effect to bind the view projection matrix to
  21850. */
  21851. bindViewProjection(effect: Effect): void;
  21852. /**
  21853. * Specifies if material alpha testing should be turned on for the mesh
  21854. * @param mesh defines the mesh to check
  21855. */
  21856. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21857. /**
  21858. * Processes to execute after binding the material to a mesh
  21859. * @param mesh defines the rendered mesh
  21860. */
  21861. protected _afterBind(mesh?: Mesh): void;
  21862. /**
  21863. * Unbinds the material from the mesh
  21864. */
  21865. unbind(): void;
  21866. /**
  21867. * Gets the active textures from the material
  21868. * @returns an array of textures
  21869. */
  21870. getActiveTextures(): BaseTexture[];
  21871. /**
  21872. * Specifies if the material uses a texture
  21873. * @param texture defines the texture to check against the material
  21874. * @returns a boolean specifying if the material uses the texture
  21875. */
  21876. hasTexture(texture: BaseTexture): boolean;
  21877. /**
  21878. * Makes a duplicate of the material, and gives it a new name
  21879. * @param name defines the new name for the duplicated material
  21880. * @returns the cloned material
  21881. */
  21882. clone(name: string): Nullable<Material>;
  21883. /**
  21884. * Gets the meshes bound to the material
  21885. * @returns an array of meshes bound to the material
  21886. */
  21887. getBindedMeshes(): AbstractMesh[];
  21888. /**
  21889. * Force shader compilation
  21890. * @param mesh defines the mesh associated with this material
  21891. * @param onCompiled defines a function to execute once the material is compiled
  21892. * @param options defines the options to configure the compilation
  21893. * @param onError defines a function to execute if the material fails compiling
  21894. */
  21895. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21896. /**
  21897. * Force shader compilation
  21898. * @param mesh defines the mesh that will use this material
  21899. * @param options defines additional options for compiling the shaders
  21900. * @returns a promise that resolves when the compilation completes
  21901. */
  21902. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21903. private static readonly _AllDirtyCallBack;
  21904. private static readonly _ImageProcessingDirtyCallBack;
  21905. private static readonly _TextureDirtyCallBack;
  21906. private static readonly _FresnelDirtyCallBack;
  21907. private static readonly _MiscDirtyCallBack;
  21908. private static readonly _LightsDirtyCallBack;
  21909. private static readonly _AttributeDirtyCallBack;
  21910. private static _FresnelAndMiscDirtyCallBack;
  21911. private static _TextureAndMiscDirtyCallBack;
  21912. private static readonly _DirtyCallbackArray;
  21913. private static readonly _RunDirtyCallBacks;
  21914. /**
  21915. * Marks a define in the material to indicate that it needs to be re-computed
  21916. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21917. */
  21918. markAsDirty(flag: number): void;
  21919. /**
  21920. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21921. * @param func defines a function which checks material defines against the submeshes
  21922. */
  21923. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21924. /**
  21925. * Indicates that we need to re-calculated for all submeshes
  21926. */
  21927. protected _markAllSubMeshesAsAllDirty(): void;
  21928. /**
  21929. * Indicates that image processing needs to be re-calculated for all submeshes
  21930. */
  21931. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21932. /**
  21933. * Indicates that textures need to be re-calculated for all submeshes
  21934. */
  21935. protected _markAllSubMeshesAsTexturesDirty(): void;
  21936. /**
  21937. * Indicates that fresnel needs to be re-calculated for all submeshes
  21938. */
  21939. protected _markAllSubMeshesAsFresnelDirty(): void;
  21940. /**
  21941. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21942. */
  21943. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21944. /**
  21945. * Indicates that lights need to be re-calculated for all submeshes
  21946. */
  21947. protected _markAllSubMeshesAsLightsDirty(): void;
  21948. /**
  21949. * Indicates that attributes need to be re-calculated for all submeshes
  21950. */
  21951. protected _markAllSubMeshesAsAttributesDirty(): void;
  21952. /**
  21953. * Indicates that misc needs to be re-calculated for all submeshes
  21954. */
  21955. protected _markAllSubMeshesAsMiscDirty(): void;
  21956. /**
  21957. * Indicates that textures and misc need to be re-calculated for all submeshes
  21958. */
  21959. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21960. /**
  21961. * Disposes the material
  21962. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21963. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21964. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21965. */
  21966. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21967. /** @hidden */
  21968. private releaseVertexArrayObject;
  21969. /**
  21970. * Serializes this material
  21971. * @returns the serialized material object
  21972. */
  21973. serialize(): any;
  21974. /**
  21975. * Creates a material from parsed material data
  21976. * @param parsedMaterial defines parsed material data
  21977. * @param scene defines the hosting scene
  21978. * @param rootUrl defines the root URL to use to load textures
  21979. * @returns a new material
  21980. */
  21981. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21982. }
  21983. }
  21984. declare module "babylonjs/Materials/multiMaterial" {
  21985. import { Nullable } from "babylonjs/types";
  21986. import { Scene } from "babylonjs/scene";
  21987. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21988. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21989. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21990. import { Material } from "babylonjs/Materials/material";
  21991. /**
  21992. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21993. * separate meshes. This can be use to improve performances.
  21994. * @see http://doc.babylonjs.com/how_to/multi_materials
  21995. */
  21996. export class MultiMaterial extends Material {
  21997. private _subMaterials;
  21998. /**
  21999. * Gets or Sets the list of Materials used within the multi material.
  22000. * They need to be ordered according to the submeshes order in the associated mesh
  22001. */
  22002. get subMaterials(): Nullable<Material>[];
  22003. set subMaterials(value: Nullable<Material>[]);
  22004. /**
  22005. * Function used to align with Node.getChildren()
  22006. * @returns the list of Materials used within the multi material
  22007. */
  22008. getChildren(): Nullable<Material>[];
  22009. /**
  22010. * Instantiates a new Multi Material
  22011. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22012. * separate meshes. This can be use to improve performances.
  22013. * @see http://doc.babylonjs.com/how_to/multi_materials
  22014. * @param name Define the name in the scene
  22015. * @param scene Define the scene the material belongs to
  22016. */
  22017. constructor(name: string, scene: Scene);
  22018. private _hookArray;
  22019. /**
  22020. * Get one of the submaterial by its index in the submaterials array
  22021. * @param index The index to look the sub material at
  22022. * @returns The Material if the index has been defined
  22023. */
  22024. getSubMaterial(index: number): Nullable<Material>;
  22025. /**
  22026. * Get the list of active textures for the whole sub materials list.
  22027. * @returns All the textures that will be used during the rendering
  22028. */
  22029. getActiveTextures(): BaseTexture[];
  22030. /**
  22031. * Gets the current class name of the material e.g. "MultiMaterial"
  22032. * Mainly use in serialization.
  22033. * @returns the class name
  22034. */
  22035. getClassName(): string;
  22036. /**
  22037. * Checks if the material is ready to render the requested sub mesh
  22038. * @param mesh Define the mesh the submesh belongs to
  22039. * @param subMesh Define the sub mesh to look readyness for
  22040. * @param useInstances Define whether or not the material is used with instances
  22041. * @returns true if ready, otherwise false
  22042. */
  22043. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22044. /**
  22045. * Clones the current material and its related sub materials
  22046. * @param name Define the name of the newly cloned material
  22047. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  22048. * @returns the cloned material
  22049. */
  22050. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  22051. /**
  22052. * Serializes the materials into a JSON representation.
  22053. * @returns the JSON representation
  22054. */
  22055. serialize(): any;
  22056. /**
  22057. * Dispose the material and release its associated resources
  22058. * @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)
  22059. * @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)
  22060. * @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)
  22061. */
  22062. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  22063. /**
  22064. * Creates a MultiMaterial from parsed MultiMaterial data.
  22065. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  22066. * @param scene defines the hosting scene
  22067. * @returns a new MultiMaterial
  22068. */
  22069. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  22070. }
  22071. }
  22072. declare module "babylonjs/Meshes/subMesh" {
  22073. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  22074. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  22075. import { Engine } from "babylonjs/Engines/engine";
  22076. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22077. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22078. import { Effect } from "babylonjs/Materials/effect";
  22079. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22080. import { Plane } from "babylonjs/Maths/math.plane";
  22081. import { Collider } from "babylonjs/Collisions/collider";
  22082. import { Material } from "babylonjs/Materials/material";
  22083. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22084. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22085. import { Mesh } from "babylonjs/Meshes/mesh";
  22086. import { Ray } from "babylonjs/Culling/ray";
  22087. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22088. /**
  22089. * Base class for submeshes
  22090. */
  22091. export class BaseSubMesh {
  22092. /** @hidden */
  22093. _materialDefines: Nullable<MaterialDefines>;
  22094. /** @hidden */
  22095. _materialEffect: Nullable<Effect>;
  22096. /**
  22097. * Gets material defines used by the effect associated to the sub mesh
  22098. */
  22099. get materialDefines(): Nullable<MaterialDefines>;
  22100. /**
  22101. * Sets material defines used by the effect associated to the sub mesh
  22102. */
  22103. set materialDefines(defines: Nullable<MaterialDefines>);
  22104. /**
  22105. * Gets associated effect
  22106. */
  22107. get effect(): Nullable<Effect>;
  22108. /**
  22109. * Sets associated effect (effect used to render this submesh)
  22110. * @param effect defines the effect to associate with
  22111. * @param defines defines the set of defines used to compile this effect
  22112. */
  22113. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22114. }
  22115. /**
  22116. * Defines a subdivision inside a mesh
  22117. */
  22118. export class SubMesh extends BaseSubMesh implements ICullable {
  22119. /** the material index to use */
  22120. materialIndex: number;
  22121. /** vertex index start */
  22122. verticesStart: number;
  22123. /** vertices count */
  22124. verticesCount: number;
  22125. /** index start */
  22126. indexStart: number;
  22127. /** indices count */
  22128. indexCount: number;
  22129. /** @hidden */
  22130. _linesIndexCount: number;
  22131. private _mesh;
  22132. private _renderingMesh;
  22133. private _boundingInfo;
  22134. private _linesIndexBuffer;
  22135. /** @hidden */
  22136. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22137. /** @hidden */
  22138. _trianglePlanes: Plane[];
  22139. /** @hidden */
  22140. _lastColliderTransformMatrix: Nullable<Matrix>;
  22141. /** @hidden */
  22142. _renderId: number;
  22143. /** @hidden */
  22144. _alphaIndex: number;
  22145. /** @hidden */
  22146. _distanceToCamera: number;
  22147. /** @hidden */
  22148. _id: number;
  22149. private _currentMaterial;
  22150. /**
  22151. * Add a new submesh to a mesh
  22152. * @param materialIndex defines the material index to use
  22153. * @param verticesStart defines vertex index start
  22154. * @param verticesCount defines vertices count
  22155. * @param indexStart defines index start
  22156. * @param indexCount defines indices count
  22157. * @param mesh defines the parent mesh
  22158. * @param renderingMesh defines an optional rendering mesh
  22159. * @param createBoundingBox defines if bounding box should be created for this submesh
  22160. * @returns the new submesh
  22161. */
  22162. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22163. /**
  22164. * Creates a new submesh
  22165. * @param materialIndex defines the material index to use
  22166. * @param verticesStart defines vertex index start
  22167. * @param verticesCount defines vertices count
  22168. * @param indexStart defines index start
  22169. * @param indexCount defines indices count
  22170. * @param mesh defines the parent mesh
  22171. * @param renderingMesh defines an optional rendering mesh
  22172. * @param createBoundingBox defines if bounding box should be created for this submesh
  22173. */
  22174. constructor(
  22175. /** the material index to use */
  22176. materialIndex: number,
  22177. /** vertex index start */
  22178. verticesStart: number,
  22179. /** vertices count */
  22180. verticesCount: number,
  22181. /** index start */
  22182. indexStart: number,
  22183. /** indices count */
  22184. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22185. /**
  22186. * Returns true if this submesh covers the entire parent mesh
  22187. * @ignorenaming
  22188. */
  22189. get IsGlobal(): boolean;
  22190. /**
  22191. * Returns the submesh BoudingInfo object
  22192. * @returns current bounding info (or mesh's one if the submesh is global)
  22193. */
  22194. getBoundingInfo(): BoundingInfo;
  22195. /**
  22196. * Sets the submesh BoundingInfo
  22197. * @param boundingInfo defines the new bounding info to use
  22198. * @returns the SubMesh
  22199. */
  22200. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22201. /**
  22202. * Returns the mesh of the current submesh
  22203. * @return the parent mesh
  22204. */
  22205. getMesh(): AbstractMesh;
  22206. /**
  22207. * Returns the rendering mesh of the submesh
  22208. * @returns the rendering mesh (could be different from parent mesh)
  22209. */
  22210. getRenderingMesh(): Mesh;
  22211. /**
  22212. * Returns the submesh material
  22213. * @returns null or the current material
  22214. */
  22215. getMaterial(): Nullable<Material>;
  22216. /**
  22217. * Sets a new updated BoundingInfo object to the submesh
  22218. * @param data defines an optional position array to use to determine the bounding info
  22219. * @returns the SubMesh
  22220. */
  22221. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22222. /** @hidden */
  22223. _checkCollision(collider: Collider): boolean;
  22224. /**
  22225. * Updates the submesh BoundingInfo
  22226. * @param world defines the world matrix to use to update the bounding info
  22227. * @returns the submesh
  22228. */
  22229. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22230. /**
  22231. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22232. * @param frustumPlanes defines the frustum planes
  22233. * @returns true if the submesh is intersecting with the frustum
  22234. */
  22235. isInFrustum(frustumPlanes: Plane[]): boolean;
  22236. /**
  22237. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22238. * @param frustumPlanes defines the frustum planes
  22239. * @returns true if the submesh is inside the frustum
  22240. */
  22241. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22242. /**
  22243. * Renders the submesh
  22244. * @param enableAlphaMode defines if alpha needs to be used
  22245. * @returns the submesh
  22246. */
  22247. render(enableAlphaMode: boolean): SubMesh;
  22248. /**
  22249. * @hidden
  22250. */
  22251. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22252. /**
  22253. * Checks if the submesh intersects with a ray
  22254. * @param ray defines the ray to test
  22255. * @returns true is the passed ray intersects the submesh bounding box
  22256. */
  22257. canIntersects(ray: Ray): boolean;
  22258. /**
  22259. * Intersects current submesh with a ray
  22260. * @param ray defines the ray to test
  22261. * @param positions defines mesh's positions array
  22262. * @param indices defines mesh's indices array
  22263. * @param fastCheck defines if only bounding info should be used
  22264. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22265. * @returns intersection info or null if no intersection
  22266. */
  22267. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22268. /** @hidden */
  22269. private _intersectLines;
  22270. /** @hidden */
  22271. private _intersectUnIndexedLines;
  22272. /** @hidden */
  22273. private _intersectTriangles;
  22274. /** @hidden */
  22275. private _intersectUnIndexedTriangles;
  22276. /** @hidden */
  22277. _rebuild(): void;
  22278. /**
  22279. * Creates a new submesh from the passed mesh
  22280. * @param newMesh defines the new hosting mesh
  22281. * @param newRenderingMesh defines an optional rendering mesh
  22282. * @returns the new submesh
  22283. */
  22284. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22285. /**
  22286. * Release associated resources
  22287. */
  22288. dispose(): void;
  22289. /**
  22290. * Gets the class name
  22291. * @returns the string "SubMesh".
  22292. */
  22293. getClassName(): string;
  22294. /**
  22295. * Creates a new submesh from indices data
  22296. * @param materialIndex the index of the main mesh material
  22297. * @param startIndex the index where to start the copy in the mesh indices array
  22298. * @param indexCount the number of indices to copy then from the startIndex
  22299. * @param mesh the main mesh to create the submesh from
  22300. * @param renderingMesh the optional rendering mesh
  22301. * @returns a new submesh
  22302. */
  22303. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22304. }
  22305. }
  22306. declare module "babylonjs/Loading/sceneLoaderFlags" {
  22307. /**
  22308. * Class used to represent data loading progression
  22309. */
  22310. export class SceneLoaderFlags {
  22311. private static _ForceFullSceneLoadingForIncremental;
  22312. private static _ShowLoadingScreen;
  22313. private static _CleanBoneMatrixWeights;
  22314. private static _loggingLevel;
  22315. /**
  22316. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22317. */
  22318. static get ForceFullSceneLoadingForIncremental(): boolean;
  22319. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22320. /**
  22321. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22322. */
  22323. static get ShowLoadingScreen(): boolean;
  22324. static set ShowLoadingScreen(value: boolean);
  22325. /**
  22326. * Defines the current logging level (while loading the scene)
  22327. * @ignorenaming
  22328. */
  22329. static get loggingLevel(): number;
  22330. static set loggingLevel(value: number);
  22331. /**
  22332. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22333. */
  22334. static get CleanBoneMatrixWeights(): boolean;
  22335. static set CleanBoneMatrixWeights(value: boolean);
  22336. }
  22337. }
  22338. declare module "babylonjs/Meshes/geometry" {
  22339. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22340. import { Scene } from "babylonjs/scene";
  22341. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  22342. import { Engine } from "babylonjs/Engines/engine";
  22343. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22344. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22345. import { Effect } from "babylonjs/Materials/effect";
  22346. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22347. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22348. import { Mesh } from "babylonjs/Meshes/mesh";
  22349. /**
  22350. * Class used to store geometry data (vertex buffers + index buffer)
  22351. */
  22352. export class Geometry implements IGetSetVerticesData {
  22353. /**
  22354. * Gets or sets the ID of the geometry
  22355. */
  22356. id: string;
  22357. /**
  22358. * Gets or sets the unique ID of the geometry
  22359. */
  22360. uniqueId: number;
  22361. /**
  22362. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22363. */
  22364. delayLoadState: number;
  22365. /**
  22366. * Gets the file containing the data to load when running in delay load state
  22367. */
  22368. delayLoadingFile: Nullable<string>;
  22369. /**
  22370. * Callback called when the geometry is updated
  22371. */
  22372. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22373. private _scene;
  22374. private _engine;
  22375. private _meshes;
  22376. private _totalVertices;
  22377. /** @hidden */
  22378. _indices: IndicesArray;
  22379. /** @hidden */
  22380. _vertexBuffers: {
  22381. [key: string]: VertexBuffer;
  22382. };
  22383. private _isDisposed;
  22384. private _extend;
  22385. private _boundingBias;
  22386. /** @hidden */
  22387. _delayInfo: Array<string>;
  22388. private _indexBuffer;
  22389. private _indexBufferIsUpdatable;
  22390. /** @hidden */
  22391. _boundingInfo: Nullable<BoundingInfo>;
  22392. /** @hidden */
  22393. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22394. /** @hidden */
  22395. _softwareSkinningFrameId: number;
  22396. private _vertexArrayObjects;
  22397. private _updatable;
  22398. /** @hidden */
  22399. _positions: Nullable<Vector3[]>;
  22400. /**
  22401. * 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
  22402. */
  22403. get boundingBias(): Vector2;
  22404. /**
  22405. * 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
  22406. */
  22407. set boundingBias(value: Vector2);
  22408. /**
  22409. * Static function used to attach a new empty geometry to a mesh
  22410. * @param mesh defines the mesh to attach the geometry to
  22411. * @returns the new Geometry
  22412. */
  22413. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22414. /**
  22415. * Creates a new geometry
  22416. * @param id defines the unique ID
  22417. * @param scene defines the hosting scene
  22418. * @param vertexData defines the VertexData used to get geometry data
  22419. * @param updatable defines if geometry must be updatable (false by default)
  22420. * @param mesh defines the mesh that will be associated with the geometry
  22421. */
  22422. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22423. /**
  22424. * Gets the current extend of the geometry
  22425. */
  22426. get extend(): {
  22427. minimum: Vector3;
  22428. maximum: Vector3;
  22429. };
  22430. /**
  22431. * Gets the hosting scene
  22432. * @returns the hosting Scene
  22433. */
  22434. getScene(): Scene;
  22435. /**
  22436. * Gets the hosting engine
  22437. * @returns the hosting Engine
  22438. */
  22439. getEngine(): Engine;
  22440. /**
  22441. * Defines if the geometry is ready to use
  22442. * @returns true if the geometry is ready to be used
  22443. */
  22444. isReady(): boolean;
  22445. /**
  22446. * Gets a value indicating that the geometry should not be serialized
  22447. */
  22448. get doNotSerialize(): boolean;
  22449. /** @hidden */
  22450. _rebuild(): void;
  22451. /**
  22452. * Affects all geometry data in one call
  22453. * @param vertexData defines the geometry data
  22454. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22455. */
  22456. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22457. /**
  22458. * Set specific vertex data
  22459. * @param kind defines the data kind (Position, normal, etc...)
  22460. * @param data defines the vertex data to use
  22461. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22462. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22463. */
  22464. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22465. /**
  22466. * Removes a specific vertex data
  22467. * @param kind defines the data kind (Position, normal, etc...)
  22468. */
  22469. removeVerticesData(kind: string): void;
  22470. /**
  22471. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22472. * @param buffer defines the vertex buffer to use
  22473. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22474. */
  22475. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22476. /**
  22477. * Update a specific vertex buffer
  22478. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22479. * It will do nothing if the buffer is not updatable
  22480. * @param kind defines the data kind (Position, normal, etc...)
  22481. * @param data defines the data to use
  22482. * @param offset defines the offset in the target buffer where to store the data
  22483. * @param useBytes set to true if the offset is in bytes
  22484. */
  22485. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22486. /**
  22487. * Update a specific vertex buffer
  22488. * This function will create a new buffer if the current one is not updatable
  22489. * @param kind defines the data kind (Position, normal, etc...)
  22490. * @param data defines the data to use
  22491. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22492. */
  22493. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22494. private _updateBoundingInfo;
  22495. /** @hidden */
  22496. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22497. /**
  22498. * Gets total number of vertices
  22499. * @returns the total number of vertices
  22500. */
  22501. getTotalVertices(): number;
  22502. /**
  22503. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22504. * @param kind defines the data kind (Position, normal, etc...)
  22505. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22506. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22507. * @returns a float array containing vertex data
  22508. */
  22509. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22510. /**
  22511. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22512. * @param kind defines the data kind (Position, normal, etc...)
  22513. * @returns true if the vertex buffer with the specified kind is updatable
  22514. */
  22515. isVertexBufferUpdatable(kind: string): boolean;
  22516. /**
  22517. * Gets a specific vertex buffer
  22518. * @param kind defines the data kind (Position, normal, etc...)
  22519. * @returns a VertexBuffer
  22520. */
  22521. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22522. /**
  22523. * Returns all vertex buffers
  22524. * @return an object holding all vertex buffers indexed by kind
  22525. */
  22526. getVertexBuffers(): Nullable<{
  22527. [key: string]: VertexBuffer;
  22528. }>;
  22529. /**
  22530. * Gets a boolean indicating if specific vertex buffer is present
  22531. * @param kind defines the data kind (Position, normal, etc...)
  22532. * @returns true if data is present
  22533. */
  22534. isVerticesDataPresent(kind: string): boolean;
  22535. /**
  22536. * Gets a list of all attached data kinds (Position, normal, etc...)
  22537. * @returns a list of string containing all kinds
  22538. */
  22539. getVerticesDataKinds(): string[];
  22540. /**
  22541. * Update index buffer
  22542. * @param indices defines the indices to store in the index buffer
  22543. * @param offset defines the offset in the target buffer where to store the data
  22544. * @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)
  22545. */
  22546. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22547. /**
  22548. * Creates a new index buffer
  22549. * @param indices defines the indices to store in the index buffer
  22550. * @param totalVertices defines the total number of vertices (could be null)
  22551. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22552. */
  22553. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22554. /**
  22555. * Return the total number of indices
  22556. * @returns the total number of indices
  22557. */
  22558. getTotalIndices(): number;
  22559. /**
  22560. * Gets the index buffer array
  22561. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22562. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22563. * @returns the index buffer array
  22564. */
  22565. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22566. /**
  22567. * Gets the index buffer
  22568. * @return the index buffer
  22569. */
  22570. getIndexBuffer(): Nullable<DataBuffer>;
  22571. /** @hidden */
  22572. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22573. /**
  22574. * Release the associated resources for a specific mesh
  22575. * @param mesh defines the source mesh
  22576. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22577. */
  22578. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22579. /**
  22580. * Apply current geometry to a given mesh
  22581. * @param mesh defines the mesh to apply geometry to
  22582. */
  22583. applyToMesh(mesh: Mesh): void;
  22584. private _updateExtend;
  22585. private _applyToMesh;
  22586. private notifyUpdate;
  22587. /**
  22588. * Load the geometry if it was flagged as delay loaded
  22589. * @param scene defines the hosting scene
  22590. * @param onLoaded defines a callback called when the geometry is loaded
  22591. */
  22592. load(scene: Scene, onLoaded?: () => void): void;
  22593. private _queueLoad;
  22594. /**
  22595. * Invert the geometry to move from a right handed system to a left handed one.
  22596. */
  22597. toLeftHanded(): void;
  22598. /** @hidden */
  22599. _resetPointsArrayCache(): void;
  22600. /** @hidden */
  22601. _generatePointsArray(): boolean;
  22602. /**
  22603. * Gets a value indicating if the geometry is disposed
  22604. * @returns true if the geometry was disposed
  22605. */
  22606. isDisposed(): boolean;
  22607. private _disposeVertexArrayObjects;
  22608. /**
  22609. * Free all associated resources
  22610. */
  22611. dispose(): void;
  22612. /**
  22613. * Clone the current geometry into a new geometry
  22614. * @param id defines the unique ID of the new geometry
  22615. * @returns a new geometry object
  22616. */
  22617. copy(id: string): Geometry;
  22618. /**
  22619. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22620. * @return a JSON representation of the current geometry data (without the vertices data)
  22621. */
  22622. serialize(): any;
  22623. private toNumberArray;
  22624. /**
  22625. * Serialize all vertices data into a JSON oject
  22626. * @returns a JSON representation of the current geometry data
  22627. */
  22628. serializeVerticeData(): any;
  22629. /**
  22630. * Extracts a clone of a mesh geometry
  22631. * @param mesh defines the source mesh
  22632. * @param id defines the unique ID of the new geometry object
  22633. * @returns the new geometry object
  22634. */
  22635. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22636. /**
  22637. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22638. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22639. * Be aware Math.random() could cause collisions, but:
  22640. * "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"
  22641. * @returns a string containing a new GUID
  22642. */
  22643. static RandomId(): string;
  22644. /** @hidden */
  22645. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22646. private static _CleanMatricesWeights;
  22647. /**
  22648. * Create a new geometry from persisted data (Using .babylon file format)
  22649. * @param parsedVertexData defines the persisted data
  22650. * @param scene defines the hosting scene
  22651. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22652. * @returns the new geometry object
  22653. */
  22654. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22655. }
  22656. }
  22657. declare module "babylonjs/Meshes/mesh.vertexData" {
  22658. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22659. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22660. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22661. import { Geometry } from "babylonjs/Meshes/geometry";
  22662. import { Mesh } from "babylonjs/Meshes/mesh";
  22663. /**
  22664. * Define an interface for all classes that will get and set the data on vertices
  22665. */
  22666. export interface IGetSetVerticesData {
  22667. /**
  22668. * Gets a boolean indicating if specific vertex data is present
  22669. * @param kind defines the vertex data kind to use
  22670. * @returns true is data kind is present
  22671. */
  22672. isVerticesDataPresent(kind: string): boolean;
  22673. /**
  22674. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22675. * @param kind defines the data kind (Position, normal, etc...)
  22676. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22677. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22678. * @returns a float array containing vertex data
  22679. */
  22680. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22681. /**
  22682. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22683. * @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.
  22684. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22685. * @returns the indices array or an empty array if the mesh has no geometry
  22686. */
  22687. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22688. /**
  22689. * Set specific vertex data
  22690. * @param kind defines the data kind (Position, normal, etc...)
  22691. * @param data defines the vertex data to use
  22692. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22693. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22694. */
  22695. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22696. /**
  22697. * Update a specific associated vertex buffer
  22698. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22699. * - VertexBuffer.PositionKind
  22700. * - VertexBuffer.UVKind
  22701. * - VertexBuffer.UV2Kind
  22702. * - VertexBuffer.UV3Kind
  22703. * - VertexBuffer.UV4Kind
  22704. * - VertexBuffer.UV5Kind
  22705. * - VertexBuffer.UV6Kind
  22706. * - VertexBuffer.ColorKind
  22707. * - VertexBuffer.MatricesIndicesKind
  22708. * - VertexBuffer.MatricesIndicesExtraKind
  22709. * - VertexBuffer.MatricesWeightsKind
  22710. * - VertexBuffer.MatricesWeightsExtraKind
  22711. * @param data defines the data source
  22712. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22713. * @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)
  22714. */
  22715. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22716. /**
  22717. * Creates a new index buffer
  22718. * @param indices defines the indices to store in the index buffer
  22719. * @param totalVertices defines the total number of vertices (could be null)
  22720. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22721. */
  22722. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22723. }
  22724. /**
  22725. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22726. */
  22727. export class VertexData {
  22728. /**
  22729. * Mesh side orientation : usually the external or front surface
  22730. */
  22731. static readonly FRONTSIDE: number;
  22732. /**
  22733. * Mesh side orientation : usually the internal or back surface
  22734. */
  22735. static readonly BACKSIDE: number;
  22736. /**
  22737. * Mesh side orientation : both internal and external or front and back surfaces
  22738. */
  22739. static readonly DOUBLESIDE: number;
  22740. /**
  22741. * Mesh side orientation : by default, `FRONTSIDE`
  22742. */
  22743. static readonly DEFAULTSIDE: number;
  22744. /**
  22745. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22746. */
  22747. positions: Nullable<FloatArray>;
  22748. /**
  22749. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22750. */
  22751. normals: Nullable<FloatArray>;
  22752. /**
  22753. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22754. */
  22755. tangents: Nullable<FloatArray>;
  22756. /**
  22757. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22758. */
  22759. uvs: Nullable<FloatArray>;
  22760. /**
  22761. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22762. */
  22763. uvs2: Nullable<FloatArray>;
  22764. /**
  22765. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22766. */
  22767. uvs3: Nullable<FloatArray>;
  22768. /**
  22769. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22770. */
  22771. uvs4: Nullable<FloatArray>;
  22772. /**
  22773. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22774. */
  22775. uvs5: Nullable<FloatArray>;
  22776. /**
  22777. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22778. */
  22779. uvs6: Nullable<FloatArray>;
  22780. /**
  22781. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22782. */
  22783. colors: Nullable<FloatArray>;
  22784. /**
  22785. * 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).
  22786. */
  22787. matricesIndices: Nullable<FloatArray>;
  22788. /**
  22789. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22790. */
  22791. matricesWeights: Nullable<FloatArray>;
  22792. /**
  22793. * An array extending the number of possible indices
  22794. */
  22795. matricesIndicesExtra: Nullable<FloatArray>;
  22796. /**
  22797. * An array extending the number of possible weights when the number of indices is extended
  22798. */
  22799. matricesWeightsExtra: Nullable<FloatArray>;
  22800. /**
  22801. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22802. */
  22803. indices: Nullable<IndicesArray>;
  22804. /**
  22805. * Uses the passed data array to set the set the values for the specified kind of data
  22806. * @param data a linear array of floating numbers
  22807. * @param kind the type of data that is being set, eg positions, colors etc
  22808. */
  22809. set(data: FloatArray, kind: string): void;
  22810. /**
  22811. * Associates the vertexData to the passed Mesh.
  22812. * Sets it as updatable or not (default `false`)
  22813. * @param mesh the mesh the vertexData is applied to
  22814. * @param updatable when used and having the value true allows new data to update the vertexData
  22815. * @returns the VertexData
  22816. */
  22817. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22818. /**
  22819. * Associates the vertexData to the passed Geometry.
  22820. * Sets it as updatable or not (default `false`)
  22821. * @param geometry the geometry the vertexData is applied to
  22822. * @param updatable when used and having the value true allows new data to update the vertexData
  22823. * @returns VertexData
  22824. */
  22825. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22826. /**
  22827. * Updates the associated mesh
  22828. * @param mesh the mesh to be updated
  22829. * @param updateExtends when true the mesh 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. updateMesh(mesh: Mesh): VertexData;
  22834. /**
  22835. * Updates the associated geometry
  22836. * @param geometry the geometry to be updated
  22837. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22838. * @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
  22839. * @returns VertexData.
  22840. */
  22841. updateGeometry(geometry: Geometry): VertexData;
  22842. private _applyTo;
  22843. private _update;
  22844. /**
  22845. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22846. * @param matrix the transforming matrix
  22847. * @returns the VertexData
  22848. */
  22849. transform(matrix: Matrix): VertexData;
  22850. /**
  22851. * Merges the passed VertexData into the current one
  22852. * @param other the VertexData to be merged into the current one
  22853. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22854. * @returns the modified VertexData
  22855. */
  22856. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22857. private _mergeElement;
  22858. private _validate;
  22859. /**
  22860. * Serializes the VertexData
  22861. * @returns a serialized object
  22862. */
  22863. serialize(): any;
  22864. /**
  22865. * Extracts the vertexData from a mesh
  22866. * @param mesh the mesh from which to extract the VertexData
  22867. * @param copyWhenShared defines if the VertexData must be cloned when 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 ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22872. /**
  22873. * Extracts the vertexData from the geometry
  22874. * @param geometry the geometry from which to extract the VertexData
  22875. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22876. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22877. * @returns the object VertexData associated to the passed mesh
  22878. */
  22879. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22880. private static _ExtractFrom;
  22881. /**
  22882. * Creates the VertexData for a Ribbon
  22883. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22884. * * pathArray array of paths, each of which an array of successive Vector3
  22885. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22886. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22887. * * 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
  22888. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22889. * * 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)
  22890. * * 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)
  22891. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22892. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22893. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22894. * @returns the VertexData of the ribbon
  22895. */
  22896. static CreateRibbon(options: {
  22897. pathArray: Vector3[][];
  22898. closeArray?: boolean;
  22899. closePath?: boolean;
  22900. offset?: number;
  22901. sideOrientation?: number;
  22902. frontUVs?: Vector4;
  22903. backUVs?: Vector4;
  22904. invertUV?: boolean;
  22905. uvs?: Vector2[];
  22906. colors?: Color4[];
  22907. }): VertexData;
  22908. /**
  22909. * Creates the VertexData for a box
  22910. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22911. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22912. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22913. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22914. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22915. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22916. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22917. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22918. * * 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)
  22919. * * 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)
  22920. * @returns the VertexData of the box
  22921. */
  22922. static CreateBox(options: {
  22923. size?: number;
  22924. width?: number;
  22925. height?: number;
  22926. depth?: number;
  22927. faceUV?: Vector4[];
  22928. faceColors?: Color4[];
  22929. sideOrientation?: number;
  22930. frontUVs?: Vector4;
  22931. backUVs?: Vector4;
  22932. }): VertexData;
  22933. /**
  22934. * Creates the VertexData for a tiled box
  22935. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22936. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22937. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22938. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22939. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22940. * @returns the VertexData of the box
  22941. */
  22942. static CreateTiledBox(options: {
  22943. pattern?: number;
  22944. width?: number;
  22945. height?: number;
  22946. depth?: number;
  22947. tileSize?: number;
  22948. tileWidth?: number;
  22949. tileHeight?: number;
  22950. alignHorizontal?: number;
  22951. alignVertical?: number;
  22952. faceUV?: Vector4[];
  22953. faceColors?: Color4[];
  22954. sideOrientation?: number;
  22955. }): VertexData;
  22956. /**
  22957. * Creates the VertexData for a tiled plane
  22958. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22959. * * pattern a limited pattern arrangement depending on the number
  22960. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22961. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22962. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22963. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22964. * * 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)
  22965. * * 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)
  22966. * @returns the VertexData of the tiled plane
  22967. */
  22968. static CreateTiledPlane(options: {
  22969. pattern?: number;
  22970. tileSize?: number;
  22971. tileWidth?: number;
  22972. tileHeight?: number;
  22973. size?: number;
  22974. width?: number;
  22975. height?: number;
  22976. alignHorizontal?: number;
  22977. alignVertical?: number;
  22978. sideOrientation?: number;
  22979. frontUVs?: Vector4;
  22980. backUVs?: Vector4;
  22981. }): VertexData;
  22982. /**
  22983. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22984. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22985. * * segments sets the number of horizontal strips optional, default 32
  22986. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22987. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22988. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22989. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22990. * * 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
  22991. * * 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
  22992. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22993. * * 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)
  22994. * * 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)
  22995. * @returns the VertexData of the ellipsoid
  22996. */
  22997. static CreateSphere(options: {
  22998. segments?: number;
  22999. diameter?: number;
  23000. diameterX?: number;
  23001. diameterY?: number;
  23002. diameterZ?: number;
  23003. arc?: number;
  23004. slice?: number;
  23005. sideOrientation?: number;
  23006. frontUVs?: Vector4;
  23007. backUVs?: Vector4;
  23008. }): VertexData;
  23009. /**
  23010. * Creates the VertexData for a cylinder, cone or prism
  23011. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23012. * * height sets the height (y direction) of the cylinder, optional, default 2
  23013. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23014. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23015. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23016. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23017. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23018. * * 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
  23019. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23020. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23021. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23022. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23023. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23024. * * 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)
  23025. * * 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)
  23026. * @returns the VertexData of the cylinder, cone or prism
  23027. */
  23028. static CreateCylinder(options: {
  23029. height?: number;
  23030. diameterTop?: number;
  23031. diameterBottom?: number;
  23032. diameter?: number;
  23033. tessellation?: number;
  23034. subdivisions?: number;
  23035. arc?: number;
  23036. faceColors?: Color4[];
  23037. faceUV?: Vector4[];
  23038. hasRings?: boolean;
  23039. enclose?: boolean;
  23040. sideOrientation?: number;
  23041. frontUVs?: Vector4;
  23042. backUVs?: Vector4;
  23043. }): VertexData;
  23044. /**
  23045. * Creates the VertexData for a torus
  23046. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23047. * * diameter the diameter of the torus, optional default 1
  23048. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23049. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23050. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23051. * * 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)
  23052. * * 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)
  23053. * @returns the VertexData of the torus
  23054. */
  23055. static CreateTorus(options: {
  23056. diameter?: number;
  23057. thickness?: number;
  23058. tessellation?: number;
  23059. sideOrientation?: number;
  23060. frontUVs?: Vector4;
  23061. backUVs?: Vector4;
  23062. }): VertexData;
  23063. /**
  23064. * Creates the VertexData of the LineSystem
  23065. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23066. * - lines an array of lines, each line being an array of successive Vector3
  23067. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23068. * @returns the VertexData of the LineSystem
  23069. */
  23070. static CreateLineSystem(options: {
  23071. lines: Vector3[][];
  23072. colors?: Nullable<Color4[][]>;
  23073. }): VertexData;
  23074. /**
  23075. * Create the VertexData for a DashedLines
  23076. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23077. * - points an array successive Vector3
  23078. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23079. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23080. * - dashNb the intended total number of dashes, optional, default 200
  23081. * @returns the VertexData for the DashedLines
  23082. */
  23083. static CreateDashedLines(options: {
  23084. points: Vector3[];
  23085. dashSize?: number;
  23086. gapSize?: number;
  23087. dashNb?: number;
  23088. }): VertexData;
  23089. /**
  23090. * Creates the VertexData for a Ground
  23091. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23092. * - width the width (x direction) of the ground, optional, default 1
  23093. * - height the height (z direction) of the ground, optional, default 1
  23094. * - subdivisions the number of subdivisions per side, optional, default 1
  23095. * @returns the VertexData of the Ground
  23096. */
  23097. static CreateGround(options: {
  23098. width?: number;
  23099. height?: number;
  23100. subdivisions?: number;
  23101. subdivisionsX?: number;
  23102. subdivisionsY?: number;
  23103. }): VertexData;
  23104. /**
  23105. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23106. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23107. * * xmin the ground minimum X coordinate, optional, default -1
  23108. * * zmin the ground minimum Z coordinate, optional, default -1
  23109. * * xmax the ground maximum X coordinate, optional, default 1
  23110. * * zmax the ground maximum Z coordinate, optional, default 1
  23111. * * 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}
  23112. * * 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}
  23113. * @returns the VertexData of the TiledGround
  23114. */
  23115. static CreateTiledGround(options: {
  23116. xmin: number;
  23117. zmin: number;
  23118. xmax: number;
  23119. zmax: number;
  23120. subdivisions?: {
  23121. w: number;
  23122. h: number;
  23123. };
  23124. precision?: {
  23125. w: number;
  23126. h: number;
  23127. };
  23128. }): VertexData;
  23129. /**
  23130. * Creates the VertexData of the Ground designed from a heightmap
  23131. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23132. * * width the width (x direction) of the ground
  23133. * * height the height (z direction) of the ground
  23134. * * subdivisions the number of subdivisions per side
  23135. * * minHeight the minimum altitude on the ground, optional, default 0
  23136. * * maxHeight the maximum altitude on the ground, optional default 1
  23137. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23138. * * buffer the array holding the image color data
  23139. * * bufferWidth the width of image
  23140. * * bufferHeight the height of image
  23141. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23142. * @returns the VertexData of the Ground designed from a heightmap
  23143. */
  23144. static CreateGroundFromHeightMap(options: {
  23145. width: number;
  23146. height: number;
  23147. subdivisions: number;
  23148. minHeight: number;
  23149. maxHeight: number;
  23150. colorFilter: Color3;
  23151. buffer: Uint8Array;
  23152. bufferWidth: number;
  23153. bufferHeight: number;
  23154. alphaFilter: number;
  23155. }): VertexData;
  23156. /**
  23157. * Creates the VertexData for a Plane
  23158. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23159. * * size sets the width and height of the plane to the value of size, optional default 1
  23160. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23161. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23162. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23163. * * 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)
  23164. * * 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)
  23165. * @returns the VertexData of the box
  23166. */
  23167. static CreatePlane(options: {
  23168. size?: number;
  23169. width?: number;
  23170. height?: number;
  23171. sideOrientation?: number;
  23172. frontUVs?: Vector4;
  23173. backUVs?: Vector4;
  23174. }): VertexData;
  23175. /**
  23176. * Creates the VertexData of the Disc or regular Polygon
  23177. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23178. * * radius the radius of the disc, optional default 0.5
  23179. * * tessellation the number of polygon sides, optional, default 64
  23180. * * 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
  23181. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23182. * * 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)
  23183. * * 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)
  23184. * @returns the VertexData of the box
  23185. */
  23186. static CreateDisc(options: {
  23187. radius?: number;
  23188. tessellation?: number;
  23189. arc?: number;
  23190. sideOrientation?: number;
  23191. frontUVs?: Vector4;
  23192. backUVs?: Vector4;
  23193. }): VertexData;
  23194. /**
  23195. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23196. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23197. * @param polygon a mesh built from polygonTriangulation.build()
  23198. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23199. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23200. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23201. * @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)
  23202. * @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)
  23203. * @returns the VertexData of the Polygon
  23204. */
  23205. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23206. /**
  23207. * Creates the VertexData of the IcoSphere
  23208. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23209. * * radius the radius of the IcoSphere, optional default 1
  23210. * * radiusX allows stretching in the x direction, optional, default radius
  23211. * * radiusY allows stretching in the y direction, optional, default radius
  23212. * * radiusZ allows stretching in the z direction, optional, default radius
  23213. * * flat when true creates a flat shaded mesh, optional, default true
  23214. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23215. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23216. * * 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)
  23217. * * 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)
  23218. * @returns the VertexData of the IcoSphere
  23219. */
  23220. static CreateIcoSphere(options: {
  23221. radius?: number;
  23222. radiusX?: number;
  23223. radiusY?: number;
  23224. radiusZ?: number;
  23225. flat?: boolean;
  23226. subdivisions?: number;
  23227. sideOrientation?: number;
  23228. frontUVs?: Vector4;
  23229. backUVs?: Vector4;
  23230. }): VertexData;
  23231. /**
  23232. * Creates the VertexData for a Polyhedron
  23233. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23234. * * type provided types are:
  23235. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23236. * * 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)
  23237. * * size the size of the IcoSphere, optional default 1
  23238. * * sizeX allows stretching in the x direction, optional, default size
  23239. * * sizeY allows stretching in the y direction, optional, default size
  23240. * * sizeZ allows stretching in the z direction, optional, default size
  23241. * * 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
  23242. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23243. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23244. * * flat when true creates a flat shaded mesh, optional, default true
  23245. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23246. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23247. * * 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)
  23248. * * 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)
  23249. * @returns the VertexData of the Polyhedron
  23250. */
  23251. static CreatePolyhedron(options: {
  23252. type?: number;
  23253. size?: number;
  23254. sizeX?: number;
  23255. sizeY?: number;
  23256. sizeZ?: number;
  23257. custom?: any;
  23258. faceUV?: Vector4[];
  23259. faceColors?: Color4[];
  23260. flat?: boolean;
  23261. sideOrientation?: number;
  23262. frontUVs?: Vector4;
  23263. backUVs?: Vector4;
  23264. }): VertexData;
  23265. /**
  23266. * Creates the VertexData for a TorusKnot
  23267. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23268. * * radius the radius of the torus knot, optional, default 2
  23269. * * tube the thickness of the tube, optional, default 0.5
  23270. * * radialSegments the number of sides on each tube segments, optional, default 32
  23271. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23272. * * p the number of windings around the z axis, optional, default 2
  23273. * * q the number of windings around the x axis, optional, default 3
  23274. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23275. * * 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)
  23276. * * 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)
  23277. * @returns the VertexData of the Torus Knot
  23278. */
  23279. static CreateTorusKnot(options: {
  23280. radius?: number;
  23281. tube?: number;
  23282. radialSegments?: number;
  23283. tubularSegments?: number;
  23284. p?: number;
  23285. q?: number;
  23286. sideOrientation?: number;
  23287. frontUVs?: Vector4;
  23288. backUVs?: Vector4;
  23289. }): VertexData;
  23290. /**
  23291. * Compute normals for given positions and indices
  23292. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23293. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23294. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23295. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23296. * * facetNormals : optional array of facet normals (vector3)
  23297. * * facetPositions : optional array of facet positions (vector3)
  23298. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23299. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23300. * * bInfo : optional bounding info, required for facetPartitioning computation
  23301. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23302. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23303. * * useRightHandedSystem: optional boolean to for right handed system computation
  23304. * * depthSort : optional boolean to enable the facet depth sort computation
  23305. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23306. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23307. */
  23308. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23309. facetNormals?: any;
  23310. facetPositions?: any;
  23311. facetPartitioning?: any;
  23312. ratio?: number;
  23313. bInfo?: any;
  23314. bbSize?: Vector3;
  23315. subDiv?: any;
  23316. useRightHandedSystem?: boolean;
  23317. depthSort?: boolean;
  23318. distanceTo?: Vector3;
  23319. depthSortedFacets?: any;
  23320. }): void;
  23321. /** @hidden */
  23322. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23323. /**
  23324. * Applies VertexData created from the imported parameters to the geometry
  23325. * @param parsedVertexData the parsed data from an imported file
  23326. * @param geometry the geometry to apply the VertexData to
  23327. */
  23328. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23329. }
  23330. }
  23331. declare module "babylonjs/Morph/morphTarget" {
  23332. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23333. import { Observable } from "babylonjs/Misc/observable";
  23334. import { Nullable, FloatArray } from "babylonjs/types";
  23335. import { Scene } from "babylonjs/scene";
  23336. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23337. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  23338. /**
  23339. * Defines a target to use with MorphTargetManager
  23340. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23341. */
  23342. export class MorphTarget implements IAnimatable {
  23343. /** defines the name of the target */
  23344. name: string;
  23345. /**
  23346. * Gets or sets the list of animations
  23347. */
  23348. animations: import("babylonjs/Animations/animation").Animation[];
  23349. private _scene;
  23350. private _positions;
  23351. private _normals;
  23352. private _tangents;
  23353. private _uvs;
  23354. private _influence;
  23355. private _uniqueId;
  23356. /**
  23357. * Observable raised when the influence changes
  23358. */
  23359. onInfluenceChanged: Observable<boolean>;
  23360. /** @hidden */
  23361. _onDataLayoutChanged: Observable<void>;
  23362. /**
  23363. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23364. */
  23365. get influence(): number;
  23366. set influence(influence: number);
  23367. /**
  23368. * Gets or sets the id of the morph Target
  23369. */
  23370. id: string;
  23371. private _animationPropertiesOverride;
  23372. /**
  23373. * Gets or sets the animation properties override
  23374. */
  23375. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23376. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23377. /**
  23378. * Creates a new MorphTarget
  23379. * @param name defines the name of the target
  23380. * @param influence defines the influence to use
  23381. * @param scene defines the scene the morphtarget belongs to
  23382. */
  23383. constructor(
  23384. /** defines the name of the target */
  23385. name: string, influence?: number, scene?: Nullable<Scene>);
  23386. /**
  23387. * Gets the unique ID of this manager
  23388. */
  23389. get uniqueId(): number;
  23390. /**
  23391. * Gets a boolean defining if the target contains position data
  23392. */
  23393. get hasPositions(): boolean;
  23394. /**
  23395. * Gets a boolean defining if the target contains normal data
  23396. */
  23397. get hasNormals(): boolean;
  23398. /**
  23399. * Gets a boolean defining if the target contains tangent data
  23400. */
  23401. get hasTangents(): boolean;
  23402. /**
  23403. * Gets a boolean defining if the target contains texture coordinates data
  23404. */
  23405. get hasUVs(): boolean;
  23406. /**
  23407. * Affects position data to this target
  23408. * @param data defines the position data to use
  23409. */
  23410. setPositions(data: Nullable<FloatArray>): void;
  23411. /**
  23412. * Gets the position data stored in this target
  23413. * @returns a FloatArray containing the position data (or null if not present)
  23414. */
  23415. getPositions(): Nullable<FloatArray>;
  23416. /**
  23417. * Affects normal data to this target
  23418. * @param data defines the normal data to use
  23419. */
  23420. setNormals(data: Nullable<FloatArray>): void;
  23421. /**
  23422. * Gets the normal data stored in this target
  23423. * @returns a FloatArray containing the normal data (or null if not present)
  23424. */
  23425. getNormals(): Nullable<FloatArray>;
  23426. /**
  23427. * Affects tangent data to this target
  23428. * @param data defines the tangent data to use
  23429. */
  23430. setTangents(data: Nullable<FloatArray>): void;
  23431. /**
  23432. * Gets the tangent data stored in this target
  23433. * @returns a FloatArray containing the tangent data (or null if not present)
  23434. */
  23435. getTangents(): Nullable<FloatArray>;
  23436. /**
  23437. * Affects texture coordinates data to this target
  23438. * @param data defines the texture coordinates data to use
  23439. */
  23440. setUVs(data: Nullable<FloatArray>): void;
  23441. /**
  23442. * Gets the texture coordinates data stored in this target
  23443. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23444. */
  23445. getUVs(): Nullable<FloatArray>;
  23446. /**
  23447. * Clone the current target
  23448. * @returns a new MorphTarget
  23449. */
  23450. clone(): MorphTarget;
  23451. /**
  23452. * Serializes the current target into a Serialization object
  23453. * @returns the serialized object
  23454. */
  23455. serialize(): any;
  23456. /**
  23457. * Returns the string "MorphTarget"
  23458. * @returns "MorphTarget"
  23459. */
  23460. getClassName(): string;
  23461. /**
  23462. * Creates a new target from serialized data
  23463. * @param serializationObject defines the serialized data to use
  23464. * @returns a new MorphTarget
  23465. */
  23466. static Parse(serializationObject: any): MorphTarget;
  23467. /**
  23468. * Creates a MorphTarget from mesh data
  23469. * @param mesh defines the source mesh
  23470. * @param name defines the name to use for the new target
  23471. * @param influence defines the influence to attach to the target
  23472. * @returns a new MorphTarget
  23473. */
  23474. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23475. }
  23476. }
  23477. declare module "babylonjs/Morph/morphTargetManager" {
  23478. import { Nullable } from "babylonjs/types";
  23479. import { Scene } from "babylonjs/scene";
  23480. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23481. /**
  23482. * This class is used to deform meshes using morphing between different targets
  23483. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23484. */
  23485. export class MorphTargetManager {
  23486. private _targets;
  23487. private _targetInfluenceChangedObservers;
  23488. private _targetDataLayoutChangedObservers;
  23489. private _activeTargets;
  23490. private _scene;
  23491. private _influences;
  23492. private _supportsNormals;
  23493. private _supportsTangents;
  23494. private _supportsUVs;
  23495. private _vertexCount;
  23496. private _uniqueId;
  23497. private _tempInfluences;
  23498. /**
  23499. * Gets or sets a boolean indicating if normals must be morphed
  23500. */
  23501. enableNormalMorphing: boolean;
  23502. /**
  23503. * Gets or sets a boolean indicating if tangents must be morphed
  23504. */
  23505. enableTangentMorphing: boolean;
  23506. /**
  23507. * Gets or sets a boolean indicating if UV must be morphed
  23508. */
  23509. enableUVMorphing: boolean;
  23510. /**
  23511. * Creates a new MorphTargetManager
  23512. * @param scene defines the current scene
  23513. */
  23514. constructor(scene?: Nullable<Scene>);
  23515. /**
  23516. * Gets the unique ID of this manager
  23517. */
  23518. get uniqueId(): number;
  23519. /**
  23520. * Gets the number of vertices handled by this manager
  23521. */
  23522. get vertexCount(): number;
  23523. /**
  23524. * Gets a boolean indicating if this manager supports morphing of normals
  23525. */
  23526. get supportsNormals(): boolean;
  23527. /**
  23528. * Gets a boolean indicating if this manager supports morphing of tangents
  23529. */
  23530. get supportsTangents(): boolean;
  23531. /**
  23532. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23533. */
  23534. get supportsUVs(): boolean;
  23535. /**
  23536. * Gets the number of targets stored in this manager
  23537. */
  23538. get numTargets(): number;
  23539. /**
  23540. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23541. */
  23542. get numInfluencers(): number;
  23543. /**
  23544. * Gets the list of influences (one per target)
  23545. */
  23546. get influences(): Float32Array;
  23547. /**
  23548. * Gets the active target at specified index. An active target is a target with an influence > 0
  23549. * @param index defines the index to check
  23550. * @returns the requested target
  23551. */
  23552. getActiveTarget(index: number): MorphTarget;
  23553. /**
  23554. * Gets the target at specified index
  23555. * @param index defines the index to check
  23556. * @returns the requested target
  23557. */
  23558. getTarget(index: number): MorphTarget;
  23559. /**
  23560. * Add a new target to this manager
  23561. * @param target defines the target to add
  23562. */
  23563. addTarget(target: MorphTarget): void;
  23564. /**
  23565. * Removes a target from the manager
  23566. * @param target defines the target to remove
  23567. */
  23568. removeTarget(target: MorphTarget): void;
  23569. /**
  23570. * Clone the current manager
  23571. * @returns a new MorphTargetManager
  23572. */
  23573. clone(): MorphTargetManager;
  23574. /**
  23575. * Serializes the current manager into a Serialization object
  23576. * @returns the serialized object
  23577. */
  23578. serialize(): any;
  23579. private _syncActiveTargets;
  23580. /**
  23581. * Syncrhonize the targets with all the meshes using this morph target manager
  23582. */
  23583. synchronize(): void;
  23584. /**
  23585. * Creates a new MorphTargetManager from serialized data
  23586. * @param serializationObject defines the serialized data
  23587. * @param scene defines the hosting scene
  23588. * @returns the new MorphTargetManager
  23589. */
  23590. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23591. }
  23592. }
  23593. declare module "babylonjs/Meshes/meshLODLevel" {
  23594. import { Mesh } from "babylonjs/Meshes/mesh";
  23595. import { Nullable } from "babylonjs/types";
  23596. /**
  23597. * Class used to represent a specific level of detail of a mesh
  23598. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23599. */
  23600. export class MeshLODLevel {
  23601. /** Defines the distance where this level should start being displayed */
  23602. distance: number;
  23603. /** Defines the mesh to use to render this level */
  23604. mesh: Nullable<Mesh>;
  23605. /**
  23606. * Creates a new LOD level
  23607. * @param distance defines the distance where this level should star being displayed
  23608. * @param mesh defines the mesh to use to render this level
  23609. */
  23610. constructor(
  23611. /** Defines the distance where this level should start being displayed */
  23612. distance: number,
  23613. /** Defines the mesh to use to render this level */
  23614. mesh: Nullable<Mesh>);
  23615. }
  23616. }
  23617. declare module "babylonjs/Meshes/groundMesh" {
  23618. import { Scene } from "babylonjs/scene";
  23619. import { Vector3 } from "babylonjs/Maths/math.vector";
  23620. import { Mesh } from "babylonjs/Meshes/mesh";
  23621. /**
  23622. * Mesh representing the gorund
  23623. */
  23624. export class GroundMesh extends Mesh {
  23625. /** If octree should be generated */
  23626. generateOctree: boolean;
  23627. private _heightQuads;
  23628. /** @hidden */
  23629. _subdivisionsX: number;
  23630. /** @hidden */
  23631. _subdivisionsY: number;
  23632. /** @hidden */
  23633. _width: number;
  23634. /** @hidden */
  23635. _height: number;
  23636. /** @hidden */
  23637. _minX: number;
  23638. /** @hidden */
  23639. _maxX: number;
  23640. /** @hidden */
  23641. _minZ: number;
  23642. /** @hidden */
  23643. _maxZ: number;
  23644. constructor(name: string, scene: Scene);
  23645. /**
  23646. * "GroundMesh"
  23647. * @returns "GroundMesh"
  23648. */
  23649. getClassName(): string;
  23650. /**
  23651. * The minimum of x and y subdivisions
  23652. */
  23653. get subdivisions(): number;
  23654. /**
  23655. * X subdivisions
  23656. */
  23657. get subdivisionsX(): number;
  23658. /**
  23659. * Y subdivisions
  23660. */
  23661. get subdivisionsY(): number;
  23662. /**
  23663. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23664. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23665. * @param chunksCount the number of subdivisions for x and y
  23666. * @param octreeBlocksSize (Default: 32)
  23667. */
  23668. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23669. /**
  23670. * Returns a height (y) value in the Worl system :
  23671. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23672. * @param x x coordinate
  23673. * @param z z coordinate
  23674. * @returns the ground y position if (x, z) are outside the ground surface.
  23675. */
  23676. getHeightAtCoordinates(x: number, z: number): number;
  23677. /**
  23678. * Returns a normalized vector (Vector3) orthogonal to the ground
  23679. * at the ground coordinates (x, z) expressed in the World system.
  23680. * @param x x coordinate
  23681. * @param z z coordinate
  23682. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23683. */
  23684. getNormalAtCoordinates(x: number, z: number): Vector3;
  23685. /**
  23686. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23687. * at the ground coordinates (x, z) expressed in the World system.
  23688. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23689. * @param x x coordinate
  23690. * @param z z coordinate
  23691. * @param ref vector to store the result
  23692. * @returns the GroundMesh.
  23693. */
  23694. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23695. /**
  23696. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23697. * if the ground has been updated.
  23698. * This can be used in the render loop.
  23699. * @returns the GroundMesh.
  23700. */
  23701. updateCoordinateHeights(): GroundMesh;
  23702. private _getFacetAt;
  23703. private _initHeightQuads;
  23704. private _computeHeightQuads;
  23705. /**
  23706. * Serializes this ground mesh
  23707. * @param serializationObject object to write serialization to
  23708. */
  23709. serialize(serializationObject: any): void;
  23710. /**
  23711. * Parses a serialized ground mesh
  23712. * @param parsedMesh the serialized mesh
  23713. * @param scene the scene to create the ground mesh in
  23714. * @returns the created ground mesh
  23715. */
  23716. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23717. }
  23718. }
  23719. declare module "babylonjs/Physics/physicsJoint" {
  23720. import { Vector3 } from "babylonjs/Maths/math.vector";
  23721. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23722. /**
  23723. * Interface for Physics-Joint data
  23724. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23725. */
  23726. export interface PhysicsJointData {
  23727. /**
  23728. * The main pivot of the joint
  23729. */
  23730. mainPivot?: Vector3;
  23731. /**
  23732. * The connected pivot of the joint
  23733. */
  23734. connectedPivot?: Vector3;
  23735. /**
  23736. * The main axis of the joint
  23737. */
  23738. mainAxis?: Vector3;
  23739. /**
  23740. * The connected axis of the joint
  23741. */
  23742. connectedAxis?: Vector3;
  23743. /**
  23744. * The collision of the joint
  23745. */
  23746. collision?: boolean;
  23747. /**
  23748. * Native Oimo/Cannon/Energy data
  23749. */
  23750. nativeParams?: any;
  23751. }
  23752. /**
  23753. * This is a holder class for the physics joint created by the physics plugin
  23754. * It holds a set of functions to control the underlying joint
  23755. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23756. */
  23757. export class PhysicsJoint {
  23758. /**
  23759. * The type of the physics joint
  23760. */
  23761. type: number;
  23762. /**
  23763. * The data for the physics joint
  23764. */
  23765. jointData: PhysicsJointData;
  23766. private _physicsJoint;
  23767. protected _physicsPlugin: IPhysicsEnginePlugin;
  23768. /**
  23769. * Initializes the physics joint
  23770. * @param type The type of the physics joint
  23771. * @param jointData The data for the physics joint
  23772. */
  23773. constructor(
  23774. /**
  23775. * The type of the physics joint
  23776. */
  23777. type: number,
  23778. /**
  23779. * The data for the physics joint
  23780. */
  23781. jointData: PhysicsJointData);
  23782. /**
  23783. * Gets the physics joint
  23784. */
  23785. get physicsJoint(): any;
  23786. /**
  23787. * Sets the physics joint
  23788. */
  23789. set physicsJoint(newJoint: any);
  23790. /**
  23791. * Sets the physics plugin
  23792. */
  23793. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23794. /**
  23795. * Execute a function that is physics-plugin specific.
  23796. * @param {Function} func the function that will be executed.
  23797. * It accepts two parameters: the physics world and the physics joint
  23798. */
  23799. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23800. /**
  23801. * Distance-Joint type
  23802. */
  23803. static DistanceJoint: number;
  23804. /**
  23805. * Hinge-Joint type
  23806. */
  23807. static HingeJoint: number;
  23808. /**
  23809. * Ball-and-Socket joint type
  23810. */
  23811. static BallAndSocketJoint: number;
  23812. /**
  23813. * Wheel-Joint type
  23814. */
  23815. static WheelJoint: number;
  23816. /**
  23817. * Slider-Joint type
  23818. */
  23819. static SliderJoint: number;
  23820. /**
  23821. * Prismatic-Joint type
  23822. */
  23823. static PrismaticJoint: number;
  23824. /**
  23825. * Universal-Joint type
  23826. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23827. */
  23828. static UniversalJoint: number;
  23829. /**
  23830. * Hinge-Joint 2 type
  23831. */
  23832. static Hinge2Joint: number;
  23833. /**
  23834. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23835. */
  23836. static PointToPointJoint: number;
  23837. /**
  23838. * Spring-Joint type
  23839. */
  23840. static SpringJoint: number;
  23841. /**
  23842. * Lock-Joint type
  23843. */
  23844. static LockJoint: number;
  23845. }
  23846. /**
  23847. * A class representing a physics distance joint
  23848. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23849. */
  23850. export class DistanceJoint extends PhysicsJoint {
  23851. /**
  23852. *
  23853. * @param jointData The data for the Distance-Joint
  23854. */
  23855. constructor(jointData: DistanceJointData);
  23856. /**
  23857. * Update the predefined distance.
  23858. * @param maxDistance The maximum preferred distance
  23859. * @param minDistance The minimum preferred distance
  23860. */
  23861. updateDistance(maxDistance: number, minDistance?: number): void;
  23862. }
  23863. /**
  23864. * Represents a Motor-Enabled Joint
  23865. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23866. */
  23867. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23868. /**
  23869. * Initializes the Motor-Enabled Joint
  23870. * @param type The type of the joint
  23871. * @param jointData The physica joint data for the joint
  23872. */
  23873. constructor(type: number, jointData: PhysicsJointData);
  23874. /**
  23875. * Set the motor values.
  23876. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23877. * @param force the force to apply
  23878. * @param maxForce max force for this motor.
  23879. */
  23880. setMotor(force?: number, maxForce?: number): void;
  23881. /**
  23882. * Set the motor's limits.
  23883. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23884. * @param upperLimit The upper limit of the motor
  23885. * @param lowerLimit The lower limit of the motor
  23886. */
  23887. setLimit(upperLimit: number, lowerLimit?: number): void;
  23888. }
  23889. /**
  23890. * This class represents a single physics Hinge-Joint
  23891. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23892. */
  23893. export class HingeJoint extends MotorEnabledJoint {
  23894. /**
  23895. * Initializes the Hinge-Joint
  23896. * @param jointData The joint data for the Hinge-Joint
  23897. */
  23898. constructor(jointData: PhysicsJointData);
  23899. /**
  23900. * Set the motor values.
  23901. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23902. * @param {number} force the force to apply
  23903. * @param {number} maxForce max force for this motor.
  23904. */
  23905. setMotor(force?: number, maxForce?: number): void;
  23906. /**
  23907. * Set the motor's limits.
  23908. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23909. * @param upperLimit The upper limit of the motor
  23910. * @param lowerLimit The lower limit of the motor
  23911. */
  23912. setLimit(upperLimit: number, lowerLimit?: number): void;
  23913. }
  23914. /**
  23915. * This class represents a dual hinge physics joint (same as wheel joint)
  23916. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23917. */
  23918. export class Hinge2Joint extends MotorEnabledJoint {
  23919. /**
  23920. * Initializes the Hinge2-Joint
  23921. * @param jointData The joint data for the Hinge2-Joint
  23922. */
  23923. constructor(jointData: PhysicsJointData);
  23924. /**
  23925. * Set the motor values.
  23926. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23927. * @param {number} targetSpeed the speed the motor is to reach
  23928. * @param {number} maxForce max force for this motor.
  23929. * @param {motorIndex} the motor's index, 0 or 1.
  23930. */
  23931. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23932. /**
  23933. * Set the motor limits.
  23934. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23935. * @param {number} upperLimit the upper limit
  23936. * @param {number} lowerLimit lower limit
  23937. * @param {motorIndex} the motor's index, 0 or 1.
  23938. */
  23939. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23940. }
  23941. /**
  23942. * Interface for a motor enabled joint
  23943. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23944. */
  23945. export interface IMotorEnabledJoint {
  23946. /**
  23947. * Physics joint
  23948. */
  23949. physicsJoint: any;
  23950. /**
  23951. * Sets the motor of the motor-enabled joint
  23952. * @param force The force of the motor
  23953. * @param maxForce The maximum force of the motor
  23954. * @param motorIndex The index of the motor
  23955. */
  23956. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23957. /**
  23958. * Sets the limit of the motor
  23959. * @param upperLimit The upper limit of the motor
  23960. * @param lowerLimit The lower limit of the motor
  23961. * @param motorIndex The index of the motor
  23962. */
  23963. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23964. }
  23965. /**
  23966. * Joint data for a Distance-Joint
  23967. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23968. */
  23969. export interface DistanceJointData extends PhysicsJointData {
  23970. /**
  23971. * Max distance the 2 joint objects can be apart
  23972. */
  23973. maxDistance: number;
  23974. }
  23975. /**
  23976. * Joint data from a spring joint
  23977. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23978. */
  23979. export interface SpringJointData extends PhysicsJointData {
  23980. /**
  23981. * Length of the spring
  23982. */
  23983. length: number;
  23984. /**
  23985. * Stiffness of the spring
  23986. */
  23987. stiffness: number;
  23988. /**
  23989. * Damping of the spring
  23990. */
  23991. damping: number;
  23992. /** this callback will be called when applying the force to the impostors. */
  23993. forceApplicationCallback: () => void;
  23994. }
  23995. }
  23996. declare module "babylonjs/Physics/physicsRaycastResult" {
  23997. import { Vector3 } from "babylonjs/Maths/math.vector";
  23998. /**
  23999. * Holds the data for the raycast result
  24000. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24001. */
  24002. export class PhysicsRaycastResult {
  24003. private _hasHit;
  24004. private _hitDistance;
  24005. private _hitNormalWorld;
  24006. private _hitPointWorld;
  24007. private _rayFromWorld;
  24008. private _rayToWorld;
  24009. /**
  24010. * Gets if there was a hit
  24011. */
  24012. get hasHit(): boolean;
  24013. /**
  24014. * Gets the distance from the hit
  24015. */
  24016. get hitDistance(): number;
  24017. /**
  24018. * Gets the hit normal/direction in the world
  24019. */
  24020. get hitNormalWorld(): Vector3;
  24021. /**
  24022. * Gets the hit point in the world
  24023. */
  24024. get hitPointWorld(): Vector3;
  24025. /**
  24026. * Gets the ray "start point" of the ray in the world
  24027. */
  24028. get rayFromWorld(): Vector3;
  24029. /**
  24030. * Gets the ray "end point" of the ray in the world
  24031. */
  24032. get rayToWorld(): Vector3;
  24033. /**
  24034. * Sets the hit data (normal & point in world space)
  24035. * @param hitNormalWorld defines the normal in world space
  24036. * @param hitPointWorld defines the point in world space
  24037. */
  24038. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  24039. /**
  24040. * Sets the distance from the start point to the hit point
  24041. * @param distance
  24042. */
  24043. setHitDistance(distance: number): void;
  24044. /**
  24045. * Calculates the distance manually
  24046. */
  24047. calculateHitDistance(): void;
  24048. /**
  24049. * Resets all the values to default
  24050. * @param from The from point on world space
  24051. * @param to The to point on world space
  24052. */
  24053. reset(from?: Vector3, to?: Vector3): void;
  24054. }
  24055. /**
  24056. * Interface for the size containing width and height
  24057. */
  24058. interface IXYZ {
  24059. /**
  24060. * X
  24061. */
  24062. x: number;
  24063. /**
  24064. * Y
  24065. */
  24066. y: number;
  24067. /**
  24068. * Z
  24069. */
  24070. z: number;
  24071. }
  24072. }
  24073. declare module "babylonjs/Physics/IPhysicsEngine" {
  24074. import { Nullable } from "babylonjs/types";
  24075. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  24076. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24077. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24078. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  24079. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  24080. /**
  24081. * Interface used to describe a physics joint
  24082. */
  24083. export interface PhysicsImpostorJoint {
  24084. /** Defines the main impostor to which the joint is linked */
  24085. mainImpostor: PhysicsImpostor;
  24086. /** Defines the impostor that is connected to the main impostor using this joint */
  24087. connectedImpostor: PhysicsImpostor;
  24088. /** Defines the joint itself */
  24089. joint: PhysicsJoint;
  24090. }
  24091. /** @hidden */
  24092. export interface IPhysicsEnginePlugin {
  24093. world: any;
  24094. name: string;
  24095. setGravity(gravity: Vector3): void;
  24096. setTimeStep(timeStep: number): void;
  24097. getTimeStep(): number;
  24098. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  24099. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24100. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24101. generatePhysicsBody(impostor: PhysicsImpostor): void;
  24102. removePhysicsBody(impostor: PhysicsImpostor): void;
  24103. generateJoint(joint: PhysicsImpostorJoint): void;
  24104. removeJoint(joint: PhysicsImpostorJoint): void;
  24105. isSupported(): boolean;
  24106. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  24107. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  24108. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24109. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24110. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24111. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24112. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  24113. getBodyMass(impostor: PhysicsImpostor): number;
  24114. getBodyFriction(impostor: PhysicsImpostor): number;
  24115. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  24116. getBodyRestitution(impostor: PhysicsImpostor): number;
  24117. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  24118. getBodyPressure?(impostor: PhysicsImpostor): number;
  24119. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  24120. getBodyStiffness?(impostor: PhysicsImpostor): number;
  24121. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  24122. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  24123. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  24124. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  24125. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  24126. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24127. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24128. sleepBody(impostor: PhysicsImpostor): void;
  24129. wakeUpBody(impostor: PhysicsImpostor): void;
  24130. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24131. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  24132. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  24133. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24134. getRadius(impostor: PhysicsImpostor): number;
  24135. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  24136. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  24137. dispose(): void;
  24138. }
  24139. /**
  24140. * Interface used to define a physics engine
  24141. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  24142. */
  24143. export interface IPhysicsEngine {
  24144. /**
  24145. * Gets the gravity vector used by the simulation
  24146. */
  24147. gravity: Vector3;
  24148. /**
  24149. * Sets the gravity vector used by the simulation
  24150. * @param gravity defines the gravity vector to use
  24151. */
  24152. setGravity(gravity: Vector3): void;
  24153. /**
  24154. * Set the time step of the physics engine.
  24155. * Default is 1/60.
  24156. * To slow it down, enter 1/600 for example.
  24157. * To speed it up, 1/30
  24158. * @param newTimeStep the new timestep to apply to this world.
  24159. */
  24160. setTimeStep(newTimeStep: number): void;
  24161. /**
  24162. * Get the time step of the physics engine.
  24163. * @returns the current time step
  24164. */
  24165. getTimeStep(): number;
  24166. /**
  24167. * Set the sub time step of the physics engine.
  24168. * Default is 0 meaning there is no sub steps
  24169. * To increase physics resolution precision, set a small value (like 1 ms)
  24170. * @param subTimeStep defines the new sub timestep used for physics resolution.
  24171. */
  24172. setSubTimeStep(subTimeStep: number): void;
  24173. /**
  24174. * Get the sub time step of the physics engine.
  24175. * @returns the current sub time step
  24176. */
  24177. getSubTimeStep(): number;
  24178. /**
  24179. * Release all resources
  24180. */
  24181. dispose(): void;
  24182. /**
  24183. * Gets the name of the current physics plugin
  24184. * @returns the name of the plugin
  24185. */
  24186. getPhysicsPluginName(): string;
  24187. /**
  24188. * Adding a new impostor for the impostor tracking.
  24189. * This will be done by the impostor itself.
  24190. * @param impostor the impostor to add
  24191. */
  24192. addImpostor(impostor: PhysicsImpostor): void;
  24193. /**
  24194. * Remove an impostor from the engine.
  24195. * This impostor and its mesh will not longer be updated by the physics engine.
  24196. * @param impostor the impostor to remove
  24197. */
  24198. removeImpostor(impostor: PhysicsImpostor): void;
  24199. /**
  24200. * Add a joint to the physics engine
  24201. * @param mainImpostor defines the main impostor to which the joint is added.
  24202. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  24203. * @param joint defines the joint that will connect both impostors.
  24204. */
  24205. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24206. /**
  24207. * Removes a joint from the simulation
  24208. * @param mainImpostor defines the impostor used with the joint
  24209. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  24210. * @param joint defines the joint to remove
  24211. */
  24212. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24213. /**
  24214. * Gets the current plugin used to run the simulation
  24215. * @returns current plugin
  24216. */
  24217. getPhysicsPlugin(): IPhysicsEnginePlugin;
  24218. /**
  24219. * Gets the list of physic impostors
  24220. * @returns an array of PhysicsImpostor
  24221. */
  24222. getImpostors(): Array<PhysicsImpostor>;
  24223. /**
  24224. * Gets the impostor for a physics enabled object
  24225. * @param object defines the object impersonated by the impostor
  24226. * @returns the PhysicsImpostor or null if not found
  24227. */
  24228. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24229. /**
  24230. * Gets the impostor for a physics body object
  24231. * @param body defines physics body used by the impostor
  24232. * @returns the PhysicsImpostor or null if not found
  24233. */
  24234. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24235. /**
  24236. * Does a raycast in the physics world
  24237. * @param from when should the ray start?
  24238. * @param to when should the ray end?
  24239. * @returns PhysicsRaycastResult
  24240. */
  24241. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24242. /**
  24243. * Called by the scene. No need to call it.
  24244. * @param delta defines the timespam between frames
  24245. */
  24246. _step(delta: number): void;
  24247. }
  24248. }
  24249. declare module "babylonjs/Physics/physicsImpostor" {
  24250. import { Nullable, IndicesArray } from "babylonjs/types";
  24251. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  24252. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24253. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24254. import { Scene } from "babylonjs/scene";
  24255. import { Bone } from "babylonjs/Bones/bone";
  24256. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24257. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  24258. import { Space } from "babylonjs/Maths/math.axis";
  24259. /**
  24260. * The interface for the physics imposter parameters
  24261. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24262. */
  24263. export interface PhysicsImpostorParameters {
  24264. /**
  24265. * The mass of the physics imposter
  24266. */
  24267. mass: number;
  24268. /**
  24269. * The friction of the physics imposter
  24270. */
  24271. friction?: number;
  24272. /**
  24273. * The coefficient of restitution of the physics imposter
  24274. */
  24275. restitution?: number;
  24276. /**
  24277. * The native options of the physics imposter
  24278. */
  24279. nativeOptions?: any;
  24280. /**
  24281. * Specifies if the parent should be ignored
  24282. */
  24283. ignoreParent?: boolean;
  24284. /**
  24285. * Specifies if bi-directional transformations should be disabled
  24286. */
  24287. disableBidirectionalTransformation?: boolean;
  24288. /**
  24289. * The pressure inside the physics imposter, soft object only
  24290. */
  24291. pressure?: number;
  24292. /**
  24293. * The stiffness the physics imposter, soft object only
  24294. */
  24295. stiffness?: number;
  24296. /**
  24297. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  24298. */
  24299. velocityIterations?: number;
  24300. /**
  24301. * The number of iterations used in maintaining consistent vertex positions, soft object only
  24302. */
  24303. positionIterations?: number;
  24304. /**
  24305. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  24306. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  24307. * Add to fix multiple points
  24308. */
  24309. fixedPoints?: number;
  24310. /**
  24311. * The collision margin around a soft object
  24312. */
  24313. margin?: number;
  24314. /**
  24315. * The collision margin around a soft object
  24316. */
  24317. damping?: number;
  24318. /**
  24319. * The path for a rope based on an extrusion
  24320. */
  24321. path?: any;
  24322. /**
  24323. * The shape of an extrusion used for a rope based on an extrusion
  24324. */
  24325. shape?: any;
  24326. }
  24327. /**
  24328. * Interface for a physics-enabled object
  24329. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24330. */
  24331. export interface IPhysicsEnabledObject {
  24332. /**
  24333. * The position of the physics-enabled object
  24334. */
  24335. position: Vector3;
  24336. /**
  24337. * The rotation of the physics-enabled object
  24338. */
  24339. rotationQuaternion: Nullable<Quaternion>;
  24340. /**
  24341. * The scale of the physics-enabled object
  24342. */
  24343. scaling: Vector3;
  24344. /**
  24345. * The rotation of the physics-enabled object
  24346. */
  24347. rotation?: Vector3;
  24348. /**
  24349. * The parent of the physics-enabled object
  24350. */
  24351. parent?: any;
  24352. /**
  24353. * The bounding info of the physics-enabled object
  24354. * @returns The bounding info of the physics-enabled object
  24355. */
  24356. getBoundingInfo(): BoundingInfo;
  24357. /**
  24358. * Computes the world matrix
  24359. * @param force Specifies if the world matrix should be computed by force
  24360. * @returns A world matrix
  24361. */
  24362. computeWorldMatrix(force: boolean): Matrix;
  24363. /**
  24364. * Gets the world matrix
  24365. * @returns A world matrix
  24366. */
  24367. getWorldMatrix?(): Matrix;
  24368. /**
  24369. * Gets the child meshes
  24370. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24371. * @returns An array of abstract meshes
  24372. */
  24373. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24374. /**
  24375. * Gets the vertex data
  24376. * @param kind The type of vertex data
  24377. * @returns A nullable array of numbers, or a float32 array
  24378. */
  24379. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24380. /**
  24381. * Gets the indices from the mesh
  24382. * @returns A nullable array of index arrays
  24383. */
  24384. getIndices?(): Nullable<IndicesArray>;
  24385. /**
  24386. * Gets the scene from the mesh
  24387. * @returns the indices array or null
  24388. */
  24389. getScene?(): Scene;
  24390. /**
  24391. * Gets the absolute position from the mesh
  24392. * @returns the absolute position
  24393. */
  24394. getAbsolutePosition(): Vector3;
  24395. /**
  24396. * Gets the absolute pivot point from the mesh
  24397. * @returns the absolute pivot point
  24398. */
  24399. getAbsolutePivotPoint(): Vector3;
  24400. /**
  24401. * Rotates the mesh
  24402. * @param axis The axis of rotation
  24403. * @param amount The amount of rotation
  24404. * @param space The space of the rotation
  24405. * @returns The rotation transform node
  24406. */
  24407. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24408. /**
  24409. * Translates the mesh
  24410. * @param axis The axis of translation
  24411. * @param distance The distance of translation
  24412. * @param space The space of the translation
  24413. * @returns The transform node
  24414. */
  24415. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24416. /**
  24417. * Sets the absolute position of the mesh
  24418. * @param absolutePosition The absolute position of the mesh
  24419. * @returns The transform node
  24420. */
  24421. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24422. /**
  24423. * Gets the class name of the mesh
  24424. * @returns The class name
  24425. */
  24426. getClassName(): string;
  24427. }
  24428. /**
  24429. * Represents a physics imposter
  24430. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24431. */
  24432. export class PhysicsImpostor {
  24433. /**
  24434. * The physics-enabled object used as the physics imposter
  24435. */
  24436. object: IPhysicsEnabledObject;
  24437. /**
  24438. * The type of the physics imposter
  24439. */
  24440. type: number;
  24441. private _options;
  24442. private _scene?;
  24443. /**
  24444. * The default object size of the imposter
  24445. */
  24446. static DEFAULT_OBJECT_SIZE: Vector3;
  24447. /**
  24448. * The identity quaternion of the imposter
  24449. */
  24450. static IDENTITY_QUATERNION: Quaternion;
  24451. /** @hidden */
  24452. _pluginData: any;
  24453. private _physicsEngine;
  24454. private _physicsBody;
  24455. private _bodyUpdateRequired;
  24456. private _onBeforePhysicsStepCallbacks;
  24457. private _onAfterPhysicsStepCallbacks;
  24458. /** @hidden */
  24459. _onPhysicsCollideCallbacks: Array<{
  24460. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24461. otherImpostors: Array<PhysicsImpostor>;
  24462. }>;
  24463. private _deltaPosition;
  24464. private _deltaRotation;
  24465. private _deltaRotationConjugated;
  24466. /** @hidden */
  24467. _isFromLine: boolean;
  24468. private _parent;
  24469. private _isDisposed;
  24470. private static _tmpVecs;
  24471. private static _tmpQuat;
  24472. /**
  24473. * Specifies if the physics imposter is disposed
  24474. */
  24475. get isDisposed(): boolean;
  24476. /**
  24477. * Gets the mass of the physics imposter
  24478. */
  24479. get mass(): number;
  24480. set mass(value: number);
  24481. /**
  24482. * Gets the coefficient of friction
  24483. */
  24484. get friction(): number;
  24485. /**
  24486. * Sets the coefficient of friction
  24487. */
  24488. set friction(value: number);
  24489. /**
  24490. * Gets the coefficient of restitution
  24491. */
  24492. get restitution(): number;
  24493. /**
  24494. * Sets the coefficient of restitution
  24495. */
  24496. set restitution(value: number);
  24497. /**
  24498. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24499. */
  24500. get pressure(): number;
  24501. /**
  24502. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24503. */
  24504. set pressure(value: number);
  24505. /**
  24506. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24507. */
  24508. get stiffness(): number;
  24509. /**
  24510. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24511. */
  24512. set stiffness(value: number);
  24513. /**
  24514. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24515. */
  24516. get velocityIterations(): number;
  24517. /**
  24518. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24519. */
  24520. set velocityIterations(value: number);
  24521. /**
  24522. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24523. */
  24524. get positionIterations(): number;
  24525. /**
  24526. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24527. */
  24528. set positionIterations(value: number);
  24529. /**
  24530. * The unique id of the physics imposter
  24531. * set by the physics engine when adding this impostor to the array
  24532. */
  24533. uniqueId: number;
  24534. /**
  24535. * @hidden
  24536. */
  24537. soft: boolean;
  24538. /**
  24539. * @hidden
  24540. */
  24541. segments: number;
  24542. private _joints;
  24543. /**
  24544. * Initializes the physics imposter
  24545. * @param object The physics-enabled object used as the physics imposter
  24546. * @param type The type of the physics imposter
  24547. * @param _options The options for the physics imposter
  24548. * @param _scene The Babylon scene
  24549. */
  24550. constructor(
  24551. /**
  24552. * The physics-enabled object used as the physics imposter
  24553. */
  24554. object: IPhysicsEnabledObject,
  24555. /**
  24556. * The type of the physics imposter
  24557. */
  24558. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24559. /**
  24560. * This function will completly initialize this impostor.
  24561. * It will create a new body - but only if this mesh has no parent.
  24562. * If it has, this impostor will not be used other than to define the impostor
  24563. * of the child mesh.
  24564. * @hidden
  24565. */
  24566. _init(): void;
  24567. private _getPhysicsParent;
  24568. /**
  24569. * Should a new body be generated.
  24570. * @returns boolean specifying if body initialization is required
  24571. */
  24572. isBodyInitRequired(): boolean;
  24573. /**
  24574. * Sets the updated scaling
  24575. * @param updated Specifies if the scaling is updated
  24576. */
  24577. setScalingUpdated(): void;
  24578. /**
  24579. * Force a regeneration of this or the parent's impostor's body.
  24580. * Use under cautious - This will remove all joints already implemented.
  24581. */
  24582. forceUpdate(): void;
  24583. /**
  24584. * Gets the body that holds this impostor. Either its own, or its parent.
  24585. */
  24586. get physicsBody(): any;
  24587. /**
  24588. * Get the parent of the physics imposter
  24589. * @returns Physics imposter or null
  24590. */
  24591. get parent(): Nullable<PhysicsImpostor>;
  24592. /**
  24593. * Sets the parent of the physics imposter
  24594. */
  24595. set parent(value: Nullable<PhysicsImpostor>);
  24596. /**
  24597. * Set the physics body. Used mainly by the physics engine/plugin
  24598. */
  24599. set physicsBody(physicsBody: any);
  24600. /**
  24601. * Resets the update flags
  24602. */
  24603. resetUpdateFlags(): void;
  24604. /**
  24605. * Gets the object extend size
  24606. * @returns the object extend size
  24607. */
  24608. getObjectExtendSize(): Vector3;
  24609. /**
  24610. * Gets the object center
  24611. * @returns The object center
  24612. */
  24613. getObjectCenter(): Vector3;
  24614. /**
  24615. * Get a specific parameter from the options parameters
  24616. * @param paramName The object parameter name
  24617. * @returns The object parameter
  24618. */
  24619. getParam(paramName: string): any;
  24620. /**
  24621. * Sets a specific parameter in the options given to the physics plugin
  24622. * @param paramName The parameter name
  24623. * @param value The value of the parameter
  24624. */
  24625. setParam(paramName: string, value: number): void;
  24626. /**
  24627. * Specifically change the body's mass option. Won't recreate the physics body object
  24628. * @param mass The mass of the physics imposter
  24629. */
  24630. setMass(mass: number): void;
  24631. /**
  24632. * Gets the linear velocity
  24633. * @returns linear velocity or null
  24634. */
  24635. getLinearVelocity(): Nullable<Vector3>;
  24636. /**
  24637. * Sets the linear velocity
  24638. * @param velocity linear velocity or null
  24639. */
  24640. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24641. /**
  24642. * Gets the angular velocity
  24643. * @returns angular velocity or null
  24644. */
  24645. getAngularVelocity(): Nullable<Vector3>;
  24646. /**
  24647. * Sets the angular velocity
  24648. * @param velocity The velocity or null
  24649. */
  24650. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24651. /**
  24652. * Execute a function with the physics plugin native code
  24653. * Provide a function the will have two variables - the world object and the physics body object
  24654. * @param func The function to execute with the physics plugin native code
  24655. */
  24656. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24657. /**
  24658. * Register a function that will be executed before the physics world is stepping forward
  24659. * @param func The function to execute before the physics world is stepped forward
  24660. */
  24661. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24662. /**
  24663. * Unregister a function that will be executed before the physics world is stepping forward
  24664. * @param func The function to execute before the physics world is stepped forward
  24665. */
  24666. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24667. /**
  24668. * Register a function that will be executed after the physics step
  24669. * @param func The function to execute after physics step
  24670. */
  24671. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24672. /**
  24673. * Unregisters a function that will be executed after the physics step
  24674. * @param func The function to execute after physics step
  24675. */
  24676. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24677. /**
  24678. * register a function that will be executed when this impostor collides against a different body
  24679. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24680. * @param func Callback that is executed on collision
  24681. */
  24682. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24683. /**
  24684. * Unregisters the physics imposter on contact
  24685. * @param collideAgainst The physics object to collide against
  24686. * @param func Callback to execute on collision
  24687. */
  24688. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24689. private _tmpQuat;
  24690. private _tmpQuat2;
  24691. /**
  24692. * Get the parent rotation
  24693. * @returns The parent rotation
  24694. */
  24695. getParentsRotation(): Quaternion;
  24696. /**
  24697. * this function is executed by the physics engine.
  24698. */
  24699. beforeStep: () => void;
  24700. /**
  24701. * this function is executed by the physics engine
  24702. */
  24703. afterStep: () => void;
  24704. /**
  24705. * Legacy collision detection event support
  24706. */
  24707. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24708. /**
  24709. * event and body object due to cannon's event-based architecture.
  24710. */
  24711. onCollide: (e: {
  24712. body: any;
  24713. }) => void;
  24714. /**
  24715. * Apply a force
  24716. * @param force The force to apply
  24717. * @param contactPoint The contact point for the force
  24718. * @returns The physics imposter
  24719. */
  24720. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24721. /**
  24722. * Apply an impulse
  24723. * @param force The impulse force
  24724. * @param contactPoint The contact point for the impulse force
  24725. * @returns The physics imposter
  24726. */
  24727. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24728. /**
  24729. * A help function to create a joint
  24730. * @param otherImpostor A physics imposter used to create a joint
  24731. * @param jointType The type of joint
  24732. * @param jointData The data for the joint
  24733. * @returns The physics imposter
  24734. */
  24735. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24736. /**
  24737. * Add a joint to this impostor with a different impostor
  24738. * @param otherImpostor A physics imposter used to add a joint
  24739. * @param joint The joint to add
  24740. * @returns The physics imposter
  24741. */
  24742. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24743. /**
  24744. * Add an anchor to a cloth impostor
  24745. * @param otherImpostor rigid impostor to anchor to
  24746. * @param width ratio across width from 0 to 1
  24747. * @param height ratio up height from 0 to 1
  24748. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24749. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24750. * @returns impostor the soft imposter
  24751. */
  24752. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24753. /**
  24754. * Add a hook to a rope impostor
  24755. * @param otherImpostor rigid impostor to anchor to
  24756. * @param length ratio across rope from 0 to 1
  24757. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24758. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24759. * @returns impostor the rope imposter
  24760. */
  24761. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24762. /**
  24763. * Will keep this body still, in a sleep mode.
  24764. * @returns the physics imposter
  24765. */
  24766. sleep(): PhysicsImpostor;
  24767. /**
  24768. * Wake the body up.
  24769. * @returns The physics imposter
  24770. */
  24771. wakeUp(): PhysicsImpostor;
  24772. /**
  24773. * Clones the physics imposter
  24774. * @param newObject The physics imposter clones to this physics-enabled object
  24775. * @returns A nullable physics imposter
  24776. */
  24777. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24778. /**
  24779. * Disposes the physics imposter
  24780. */
  24781. dispose(): void;
  24782. /**
  24783. * Sets the delta position
  24784. * @param position The delta position amount
  24785. */
  24786. setDeltaPosition(position: Vector3): void;
  24787. /**
  24788. * Sets the delta rotation
  24789. * @param rotation The delta rotation amount
  24790. */
  24791. setDeltaRotation(rotation: Quaternion): void;
  24792. /**
  24793. * Gets the box size of the physics imposter and stores the result in the input parameter
  24794. * @param result Stores the box size
  24795. * @returns The physics imposter
  24796. */
  24797. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24798. /**
  24799. * Gets the radius of the physics imposter
  24800. * @returns Radius of the physics imposter
  24801. */
  24802. getRadius(): number;
  24803. /**
  24804. * Sync a bone with this impostor
  24805. * @param bone The bone to sync to the impostor.
  24806. * @param boneMesh The mesh that the bone is influencing.
  24807. * @param jointPivot The pivot of the joint / bone in local space.
  24808. * @param distToJoint Optional distance from the impostor to the joint.
  24809. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24810. */
  24811. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24812. /**
  24813. * Sync impostor to a bone
  24814. * @param bone The bone that the impostor will be synced to.
  24815. * @param boneMesh The mesh that the bone is influencing.
  24816. * @param jointPivot The pivot of the joint / bone in local space.
  24817. * @param distToJoint Optional distance from the impostor to the joint.
  24818. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24819. * @param boneAxis Optional vector3 axis the bone is aligned with
  24820. */
  24821. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24822. /**
  24823. * No-Imposter type
  24824. */
  24825. static NoImpostor: number;
  24826. /**
  24827. * Sphere-Imposter type
  24828. */
  24829. static SphereImpostor: number;
  24830. /**
  24831. * Box-Imposter type
  24832. */
  24833. static BoxImpostor: number;
  24834. /**
  24835. * Plane-Imposter type
  24836. */
  24837. static PlaneImpostor: number;
  24838. /**
  24839. * Mesh-imposter type
  24840. */
  24841. static MeshImpostor: number;
  24842. /**
  24843. * Capsule-Impostor type (Ammo.js plugin only)
  24844. */
  24845. static CapsuleImpostor: number;
  24846. /**
  24847. * Cylinder-Imposter type
  24848. */
  24849. static CylinderImpostor: number;
  24850. /**
  24851. * Particle-Imposter type
  24852. */
  24853. static ParticleImpostor: number;
  24854. /**
  24855. * Heightmap-Imposter type
  24856. */
  24857. static HeightmapImpostor: number;
  24858. /**
  24859. * ConvexHull-Impostor type (Ammo.js plugin only)
  24860. */
  24861. static ConvexHullImpostor: number;
  24862. /**
  24863. * Custom-Imposter type (Ammo.js plugin only)
  24864. */
  24865. static CustomImpostor: number;
  24866. /**
  24867. * Rope-Imposter type
  24868. */
  24869. static RopeImpostor: number;
  24870. /**
  24871. * Cloth-Imposter type
  24872. */
  24873. static ClothImpostor: number;
  24874. /**
  24875. * Softbody-Imposter type
  24876. */
  24877. static SoftbodyImpostor: number;
  24878. }
  24879. }
  24880. declare module "babylonjs/Meshes/mesh" {
  24881. import { Observable } from "babylonjs/Misc/observable";
  24882. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24883. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24884. import { Camera } from "babylonjs/Cameras/camera";
  24885. import { Scene } from "babylonjs/scene";
  24886. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24887. import { Color4 } from "babylonjs/Maths/math.color";
  24888. import { Engine } from "babylonjs/Engines/engine";
  24889. import { Node } from "babylonjs/node";
  24890. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24891. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24892. import { Buffer } from "babylonjs/Meshes/buffer";
  24893. import { Geometry } from "babylonjs/Meshes/geometry";
  24894. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24895. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24896. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24897. import { Effect } from "babylonjs/Materials/effect";
  24898. import { Material } from "babylonjs/Materials/material";
  24899. import { Skeleton } from "babylonjs/Bones/skeleton";
  24900. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24901. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24902. import { Path3D } from "babylonjs/Maths/math.path";
  24903. import { Plane } from "babylonjs/Maths/math.plane";
  24904. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24905. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24906. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24907. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24908. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24909. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24910. /**
  24911. * @hidden
  24912. **/
  24913. export class _CreationDataStorage {
  24914. closePath?: boolean;
  24915. closeArray?: boolean;
  24916. idx: number[];
  24917. dashSize: number;
  24918. gapSize: number;
  24919. path3D: Path3D;
  24920. pathArray: Vector3[][];
  24921. arc: number;
  24922. radius: number;
  24923. cap: number;
  24924. tessellation: number;
  24925. }
  24926. /**
  24927. * @hidden
  24928. **/
  24929. class _InstanceDataStorage {
  24930. visibleInstances: any;
  24931. batchCache: _InstancesBatch;
  24932. instancesBufferSize: number;
  24933. instancesBuffer: Nullable<Buffer>;
  24934. instancesData: Float32Array;
  24935. overridenInstanceCount: number;
  24936. isFrozen: boolean;
  24937. previousBatch: Nullable<_InstancesBatch>;
  24938. hardwareInstancedRendering: boolean;
  24939. sideOrientation: number;
  24940. manualUpdate: boolean;
  24941. }
  24942. /**
  24943. * @hidden
  24944. **/
  24945. export class _InstancesBatch {
  24946. mustReturn: boolean;
  24947. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24948. renderSelf: boolean[];
  24949. hardwareInstancedRendering: boolean[];
  24950. }
  24951. /**
  24952. * Class used to represent renderable models
  24953. */
  24954. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24955. /**
  24956. * Mesh side orientation : usually the external or front surface
  24957. */
  24958. static readonly FRONTSIDE: number;
  24959. /**
  24960. * Mesh side orientation : usually the internal or back surface
  24961. */
  24962. static readonly BACKSIDE: number;
  24963. /**
  24964. * Mesh side orientation : both internal and external or front and back surfaces
  24965. */
  24966. static readonly DOUBLESIDE: number;
  24967. /**
  24968. * Mesh side orientation : by default, `FRONTSIDE`
  24969. */
  24970. static readonly DEFAULTSIDE: number;
  24971. /**
  24972. * Mesh cap setting : no cap
  24973. */
  24974. static readonly NO_CAP: number;
  24975. /**
  24976. * Mesh cap setting : one cap at the beginning of the mesh
  24977. */
  24978. static readonly CAP_START: number;
  24979. /**
  24980. * Mesh cap setting : one cap at the end of the mesh
  24981. */
  24982. static readonly CAP_END: number;
  24983. /**
  24984. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24985. */
  24986. static readonly CAP_ALL: number;
  24987. /**
  24988. * Mesh pattern setting : no flip or rotate
  24989. */
  24990. static readonly NO_FLIP: number;
  24991. /**
  24992. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24993. */
  24994. static readonly FLIP_TILE: number;
  24995. /**
  24996. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24997. */
  24998. static readonly ROTATE_TILE: number;
  24999. /**
  25000. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  25001. */
  25002. static readonly FLIP_ROW: number;
  25003. /**
  25004. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  25005. */
  25006. static readonly ROTATE_ROW: number;
  25007. /**
  25008. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  25009. */
  25010. static readonly FLIP_N_ROTATE_TILE: number;
  25011. /**
  25012. * Mesh pattern setting : rotate pattern and rotate
  25013. */
  25014. static readonly FLIP_N_ROTATE_ROW: number;
  25015. /**
  25016. * Mesh tile positioning : part tiles same on left/right or top/bottom
  25017. */
  25018. static readonly CENTER: number;
  25019. /**
  25020. * Mesh tile positioning : part tiles on left
  25021. */
  25022. static readonly LEFT: number;
  25023. /**
  25024. * Mesh tile positioning : part tiles on right
  25025. */
  25026. static readonly RIGHT: number;
  25027. /**
  25028. * Mesh tile positioning : part tiles on top
  25029. */
  25030. static readonly TOP: number;
  25031. /**
  25032. * Mesh tile positioning : part tiles on bottom
  25033. */
  25034. static readonly BOTTOM: number;
  25035. /**
  25036. * Gets the default side orientation.
  25037. * @param orientation the orientation to value to attempt to get
  25038. * @returns the default orientation
  25039. * @hidden
  25040. */
  25041. static _GetDefaultSideOrientation(orientation?: number): number;
  25042. private _internalMeshDataInfo;
  25043. /**
  25044. * An event triggered before rendering the mesh
  25045. */
  25046. get onBeforeRenderObservable(): Observable<Mesh>;
  25047. /**
  25048. * An event triggered before binding the mesh
  25049. */
  25050. get onBeforeBindObservable(): Observable<Mesh>;
  25051. /**
  25052. * An event triggered after rendering the mesh
  25053. */
  25054. get onAfterRenderObservable(): Observable<Mesh>;
  25055. /**
  25056. * An event triggered before drawing the mesh
  25057. */
  25058. get onBeforeDrawObservable(): Observable<Mesh>;
  25059. private _onBeforeDrawObserver;
  25060. /**
  25061. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  25062. */
  25063. set onBeforeDraw(callback: () => void);
  25064. get hasInstances(): boolean;
  25065. /**
  25066. * Gets the delay loading state of the mesh (when delay loading is turned on)
  25067. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  25068. */
  25069. delayLoadState: number;
  25070. /**
  25071. * Gets the list of instances created from this mesh
  25072. * it is not supposed to be modified manually.
  25073. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  25074. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25075. */
  25076. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  25077. /**
  25078. * Gets the file containing delay loading data for this mesh
  25079. */
  25080. delayLoadingFile: string;
  25081. /** @hidden */
  25082. _binaryInfo: any;
  25083. /**
  25084. * User defined function used to change how LOD level selection is done
  25085. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25086. */
  25087. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  25088. /**
  25089. * Gets or sets the morph target manager
  25090. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25091. */
  25092. get morphTargetManager(): Nullable<MorphTargetManager>;
  25093. set morphTargetManager(value: Nullable<MorphTargetManager>);
  25094. /** @hidden */
  25095. _creationDataStorage: Nullable<_CreationDataStorage>;
  25096. /** @hidden */
  25097. _geometry: Nullable<Geometry>;
  25098. /** @hidden */
  25099. _delayInfo: Array<string>;
  25100. /** @hidden */
  25101. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  25102. /** @hidden */
  25103. _instanceDataStorage: _InstanceDataStorage;
  25104. private _effectiveMaterial;
  25105. /** @hidden */
  25106. _shouldGenerateFlatShading: boolean;
  25107. /** @hidden */
  25108. _originalBuilderSideOrientation: number;
  25109. /**
  25110. * Use this property to change the original side orientation defined at construction time
  25111. */
  25112. overrideMaterialSideOrientation: Nullable<number>;
  25113. /**
  25114. * Gets the source mesh (the one used to clone this one from)
  25115. */
  25116. get source(): Nullable<Mesh>;
  25117. /**
  25118. * Gets or sets a boolean indicating that this mesh does not use index buffer
  25119. */
  25120. get isUnIndexed(): boolean;
  25121. set isUnIndexed(value: boolean);
  25122. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  25123. get worldMatrixInstancedBuffer(): Float32Array;
  25124. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  25125. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  25126. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  25127. /**
  25128. * @constructor
  25129. * @param name The value used by scene.getMeshByName() to do a lookup.
  25130. * @param scene The scene to add this mesh to.
  25131. * @param parent The parent of this mesh, if it has one
  25132. * @param source An optional Mesh from which geometry is shared, cloned.
  25133. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  25134. * When false, achieved by calling a clone(), also passing False.
  25135. * This will make creation of children, recursive.
  25136. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  25137. */
  25138. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  25139. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  25140. doNotInstantiate: boolean;
  25141. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  25142. /**
  25143. * Gets the class name
  25144. * @returns the string "Mesh".
  25145. */
  25146. getClassName(): string;
  25147. /** @hidden */
  25148. get _isMesh(): boolean;
  25149. /**
  25150. * Returns a description of this mesh
  25151. * @param fullDetails define if full details about this mesh must be used
  25152. * @returns a descriptive string representing this mesh
  25153. */
  25154. toString(fullDetails?: boolean): string;
  25155. /** @hidden */
  25156. _unBindEffect(): void;
  25157. /**
  25158. * Gets a boolean indicating if this mesh has LOD
  25159. */
  25160. get hasLODLevels(): boolean;
  25161. /**
  25162. * Gets the list of MeshLODLevel associated with the current mesh
  25163. * @returns an array of MeshLODLevel
  25164. */
  25165. getLODLevels(): MeshLODLevel[];
  25166. private _sortLODLevels;
  25167. /**
  25168. * Add a mesh as LOD level triggered at the given distance.
  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. * @param mesh The mesh to be added as LOD level (can be null)
  25172. * @return This mesh (for chaining)
  25173. */
  25174. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  25175. /**
  25176. * Returns the LOD level mesh at the passed distance or null if not found.
  25177. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25178. * @param distance The distance from the center of the object to show this level
  25179. * @returns a Mesh or `null`
  25180. */
  25181. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  25182. /**
  25183. * Remove a mesh from the LOD array
  25184. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25185. * @param mesh defines the mesh to be removed
  25186. * @return This mesh (for chaining)
  25187. */
  25188. removeLODLevel(mesh: Mesh): Mesh;
  25189. /**
  25190. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  25191. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25192. * @param camera defines the camera to use to compute distance
  25193. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  25194. * @return This mesh (for chaining)
  25195. */
  25196. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  25197. /**
  25198. * Gets the mesh internal Geometry object
  25199. */
  25200. get geometry(): Nullable<Geometry>;
  25201. /**
  25202. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  25203. * @returns the total number of vertices
  25204. */
  25205. getTotalVertices(): number;
  25206. /**
  25207. * Returns the content of an associated vertex buffer
  25208. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25209. * - VertexBuffer.PositionKind
  25210. * - VertexBuffer.UVKind
  25211. * - VertexBuffer.UV2Kind
  25212. * - VertexBuffer.UV3Kind
  25213. * - VertexBuffer.UV4Kind
  25214. * - VertexBuffer.UV5Kind
  25215. * - VertexBuffer.UV6Kind
  25216. * - VertexBuffer.ColorKind
  25217. * - VertexBuffer.MatricesIndicesKind
  25218. * - VertexBuffer.MatricesIndicesExtraKind
  25219. * - VertexBuffer.MatricesWeightsKind
  25220. * - VertexBuffer.MatricesWeightsExtraKind
  25221. * @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
  25222. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  25223. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  25224. */
  25225. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25226. /**
  25227. * Returns the mesh VertexBuffer object from the requested `kind`
  25228. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25229. * - VertexBuffer.PositionKind
  25230. * - VertexBuffer.NormalKind
  25231. * - VertexBuffer.UVKind
  25232. * - VertexBuffer.UV2Kind
  25233. * - VertexBuffer.UV3Kind
  25234. * - VertexBuffer.UV4Kind
  25235. * - VertexBuffer.UV5Kind
  25236. * - VertexBuffer.UV6Kind
  25237. * - VertexBuffer.ColorKind
  25238. * - VertexBuffer.MatricesIndicesKind
  25239. * - VertexBuffer.MatricesIndicesExtraKind
  25240. * - VertexBuffer.MatricesWeightsKind
  25241. * - VertexBuffer.MatricesWeightsExtraKind
  25242. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  25243. */
  25244. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25245. /**
  25246. * Tests if a specific vertex buffer is associated with this mesh
  25247. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25248. * - VertexBuffer.PositionKind
  25249. * - VertexBuffer.NormalKind
  25250. * - VertexBuffer.UVKind
  25251. * - VertexBuffer.UV2Kind
  25252. * - VertexBuffer.UV3Kind
  25253. * - VertexBuffer.UV4Kind
  25254. * - VertexBuffer.UV5Kind
  25255. * - VertexBuffer.UV6Kind
  25256. * - VertexBuffer.ColorKind
  25257. * - VertexBuffer.MatricesIndicesKind
  25258. * - VertexBuffer.MatricesIndicesExtraKind
  25259. * - VertexBuffer.MatricesWeightsKind
  25260. * - VertexBuffer.MatricesWeightsExtraKind
  25261. * @returns a boolean
  25262. */
  25263. isVerticesDataPresent(kind: string): boolean;
  25264. /**
  25265. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  25266. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25267. * - VertexBuffer.PositionKind
  25268. * - VertexBuffer.UVKind
  25269. * - VertexBuffer.UV2Kind
  25270. * - VertexBuffer.UV3Kind
  25271. * - VertexBuffer.UV4Kind
  25272. * - VertexBuffer.UV5Kind
  25273. * - VertexBuffer.UV6Kind
  25274. * - VertexBuffer.ColorKind
  25275. * - VertexBuffer.MatricesIndicesKind
  25276. * - VertexBuffer.MatricesIndicesExtraKind
  25277. * - VertexBuffer.MatricesWeightsKind
  25278. * - VertexBuffer.MatricesWeightsExtraKind
  25279. * @returns a boolean
  25280. */
  25281. isVertexBufferUpdatable(kind: string): boolean;
  25282. /**
  25283. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  25284. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25285. * - VertexBuffer.PositionKind
  25286. * - VertexBuffer.NormalKind
  25287. * - VertexBuffer.UVKind
  25288. * - VertexBuffer.UV2Kind
  25289. * - VertexBuffer.UV3Kind
  25290. * - VertexBuffer.UV4Kind
  25291. * - VertexBuffer.UV5Kind
  25292. * - VertexBuffer.UV6Kind
  25293. * - VertexBuffer.ColorKind
  25294. * - VertexBuffer.MatricesIndicesKind
  25295. * - VertexBuffer.MatricesIndicesExtraKind
  25296. * - VertexBuffer.MatricesWeightsKind
  25297. * - VertexBuffer.MatricesWeightsExtraKind
  25298. * @returns an array of strings
  25299. */
  25300. getVerticesDataKinds(): string[];
  25301. /**
  25302. * Returns a positive integer : the total number of indices in this mesh geometry.
  25303. * @returns the numner of indices or zero if the mesh has no geometry.
  25304. */
  25305. getTotalIndices(): number;
  25306. /**
  25307. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25308. * @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.
  25309. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25310. * @returns the indices array or an empty array if the mesh has no geometry
  25311. */
  25312. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25313. get isBlocked(): boolean;
  25314. /**
  25315. * Determine if the current mesh is ready to be rendered
  25316. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25317. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25318. * @returns true if all associated assets are ready (material, textures, shaders)
  25319. */
  25320. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25321. /**
  25322. * 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.
  25323. */
  25324. get areNormalsFrozen(): boolean;
  25325. /**
  25326. * 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.
  25327. * @returns the current mesh
  25328. */
  25329. freezeNormals(): Mesh;
  25330. /**
  25331. * 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
  25332. * @returns the current mesh
  25333. */
  25334. unfreezeNormals(): Mesh;
  25335. /**
  25336. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25337. */
  25338. set overridenInstanceCount(count: number);
  25339. /** @hidden */
  25340. _preActivate(): Mesh;
  25341. /** @hidden */
  25342. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25343. /** @hidden */
  25344. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25345. /**
  25346. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25347. * This means the mesh underlying bounding box and sphere are recomputed.
  25348. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25349. * @returns the current mesh
  25350. */
  25351. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25352. /** @hidden */
  25353. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25354. /**
  25355. * This function will subdivide the mesh into multiple submeshes
  25356. * @param count defines the expected number of submeshes
  25357. */
  25358. subdivide(count: number): void;
  25359. /**
  25360. * Copy a FloatArray into a specific associated vertex buffer
  25361. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25362. * - VertexBuffer.PositionKind
  25363. * - VertexBuffer.UVKind
  25364. * - VertexBuffer.UV2Kind
  25365. * - VertexBuffer.UV3Kind
  25366. * - VertexBuffer.UV4Kind
  25367. * - VertexBuffer.UV5Kind
  25368. * - VertexBuffer.UV6Kind
  25369. * - VertexBuffer.ColorKind
  25370. * - VertexBuffer.MatricesIndicesKind
  25371. * - VertexBuffer.MatricesIndicesExtraKind
  25372. * - VertexBuffer.MatricesWeightsKind
  25373. * - VertexBuffer.MatricesWeightsExtraKind
  25374. * @param data defines the data source
  25375. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25376. * @param stride defines the data stride size (can be null)
  25377. * @returns the current mesh
  25378. */
  25379. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25380. /**
  25381. * Delete a vertex buffer associated with this mesh
  25382. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25383. * - VertexBuffer.PositionKind
  25384. * - VertexBuffer.UVKind
  25385. * - VertexBuffer.UV2Kind
  25386. * - VertexBuffer.UV3Kind
  25387. * - VertexBuffer.UV4Kind
  25388. * - VertexBuffer.UV5Kind
  25389. * - VertexBuffer.UV6Kind
  25390. * - VertexBuffer.ColorKind
  25391. * - VertexBuffer.MatricesIndicesKind
  25392. * - VertexBuffer.MatricesIndicesExtraKind
  25393. * - VertexBuffer.MatricesWeightsKind
  25394. * - VertexBuffer.MatricesWeightsExtraKind
  25395. */
  25396. removeVerticesData(kind: string): void;
  25397. /**
  25398. * Flags an associated vertex buffer as updatable
  25399. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25400. * - VertexBuffer.PositionKind
  25401. * - VertexBuffer.UVKind
  25402. * - VertexBuffer.UV2Kind
  25403. * - VertexBuffer.UV3Kind
  25404. * - VertexBuffer.UV4Kind
  25405. * - VertexBuffer.UV5Kind
  25406. * - VertexBuffer.UV6Kind
  25407. * - VertexBuffer.ColorKind
  25408. * - VertexBuffer.MatricesIndicesKind
  25409. * - VertexBuffer.MatricesIndicesExtraKind
  25410. * - VertexBuffer.MatricesWeightsKind
  25411. * - VertexBuffer.MatricesWeightsExtraKind
  25412. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25413. */
  25414. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25415. /**
  25416. * Sets the mesh global Vertex Buffer
  25417. * @param buffer defines the buffer to use
  25418. * @returns the current mesh
  25419. */
  25420. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25421. /**
  25422. * Update a specific associated vertex buffer
  25423. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25424. * - VertexBuffer.PositionKind
  25425. * - VertexBuffer.UVKind
  25426. * - VertexBuffer.UV2Kind
  25427. * - VertexBuffer.UV3Kind
  25428. * - VertexBuffer.UV4Kind
  25429. * - VertexBuffer.UV5Kind
  25430. * - VertexBuffer.UV6Kind
  25431. * - VertexBuffer.ColorKind
  25432. * - VertexBuffer.MatricesIndicesKind
  25433. * - VertexBuffer.MatricesIndicesExtraKind
  25434. * - VertexBuffer.MatricesWeightsKind
  25435. * - VertexBuffer.MatricesWeightsExtraKind
  25436. * @param data defines the data source
  25437. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25438. * @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)
  25439. * @returns the current mesh
  25440. */
  25441. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25442. /**
  25443. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25444. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25445. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25446. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25447. * @returns the current mesh
  25448. */
  25449. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25450. /**
  25451. * Creates a un-shared specific occurence of the geometry for the mesh.
  25452. * @returns the current mesh
  25453. */
  25454. makeGeometryUnique(): Mesh;
  25455. /**
  25456. * Set the index buffer of this mesh
  25457. * @param indices defines the source data
  25458. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25459. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25460. * @returns the current mesh
  25461. */
  25462. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25463. /**
  25464. * Update the current index buffer
  25465. * @param indices defines the source data
  25466. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25467. * @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)
  25468. * @returns the current mesh
  25469. */
  25470. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25471. /**
  25472. * Invert the geometry to move from a right handed system to a left handed one.
  25473. * @returns the current mesh
  25474. */
  25475. toLeftHanded(): Mesh;
  25476. /** @hidden */
  25477. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25478. /** @hidden */
  25479. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25480. /**
  25481. * Registers for this mesh a javascript function called just before the rendering process
  25482. * @param func defines the function to call before rendering this mesh
  25483. * @returns the current mesh
  25484. */
  25485. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25486. /**
  25487. * Disposes a previously registered javascript function called before the rendering
  25488. * @param func defines the function to remove
  25489. * @returns the current mesh
  25490. */
  25491. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25492. /**
  25493. * Registers for this mesh a javascript function called just after the rendering is complete
  25494. * @param func defines the function to call after rendering this mesh
  25495. * @returns the current mesh
  25496. */
  25497. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25498. /**
  25499. * Disposes a previously registered javascript function called after the rendering.
  25500. * @param func defines the function to remove
  25501. * @returns the current mesh
  25502. */
  25503. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25504. /** @hidden */
  25505. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25506. /** @hidden */
  25507. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25508. /** @hidden */
  25509. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25510. /** @hidden */
  25511. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25512. /** @hidden */
  25513. _rebuild(): void;
  25514. /** @hidden */
  25515. _freeze(): void;
  25516. /** @hidden */
  25517. _unFreeze(): void;
  25518. /**
  25519. * 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
  25520. * @param subMesh defines the subMesh to render
  25521. * @param enableAlphaMode defines if alpha mode can be changed
  25522. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25523. * @returns the current mesh
  25524. */
  25525. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25526. private _onBeforeDraw;
  25527. /**
  25528. * Renormalize the mesh and patch it up if there are no weights
  25529. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25530. * However in the case of zero weights then we set just a single influence to 1.
  25531. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25532. */
  25533. cleanMatrixWeights(): void;
  25534. private normalizeSkinFourWeights;
  25535. private normalizeSkinWeightsAndExtra;
  25536. /**
  25537. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25538. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25539. * the user know there was an issue with importing the mesh
  25540. * @returns a validation object with skinned, valid and report string
  25541. */
  25542. validateSkinning(): {
  25543. skinned: boolean;
  25544. valid: boolean;
  25545. report: string;
  25546. };
  25547. /** @hidden */
  25548. _checkDelayState(): Mesh;
  25549. private _queueLoad;
  25550. /**
  25551. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25552. * A mesh is in the frustum if its bounding box intersects the frustum
  25553. * @param frustumPlanes defines the frustum to test
  25554. * @returns true if the mesh is in the frustum planes
  25555. */
  25556. isInFrustum(frustumPlanes: Plane[]): boolean;
  25557. /**
  25558. * Sets the mesh material by the material or multiMaterial `id` property
  25559. * @param id is a string identifying the material or the multiMaterial
  25560. * @returns the current mesh
  25561. */
  25562. setMaterialByID(id: string): Mesh;
  25563. /**
  25564. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25565. * @returns an array of IAnimatable
  25566. */
  25567. getAnimatables(): IAnimatable[];
  25568. /**
  25569. * Modifies the mesh geometry according to the passed transformation matrix.
  25570. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25571. * The mesh normals are modified using the same transformation.
  25572. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25573. * @param transform defines the transform matrix to use
  25574. * @see http://doc.babylonjs.com/resources/baking_transformations
  25575. * @returns the current mesh
  25576. */
  25577. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25578. /**
  25579. * Modifies the mesh geometry according to its own current World Matrix.
  25580. * The mesh World Matrix is then reset.
  25581. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25582. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25583. * @see http://doc.babylonjs.com/resources/baking_transformations
  25584. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  25585. * @returns the current mesh
  25586. */
  25587. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  25588. /** @hidden */
  25589. get _positions(): Nullable<Vector3[]>;
  25590. /** @hidden */
  25591. _resetPointsArrayCache(): Mesh;
  25592. /** @hidden */
  25593. _generatePointsArray(): boolean;
  25594. /**
  25595. * Returns a new Mesh object generated from the current mesh properties.
  25596. * This method must not get confused with createInstance()
  25597. * @param name is a string, the name given to the new mesh
  25598. * @param newParent can be any Node object (default `null`)
  25599. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25600. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25601. * @returns a new mesh
  25602. */
  25603. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  25604. /**
  25605. * Releases resources associated with this mesh.
  25606. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25607. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25608. */
  25609. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25610. /** @hidden */
  25611. _disposeInstanceSpecificData(): void;
  25612. /**
  25613. * Modifies the mesh geometry according to a displacement map.
  25614. * 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.
  25615. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25616. * @param url is a string, the URL from the image file is to be downloaded.
  25617. * @param minHeight is the lower limit of the displacement.
  25618. * @param maxHeight is the upper limit of the displacement.
  25619. * @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.
  25620. * @param uvOffset is an optional vector2 used to offset UV.
  25621. * @param uvScale is an optional vector2 used to scale UV.
  25622. * @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.
  25623. * @returns the Mesh.
  25624. */
  25625. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25626. /**
  25627. * Modifies the mesh geometry according to a displacementMap buffer.
  25628. * 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.
  25629. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25630. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25631. * @param heightMapWidth is the width of the buffer image.
  25632. * @param heightMapHeight is the height of the buffer image.
  25633. * @param minHeight is the lower limit of the displacement.
  25634. * @param maxHeight is the upper limit of the displacement.
  25635. * @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.
  25636. * @param uvOffset is an optional vector2 used to offset UV.
  25637. * @param uvScale is an optional vector2 used to scale UV.
  25638. * @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.
  25639. * @returns the Mesh.
  25640. */
  25641. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25642. /**
  25643. * Modify the mesh to get a flat shading rendering.
  25644. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25645. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25646. * @returns current mesh
  25647. */
  25648. convertToFlatShadedMesh(): Mesh;
  25649. /**
  25650. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25651. * In other words, more vertices, no more indices and a single bigger VBO.
  25652. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25653. * @returns current mesh
  25654. */
  25655. convertToUnIndexedMesh(): Mesh;
  25656. /**
  25657. * Inverses facet orientations.
  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 flipNormals will also inverts the normals
  25660. * @returns current mesh
  25661. */
  25662. flipFaces(flipNormals?: boolean): Mesh;
  25663. /**
  25664. * Increase the number of facets and hence vertices in a mesh
  25665. * Vertex normals are interpolated from existing vertex normals
  25666. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25667. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25668. */
  25669. increaseVertices(numberPerEdge: number): void;
  25670. /**
  25671. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25672. * This will undo any application of covertToFlatShadedMesh
  25673. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25674. */
  25675. forceSharedVertices(): void;
  25676. /** @hidden */
  25677. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25678. /** @hidden */
  25679. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25680. /**
  25681. * Creates a new InstancedMesh object from the mesh model.
  25682. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25683. * @param name defines the name of the new instance
  25684. * @returns a new InstancedMesh
  25685. */
  25686. createInstance(name: string): InstancedMesh;
  25687. /**
  25688. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25689. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25690. * @returns the current mesh
  25691. */
  25692. synchronizeInstances(): Mesh;
  25693. /**
  25694. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25695. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25696. * This should be used together with the simplification to avoid disappearing triangles.
  25697. * @param successCallback an optional success callback to be called after the optimization finished.
  25698. * @returns the current mesh
  25699. */
  25700. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25701. /**
  25702. * Serialize current mesh
  25703. * @param serializationObject defines the object which will receive the serialization data
  25704. */
  25705. serialize(serializationObject: any): void;
  25706. /** @hidden */
  25707. _syncGeometryWithMorphTargetManager(): void;
  25708. /** @hidden */
  25709. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25710. /**
  25711. * Returns a new Mesh object parsed from the source provided.
  25712. * @param parsedMesh is the source
  25713. * @param scene defines the hosting scene
  25714. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25715. * @returns a new Mesh
  25716. */
  25717. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25718. /**
  25719. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25720. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25721. * @param name defines the name of the mesh to create
  25722. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25723. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25724. * @param closePath creates a seam between the first and the last points of each path of the path array
  25725. * @param offset is taken in account only if the `pathArray` is containing a single path
  25726. * @param scene defines the hosting scene
  25727. * @param updatable defines if the mesh must be flagged as updatable
  25728. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25729. * @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)
  25730. * @returns a new Mesh
  25731. */
  25732. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25733. /**
  25734. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25735. * @param name defines the name of the mesh to create
  25736. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25737. * @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
  25738. * @param scene defines the hosting scene
  25739. * @param updatable defines if the mesh must be flagged as updatable
  25740. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25741. * @returns a new Mesh
  25742. */
  25743. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25744. /**
  25745. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25746. * @param name defines the name of the mesh to create
  25747. * @param size sets the size (float) of each box side (default 1)
  25748. * @param scene defines the hosting scene
  25749. * @param updatable defines if the mesh must be flagged as updatable
  25750. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25751. * @returns a new Mesh
  25752. */
  25753. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25754. /**
  25755. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25756. * @param name defines the name of the mesh to create
  25757. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25758. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25759. * @param scene defines the hosting scene
  25760. * @param updatable defines if the mesh must be flagged as updatable
  25761. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25762. * @returns a new Mesh
  25763. */
  25764. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25765. /**
  25766. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25767. * @param name defines the name of the mesh to create
  25768. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25769. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25770. * @param scene defines the hosting scene
  25771. * @returns a new Mesh
  25772. */
  25773. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25774. /**
  25775. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25776. * @param name defines the name of the mesh to create
  25777. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25778. * @param diameterTop set the top cap diameter (floats, default 1)
  25779. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25780. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25781. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25782. * @param scene defines the hosting scene
  25783. * @param updatable defines if the mesh must be flagged as updatable
  25784. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25785. * @returns a new Mesh
  25786. */
  25787. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25788. /**
  25789. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25790. * @param name defines the name of the mesh to create
  25791. * @param diameter sets the diameter size (float) of the torus (default 1)
  25792. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25793. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25794. * @param scene defines the hosting scene
  25795. * @param updatable defines if the mesh must be flagged as updatable
  25796. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25797. * @returns a new Mesh
  25798. */
  25799. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25800. /**
  25801. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25802. * @param name defines the name of the mesh to create
  25803. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25804. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25805. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25806. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25807. * @param p the number of windings on X axis (positive integers, default 2)
  25808. * @param q the number of windings on Y axis (positive integers, default 3)
  25809. * @param scene defines the hosting scene
  25810. * @param updatable defines if the mesh must be flagged as updatable
  25811. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25812. * @returns a new Mesh
  25813. */
  25814. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25815. /**
  25816. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25817. * @param name defines the name of the mesh to create
  25818. * @param points is an array successive Vector3
  25819. * @param scene defines the hosting scene
  25820. * @param updatable defines if the mesh must be flagged as updatable
  25821. * @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).
  25822. * @returns a new Mesh
  25823. */
  25824. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25825. /**
  25826. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25827. * @param name defines the name of the mesh to create
  25828. * @param points is an array successive Vector3
  25829. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25830. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25831. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25832. * @param scene defines the hosting scene
  25833. * @param updatable defines if the mesh must be flagged as updatable
  25834. * @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)
  25835. * @returns a new Mesh
  25836. */
  25837. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25838. /**
  25839. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25840. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25841. * 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.
  25842. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25843. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25844. * Remember you can only change the shape positions, not their number when updating a polygon.
  25845. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25846. * @param name defines the name of the mesh to create
  25847. * @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
  25848. * @param scene defines the hosting scene
  25849. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25850. * @param updatable defines if the mesh must be flagged as updatable
  25851. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25852. * @param earcutInjection can be used to inject your own earcut reference
  25853. * @returns a new Mesh
  25854. */
  25855. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25856. /**
  25857. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25858. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25859. * @param name defines the name of the mesh to create
  25860. * @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
  25861. * @param depth defines the height of extrusion
  25862. * @param scene defines the hosting scene
  25863. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25864. * @param updatable defines if the mesh must be flagged as updatable
  25865. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25866. * @param earcutInjection can be used to inject your own earcut reference
  25867. * @returns a new Mesh
  25868. */
  25869. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25870. /**
  25871. * Creates an extruded shape mesh.
  25872. * 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
  25873. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25874. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25875. * @param name defines the name of the mesh to create
  25876. * @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
  25877. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25878. * @param scale is the value to scale the shape
  25879. * @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
  25880. * @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
  25881. * @param scene defines the hosting scene
  25882. * @param updatable defines if the mesh must be flagged as updatable
  25883. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25884. * @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)
  25885. * @returns a new Mesh
  25886. */
  25887. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25888. /**
  25889. * Creates an custom extruded shape mesh.
  25890. * The custom extrusion is a parametric shape.
  25891. * It has no predefined shape. Its final shape will depend on the input parameters.
  25892. * Please consider using the same method from the MeshBuilder class instead
  25893. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25894. * @param name defines the name of the mesh to create
  25895. * @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
  25896. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25897. * @param scaleFunction is a custom Javascript function called on each path point
  25898. * @param rotationFunction is a custom Javascript function called on each path point
  25899. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25900. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25901. * @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
  25902. * @param scene defines the hosting scene
  25903. * @param updatable defines if the mesh must be flagged as updatable
  25904. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25905. * @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)
  25906. * @returns a new Mesh
  25907. */
  25908. 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;
  25909. /**
  25910. * Creates lathe mesh.
  25911. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25912. * Please consider using the same method from the MeshBuilder class instead
  25913. * @param name defines the name of the mesh to create
  25914. * @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
  25915. * @param radius is the radius value of the lathe
  25916. * @param tessellation is the side number of the lathe.
  25917. * @param scene defines the hosting scene
  25918. * @param updatable defines if the mesh must be flagged as updatable
  25919. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25920. * @returns a new Mesh
  25921. */
  25922. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25923. /**
  25924. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25925. * @param name defines the name of the mesh to create
  25926. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25927. * @param scene defines the hosting scene
  25928. * @param updatable defines if the mesh must be flagged as updatable
  25929. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25930. * @returns a new Mesh
  25931. */
  25932. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25933. /**
  25934. * Creates a ground mesh.
  25935. * Please consider using the same method from the MeshBuilder class instead
  25936. * @param name defines the name of the mesh to create
  25937. * @param width set the width of the ground
  25938. * @param height set the height of the ground
  25939. * @param subdivisions sets the number of subdivisions per side
  25940. * @param scene defines the hosting scene
  25941. * @param updatable defines if the mesh must be flagged as updatable
  25942. * @returns a new Mesh
  25943. */
  25944. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25945. /**
  25946. * Creates a tiled ground mesh.
  25947. * Please consider using the same method from the MeshBuilder class instead
  25948. * @param name defines the name of the mesh to create
  25949. * @param xmin set the ground minimum X coordinate
  25950. * @param zmin set the ground minimum Y coordinate
  25951. * @param xmax set the ground maximum X coordinate
  25952. * @param zmax set the ground maximum Z coordinate
  25953. * @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
  25954. * @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
  25955. * @param scene defines the hosting scene
  25956. * @param updatable defines if the mesh must be flagged as updatable
  25957. * @returns a new Mesh
  25958. */
  25959. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25960. w: number;
  25961. h: number;
  25962. }, precision: {
  25963. w: number;
  25964. h: number;
  25965. }, scene: Scene, updatable?: boolean): Mesh;
  25966. /**
  25967. * Creates a ground mesh from a height map.
  25968. * Please consider using the same method from the MeshBuilder class instead
  25969. * @see http://doc.babylonjs.com/babylon101/height_map
  25970. * @param name defines the name of the mesh to create
  25971. * @param url sets the URL of the height map image resource
  25972. * @param width set the ground width size
  25973. * @param height set the ground height size
  25974. * @param subdivisions sets the number of subdivision per side
  25975. * @param minHeight is the minimum altitude on the ground
  25976. * @param maxHeight is the maximum altitude on the ground
  25977. * @param scene defines the hosting scene
  25978. * @param updatable defines if the mesh must be flagged as updatable
  25979. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25980. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25981. * @returns a new Mesh
  25982. */
  25983. 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;
  25984. /**
  25985. * Creates a tube mesh.
  25986. * The tube is a parametric shape.
  25987. * It has no predefined shape. Its final shape will depend on the input parameters.
  25988. * Please consider using the same method from the MeshBuilder class instead
  25989. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25990. * @param name defines the name of the mesh to create
  25991. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25992. * @param radius sets the tube radius size
  25993. * @param tessellation is the number of sides on the tubular surface
  25994. * @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
  25995. * @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
  25996. * @param scene defines the hosting scene
  25997. * @param updatable defines if the mesh must be flagged as updatable
  25998. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25999. * @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)
  26000. * @returns a new Mesh
  26001. */
  26002. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  26003. (i: number, distance: number): number;
  26004. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26005. /**
  26006. * Creates a polyhedron mesh.
  26007. * Please consider using the same method from the MeshBuilder class instead.
  26008. * * 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
  26009. * * The parameter `size` (positive float, default 1) sets the polygon size
  26010. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  26011. * * 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`
  26012. * * 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
  26013. * * 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)`)
  26014. * * 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
  26015. * * 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
  26016. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26017. * * If you create a double-sided mesh, you can choose what parts of 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
  26018. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26019. * @param name defines the name of the mesh to create
  26020. * @param options defines the options used to create the mesh
  26021. * @param scene defines the hosting scene
  26022. * @returns a new Mesh
  26023. */
  26024. static CreatePolyhedron(name: string, options: {
  26025. type?: number;
  26026. size?: number;
  26027. sizeX?: number;
  26028. sizeY?: number;
  26029. sizeZ?: number;
  26030. custom?: any;
  26031. faceUV?: Vector4[];
  26032. faceColors?: Color4[];
  26033. updatable?: boolean;
  26034. sideOrientation?: number;
  26035. }, scene: Scene): Mesh;
  26036. /**
  26037. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  26038. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  26039. * * 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`)
  26040. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  26041. * * 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
  26042. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26043. * * If you create a double-sided mesh, you can choose what parts of 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
  26044. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26045. * @param name defines the name of the mesh
  26046. * @param options defines the options used to create the mesh
  26047. * @param scene defines the hosting scene
  26048. * @returns a new Mesh
  26049. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  26050. */
  26051. static CreateIcoSphere(name: string, options: {
  26052. radius?: number;
  26053. flat?: boolean;
  26054. subdivisions?: number;
  26055. sideOrientation?: number;
  26056. updatable?: boolean;
  26057. }, scene: Scene): Mesh;
  26058. /**
  26059. * Creates a decal mesh.
  26060. * Please consider using the same method from the MeshBuilder class instead.
  26061. * A decal is a mesh usually applied as a model onto the surface of another mesh
  26062. * @param name defines the name of the mesh
  26063. * @param sourceMesh defines the mesh receiving the decal
  26064. * @param position sets the position of the decal in world coordinates
  26065. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  26066. * @param size sets the decal scaling
  26067. * @param angle sets the angle to rotate the decal
  26068. * @returns a new Mesh
  26069. */
  26070. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  26071. /**
  26072. * Prepare internal position array for software CPU skinning
  26073. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  26074. */
  26075. setPositionsForCPUSkinning(): Float32Array;
  26076. /**
  26077. * Prepare internal normal array for software CPU skinning
  26078. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  26079. */
  26080. setNormalsForCPUSkinning(): Float32Array;
  26081. /**
  26082. * Updates the vertex buffer by applying transformation from the bones
  26083. * @param skeleton defines the skeleton to apply to current mesh
  26084. * @returns the current mesh
  26085. */
  26086. applySkeleton(skeleton: Skeleton): Mesh;
  26087. /**
  26088. * 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
  26089. * @param meshes defines the list of meshes to scan
  26090. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  26091. */
  26092. static MinMax(meshes: AbstractMesh[]): {
  26093. min: Vector3;
  26094. max: Vector3;
  26095. };
  26096. /**
  26097. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  26098. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  26099. * @returns a vector3
  26100. */
  26101. static Center(meshesOrMinMaxVector: {
  26102. min: Vector3;
  26103. max: Vector3;
  26104. } | AbstractMesh[]): Vector3;
  26105. /**
  26106. * Merge the array of meshes into a single mesh for performance reasons.
  26107. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  26108. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  26109. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  26110. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  26111. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  26112. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  26113. * @returns a new mesh
  26114. */
  26115. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  26116. /** @hidden */
  26117. addInstance(instance: InstancedMesh): void;
  26118. /** @hidden */
  26119. removeInstance(instance: InstancedMesh): void;
  26120. }
  26121. }
  26122. declare module "babylonjs/Cameras/camera" {
  26123. import { SmartArray } from "babylonjs/Misc/smartArray";
  26124. import { Observable } from "babylonjs/Misc/observable";
  26125. import { Nullable } from "babylonjs/types";
  26126. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  26127. import { Scene } from "babylonjs/scene";
  26128. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  26129. import { Node } from "babylonjs/node";
  26130. import { Mesh } from "babylonjs/Meshes/mesh";
  26131. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26132. import { ICullable } from "babylonjs/Culling/boundingInfo";
  26133. import { Viewport } from "babylonjs/Maths/math.viewport";
  26134. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26135. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26136. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  26137. import { Ray } from "babylonjs/Culling/ray";
  26138. /**
  26139. * This is the base class of all the camera used in the application.
  26140. * @see http://doc.babylonjs.com/features/cameras
  26141. */
  26142. export class Camera extends Node {
  26143. /** @hidden */
  26144. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  26145. /**
  26146. * This is the default projection mode used by the cameras.
  26147. * It helps recreating a feeling of perspective and better appreciate depth.
  26148. * This is the best way to simulate real life cameras.
  26149. */
  26150. static readonly PERSPECTIVE_CAMERA: number;
  26151. /**
  26152. * This helps creating camera with an orthographic mode.
  26153. * 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.
  26154. */
  26155. static readonly ORTHOGRAPHIC_CAMERA: number;
  26156. /**
  26157. * This is the default FOV mode for perspective cameras.
  26158. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  26159. */
  26160. static readonly FOVMODE_VERTICAL_FIXED: number;
  26161. /**
  26162. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  26163. */
  26164. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  26165. /**
  26166. * This specifies ther is no need for a camera rig.
  26167. * Basically only one eye is rendered corresponding to the camera.
  26168. */
  26169. static readonly RIG_MODE_NONE: number;
  26170. /**
  26171. * Simulates a camera Rig with one blue eye and one red eye.
  26172. * This can be use with 3d blue and red glasses.
  26173. */
  26174. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  26175. /**
  26176. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  26177. */
  26178. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  26179. /**
  26180. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  26181. */
  26182. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  26183. /**
  26184. * Defines that both eyes of the camera will be rendered over under each other.
  26185. */
  26186. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  26187. /**
  26188. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  26189. */
  26190. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  26191. /**
  26192. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  26193. */
  26194. static readonly RIG_MODE_VR: number;
  26195. /**
  26196. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  26197. */
  26198. static readonly RIG_MODE_WEBVR: number;
  26199. /**
  26200. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  26201. */
  26202. static readonly RIG_MODE_CUSTOM: number;
  26203. /**
  26204. * Defines if by default attaching controls should prevent the default javascript event to continue.
  26205. */
  26206. static ForceAttachControlToAlwaysPreventDefault: boolean;
  26207. /**
  26208. * Define the input manager associated with the camera.
  26209. */
  26210. inputs: CameraInputsManager<Camera>;
  26211. /** @hidden */
  26212. _position: Vector3;
  26213. /**
  26214. * Define the current local position of the camera in the scene
  26215. */
  26216. get position(): Vector3;
  26217. set position(newPosition: Vector3);
  26218. /**
  26219. * The vector the camera should consider as up.
  26220. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  26221. */
  26222. upVector: Vector3;
  26223. /**
  26224. * Define the current limit on the left side for an orthographic camera
  26225. * In scene unit
  26226. */
  26227. orthoLeft: Nullable<number>;
  26228. /**
  26229. * Define the current limit on the right side for an orthographic camera
  26230. * In scene unit
  26231. */
  26232. orthoRight: Nullable<number>;
  26233. /**
  26234. * Define the current limit on the bottom side for an orthographic camera
  26235. * In scene unit
  26236. */
  26237. orthoBottom: Nullable<number>;
  26238. /**
  26239. * Define the current limit on the top side for an orthographic camera
  26240. * In scene unit
  26241. */
  26242. orthoTop: Nullable<number>;
  26243. /**
  26244. * Field Of View is set in Radians. (default is 0.8)
  26245. */
  26246. fov: number;
  26247. /**
  26248. * Define the minimum distance the camera can see from.
  26249. * This is important to note that the depth buffer are not infinite and the closer it starts
  26250. * the more your scene might encounter depth fighting issue.
  26251. */
  26252. minZ: number;
  26253. /**
  26254. * Define the maximum distance the camera can see to.
  26255. * This is important to note that the depth buffer are not infinite and the further it end
  26256. * the more your scene might encounter depth fighting issue.
  26257. */
  26258. maxZ: number;
  26259. /**
  26260. * Define the default inertia of the camera.
  26261. * This helps giving a smooth feeling to the camera movement.
  26262. */
  26263. inertia: number;
  26264. /**
  26265. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  26266. */
  26267. mode: number;
  26268. /**
  26269. * Define whether the camera is intermediate.
  26270. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  26271. */
  26272. isIntermediate: boolean;
  26273. /**
  26274. * Define the viewport of the camera.
  26275. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  26276. */
  26277. viewport: Viewport;
  26278. /**
  26279. * Restricts the camera to viewing objects with the same layerMask.
  26280. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  26281. */
  26282. layerMask: number;
  26283. /**
  26284. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  26285. */
  26286. fovMode: number;
  26287. /**
  26288. * Rig mode of the camera.
  26289. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  26290. * This is normally controlled byt the camera themselves as internal use.
  26291. */
  26292. cameraRigMode: number;
  26293. /**
  26294. * Defines the distance between both "eyes" in case of a RIG
  26295. */
  26296. interaxialDistance: number;
  26297. /**
  26298. * Defines if stereoscopic rendering is done side by side or over under.
  26299. */
  26300. isStereoscopicSideBySide: boolean;
  26301. /**
  26302. * 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
  26303. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  26304. * else in the scene. (Eg. security camera)
  26305. *
  26306. * 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)
  26307. */
  26308. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  26309. /**
  26310. * When set, the camera will render to this render target instead of the default canvas
  26311. *
  26312. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  26313. */
  26314. outputRenderTarget: Nullable<RenderTargetTexture>;
  26315. /**
  26316. * Observable triggered when the camera view matrix has changed.
  26317. */
  26318. onViewMatrixChangedObservable: Observable<Camera>;
  26319. /**
  26320. * Observable triggered when the camera Projection matrix has changed.
  26321. */
  26322. onProjectionMatrixChangedObservable: Observable<Camera>;
  26323. /**
  26324. * Observable triggered when the inputs have been processed.
  26325. */
  26326. onAfterCheckInputsObservable: Observable<Camera>;
  26327. /**
  26328. * Observable triggered when reset has been called and applied to the camera.
  26329. */
  26330. onRestoreStateObservable: Observable<Camera>;
  26331. /**
  26332. * Is this camera a part of a rig system?
  26333. */
  26334. isRigCamera: boolean;
  26335. /**
  26336. * If isRigCamera set to true this will be set with the parent camera.
  26337. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  26338. */
  26339. rigParent?: Camera;
  26340. /** @hidden */
  26341. _cameraRigParams: any;
  26342. /** @hidden */
  26343. _rigCameras: Camera[];
  26344. /** @hidden */
  26345. _rigPostProcess: Nullable<PostProcess>;
  26346. protected _webvrViewMatrix: Matrix;
  26347. /** @hidden */
  26348. _skipRendering: boolean;
  26349. /** @hidden */
  26350. _projectionMatrix: Matrix;
  26351. /** @hidden */
  26352. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  26353. /** @hidden */
  26354. _activeMeshes: SmartArray<AbstractMesh>;
  26355. protected _globalPosition: Vector3;
  26356. /** @hidden */
  26357. _computedViewMatrix: Matrix;
  26358. private _doNotComputeProjectionMatrix;
  26359. private _transformMatrix;
  26360. private _frustumPlanes;
  26361. private _refreshFrustumPlanes;
  26362. private _storedFov;
  26363. private _stateStored;
  26364. /**
  26365. * Instantiates a new camera object.
  26366. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26367. * @see http://doc.babylonjs.com/features/cameras
  26368. * @param name Defines the name of the camera in the scene
  26369. * @param position Defines the position of the camera
  26370. * @param scene Defines the scene the camera belongs too
  26371. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26372. */
  26373. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26374. /**
  26375. * Store current camera state (fov, position, etc..)
  26376. * @returns the camera
  26377. */
  26378. storeState(): Camera;
  26379. /**
  26380. * Restores the camera state values if it has been stored. You must call storeState() first
  26381. */
  26382. protected _restoreStateValues(): boolean;
  26383. /**
  26384. * Restored camera state. You must call storeState() first.
  26385. * @returns true if restored and false otherwise
  26386. */
  26387. restoreState(): boolean;
  26388. /**
  26389. * Gets the class name of the camera.
  26390. * @returns the class name
  26391. */
  26392. getClassName(): string;
  26393. /** @hidden */
  26394. readonly _isCamera: boolean;
  26395. /**
  26396. * Gets a string representation of the camera useful for debug purpose.
  26397. * @param fullDetails Defines that a more verboe level of logging is required
  26398. * @returns the string representation
  26399. */
  26400. toString(fullDetails?: boolean): string;
  26401. /**
  26402. * Gets the current world space position of the camera.
  26403. */
  26404. get globalPosition(): Vector3;
  26405. /**
  26406. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26407. * @returns the active meshe list
  26408. */
  26409. getActiveMeshes(): SmartArray<AbstractMesh>;
  26410. /**
  26411. * Check whether a mesh is part of the current active mesh list of the camera
  26412. * @param mesh Defines the mesh to check
  26413. * @returns true if active, false otherwise
  26414. */
  26415. isActiveMesh(mesh: Mesh): boolean;
  26416. /**
  26417. * Is this camera ready to be used/rendered
  26418. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26419. * @return true if the camera is ready
  26420. */
  26421. isReady(completeCheck?: boolean): boolean;
  26422. /** @hidden */
  26423. _initCache(): void;
  26424. /** @hidden */
  26425. _updateCache(ignoreParentClass?: boolean): void;
  26426. /** @hidden */
  26427. _isSynchronized(): boolean;
  26428. /** @hidden */
  26429. _isSynchronizedViewMatrix(): boolean;
  26430. /** @hidden */
  26431. _isSynchronizedProjectionMatrix(): boolean;
  26432. /**
  26433. * Attach the input controls to a specific dom element to get the input from.
  26434. * @param element Defines the element the controls should be listened from
  26435. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26436. */
  26437. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26438. /**
  26439. * Detach the current controls from the specified dom element.
  26440. * @param element Defines the element to stop listening the inputs from
  26441. */
  26442. detachControl(element: HTMLElement): void;
  26443. /**
  26444. * Update the camera state according to the different inputs gathered during the frame.
  26445. */
  26446. update(): void;
  26447. /** @hidden */
  26448. _checkInputs(): void;
  26449. /** @hidden */
  26450. get rigCameras(): Camera[];
  26451. /**
  26452. * Gets the post process used by the rig cameras
  26453. */
  26454. get rigPostProcess(): Nullable<PostProcess>;
  26455. /**
  26456. * Internal, gets the first post proces.
  26457. * @returns the first post process to be run on this camera.
  26458. */
  26459. _getFirstPostProcess(): Nullable<PostProcess>;
  26460. private _cascadePostProcessesToRigCams;
  26461. /**
  26462. * Attach 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 attach to the camera
  26465. * @param insertAt The position of the post process in case several of them are in use in the scene
  26466. * @returns the position the post process has been inserted at
  26467. */
  26468. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26469. /**
  26470. * Detach a post process to the camera.
  26471. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26472. * @param postProcess The post process to detach from the camera
  26473. */
  26474. detachPostProcess(postProcess: PostProcess): void;
  26475. /**
  26476. * Gets the current world matrix of the camera
  26477. */
  26478. getWorldMatrix(): Matrix;
  26479. /** @hidden */
  26480. _getViewMatrix(): Matrix;
  26481. /**
  26482. * Gets the current view matrix of the camera.
  26483. * @param force forces the camera to recompute the matrix without looking at the cached state
  26484. * @returns the view matrix
  26485. */
  26486. getViewMatrix(force?: boolean): Matrix;
  26487. /**
  26488. * Freeze the projection matrix.
  26489. * It will prevent the cache check of the camera projection compute and can speed up perf
  26490. * if no parameter of the camera are meant to change
  26491. * @param projection Defines manually a projection if necessary
  26492. */
  26493. freezeProjectionMatrix(projection?: Matrix): void;
  26494. /**
  26495. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26496. */
  26497. unfreezeProjectionMatrix(): void;
  26498. /**
  26499. * Gets the current projection matrix of the camera.
  26500. * @param force forces the camera to recompute the matrix without looking at the cached state
  26501. * @returns the projection matrix
  26502. */
  26503. getProjectionMatrix(force?: boolean): Matrix;
  26504. /**
  26505. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26506. * @returns a Matrix
  26507. */
  26508. getTransformationMatrix(): Matrix;
  26509. private _updateFrustumPlanes;
  26510. /**
  26511. * Checks if a cullable object (mesh...) is in the camera frustum
  26512. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26513. * @param target The object to check
  26514. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26515. * @returns true if the object is in frustum otherwise false
  26516. */
  26517. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26518. /**
  26519. * Checks if a cullable object (mesh...) is in the camera frustum
  26520. * Unlike isInFrustum this cheks the full bounding box
  26521. * @param target The object to check
  26522. * @returns true if the object is in frustum otherwise false
  26523. */
  26524. isCompletelyInFrustum(target: ICullable): boolean;
  26525. /**
  26526. * Gets a ray in the forward direction from the camera.
  26527. * @param length Defines the length of the ray to create
  26528. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26529. * @param origin Defines the start point of the ray which defaults to the camera position
  26530. * @returns the forward ray
  26531. */
  26532. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26533. /**
  26534. * Releases resources associated with this node.
  26535. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26536. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26537. */
  26538. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26539. /** @hidden */
  26540. _isLeftCamera: boolean;
  26541. /**
  26542. * Gets the left camera of a rig setup in case of Rigged Camera
  26543. */
  26544. get isLeftCamera(): boolean;
  26545. /** @hidden */
  26546. _isRightCamera: boolean;
  26547. /**
  26548. * Gets the right camera of a rig setup in case of Rigged Camera
  26549. */
  26550. get isRightCamera(): boolean;
  26551. /**
  26552. * Gets the left camera of a rig setup in case of Rigged Camera
  26553. */
  26554. get leftCamera(): Nullable<FreeCamera>;
  26555. /**
  26556. * Gets the right camera of a rig setup in case of Rigged Camera
  26557. */
  26558. get rightCamera(): Nullable<FreeCamera>;
  26559. /**
  26560. * Gets the left camera target of a rig setup in case of Rigged Camera
  26561. * @returns the target position
  26562. */
  26563. getLeftTarget(): Nullable<Vector3>;
  26564. /**
  26565. * Gets the right camera target of a rig setup in case of Rigged Camera
  26566. * @returns the target position
  26567. */
  26568. getRightTarget(): Nullable<Vector3>;
  26569. /**
  26570. * @hidden
  26571. */
  26572. setCameraRigMode(mode: number, rigParams: any): void;
  26573. /** @hidden */
  26574. static _setStereoscopicRigMode(camera: Camera): void;
  26575. /** @hidden */
  26576. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26577. /** @hidden */
  26578. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26579. /** @hidden */
  26580. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26581. /** @hidden */
  26582. _getVRProjectionMatrix(): Matrix;
  26583. protected _updateCameraRotationMatrix(): void;
  26584. protected _updateWebVRCameraRotationMatrix(): void;
  26585. /**
  26586. * This function MUST be overwritten by the different WebVR cameras available.
  26587. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26588. * @hidden
  26589. */
  26590. _getWebVRProjectionMatrix(): Matrix;
  26591. /**
  26592. * This function MUST be overwritten by the different WebVR cameras available.
  26593. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26594. * @hidden
  26595. */
  26596. _getWebVRViewMatrix(): Matrix;
  26597. /** @hidden */
  26598. setCameraRigParameter(name: string, value: any): void;
  26599. /**
  26600. * needs to be overridden by children so sub has required properties to be copied
  26601. * @hidden
  26602. */
  26603. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26604. /**
  26605. * May need to be overridden by children
  26606. * @hidden
  26607. */
  26608. _updateRigCameras(): void;
  26609. /** @hidden */
  26610. _setupInputs(): void;
  26611. /**
  26612. * Serialiaze the camera setup to a json represention
  26613. * @returns the JSON representation
  26614. */
  26615. serialize(): any;
  26616. /**
  26617. * Clones the current camera.
  26618. * @param name The cloned camera name
  26619. * @returns the cloned camera
  26620. */
  26621. clone(name: string): Camera;
  26622. /**
  26623. * Gets the direction of the camera relative to a given local axis.
  26624. * @param localAxis Defines the reference axis to provide a relative direction.
  26625. * @return the direction
  26626. */
  26627. getDirection(localAxis: Vector3): Vector3;
  26628. /**
  26629. * Returns the current camera absolute rotation
  26630. */
  26631. get absoluteRotation(): Quaternion;
  26632. /**
  26633. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26634. * @param localAxis Defines the reference axis to provide a relative direction.
  26635. * @param result Defines the vector to store the result in
  26636. */
  26637. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26638. /**
  26639. * Gets a camera constructor for a given camera type
  26640. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26641. * @param name The name of the camera the result will be able to instantiate
  26642. * @param scene The scene the result will construct the camera in
  26643. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26644. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26645. * @returns a factory method to construc the camera
  26646. */
  26647. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26648. /**
  26649. * Compute the world matrix of the camera.
  26650. * @returns the camera world matrix
  26651. */
  26652. computeWorldMatrix(): Matrix;
  26653. /**
  26654. * Parse a JSON and creates the camera from the parsed information
  26655. * @param parsedCamera The JSON to parse
  26656. * @param scene The scene to instantiate the camera in
  26657. * @returns the newly constructed camera
  26658. */
  26659. static Parse(parsedCamera: any, scene: Scene): Camera;
  26660. }
  26661. }
  26662. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26663. import { Nullable } from "babylonjs/types";
  26664. import { Scene } from "babylonjs/scene";
  26665. import { Vector4 } from "babylonjs/Maths/math.vector";
  26666. import { Mesh } from "babylonjs/Meshes/mesh";
  26667. /**
  26668. * Class containing static functions to help procedurally build meshes
  26669. */
  26670. export class DiscBuilder {
  26671. /**
  26672. * Creates a plane polygonal mesh. By default, this is a disc
  26673. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26674. * * 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
  26675. * * 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
  26676. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26677. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26678. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26679. * @param name defines the name of the mesh
  26680. * @param options defines the options used to create the mesh
  26681. * @param scene defines the hosting scene
  26682. * @returns the plane polygonal mesh
  26683. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26684. */
  26685. static CreateDisc(name: string, options: {
  26686. radius?: number;
  26687. tessellation?: number;
  26688. arc?: number;
  26689. updatable?: boolean;
  26690. sideOrientation?: number;
  26691. frontUVs?: Vector4;
  26692. backUVs?: Vector4;
  26693. }, scene?: Nullable<Scene>): Mesh;
  26694. }
  26695. }
  26696. declare module "babylonjs/Materials/fresnelParameters" {
  26697. import { Color3 } from "babylonjs/Maths/math.color";
  26698. /**
  26699. * This represents all the required information to add a fresnel effect on a material:
  26700. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26701. */
  26702. export class FresnelParameters {
  26703. private _isEnabled;
  26704. /**
  26705. * Define if the fresnel effect is enable or not.
  26706. */
  26707. get isEnabled(): boolean;
  26708. set isEnabled(value: boolean);
  26709. /**
  26710. * Define the color used on edges (grazing angle)
  26711. */
  26712. leftColor: Color3;
  26713. /**
  26714. * Define the color used on center
  26715. */
  26716. rightColor: Color3;
  26717. /**
  26718. * Define bias applied to computed fresnel term
  26719. */
  26720. bias: number;
  26721. /**
  26722. * Defined the power exponent applied to fresnel term
  26723. */
  26724. power: number;
  26725. /**
  26726. * Clones the current fresnel and its valuues
  26727. * @returns a clone fresnel configuration
  26728. */
  26729. clone(): FresnelParameters;
  26730. /**
  26731. * Serializes the current fresnel parameters to a JSON representation.
  26732. * @return the JSON serialization
  26733. */
  26734. serialize(): any;
  26735. /**
  26736. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26737. * @param parsedFresnelParameters Define the JSON representation
  26738. * @returns the parsed parameters
  26739. */
  26740. static Parse(parsedFresnelParameters: any): FresnelParameters;
  26741. }
  26742. }
  26743. declare module "babylonjs/Materials/pushMaterial" {
  26744. import { Nullable } from "babylonjs/types";
  26745. import { Scene } from "babylonjs/scene";
  26746. import { Matrix } from "babylonjs/Maths/math.vector";
  26747. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26748. import { Mesh } from "babylonjs/Meshes/mesh";
  26749. import { Material } from "babylonjs/Materials/material";
  26750. import { Effect } from "babylonjs/Materials/effect";
  26751. /**
  26752. * Base class of materials working in push mode in babylon JS
  26753. * @hidden
  26754. */
  26755. export class PushMaterial extends Material {
  26756. protected _activeEffect: Effect;
  26757. protected _normalMatrix: Matrix;
  26758. /**
  26759. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26760. * This means that the material can keep using a previous shader while a new one is being compiled.
  26761. * This is mostly used when shader parallel compilation is supported (true by default)
  26762. */
  26763. allowShaderHotSwapping: boolean;
  26764. constructor(name: string, scene: Scene);
  26765. getEffect(): Effect;
  26766. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26767. /**
  26768. * Binds the given world matrix to the active effect
  26769. *
  26770. * @param world the matrix to bind
  26771. */
  26772. bindOnlyWorldMatrix(world: Matrix): void;
  26773. /**
  26774. * Binds the given normal matrix to the active effect
  26775. *
  26776. * @param normalMatrix the matrix to bind
  26777. */
  26778. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26779. bind(world: Matrix, mesh?: Mesh): void;
  26780. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26781. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26782. }
  26783. }
  26784. declare module "babylonjs/Materials/materialFlags" {
  26785. /**
  26786. * This groups all the flags used to control the materials channel.
  26787. */
  26788. export class MaterialFlags {
  26789. private static _DiffuseTextureEnabled;
  26790. /**
  26791. * Are diffuse textures enabled in the application.
  26792. */
  26793. static get DiffuseTextureEnabled(): boolean;
  26794. static set DiffuseTextureEnabled(value: boolean);
  26795. private static _AmbientTextureEnabled;
  26796. /**
  26797. * Are ambient textures enabled in the application.
  26798. */
  26799. static get AmbientTextureEnabled(): boolean;
  26800. static set AmbientTextureEnabled(value: boolean);
  26801. private static _OpacityTextureEnabled;
  26802. /**
  26803. * Are opacity textures enabled in the application.
  26804. */
  26805. static get OpacityTextureEnabled(): boolean;
  26806. static set OpacityTextureEnabled(value: boolean);
  26807. private static _ReflectionTextureEnabled;
  26808. /**
  26809. * Are reflection textures enabled in the application.
  26810. */
  26811. static get ReflectionTextureEnabled(): boolean;
  26812. static set ReflectionTextureEnabled(value: boolean);
  26813. private static _EmissiveTextureEnabled;
  26814. /**
  26815. * Are emissive textures enabled in the application.
  26816. */
  26817. static get EmissiveTextureEnabled(): boolean;
  26818. static set EmissiveTextureEnabled(value: boolean);
  26819. private static _SpecularTextureEnabled;
  26820. /**
  26821. * Are specular textures enabled in the application.
  26822. */
  26823. static get SpecularTextureEnabled(): boolean;
  26824. static set SpecularTextureEnabled(value: boolean);
  26825. private static _BumpTextureEnabled;
  26826. /**
  26827. * Are bump textures enabled in the application.
  26828. */
  26829. static get BumpTextureEnabled(): boolean;
  26830. static set BumpTextureEnabled(value: boolean);
  26831. private static _LightmapTextureEnabled;
  26832. /**
  26833. * Are lightmap textures enabled in the application.
  26834. */
  26835. static get LightmapTextureEnabled(): boolean;
  26836. static set LightmapTextureEnabled(value: boolean);
  26837. private static _RefractionTextureEnabled;
  26838. /**
  26839. * Are refraction textures enabled in the application.
  26840. */
  26841. static get RefractionTextureEnabled(): boolean;
  26842. static set RefractionTextureEnabled(value: boolean);
  26843. private static _ColorGradingTextureEnabled;
  26844. /**
  26845. * Are color grading textures enabled in the application.
  26846. */
  26847. static get ColorGradingTextureEnabled(): boolean;
  26848. static set ColorGradingTextureEnabled(value: boolean);
  26849. private static _FresnelEnabled;
  26850. /**
  26851. * Are fresnels enabled in the application.
  26852. */
  26853. static get FresnelEnabled(): boolean;
  26854. static set FresnelEnabled(value: boolean);
  26855. private static _ClearCoatTextureEnabled;
  26856. /**
  26857. * Are clear coat textures enabled in the application.
  26858. */
  26859. static get ClearCoatTextureEnabled(): boolean;
  26860. static set ClearCoatTextureEnabled(value: boolean);
  26861. private static _ClearCoatBumpTextureEnabled;
  26862. /**
  26863. * Are clear coat bump textures enabled in the application.
  26864. */
  26865. static get ClearCoatBumpTextureEnabled(): boolean;
  26866. static set ClearCoatBumpTextureEnabled(value: boolean);
  26867. private static _ClearCoatTintTextureEnabled;
  26868. /**
  26869. * Are clear coat tint textures enabled in the application.
  26870. */
  26871. static get ClearCoatTintTextureEnabled(): boolean;
  26872. static set ClearCoatTintTextureEnabled(value: boolean);
  26873. private static _SheenTextureEnabled;
  26874. /**
  26875. * Are sheen textures enabled in the application.
  26876. */
  26877. static get SheenTextureEnabled(): boolean;
  26878. static set SheenTextureEnabled(value: boolean);
  26879. private static _AnisotropicTextureEnabled;
  26880. /**
  26881. * Are anisotropic textures enabled in the application.
  26882. */
  26883. static get AnisotropicTextureEnabled(): boolean;
  26884. static set AnisotropicTextureEnabled(value: boolean);
  26885. private static _ThicknessTextureEnabled;
  26886. /**
  26887. * Are thickness textures enabled in the application.
  26888. */
  26889. static get ThicknessTextureEnabled(): boolean;
  26890. static set ThicknessTextureEnabled(value: boolean);
  26891. }
  26892. }
  26893. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  26894. /** @hidden */
  26895. export var defaultFragmentDeclaration: {
  26896. name: string;
  26897. shader: string;
  26898. };
  26899. }
  26900. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  26901. /** @hidden */
  26902. export var defaultUboDeclaration: {
  26903. name: string;
  26904. shader: string;
  26905. };
  26906. }
  26907. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  26908. /** @hidden */
  26909. export var lightFragmentDeclaration: {
  26910. name: string;
  26911. shader: string;
  26912. };
  26913. }
  26914. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  26915. /** @hidden */
  26916. export var lightUboDeclaration: {
  26917. name: string;
  26918. shader: string;
  26919. };
  26920. }
  26921. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  26922. /** @hidden */
  26923. export var lightsFragmentFunctions: {
  26924. name: string;
  26925. shader: string;
  26926. };
  26927. }
  26928. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  26929. /** @hidden */
  26930. export var shadowsFragmentFunctions: {
  26931. name: string;
  26932. shader: string;
  26933. };
  26934. }
  26935. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  26936. /** @hidden */
  26937. export var fresnelFunction: {
  26938. name: string;
  26939. shader: string;
  26940. };
  26941. }
  26942. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  26943. /** @hidden */
  26944. export var reflectionFunction: {
  26945. name: string;
  26946. shader: string;
  26947. };
  26948. }
  26949. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  26950. /** @hidden */
  26951. export var bumpFragmentFunctions: {
  26952. name: string;
  26953. shader: string;
  26954. };
  26955. }
  26956. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  26957. /** @hidden */
  26958. export var logDepthDeclaration: {
  26959. name: string;
  26960. shader: string;
  26961. };
  26962. }
  26963. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  26964. /** @hidden */
  26965. export var bumpFragment: {
  26966. name: string;
  26967. shader: string;
  26968. };
  26969. }
  26970. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  26971. /** @hidden */
  26972. export var depthPrePass: {
  26973. name: string;
  26974. shader: string;
  26975. };
  26976. }
  26977. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  26978. /** @hidden */
  26979. export var lightFragment: {
  26980. name: string;
  26981. shader: string;
  26982. };
  26983. }
  26984. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  26985. /** @hidden */
  26986. export var logDepthFragment: {
  26987. name: string;
  26988. shader: string;
  26989. };
  26990. }
  26991. declare module "babylonjs/Shaders/default.fragment" {
  26992. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  26993. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  26994. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26995. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26996. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26997. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  26998. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  26999. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  27000. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  27001. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  27002. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  27003. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  27004. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  27005. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27006. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  27007. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  27008. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  27009. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  27010. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  27011. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  27012. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  27013. /** @hidden */
  27014. export var defaultPixelShader: {
  27015. name: string;
  27016. shader: string;
  27017. };
  27018. }
  27019. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  27020. /** @hidden */
  27021. export var defaultVertexDeclaration: {
  27022. name: string;
  27023. shader: string;
  27024. };
  27025. }
  27026. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  27027. /** @hidden */
  27028. export var bumpVertexDeclaration: {
  27029. name: string;
  27030. shader: string;
  27031. };
  27032. }
  27033. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  27034. /** @hidden */
  27035. export var bumpVertex: {
  27036. name: string;
  27037. shader: string;
  27038. };
  27039. }
  27040. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  27041. /** @hidden */
  27042. export var fogVertex: {
  27043. name: string;
  27044. shader: string;
  27045. };
  27046. }
  27047. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  27048. /** @hidden */
  27049. export var shadowsVertex: {
  27050. name: string;
  27051. shader: string;
  27052. };
  27053. }
  27054. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  27055. /** @hidden */
  27056. export var pointCloudVertex: {
  27057. name: string;
  27058. shader: string;
  27059. };
  27060. }
  27061. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  27062. /** @hidden */
  27063. export var logDepthVertex: {
  27064. name: string;
  27065. shader: string;
  27066. };
  27067. }
  27068. declare module "babylonjs/Shaders/default.vertex" {
  27069. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  27070. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  27071. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27072. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  27073. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  27074. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  27075. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  27076. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  27077. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27078. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27079. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  27080. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  27081. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27082. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  27083. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  27084. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  27085. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  27086. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  27087. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  27088. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  27089. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  27090. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  27091. /** @hidden */
  27092. export var defaultVertexShader: {
  27093. name: string;
  27094. shader: string;
  27095. };
  27096. }
  27097. declare module "babylonjs/Materials/standardMaterial" {
  27098. import { SmartArray } from "babylonjs/Misc/smartArray";
  27099. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27100. import { Nullable } from "babylonjs/types";
  27101. import { Scene } from "babylonjs/scene";
  27102. import { Matrix } from "babylonjs/Maths/math.vector";
  27103. import { Color3 } from "babylonjs/Maths/math.color";
  27104. import { SubMesh } from "babylonjs/Meshes/subMesh";
  27105. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27106. import { Mesh } from "babylonjs/Meshes/mesh";
  27107. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  27108. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  27109. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  27110. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  27111. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  27112. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27113. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27114. import "babylonjs/Shaders/default.fragment";
  27115. import "babylonjs/Shaders/default.vertex";
  27116. /** @hidden */
  27117. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  27118. MAINUV1: boolean;
  27119. MAINUV2: boolean;
  27120. DIFFUSE: boolean;
  27121. DIFFUSEDIRECTUV: number;
  27122. AMBIENT: boolean;
  27123. AMBIENTDIRECTUV: number;
  27124. OPACITY: boolean;
  27125. OPACITYDIRECTUV: number;
  27126. OPACITYRGB: boolean;
  27127. REFLECTION: boolean;
  27128. EMISSIVE: boolean;
  27129. EMISSIVEDIRECTUV: number;
  27130. SPECULAR: boolean;
  27131. SPECULARDIRECTUV: number;
  27132. BUMP: boolean;
  27133. BUMPDIRECTUV: number;
  27134. PARALLAX: boolean;
  27135. PARALLAXOCCLUSION: boolean;
  27136. SPECULAROVERALPHA: boolean;
  27137. CLIPPLANE: boolean;
  27138. CLIPPLANE2: boolean;
  27139. CLIPPLANE3: boolean;
  27140. CLIPPLANE4: boolean;
  27141. CLIPPLANE5: boolean;
  27142. CLIPPLANE6: boolean;
  27143. ALPHATEST: boolean;
  27144. DEPTHPREPASS: boolean;
  27145. ALPHAFROMDIFFUSE: boolean;
  27146. POINTSIZE: boolean;
  27147. FOG: boolean;
  27148. SPECULARTERM: boolean;
  27149. DIFFUSEFRESNEL: boolean;
  27150. OPACITYFRESNEL: boolean;
  27151. REFLECTIONFRESNEL: boolean;
  27152. REFRACTIONFRESNEL: boolean;
  27153. EMISSIVEFRESNEL: boolean;
  27154. FRESNEL: boolean;
  27155. NORMAL: boolean;
  27156. UV1: boolean;
  27157. UV2: boolean;
  27158. VERTEXCOLOR: boolean;
  27159. VERTEXALPHA: boolean;
  27160. NUM_BONE_INFLUENCERS: number;
  27161. BonesPerMesh: number;
  27162. BONETEXTURE: boolean;
  27163. INSTANCES: boolean;
  27164. GLOSSINESS: boolean;
  27165. ROUGHNESS: boolean;
  27166. EMISSIVEASILLUMINATION: boolean;
  27167. LINKEMISSIVEWITHDIFFUSE: boolean;
  27168. REFLECTIONFRESNELFROMSPECULAR: boolean;
  27169. LIGHTMAP: boolean;
  27170. LIGHTMAPDIRECTUV: number;
  27171. OBJECTSPACE_NORMALMAP: boolean;
  27172. USELIGHTMAPASSHADOWMAP: boolean;
  27173. REFLECTIONMAP_3D: boolean;
  27174. REFLECTIONMAP_SPHERICAL: boolean;
  27175. REFLECTIONMAP_PLANAR: boolean;
  27176. REFLECTIONMAP_CUBIC: boolean;
  27177. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  27178. REFLECTIONMAP_PROJECTION: boolean;
  27179. REFLECTIONMAP_SKYBOX: boolean;
  27180. REFLECTIONMAP_EXPLICIT: boolean;
  27181. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  27182. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  27183. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  27184. INVERTCUBICMAP: boolean;
  27185. LOGARITHMICDEPTH: boolean;
  27186. REFRACTION: boolean;
  27187. REFRACTIONMAP_3D: boolean;
  27188. REFLECTIONOVERALPHA: boolean;
  27189. TWOSIDEDLIGHTING: boolean;
  27190. SHADOWFLOAT: boolean;
  27191. MORPHTARGETS: boolean;
  27192. MORPHTARGETS_NORMAL: boolean;
  27193. MORPHTARGETS_TANGENT: boolean;
  27194. MORPHTARGETS_UV: boolean;
  27195. NUM_MORPH_INFLUENCERS: number;
  27196. NONUNIFORMSCALING: boolean;
  27197. PREMULTIPLYALPHA: boolean;
  27198. IMAGEPROCESSING: boolean;
  27199. VIGNETTE: boolean;
  27200. VIGNETTEBLENDMODEMULTIPLY: boolean;
  27201. VIGNETTEBLENDMODEOPAQUE: boolean;
  27202. TONEMAPPING: boolean;
  27203. TONEMAPPING_ACES: boolean;
  27204. CONTRAST: boolean;
  27205. COLORCURVES: boolean;
  27206. COLORGRADING: boolean;
  27207. COLORGRADING3D: boolean;
  27208. SAMPLER3DGREENDEPTH: boolean;
  27209. SAMPLER3DBGRMAP: boolean;
  27210. IMAGEPROCESSINGPOSTPROCESS: boolean;
  27211. MULTIVIEW: boolean;
  27212. /**
  27213. * If the reflection texture on this material is in linear color space
  27214. * @hidden
  27215. */
  27216. IS_REFLECTION_LINEAR: boolean;
  27217. /**
  27218. * If the refraction texture on this material is in linear color space
  27219. * @hidden
  27220. */
  27221. IS_REFRACTION_LINEAR: boolean;
  27222. EXPOSURE: boolean;
  27223. constructor();
  27224. setReflectionMode(modeToEnable: string): void;
  27225. }
  27226. /**
  27227. * This is the default material used in Babylon. It is the best trade off between quality
  27228. * and performances.
  27229. * @see http://doc.babylonjs.com/babylon101/materials
  27230. */
  27231. export class StandardMaterial extends PushMaterial {
  27232. private _diffuseTexture;
  27233. /**
  27234. * The basic texture of the material as viewed under a light.
  27235. */
  27236. diffuseTexture: Nullable<BaseTexture>;
  27237. private _ambientTexture;
  27238. /**
  27239. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  27240. */
  27241. ambientTexture: Nullable<BaseTexture>;
  27242. private _opacityTexture;
  27243. /**
  27244. * Define the transparency of the material from a texture.
  27245. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  27246. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  27247. */
  27248. opacityTexture: Nullable<BaseTexture>;
  27249. private _reflectionTexture;
  27250. /**
  27251. * Define the texture used to display the reflection.
  27252. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27253. */
  27254. reflectionTexture: Nullable<BaseTexture>;
  27255. private _emissiveTexture;
  27256. /**
  27257. * Define texture of the material as if self lit.
  27258. * This will be mixed in the final result even in the absence of light.
  27259. */
  27260. emissiveTexture: Nullable<BaseTexture>;
  27261. private _specularTexture;
  27262. /**
  27263. * Define how the color and intensity of the highlight given by the light in the material.
  27264. */
  27265. specularTexture: Nullable<BaseTexture>;
  27266. private _bumpTexture;
  27267. /**
  27268. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  27269. * 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.
  27270. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  27271. */
  27272. bumpTexture: Nullable<BaseTexture>;
  27273. private _lightmapTexture;
  27274. /**
  27275. * Complex lighting can be computationally expensive to compute at runtime.
  27276. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  27277. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  27278. */
  27279. lightmapTexture: Nullable<BaseTexture>;
  27280. private _refractionTexture;
  27281. /**
  27282. * Define the texture used to display the refraction.
  27283. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27284. */
  27285. refractionTexture: Nullable<BaseTexture>;
  27286. /**
  27287. * The color of the material lit by the environmental background lighting.
  27288. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  27289. */
  27290. ambientColor: Color3;
  27291. /**
  27292. * The basic color of the material as viewed under a light.
  27293. */
  27294. diffuseColor: Color3;
  27295. /**
  27296. * Define how the color and intensity of the highlight given by the light in the material.
  27297. */
  27298. specularColor: Color3;
  27299. /**
  27300. * Define the color of the material as if self lit.
  27301. * This will be mixed in the final result even in the absence of light.
  27302. */
  27303. emissiveColor: Color3;
  27304. /**
  27305. * Defines how sharp are the highlights in the material.
  27306. * The bigger the value the sharper giving a more glossy feeling to the result.
  27307. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  27308. */
  27309. specularPower: number;
  27310. private _useAlphaFromDiffuseTexture;
  27311. /**
  27312. * Does the transparency come from the diffuse texture alpha channel.
  27313. */
  27314. useAlphaFromDiffuseTexture: boolean;
  27315. private _useEmissiveAsIllumination;
  27316. /**
  27317. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  27318. */
  27319. useEmissiveAsIllumination: boolean;
  27320. private _linkEmissiveWithDiffuse;
  27321. /**
  27322. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  27323. * the emissive level when the final color is close to one.
  27324. */
  27325. linkEmissiveWithDiffuse: boolean;
  27326. private _useSpecularOverAlpha;
  27327. /**
  27328. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27329. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27330. */
  27331. useSpecularOverAlpha: boolean;
  27332. private _useReflectionOverAlpha;
  27333. /**
  27334. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27335. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27336. */
  27337. useReflectionOverAlpha: boolean;
  27338. private _disableLighting;
  27339. /**
  27340. * Does lights from the scene impacts this material.
  27341. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  27342. */
  27343. disableLighting: boolean;
  27344. private _useObjectSpaceNormalMap;
  27345. /**
  27346. * Allows using an object space normal map (instead of tangent space).
  27347. */
  27348. useObjectSpaceNormalMap: boolean;
  27349. private _useParallax;
  27350. /**
  27351. * Is parallax enabled or not.
  27352. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27353. */
  27354. useParallax: boolean;
  27355. private _useParallaxOcclusion;
  27356. /**
  27357. * Is parallax occlusion enabled or not.
  27358. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27359. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27360. */
  27361. useParallaxOcclusion: boolean;
  27362. /**
  27363. * 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.
  27364. */
  27365. parallaxScaleBias: number;
  27366. private _roughness;
  27367. /**
  27368. * Helps to define how blurry the reflections should appears in the material.
  27369. */
  27370. roughness: number;
  27371. /**
  27372. * In case of refraction, define the value of the index of refraction.
  27373. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27374. */
  27375. indexOfRefraction: number;
  27376. /**
  27377. * Invert the refraction texture alongside the y axis.
  27378. * It can be useful with procedural textures or probe for instance.
  27379. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27380. */
  27381. invertRefractionY: boolean;
  27382. /**
  27383. * Defines the alpha limits in alpha test mode.
  27384. */
  27385. alphaCutOff: number;
  27386. private _useLightmapAsShadowmap;
  27387. /**
  27388. * In case of light mapping, define whether the map contains light or shadow informations.
  27389. */
  27390. useLightmapAsShadowmap: boolean;
  27391. private _diffuseFresnelParameters;
  27392. /**
  27393. * Define the diffuse fresnel parameters of the material.
  27394. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27395. */
  27396. diffuseFresnelParameters: FresnelParameters;
  27397. private _opacityFresnelParameters;
  27398. /**
  27399. * Define the opacity fresnel parameters of the material.
  27400. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27401. */
  27402. opacityFresnelParameters: FresnelParameters;
  27403. private _reflectionFresnelParameters;
  27404. /**
  27405. * Define the reflection fresnel parameters of the material.
  27406. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27407. */
  27408. reflectionFresnelParameters: FresnelParameters;
  27409. private _refractionFresnelParameters;
  27410. /**
  27411. * Define the refraction fresnel parameters of the material.
  27412. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27413. */
  27414. refractionFresnelParameters: FresnelParameters;
  27415. private _emissiveFresnelParameters;
  27416. /**
  27417. * Define the emissive fresnel parameters of the material.
  27418. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27419. */
  27420. emissiveFresnelParameters: FresnelParameters;
  27421. private _useReflectionFresnelFromSpecular;
  27422. /**
  27423. * If true automatically deducts the fresnels values from the material specularity.
  27424. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27425. */
  27426. useReflectionFresnelFromSpecular: boolean;
  27427. private _useGlossinessFromSpecularMapAlpha;
  27428. /**
  27429. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27430. */
  27431. useGlossinessFromSpecularMapAlpha: boolean;
  27432. private _maxSimultaneousLights;
  27433. /**
  27434. * Defines the maximum number of lights that can be used in the material
  27435. */
  27436. maxSimultaneousLights: number;
  27437. private _invertNormalMapX;
  27438. /**
  27439. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27440. */
  27441. invertNormalMapX: boolean;
  27442. private _invertNormalMapY;
  27443. /**
  27444. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27445. */
  27446. invertNormalMapY: boolean;
  27447. private _twoSidedLighting;
  27448. /**
  27449. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27450. */
  27451. twoSidedLighting: boolean;
  27452. /**
  27453. * Default configuration related to image processing available in the standard Material.
  27454. */
  27455. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27456. /**
  27457. * Gets the image processing configuration used either in this material.
  27458. */
  27459. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27460. /**
  27461. * Sets the Default image processing configuration used either in the this material.
  27462. *
  27463. * If sets to null, the scene one is in use.
  27464. */
  27465. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27466. /**
  27467. * Keep track of the image processing observer to allow dispose and replace.
  27468. */
  27469. private _imageProcessingObserver;
  27470. /**
  27471. * Attaches a new image processing configuration to the Standard Material.
  27472. * @param configuration
  27473. */
  27474. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27475. /**
  27476. * Gets wether the color curves effect is enabled.
  27477. */
  27478. get cameraColorCurvesEnabled(): boolean;
  27479. /**
  27480. * Sets wether the color curves effect is enabled.
  27481. */
  27482. set cameraColorCurvesEnabled(value: boolean);
  27483. /**
  27484. * Gets wether the color grading effect is enabled.
  27485. */
  27486. get cameraColorGradingEnabled(): boolean;
  27487. /**
  27488. * Gets wether the color grading effect is enabled.
  27489. */
  27490. set cameraColorGradingEnabled(value: boolean);
  27491. /**
  27492. * Gets wether tonemapping is enabled or not.
  27493. */
  27494. get cameraToneMappingEnabled(): boolean;
  27495. /**
  27496. * Sets wether tonemapping is enabled or not
  27497. */
  27498. set cameraToneMappingEnabled(value: boolean);
  27499. /**
  27500. * The camera exposure used on this material.
  27501. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27502. * This corresponds to a photographic exposure.
  27503. */
  27504. get cameraExposure(): number;
  27505. /**
  27506. * The camera exposure used on this material.
  27507. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27508. * This corresponds to a photographic exposure.
  27509. */
  27510. set cameraExposure(value: number);
  27511. /**
  27512. * Gets The camera contrast used on this material.
  27513. */
  27514. get cameraContrast(): number;
  27515. /**
  27516. * Sets The camera contrast used on this material.
  27517. */
  27518. set cameraContrast(value: number);
  27519. /**
  27520. * Gets the Color Grading 2D Lookup Texture.
  27521. */
  27522. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27523. /**
  27524. * Sets the Color Grading 2D Lookup Texture.
  27525. */
  27526. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27527. /**
  27528. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27529. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27530. * 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;
  27531. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27532. */
  27533. get cameraColorCurves(): Nullable<ColorCurves>;
  27534. /**
  27535. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27536. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27537. * 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;
  27538. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27539. */
  27540. set cameraColorCurves(value: Nullable<ColorCurves>);
  27541. /**
  27542. * Custom callback helping to override the default shader used in the material.
  27543. */
  27544. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  27545. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27546. protected _worldViewProjectionMatrix: Matrix;
  27547. protected _globalAmbientColor: Color3;
  27548. protected _useLogarithmicDepth: boolean;
  27549. protected _rebuildInParallel: boolean;
  27550. /**
  27551. * Instantiates a new standard material.
  27552. * This is the default material used in Babylon. It is the best trade off between quality
  27553. * and performances.
  27554. * @see http://doc.babylonjs.com/babylon101/materials
  27555. * @param name Define the name of the material in the scene
  27556. * @param scene Define the scene the material belong to
  27557. */
  27558. constructor(name: string, scene: Scene);
  27559. /**
  27560. * Gets a boolean indicating that current material needs to register RTT
  27561. */
  27562. get hasRenderTargetTextures(): boolean;
  27563. /**
  27564. * Gets the current class name of the material e.g. "StandardMaterial"
  27565. * Mainly use in serialization.
  27566. * @returns the class name
  27567. */
  27568. getClassName(): string;
  27569. /**
  27570. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27571. * You can try switching to logarithmic depth.
  27572. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27573. */
  27574. get useLogarithmicDepth(): boolean;
  27575. set useLogarithmicDepth(value: boolean);
  27576. /**
  27577. * Specifies if the material will require alpha blending
  27578. * @returns a boolean specifying if alpha blending is needed
  27579. */
  27580. needAlphaBlending(): boolean;
  27581. /**
  27582. * Specifies if this material should be rendered in alpha test mode
  27583. * @returns a boolean specifying if an alpha test is needed.
  27584. */
  27585. needAlphaTesting(): boolean;
  27586. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27587. /**
  27588. * Get the texture used for alpha test purpose.
  27589. * @returns the diffuse texture in case of the standard material.
  27590. */
  27591. getAlphaTestTexture(): Nullable<BaseTexture>;
  27592. /**
  27593. * Get if the submesh is ready to be used and all its information available.
  27594. * Child classes can use it to update shaders
  27595. * @param mesh defines the mesh to check
  27596. * @param subMesh defines which submesh to check
  27597. * @param useInstances specifies that instances should be used
  27598. * @returns a boolean indicating that the submesh is ready or not
  27599. */
  27600. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27601. /**
  27602. * Builds the material UBO layouts.
  27603. * Used internally during the effect preparation.
  27604. */
  27605. buildUniformLayout(): void;
  27606. /**
  27607. * Unbinds the material from the mesh
  27608. */
  27609. unbind(): void;
  27610. /**
  27611. * Binds the submesh to this material by preparing the effect and shader to draw
  27612. * @param world defines the world transformation matrix
  27613. * @param mesh defines the mesh containing the submesh
  27614. * @param subMesh defines the submesh to bind the material to
  27615. */
  27616. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27617. /**
  27618. * Get the list of animatables in the material.
  27619. * @returns the list of animatables object used in the material
  27620. */
  27621. getAnimatables(): IAnimatable[];
  27622. /**
  27623. * Gets the active textures from the material
  27624. * @returns an array of textures
  27625. */
  27626. getActiveTextures(): BaseTexture[];
  27627. /**
  27628. * Specifies if the material uses a texture
  27629. * @param texture defines the texture to check against the material
  27630. * @returns a boolean specifying if the material uses the texture
  27631. */
  27632. hasTexture(texture: BaseTexture): boolean;
  27633. /**
  27634. * Disposes the material
  27635. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27636. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27637. */
  27638. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27639. /**
  27640. * Makes a duplicate of the material, and gives it a new name
  27641. * @param name defines the new name for the duplicated material
  27642. * @returns the cloned material
  27643. */
  27644. clone(name: string): StandardMaterial;
  27645. /**
  27646. * Serializes this material in a JSON representation
  27647. * @returns the serialized material object
  27648. */
  27649. serialize(): any;
  27650. /**
  27651. * Creates a standard material from parsed material data
  27652. * @param source defines the JSON representation of the material
  27653. * @param scene defines the hosting scene
  27654. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27655. * @returns a new standard material
  27656. */
  27657. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27658. /**
  27659. * Are diffuse textures enabled in the application.
  27660. */
  27661. static get DiffuseTextureEnabled(): boolean;
  27662. static set DiffuseTextureEnabled(value: boolean);
  27663. /**
  27664. * Are ambient textures enabled in the application.
  27665. */
  27666. static get AmbientTextureEnabled(): boolean;
  27667. static set AmbientTextureEnabled(value: boolean);
  27668. /**
  27669. * Are opacity textures enabled in the application.
  27670. */
  27671. static get OpacityTextureEnabled(): boolean;
  27672. static set OpacityTextureEnabled(value: boolean);
  27673. /**
  27674. * Are reflection textures enabled in the application.
  27675. */
  27676. static get ReflectionTextureEnabled(): boolean;
  27677. static set ReflectionTextureEnabled(value: boolean);
  27678. /**
  27679. * Are emissive textures enabled in the application.
  27680. */
  27681. static get EmissiveTextureEnabled(): boolean;
  27682. static set EmissiveTextureEnabled(value: boolean);
  27683. /**
  27684. * Are specular textures enabled in the application.
  27685. */
  27686. static get SpecularTextureEnabled(): boolean;
  27687. static set SpecularTextureEnabled(value: boolean);
  27688. /**
  27689. * Are bump textures enabled in the application.
  27690. */
  27691. static get BumpTextureEnabled(): boolean;
  27692. static set BumpTextureEnabled(value: boolean);
  27693. /**
  27694. * Are lightmap textures enabled in the application.
  27695. */
  27696. static get LightmapTextureEnabled(): boolean;
  27697. static set LightmapTextureEnabled(value: boolean);
  27698. /**
  27699. * Are refraction textures enabled in the application.
  27700. */
  27701. static get RefractionTextureEnabled(): boolean;
  27702. static set RefractionTextureEnabled(value: boolean);
  27703. /**
  27704. * Are color grading textures enabled in the application.
  27705. */
  27706. static get ColorGradingTextureEnabled(): boolean;
  27707. static set ColorGradingTextureEnabled(value: boolean);
  27708. /**
  27709. * Are fresnels enabled in the application.
  27710. */
  27711. static get FresnelEnabled(): boolean;
  27712. static set FresnelEnabled(value: boolean);
  27713. }
  27714. }
  27715. declare module "babylonjs/Particles/solidParticleSystem" {
  27716. import { Nullable } from "babylonjs/types";
  27717. import { Vector3 } from "babylonjs/Maths/math.vector";
  27718. import { Mesh } from "babylonjs/Meshes/mesh";
  27719. import { Scene, IDisposable } from "babylonjs/scene";
  27720. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  27721. import { Material } from "babylonjs/Materials/material";
  27722. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  27723. /**
  27724. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27725. *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.
  27726. * The SPS is also a particle system. It provides some methods to manage the particles.
  27727. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27728. *
  27729. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27730. */
  27731. export class SolidParticleSystem implements IDisposable {
  27732. /**
  27733. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27734. * Example : var p = SPS.particles[i];
  27735. */
  27736. particles: SolidParticle[];
  27737. /**
  27738. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27739. */
  27740. nbParticles: number;
  27741. /**
  27742. * If the particles must ever face the camera (default false). Useful for planar particles.
  27743. */
  27744. billboard: boolean;
  27745. /**
  27746. * Recompute normals when adding a shape
  27747. */
  27748. recomputeNormals: boolean;
  27749. /**
  27750. * This a counter ofr your own usage. It's not set by any SPS functions.
  27751. */
  27752. counter: number;
  27753. /**
  27754. * The SPS name. This name is also given to the underlying mesh.
  27755. */
  27756. name: string;
  27757. /**
  27758. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27759. */
  27760. mesh: Mesh;
  27761. /**
  27762. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27763. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27764. */
  27765. vars: any;
  27766. /**
  27767. * This array is populated when the SPS is set as 'pickable'.
  27768. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27769. * Each element of this array is an object `{idx: int, faceId: int}`.
  27770. * `idx` is the picked particle index in the `SPS.particles` array
  27771. * `faceId` is the picked face index counted within this particle.
  27772. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27773. */
  27774. pickedParticles: {
  27775. idx: number;
  27776. faceId: number;
  27777. }[];
  27778. /**
  27779. * This array is populated when `enableDepthSort` is set to true.
  27780. * Each element of this array is an instance of the class DepthSortedParticle.
  27781. */
  27782. depthSortedParticles: DepthSortedParticle[];
  27783. /**
  27784. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27785. * @hidden
  27786. */
  27787. _bSphereOnly: boolean;
  27788. /**
  27789. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27790. * @hidden
  27791. */
  27792. _bSphereRadiusFactor: number;
  27793. private _scene;
  27794. private _positions;
  27795. private _indices;
  27796. private _normals;
  27797. private _colors;
  27798. private _uvs;
  27799. private _indices32;
  27800. private _positions32;
  27801. private _normals32;
  27802. private _fixedNormal32;
  27803. private _colors32;
  27804. private _uvs32;
  27805. private _index;
  27806. private _updatable;
  27807. private _pickable;
  27808. private _isVisibilityBoxLocked;
  27809. private _alwaysVisible;
  27810. private _depthSort;
  27811. private _expandable;
  27812. private _shapeCounter;
  27813. private _copy;
  27814. private _color;
  27815. private _computeParticleColor;
  27816. private _computeParticleTexture;
  27817. private _computeParticleRotation;
  27818. private _computeParticleVertex;
  27819. private _computeBoundingBox;
  27820. private _depthSortParticles;
  27821. private _camera;
  27822. private _mustUnrotateFixedNormals;
  27823. private _particlesIntersect;
  27824. private _needs32Bits;
  27825. private _isNotBuilt;
  27826. private _lastParticleId;
  27827. private _idxOfId;
  27828. private _multimaterialEnabled;
  27829. private _useModelMaterial;
  27830. private _indicesByMaterial;
  27831. private _materialIndexes;
  27832. private _depthSortFunction;
  27833. private _materialSortFunction;
  27834. private _materials;
  27835. private _multimaterial;
  27836. private _materialIndexesById;
  27837. private _defaultMaterial;
  27838. private _autoUpdateSubMeshes;
  27839. /**
  27840. * Creates a SPS (Solid Particle System) object.
  27841. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27842. * @param scene (Scene) is the scene in which the SPS is added.
  27843. * @param options defines the options of the sps e.g.
  27844. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27845. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27846. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27847. * * 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.
  27848. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27849. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27850. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27851. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27852. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27853. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27854. */
  27855. constructor(name: string, scene: Scene, options?: {
  27856. updatable?: boolean;
  27857. isPickable?: boolean;
  27858. enableDepthSort?: boolean;
  27859. particleIntersection?: boolean;
  27860. boundingSphereOnly?: boolean;
  27861. bSphereRadiusFactor?: number;
  27862. expandable?: boolean;
  27863. useModelMaterial?: boolean;
  27864. enableMultiMaterial?: boolean;
  27865. });
  27866. /**
  27867. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27868. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27869. * @returns the created mesh
  27870. */
  27871. buildMesh(): Mesh;
  27872. /**
  27873. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27874. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27875. * Thus the particles generated from `digest()` have their property `position` set yet.
  27876. * @param mesh ( Mesh ) is the mesh to be digested
  27877. * @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
  27878. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27879. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27880. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27881. * @returns the current SPS
  27882. */
  27883. digest(mesh: Mesh, options?: {
  27884. facetNb?: number;
  27885. number?: number;
  27886. delta?: number;
  27887. storage?: [];
  27888. }): SolidParticleSystem;
  27889. /**
  27890. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27891. * @hidden
  27892. */
  27893. private _unrotateFixedNormals;
  27894. /**
  27895. * Resets the temporary working copy particle
  27896. * @hidden
  27897. */
  27898. private _resetCopy;
  27899. /**
  27900. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27901. * @param p the current index in the positions array to be updated
  27902. * @param ind the current index in the indices array
  27903. * @param shape a Vector3 array, the shape geometry
  27904. * @param positions the positions array to be updated
  27905. * @param meshInd the shape indices array
  27906. * @param indices the indices array to be updated
  27907. * @param meshUV the shape uv array
  27908. * @param uvs the uv array to be updated
  27909. * @param meshCol the shape color array
  27910. * @param colors the color array to be updated
  27911. * @param meshNor the shape normals array
  27912. * @param normals the normals array to be updated
  27913. * @param idx the particle index
  27914. * @param idxInShape the particle index in its shape
  27915. * @param options the addShape() method passed options
  27916. * @model the particle model
  27917. * @hidden
  27918. */
  27919. private _meshBuilder;
  27920. /**
  27921. * Returns a shape Vector3 array from positions float array
  27922. * @param positions float array
  27923. * @returns a vector3 array
  27924. * @hidden
  27925. */
  27926. private _posToShape;
  27927. /**
  27928. * Returns a shapeUV array from a float uvs (array deep copy)
  27929. * @param uvs as a float array
  27930. * @returns a shapeUV array
  27931. * @hidden
  27932. */
  27933. private _uvsToShapeUV;
  27934. /**
  27935. * Adds a new particle object in the particles array
  27936. * @param idx particle index in particles array
  27937. * @param id particle id
  27938. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27939. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27940. * @param model particle ModelShape object
  27941. * @param shapeId model shape identifier
  27942. * @param idxInShape index of the particle in the current model
  27943. * @param bInfo model bounding info object
  27944. * @param storage target storage array, if any
  27945. * @hidden
  27946. */
  27947. private _addParticle;
  27948. /**
  27949. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27950. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27951. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27952. * @param nb (positive integer) the number of particles to be created from this model
  27953. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27954. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27955. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27956. * @returns the number of shapes in the system
  27957. */
  27958. addShape(mesh: Mesh, nb: number, options?: {
  27959. positionFunction?: any;
  27960. vertexFunction?: any;
  27961. storage?: [];
  27962. }): number;
  27963. /**
  27964. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27965. * @hidden
  27966. */
  27967. private _rebuildParticle;
  27968. /**
  27969. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27970. * @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.
  27971. * @returns the SPS.
  27972. */
  27973. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27974. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27975. * Returns an array with the removed particles.
  27976. * 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.
  27977. * The SPS can't be empty so at least one particle needs to remain in place.
  27978. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27979. * @param start index of the first particle to remove
  27980. * @param end index of the last particle to remove (included)
  27981. * @returns an array populated with the removed particles
  27982. */
  27983. removeParticles(start: number, end: number): SolidParticle[];
  27984. /**
  27985. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27986. * @param solidParticleArray an array populated with Solid Particles objects
  27987. * @returns the SPS
  27988. */
  27989. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27990. /**
  27991. * Creates a new particle and modifies the SPS mesh geometry :
  27992. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27993. * - calls _addParticle() to populate the particle array
  27994. * factorized code from addShape() and insertParticlesFromArray()
  27995. * @param idx particle index in the particles array
  27996. * @param i particle index in its shape
  27997. * @param modelShape particle ModelShape object
  27998. * @param shape shape vertex array
  27999. * @param meshInd shape indices array
  28000. * @param meshUV shape uv array
  28001. * @param meshCol shape color array
  28002. * @param meshNor shape normals array
  28003. * @param bbInfo shape bounding info
  28004. * @param storage target particle storage
  28005. * @options addShape() passed options
  28006. * @hidden
  28007. */
  28008. private _insertNewParticle;
  28009. /**
  28010. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  28011. * This method calls `updateParticle()` for each particle of the SPS.
  28012. * For an animated SPS, it is usually called within the render loop.
  28013. * 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.
  28014. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  28015. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  28016. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  28017. * @returns the SPS.
  28018. */
  28019. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  28020. /**
  28021. * Disposes the SPS.
  28022. */
  28023. dispose(): void;
  28024. /**
  28025. * Returns a SolidParticle object from its identifier : particle.id
  28026. * @param id (integer) the particle Id
  28027. * @returns the searched particle or null if not found in the SPS.
  28028. */
  28029. getParticleById(id: number): Nullable<SolidParticle>;
  28030. /**
  28031. * Returns a new array populated with the particles having the passed shapeId.
  28032. * @param shapeId (integer) the shape identifier
  28033. * @returns a new solid particle array
  28034. */
  28035. getParticlesByShapeId(shapeId: number): SolidParticle[];
  28036. /**
  28037. * Populates the passed array "ref" with the particles having the passed shapeId.
  28038. * @param shapeId the shape identifier
  28039. * @returns the SPS
  28040. * @param ref
  28041. */
  28042. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  28043. /**
  28044. * Computes the required SubMeshes according the materials assigned to the particles.
  28045. * @returns the solid particle system.
  28046. * Does nothing if called before the SPS mesh is built.
  28047. */
  28048. computeSubMeshes(): SolidParticleSystem;
  28049. /**
  28050. * Sorts the solid particles by material when MultiMaterial is enabled.
  28051. * Updates the indices32 array.
  28052. * Updates the indicesByMaterial array.
  28053. * Updates the mesh indices array.
  28054. * @returns the SPS
  28055. * @hidden
  28056. */
  28057. private _sortParticlesByMaterial;
  28058. /**
  28059. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  28060. * @hidden
  28061. */
  28062. private _setMaterialIndexesById;
  28063. /**
  28064. * Returns an array with unique values of Materials from the passed array
  28065. * @param array the material array to be checked and filtered
  28066. * @hidden
  28067. */
  28068. private _filterUniqueMaterialId;
  28069. /**
  28070. * Sets a new Standard Material as _defaultMaterial if not already set.
  28071. * @hidden
  28072. */
  28073. private _setDefaultMaterial;
  28074. /**
  28075. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  28076. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28077. * @returns the SPS.
  28078. */
  28079. refreshVisibleSize(): SolidParticleSystem;
  28080. /**
  28081. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  28082. * @param size the size (float) of the visibility box
  28083. * note : this doesn't lock the SPS mesh bounding box.
  28084. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28085. */
  28086. setVisibilityBox(size: number): void;
  28087. /**
  28088. * Gets whether the SPS as always visible or not
  28089. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28090. */
  28091. get isAlwaysVisible(): boolean;
  28092. /**
  28093. * Sets the SPS as always visible or not
  28094. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28095. */
  28096. set isAlwaysVisible(val: boolean);
  28097. /**
  28098. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28099. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28100. */
  28101. set isVisibilityBoxLocked(val: boolean);
  28102. /**
  28103. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28104. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28105. */
  28106. get isVisibilityBoxLocked(): boolean;
  28107. /**
  28108. * Tells to `setParticles()` to compute the particle rotations or not.
  28109. * Default value : true. The SPS is faster when it's set to false.
  28110. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28111. */
  28112. set computeParticleRotation(val: boolean);
  28113. /**
  28114. * Tells to `setParticles()` to compute the particle colors or not.
  28115. * Default value : true. The SPS is faster when it's set to false.
  28116. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28117. */
  28118. set computeParticleColor(val: boolean);
  28119. set computeParticleTexture(val: boolean);
  28120. /**
  28121. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  28122. * Default value : false. The SPS is faster when it's set to false.
  28123. * Note : the particle custom vertex positions aren't stored values.
  28124. */
  28125. set computeParticleVertex(val: boolean);
  28126. /**
  28127. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  28128. */
  28129. set computeBoundingBox(val: boolean);
  28130. /**
  28131. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  28132. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28133. * Default : `true`
  28134. */
  28135. set depthSortParticles(val: boolean);
  28136. /**
  28137. * Gets if `setParticles()` computes the particle rotations or not.
  28138. * Default value : true. The SPS is faster when it's set to false.
  28139. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28140. */
  28141. get computeParticleRotation(): boolean;
  28142. /**
  28143. * Gets if `setParticles()` computes the particle colors or not.
  28144. * Default value : true. The SPS is faster when it's set to false.
  28145. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28146. */
  28147. get computeParticleColor(): boolean;
  28148. /**
  28149. * Gets if `setParticles()` computes the particle textures or not.
  28150. * Default value : true. The SPS is faster when it's set to false.
  28151. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  28152. */
  28153. get computeParticleTexture(): boolean;
  28154. /**
  28155. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  28156. * Default value : false. The SPS is faster when it's set to false.
  28157. * Note : the particle custom vertex positions aren't stored values.
  28158. */
  28159. get computeParticleVertex(): boolean;
  28160. /**
  28161. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  28162. */
  28163. get computeBoundingBox(): boolean;
  28164. /**
  28165. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  28166. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28167. * Default : `true`
  28168. */
  28169. get depthSortParticles(): boolean;
  28170. /**
  28171. * Gets if the SPS is created as expandable at construction time.
  28172. * Default : `false`
  28173. */
  28174. get expandable(): boolean;
  28175. /**
  28176. * Gets if the SPS supports the Multi Materials
  28177. */
  28178. get multimaterialEnabled(): boolean;
  28179. /**
  28180. * Gets if the SPS uses the model materials for its own multimaterial.
  28181. */
  28182. get useModelMaterial(): boolean;
  28183. /**
  28184. * The SPS used material array.
  28185. */
  28186. get materials(): Material[];
  28187. /**
  28188. * Sets the SPS MultiMaterial from the passed materials.
  28189. * Note : the passed array is internally copied and not used then by reference.
  28190. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  28191. */
  28192. setMultiMaterial(materials: Material[]): void;
  28193. /**
  28194. * The SPS computed multimaterial object
  28195. */
  28196. get multimaterial(): MultiMaterial;
  28197. set multimaterial(mm: MultiMaterial);
  28198. /**
  28199. * If the subMeshes must be updated on the next call to setParticles()
  28200. */
  28201. get autoUpdateSubMeshes(): boolean;
  28202. set autoUpdateSubMeshes(val: boolean);
  28203. /**
  28204. * This function does nothing. It may be overwritten to set all the particle first values.
  28205. * The SPS doesn't call this function, you may have to call it by your own.
  28206. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28207. */
  28208. initParticles(): void;
  28209. /**
  28210. * This function does nothing. It may be overwritten to recycle a particle.
  28211. * The SPS doesn't call this function, you may have to call it by your own.
  28212. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28213. * @param particle The particle to recycle
  28214. * @returns the recycled particle
  28215. */
  28216. recycleParticle(particle: SolidParticle): SolidParticle;
  28217. /**
  28218. * Updates a particle : this function should be overwritten by the user.
  28219. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  28220. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28221. * @example : just set a particle position or velocity and recycle conditions
  28222. * @param particle The particle to update
  28223. * @returns the updated particle
  28224. */
  28225. updateParticle(particle: SolidParticle): SolidParticle;
  28226. /**
  28227. * Updates a vertex of a particle : it can be overwritten by the user.
  28228. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  28229. * @param particle the current particle
  28230. * @param vertex the current index of the current particle
  28231. * @param pt the index of the current vertex in the particle shape
  28232. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  28233. * @example : just set a vertex particle position
  28234. * @returns the updated vertex
  28235. */
  28236. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  28237. /**
  28238. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  28239. * This does nothing and may be overwritten by the user.
  28240. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28241. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28242. * @param update the boolean update value actually passed to setParticles()
  28243. */
  28244. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28245. /**
  28246. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  28247. * This will be passed three parameters.
  28248. * This does nothing and may be overwritten by the user.
  28249. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28250. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28251. * @param update the boolean update value actually passed to setParticles()
  28252. */
  28253. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28254. }
  28255. }
  28256. declare module "babylonjs/Particles/solidParticle" {
  28257. import { Nullable } from "babylonjs/types";
  28258. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  28259. import { Color4 } from "babylonjs/Maths/math.color";
  28260. import { Mesh } from "babylonjs/Meshes/mesh";
  28261. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28262. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  28263. import { Plane } from "babylonjs/Maths/math.plane";
  28264. import { Material } from "babylonjs/Materials/material";
  28265. /**
  28266. * Represents one particle of a solid particle system.
  28267. */
  28268. export class SolidParticle {
  28269. /**
  28270. * particle global index
  28271. */
  28272. idx: number;
  28273. /**
  28274. * particle identifier
  28275. */
  28276. id: number;
  28277. /**
  28278. * The color of the particle
  28279. */
  28280. color: Nullable<Color4>;
  28281. /**
  28282. * The world space position of the particle.
  28283. */
  28284. position: Vector3;
  28285. /**
  28286. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  28287. */
  28288. rotation: Vector3;
  28289. /**
  28290. * The world space rotation quaternion of the particle.
  28291. */
  28292. rotationQuaternion: Nullable<Quaternion>;
  28293. /**
  28294. * The scaling of the particle.
  28295. */
  28296. scaling: Vector3;
  28297. /**
  28298. * The uvs of the particle.
  28299. */
  28300. uvs: Vector4;
  28301. /**
  28302. * The current speed of the particle.
  28303. */
  28304. velocity: Vector3;
  28305. /**
  28306. * The pivot point in the particle local space.
  28307. */
  28308. pivot: Vector3;
  28309. /**
  28310. * Must the particle be translated from its pivot point in its local space ?
  28311. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  28312. * Default : false
  28313. */
  28314. translateFromPivot: boolean;
  28315. /**
  28316. * Is the particle active or not ?
  28317. */
  28318. alive: boolean;
  28319. /**
  28320. * Is the particle visible or not ?
  28321. */
  28322. isVisible: boolean;
  28323. /**
  28324. * Index of this particle in the global "positions" array (Internal use)
  28325. * @hidden
  28326. */
  28327. _pos: number;
  28328. /**
  28329. * @hidden Index of this particle in the global "indices" array (Internal use)
  28330. */
  28331. _ind: number;
  28332. /**
  28333. * @hidden ModelShape of this particle (Internal use)
  28334. */
  28335. _model: ModelShape;
  28336. /**
  28337. * ModelShape id of this particle
  28338. */
  28339. shapeId: number;
  28340. /**
  28341. * Index of the particle in its shape id
  28342. */
  28343. idxInShape: number;
  28344. /**
  28345. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28346. */
  28347. _modelBoundingInfo: BoundingInfo;
  28348. /**
  28349. * @hidden Particle BoundingInfo object (Internal use)
  28350. */
  28351. _boundingInfo: BoundingInfo;
  28352. /**
  28353. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28354. */
  28355. _sps: SolidParticleSystem;
  28356. /**
  28357. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28358. */
  28359. _stillInvisible: boolean;
  28360. /**
  28361. * @hidden Last computed particle rotation matrix
  28362. */
  28363. _rotationMatrix: number[];
  28364. /**
  28365. * Parent particle Id, if any.
  28366. * Default null.
  28367. */
  28368. parentId: Nullable<number>;
  28369. /**
  28370. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28371. */
  28372. materialIndex: Nullable<number>;
  28373. /**
  28374. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28375. * The possible values are :
  28376. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28377. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28378. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28379. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28380. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28381. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28382. * */
  28383. cullingStrategy: number;
  28384. /**
  28385. * @hidden Internal global position in the SPS.
  28386. */
  28387. _globalPosition: Vector3;
  28388. /**
  28389. * Creates a Solid Particle object.
  28390. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28391. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28392. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28393. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28394. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28395. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28396. * @param shapeId (integer) is the model shape identifier in the SPS.
  28397. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28398. * @param sps defines the sps it is associated to
  28399. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28400. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28401. */
  28402. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28403. /**
  28404. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28405. * @param target the particle target
  28406. * @returns the current particle
  28407. */
  28408. copyToRef(target: SolidParticle): SolidParticle;
  28409. /**
  28410. * Legacy support, changed scale to scaling
  28411. */
  28412. get scale(): Vector3;
  28413. /**
  28414. * Legacy support, changed scale to scaling
  28415. */
  28416. set scale(scale: Vector3);
  28417. /**
  28418. * Legacy support, changed quaternion to rotationQuaternion
  28419. */
  28420. get quaternion(): Nullable<Quaternion>;
  28421. /**
  28422. * Legacy support, changed quaternion to rotationQuaternion
  28423. */
  28424. set quaternion(q: Nullable<Quaternion>);
  28425. /**
  28426. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  28427. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  28428. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  28429. * @returns true if it intersects
  28430. */
  28431. intersectsMesh(target: Mesh | SolidParticle): boolean;
  28432. /**
  28433. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  28434. * A particle is in the frustum if its bounding box intersects the frustum
  28435. * @param frustumPlanes defines the frustum to test
  28436. * @returns true if the particle is in the frustum planes
  28437. */
  28438. isInFrustum(frustumPlanes: Plane[]): boolean;
  28439. /**
  28440. * get the rotation matrix of the particle
  28441. * @hidden
  28442. */
  28443. getRotationMatrix(m: Matrix): void;
  28444. }
  28445. /**
  28446. * Represents the shape of the model used by one particle of a solid particle system.
  28447. * SPS internal tool, don't use it manually.
  28448. */
  28449. export class ModelShape {
  28450. /**
  28451. * The shape id
  28452. * @hidden
  28453. */
  28454. shapeID: number;
  28455. /**
  28456. * flat array of model positions (internal use)
  28457. * @hidden
  28458. */
  28459. _shape: Vector3[];
  28460. /**
  28461. * flat array of model UVs (internal use)
  28462. * @hidden
  28463. */
  28464. _shapeUV: number[];
  28465. /**
  28466. * color array of the model
  28467. * @hidden
  28468. */
  28469. _shapeColors: number[];
  28470. /**
  28471. * indices array of the model
  28472. * @hidden
  28473. */
  28474. _indices: number[];
  28475. /**
  28476. * normals array of the model
  28477. * @hidden
  28478. */
  28479. _normals: number[];
  28480. /**
  28481. * length of the shape in the model indices array (internal use)
  28482. * @hidden
  28483. */
  28484. _indicesLength: number;
  28485. /**
  28486. * Custom position function (internal use)
  28487. * @hidden
  28488. */
  28489. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28490. /**
  28491. * Custom vertex function (internal use)
  28492. * @hidden
  28493. */
  28494. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28495. /**
  28496. * Model material (internal use)
  28497. * @hidden
  28498. */
  28499. _material: Nullable<Material>;
  28500. /**
  28501. * 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.
  28502. * SPS internal tool, don't use it manually.
  28503. * @hidden
  28504. */
  28505. 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>);
  28506. }
  28507. /**
  28508. * Represents a Depth Sorted Particle in the solid particle system.
  28509. * @hidden
  28510. */
  28511. export class DepthSortedParticle {
  28512. /**
  28513. * Index of the particle in the "indices" array
  28514. */
  28515. ind: number;
  28516. /**
  28517. * Length of the particle shape in the "indices" array
  28518. */
  28519. indicesLength: number;
  28520. /**
  28521. * Squared distance from the particle to the camera
  28522. */
  28523. sqDistance: number;
  28524. /**
  28525. * Material index when used with MultiMaterials
  28526. */
  28527. materialIndex: number;
  28528. /**
  28529. * Creates a new sorted particle
  28530. * @param materialIndex
  28531. */
  28532. constructor(ind: number, indLength: number, materialIndex: number);
  28533. }
  28534. }
  28535. declare module "babylonjs/Collisions/meshCollisionData" {
  28536. import { Collider } from "babylonjs/Collisions/collider";
  28537. import { Vector3 } from "babylonjs/Maths/math.vector";
  28538. import { Nullable } from "babylonjs/types";
  28539. import { Observer } from "babylonjs/Misc/observable";
  28540. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28541. /**
  28542. * @hidden
  28543. */
  28544. export class _MeshCollisionData {
  28545. _checkCollisions: boolean;
  28546. _collisionMask: number;
  28547. _collisionGroup: number;
  28548. _collider: Nullable<Collider>;
  28549. _oldPositionForCollisions: Vector3;
  28550. _diffPositionForCollisions: Vector3;
  28551. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28552. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28553. }
  28554. }
  28555. declare module "babylonjs/Meshes/abstractMesh" {
  28556. import { Observable } from "babylonjs/Misc/observable";
  28557. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  28558. import { Camera } from "babylonjs/Cameras/camera";
  28559. import { Scene, IDisposable } from "babylonjs/scene";
  28560. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  28561. import { Node } from "babylonjs/node";
  28562. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28563. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28564. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28565. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28566. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28567. import { Material } from "babylonjs/Materials/material";
  28568. import { Light } from "babylonjs/Lights/light";
  28569. import { Skeleton } from "babylonjs/Bones/skeleton";
  28570. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  28571. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  28572. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  28573. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  28574. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28575. import { Plane } from "babylonjs/Maths/math.plane";
  28576. import { Ray } from "babylonjs/Culling/ray";
  28577. import { Collider } from "babylonjs/Collisions/collider";
  28578. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  28579. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  28580. /** @hidden */
  28581. class _FacetDataStorage {
  28582. facetPositions: Vector3[];
  28583. facetNormals: Vector3[];
  28584. facetPartitioning: number[][];
  28585. facetNb: number;
  28586. partitioningSubdivisions: number;
  28587. partitioningBBoxRatio: number;
  28588. facetDataEnabled: boolean;
  28589. facetParameters: any;
  28590. bbSize: Vector3;
  28591. subDiv: {
  28592. max: number;
  28593. X: number;
  28594. Y: number;
  28595. Z: number;
  28596. };
  28597. facetDepthSort: boolean;
  28598. facetDepthSortEnabled: boolean;
  28599. depthSortedIndices: IndicesArray;
  28600. depthSortedFacets: {
  28601. ind: number;
  28602. sqDistance: number;
  28603. }[];
  28604. facetDepthSortFunction: (f1: {
  28605. ind: number;
  28606. sqDistance: number;
  28607. }, f2: {
  28608. ind: number;
  28609. sqDistance: number;
  28610. }) => number;
  28611. facetDepthSortFrom: Vector3;
  28612. facetDepthSortOrigin: Vector3;
  28613. invertedMatrix: Matrix;
  28614. }
  28615. /**
  28616. * @hidden
  28617. **/
  28618. class _InternalAbstractMeshDataInfo {
  28619. _hasVertexAlpha: boolean;
  28620. _useVertexColors: boolean;
  28621. _numBoneInfluencers: number;
  28622. _applyFog: boolean;
  28623. _receiveShadows: boolean;
  28624. _facetData: _FacetDataStorage;
  28625. _visibility: number;
  28626. _skeleton: Nullable<Skeleton>;
  28627. _layerMask: number;
  28628. _computeBonesUsingShaders: boolean;
  28629. _isActive: boolean;
  28630. _onlyForInstances: boolean;
  28631. _isActiveIntermediate: boolean;
  28632. _onlyForInstancesIntermediate: boolean;
  28633. _actAsRegularMesh: boolean;
  28634. }
  28635. /**
  28636. * Class used to store all common mesh properties
  28637. */
  28638. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28639. /** No occlusion */
  28640. static OCCLUSION_TYPE_NONE: number;
  28641. /** Occlusion set to optimisitic */
  28642. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28643. /** Occlusion set to strict */
  28644. static OCCLUSION_TYPE_STRICT: number;
  28645. /** Use an accurante occlusion algorithm */
  28646. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28647. /** Use a conservative occlusion algorithm */
  28648. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28649. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28650. * Test order :
  28651. * Is the bounding sphere outside the frustum ?
  28652. * If not, are the bounding box vertices outside the frustum ?
  28653. * It not, then the cullable object is in the frustum.
  28654. */
  28655. static readonly CULLINGSTRATEGY_STANDARD: number;
  28656. /** Culling strategy : Bounding Sphere Only.
  28657. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28658. * It's also less accurate than the standard because some not visible objects can still be selected.
  28659. * Test : is the bounding sphere outside the frustum ?
  28660. * If not, then the cullable object is in the frustum.
  28661. */
  28662. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28663. /** Culling strategy : Optimistic Inclusion.
  28664. * This in an inclusion test first, then the standard exclusion test.
  28665. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28666. * 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.
  28667. * Anyway, it's as accurate as the standard strategy.
  28668. * Test :
  28669. * Is the cullable object bounding sphere center in the frustum ?
  28670. * If not, apply the default culling strategy.
  28671. */
  28672. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28673. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28674. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28675. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28676. * 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.
  28677. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28678. * Test :
  28679. * Is the cullable object bounding sphere center in the frustum ?
  28680. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28681. */
  28682. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28683. /**
  28684. * No billboard
  28685. */
  28686. static get BILLBOARDMODE_NONE(): number;
  28687. /** Billboard on X axis */
  28688. static get BILLBOARDMODE_X(): number;
  28689. /** Billboard on Y axis */
  28690. static get BILLBOARDMODE_Y(): number;
  28691. /** Billboard on Z axis */
  28692. static get BILLBOARDMODE_Z(): number;
  28693. /** Billboard on all axes */
  28694. static get BILLBOARDMODE_ALL(): number;
  28695. /** Billboard on using position instead of orientation */
  28696. static get BILLBOARDMODE_USE_POSITION(): number;
  28697. /** @hidden */
  28698. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28699. /**
  28700. * The culling strategy to use to check whether the mesh must be rendered or not.
  28701. * This value can be changed at any time and will be used on the next render mesh selection.
  28702. * The possible values are :
  28703. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28704. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28705. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28706. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28707. * Please read each static variable documentation to get details about the culling process.
  28708. * */
  28709. cullingStrategy: number;
  28710. /**
  28711. * Gets the number of facets in the mesh
  28712. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28713. */
  28714. get facetNb(): number;
  28715. /**
  28716. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28717. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28718. */
  28719. get partitioningSubdivisions(): number;
  28720. set partitioningSubdivisions(nb: number);
  28721. /**
  28722. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28723. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28724. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28725. */
  28726. get partitioningBBoxRatio(): number;
  28727. set partitioningBBoxRatio(ratio: number);
  28728. /**
  28729. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28730. * Works only for updatable meshes.
  28731. * Doesn't work with multi-materials
  28732. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28733. */
  28734. get mustDepthSortFacets(): boolean;
  28735. set mustDepthSortFacets(sort: boolean);
  28736. /**
  28737. * The location (Vector3) where the facet depth sort must be computed from.
  28738. * By default, the active camera position.
  28739. * Used only when facet depth sort is enabled
  28740. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28741. */
  28742. get facetDepthSortFrom(): Vector3;
  28743. set facetDepthSortFrom(location: Vector3);
  28744. /**
  28745. * gets a boolean indicating if facetData is enabled
  28746. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28747. */
  28748. get isFacetDataEnabled(): boolean;
  28749. /** @hidden */
  28750. _updateNonUniformScalingState(value: boolean): boolean;
  28751. /**
  28752. * An event triggered when this mesh collides with another one
  28753. */
  28754. onCollideObservable: Observable<AbstractMesh>;
  28755. /** Set a function to call when this mesh collides with another one */
  28756. set onCollide(callback: () => void);
  28757. /**
  28758. * An event triggered when the collision's position changes
  28759. */
  28760. onCollisionPositionChangeObservable: Observable<Vector3>;
  28761. /** Set a function to call when the collision's position changes */
  28762. set onCollisionPositionChange(callback: () => void);
  28763. /**
  28764. * An event triggered when material is changed
  28765. */
  28766. onMaterialChangedObservable: Observable<AbstractMesh>;
  28767. /**
  28768. * Gets or sets the orientation for POV movement & rotation
  28769. */
  28770. definedFacingForward: boolean;
  28771. /** @hidden */
  28772. _occlusionQuery: Nullable<WebGLQuery>;
  28773. /** @hidden */
  28774. _renderingGroup: Nullable<RenderingGroup>;
  28775. /**
  28776. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28777. */
  28778. get visibility(): number;
  28779. /**
  28780. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28781. */
  28782. set visibility(value: number);
  28783. /** Gets or sets the alpha index used to sort transparent meshes
  28784. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28785. */
  28786. alphaIndex: number;
  28787. /**
  28788. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28789. */
  28790. isVisible: boolean;
  28791. /**
  28792. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28793. */
  28794. isPickable: boolean;
  28795. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28796. showSubMeshesBoundingBox: boolean;
  28797. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28798. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28799. */
  28800. isBlocker: boolean;
  28801. /**
  28802. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28803. */
  28804. enablePointerMoveEvents: boolean;
  28805. /**
  28806. * Specifies the rendering group id for this mesh (0 by default)
  28807. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28808. */
  28809. renderingGroupId: number;
  28810. private _material;
  28811. /** Gets or sets current material */
  28812. get material(): Nullable<Material>;
  28813. set material(value: Nullable<Material>);
  28814. /**
  28815. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28816. * @see http://doc.babylonjs.com/babylon101/shadows
  28817. */
  28818. get receiveShadows(): boolean;
  28819. set receiveShadows(value: boolean);
  28820. /** Defines color to use when rendering outline */
  28821. outlineColor: Color3;
  28822. /** Define width to use when rendering outline */
  28823. outlineWidth: number;
  28824. /** Defines color to use when rendering overlay */
  28825. overlayColor: Color3;
  28826. /** Defines alpha to use when rendering overlay */
  28827. overlayAlpha: number;
  28828. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28829. get hasVertexAlpha(): boolean;
  28830. set hasVertexAlpha(value: boolean);
  28831. /** 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) */
  28832. get useVertexColors(): boolean;
  28833. set useVertexColors(value: boolean);
  28834. /**
  28835. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28836. */
  28837. get computeBonesUsingShaders(): boolean;
  28838. set computeBonesUsingShaders(value: boolean);
  28839. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28840. get numBoneInfluencers(): number;
  28841. set numBoneInfluencers(value: number);
  28842. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28843. get applyFog(): boolean;
  28844. set applyFog(value: boolean);
  28845. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28846. useOctreeForRenderingSelection: boolean;
  28847. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28848. useOctreeForPicking: boolean;
  28849. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28850. useOctreeForCollisions: boolean;
  28851. /**
  28852. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28853. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28854. */
  28855. get layerMask(): number;
  28856. set layerMask(value: number);
  28857. /**
  28858. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28859. */
  28860. alwaysSelectAsActiveMesh: boolean;
  28861. /**
  28862. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28863. */
  28864. doNotSyncBoundingInfo: boolean;
  28865. /**
  28866. * Gets or sets the current action manager
  28867. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28868. */
  28869. actionManager: Nullable<AbstractActionManager>;
  28870. private _meshCollisionData;
  28871. /**
  28872. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28873. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28874. */
  28875. ellipsoid: Vector3;
  28876. /**
  28877. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28878. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28879. */
  28880. ellipsoidOffset: Vector3;
  28881. /**
  28882. * Gets or sets a collision mask used to mask collisions (default is -1).
  28883. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28884. */
  28885. get collisionMask(): number;
  28886. set collisionMask(mask: number);
  28887. /**
  28888. * Gets or sets the current collision group mask (-1 by default).
  28889. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28890. */
  28891. get collisionGroup(): number;
  28892. set collisionGroup(mask: number);
  28893. /**
  28894. * Defines edge width used when edgesRenderer is enabled
  28895. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28896. */
  28897. edgesWidth: number;
  28898. /**
  28899. * Defines edge color used when edgesRenderer is enabled
  28900. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28901. */
  28902. edgesColor: Color4;
  28903. /** @hidden */
  28904. _edgesRenderer: Nullable<IEdgesRenderer>;
  28905. /** @hidden */
  28906. _masterMesh: Nullable<AbstractMesh>;
  28907. /** @hidden */
  28908. _boundingInfo: Nullable<BoundingInfo>;
  28909. /** @hidden */
  28910. _renderId: number;
  28911. /**
  28912. * Gets or sets the list of subMeshes
  28913. * @see http://doc.babylonjs.com/how_to/multi_materials
  28914. */
  28915. subMeshes: SubMesh[];
  28916. /** @hidden */
  28917. _intersectionsInProgress: AbstractMesh[];
  28918. /** @hidden */
  28919. _unIndexed: boolean;
  28920. /** @hidden */
  28921. _lightSources: Light[];
  28922. /** Gets the list of lights affecting that mesh */
  28923. get lightSources(): Light[];
  28924. /** @hidden */
  28925. get _positions(): Nullable<Vector3[]>;
  28926. /** @hidden */
  28927. _waitingData: {
  28928. lods: Nullable<any>;
  28929. actions: Nullable<any>;
  28930. freezeWorldMatrix: Nullable<boolean>;
  28931. };
  28932. /** @hidden */
  28933. _bonesTransformMatrices: Nullable<Float32Array>;
  28934. /** @hidden */
  28935. _transformMatrixTexture: Nullable<RawTexture>;
  28936. /**
  28937. * Gets or sets a skeleton to apply skining transformations
  28938. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28939. */
  28940. set skeleton(value: Nullable<Skeleton>);
  28941. get skeleton(): Nullable<Skeleton>;
  28942. /**
  28943. * An event triggered when the mesh is rebuilt.
  28944. */
  28945. onRebuildObservable: Observable<AbstractMesh>;
  28946. /**
  28947. * Creates a new AbstractMesh
  28948. * @param name defines the name of the mesh
  28949. * @param scene defines the hosting scene
  28950. */
  28951. constructor(name: string, scene?: Nullable<Scene>);
  28952. /**
  28953. * Returns the string "AbstractMesh"
  28954. * @returns "AbstractMesh"
  28955. */
  28956. getClassName(): string;
  28957. /**
  28958. * Gets a string representation of the current mesh
  28959. * @param fullDetails defines a boolean indicating if full details must be included
  28960. * @returns a string representation of the current mesh
  28961. */
  28962. toString(fullDetails?: boolean): string;
  28963. /**
  28964. * @hidden
  28965. */
  28966. protected _getEffectiveParent(): Nullable<Node>;
  28967. /** @hidden */
  28968. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28969. /** @hidden */
  28970. _rebuild(): void;
  28971. /** @hidden */
  28972. _resyncLightSources(): void;
  28973. /** @hidden */
  28974. _resyncLightSource(light: Light): void;
  28975. /** @hidden */
  28976. _unBindEffect(): void;
  28977. /** @hidden */
  28978. _removeLightSource(light: Light, dispose: boolean): void;
  28979. private _markSubMeshesAsDirty;
  28980. /** @hidden */
  28981. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28982. /** @hidden */
  28983. _markSubMeshesAsAttributesDirty(): void;
  28984. /** @hidden */
  28985. _markSubMeshesAsMiscDirty(): void;
  28986. /**
  28987. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28988. */
  28989. get scaling(): Vector3;
  28990. set scaling(newScaling: Vector3);
  28991. /**
  28992. * Returns true if the mesh is blocked. Implemented by child classes
  28993. */
  28994. get isBlocked(): boolean;
  28995. /**
  28996. * Returns the mesh itself by default. Implemented by child classes
  28997. * @param camera defines the camera to use to pick the right LOD level
  28998. * @returns the currentAbstractMesh
  28999. */
  29000. getLOD(camera: Camera): Nullable<AbstractMesh>;
  29001. /**
  29002. * Returns 0 by default. Implemented by child classes
  29003. * @returns an integer
  29004. */
  29005. getTotalVertices(): number;
  29006. /**
  29007. * Returns a positive integer : the total number of indices in this mesh geometry.
  29008. * @returns the numner of indices or zero if the mesh has no geometry.
  29009. */
  29010. getTotalIndices(): number;
  29011. /**
  29012. * Returns null by default. Implemented by child classes
  29013. * @returns null
  29014. */
  29015. getIndices(): Nullable<IndicesArray>;
  29016. /**
  29017. * Returns the array of the requested vertex data kind. Implemented by child classes
  29018. * @param kind defines the vertex data kind to use
  29019. * @returns null
  29020. */
  29021. getVerticesData(kind: string): Nullable<FloatArray>;
  29022. /**
  29023. * Sets the vertex data of the mesh geometry for the requested `kind`.
  29024. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  29025. * Note that a new underlying VertexBuffer object is created each call.
  29026. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  29027. * @param kind defines vertex data kind:
  29028. * * VertexBuffer.PositionKind
  29029. * * VertexBuffer.UVKind
  29030. * * VertexBuffer.UV2Kind
  29031. * * VertexBuffer.UV3Kind
  29032. * * VertexBuffer.UV4Kind
  29033. * * VertexBuffer.UV5Kind
  29034. * * VertexBuffer.UV6Kind
  29035. * * VertexBuffer.ColorKind
  29036. * * VertexBuffer.MatricesIndicesKind
  29037. * * VertexBuffer.MatricesIndicesExtraKind
  29038. * * VertexBuffer.MatricesWeightsKind
  29039. * * VertexBuffer.MatricesWeightsExtraKind
  29040. * @param data defines the data source
  29041. * @param updatable defines if the data must be flagged as updatable (or static)
  29042. * @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
  29043. * @returns the current mesh
  29044. */
  29045. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29046. /**
  29047. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  29048. * If the mesh has no geometry, it is simply returned as it is.
  29049. * @param kind defines vertex data kind:
  29050. * * VertexBuffer.PositionKind
  29051. * * VertexBuffer.UVKind
  29052. * * VertexBuffer.UV2Kind
  29053. * * VertexBuffer.UV3Kind
  29054. * * VertexBuffer.UV4Kind
  29055. * * VertexBuffer.UV5Kind
  29056. * * VertexBuffer.UV6Kind
  29057. * * VertexBuffer.ColorKind
  29058. * * VertexBuffer.MatricesIndicesKind
  29059. * * VertexBuffer.MatricesIndicesExtraKind
  29060. * * VertexBuffer.MatricesWeightsKind
  29061. * * VertexBuffer.MatricesWeightsExtraKind
  29062. * @param data defines the data source
  29063. * @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
  29064. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  29065. * @returns the current mesh
  29066. */
  29067. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29068. /**
  29069. * Sets the mesh indices,
  29070. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  29071. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  29072. * @param totalVertices Defines the total number of vertices
  29073. * @returns the current mesh
  29074. */
  29075. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  29076. /**
  29077. * Gets a boolean indicating if specific vertex data is present
  29078. * @param kind defines the vertex data kind to use
  29079. * @returns true is data kind is present
  29080. */
  29081. isVerticesDataPresent(kind: string): boolean;
  29082. /**
  29083. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  29084. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  29085. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  29086. * @returns a BoundingInfo
  29087. */
  29088. getBoundingInfo(): BoundingInfo;
  29089. /**
  29090. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  29091. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  29092. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  29093. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  29094. * @returns the current mesh
  29095. */
  29096. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  29097. /**
  29098. * Overwrite the current bounding info
  29099. * @param boundingInfo defines the new bounding info
  29100. * @returns the current mesh
  29101. */
  29102. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  29103. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  29104. get useBones(): boolean;
  29105. /** @hidden */
  29106. _preActivate(): void;
  29107. /** @hidden */
  29108. _preActivateForIntermediateRendering(renderId: number): void;
  29109. /** @hidden */
  29110. _activate(renderId: number, intermediateRendering: boolean): boolean;
  29111. /** @hidden */
  29112. _postActivate(): void;
  29113. /** @hidden */
  29114. _freeze(): void;
  29115. /** @hidden */
  29116. _unFreeze(): void;
  29117. /**
  29118. * Gets the current world matrix
  29119. * @returns a Matrix
  29120. */
  29121. getWorldMatrix(): Matrix;
  29122. /** @hidden */
  29123. _getWorldMatrixDeterminant(): number;
  29124. /**
  29125. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  29126. */
  29127. get isAnInstance(): boolean;
  29128. /**
  29129. * Gets a boolean indicating if this mesh has instances
  29130. */
  29131. get hasInstances(): boolean;
  29132. /**
  29133. * Perform relative position change from the point of view of behind the front of the mesh.
  29134. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29135. * Supports definition of mesh facing forward or backward
  29136. * @param amountRight defines the distance on the right axis
  29137. * @param amountUp defines the distance on the up axis
  29138. * @param amountForward defines the distance on the forward axis
  29139. * @returns the current mesh
  29140. */
  29141. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  29142. /**
  29143. * Calculate relative position change from the point of view of behind the front of the mesh.
  29144. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29145. * Supports definition of mesh facing forward or backward
  29146. * @param amountRight defines the distance on the right axis
  29147. * @param amountUp defines the distance on the up axis
  29148. * @param amountForward defines the distance on the forward axis
  29149. * @returns the new displacement vector
  29150. */
  29151. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  29152. /**
  29153. * Perform relative rotation change from the point of view of behind the front of the mesh.
  29154. * Supports definition of mesh facing forward or backward
  29155. * @param flipBack defines the flip
  29156. * @param twirlClockwise defines the twirl
  29157. * @param tiltRight defines the tilt
  29158. * @returns the current mesh
  29159. */
  29160. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  29161. /**
  29162. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  29163. * Supports definition of mesh facing forward or backward.
  29164. * @param flipBack defines the flip
  29165. * @param twirlClockwise defines the twirl
  29166. * @param tiltRight defines the tilt
  29167. * @returns the new rotation vector
  29168. */
  29169. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  29170. /**
  29171. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29172. * This means the mesh underlying bounding box and sphere are recomputed.
  29173. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29174. * @returns the current mesh
  29175. */
  29176. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  29177. /** @hidden */
  29178. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  29179. /** @hidden */
  29180. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  29181. /** @hidden */
  29182. _updateBoundingInfo(): AbstractMesh;
  29183. /** @hidden */
  29184. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  29185. /** @hidden */
  29186. protected _afterComputeWorldMatrix(): void;
  29187. /** @hidden */
  29188. get _effectiveMesh(): AbstractMesh;
  29189. /**
  29190. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29191. * A mesh is in the frustum if its bounding box intersects the frustum
  29192. * @param frustumPlanes defines the frustum to test
  29193. * @returns true if the mesh is in the frustum planes
  29194. */
  29195. isInFrustum(frustumPlanes: Plane[]): boolean;
  29196. /**
  29197. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  29198. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  29199. * @param frustumPlanes defines the frustum to test
  29200. * @returns true if the mesh is completely in the frustum planes
  29201. */
  29202. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29203. /**
  29204. * True if the mesh intersects another mesh or a SolidParticle object
  29205. * @param mesh defines a target mesh or SolidParticle to test
  29206. * @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)
  29207. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  29208. * @returns true if there is an intersection
  29209. */
  29210. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  29211. /**
  29212. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  29213. * @param point defines the point to test
  29214. * @returns true if there is an intersection
  29215. */
  29216. intersectsPoint(point: Vector3): boolean;
  29217. /**
  29218. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  29219. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29220. */
  29221. get checkCollisions(): boolean;
  29222. set checkCollisions(collisionEnabled: boolean);
  29223. /**
  29224. * Gets Collider object used to compute collisions (not physics)
  29225. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29226. */
  29227. get collider(): Nullable<Collider>;
  29228. /**
  29229. * Move the mesh using collision engine
  29230. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29231. * @param displacement defines the requested displacement vector
  29232. * @returns the current mesh
  29233. */
  29234. moveWithCollisions(displacement: Vector3): AbstractMesh;
  29235. private _onCollisionPositionChange;
  29236. /** @hidden */
  29237. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  29238. /** @hidden */
  29239. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  29240. /** @hidden */
  29241. _checkCollision(collider: Collider): AbstractMesh;
  29242. /** @hidden */
  29243. _generatePointsArray(): boolean;
  29244. /**
  29245. * Checks if the passed Ray intersects with the mesh
  29246. * @param ray defines the ray to use
  29247. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  29248. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  29249. * @returns the picking info
  29250. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  29251. */
  29252. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  29253. /**
  29254. * Clones the current mesh
  29255. * @param name defines the mesh name
  29256. * @param newParent defines the new mesh parent
  29257. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  29258. * @returns the new mesh
  29259. */
  29260. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  29261. /**
  29262. * Disposes all the submeshes of the current meshnp
  29263. * @returns the current mesh
  29264. */
  29265. releaseSubMeshes(): AbstractMesh;
  29266. /**
  29267. * Releases resources associated with this abstract mesh.
  29268. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29269. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29270. */
  29271. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29272. /**
  29273. * Adds the passed mesh as a child to the current mesh
  29274. * @param mesh defines the child mesh
  29275. * @returns the current mesh
  29276. */
  29277. addChild(mesh: AbstractMesh): AbstractMesh;
  29278. /**
  29279. * Removes the passed mesh from the current mesh children list
  29280. * @param mesh defines the child mesh
  29281. * @returns the current mesh
  29282. */
  29283. removeChild(mesh: AbstractMesh): AbstractMesh;
  29284. /** @hidden */
  29285. private _initFacetData;
  29286. /**
  29287. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  29288. * This method can be called within the render loop.
  29289. * 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
  29290. * @returns the current mesh
  29291. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29292. */
  29293. updateFacetData(): AbstractMesh;
  29294. /**
  29295. * Returns the facetLocalNormals array.
  29296. * The normals are expressed in the mesh local spac
  29297. * @returns an array of Vector3
  29298. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29299. */
  29300. getFacetLocalNormals(): Vector3[];
  29301. /**
  29302. * Returns the facetLocalPositions array.
  29303. * The facet positions are expressed in the mesh local space
  29304. * @returns an array of Vector3
  29305. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29306. */
  29307. getFacetLocalPositions(): Vector3[];
  29308. /**
  29309. * Returns the facetLocalPartioning array
  29310. * @returns an array of array of numbers
  29311. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29312. */
  29313. getFacetLocalPartitioning(): number[][];
  29314. /**
  29315. * Returns the i-th facet position in the world system.
  29316. * This method allocates a new Vector3 per call
  29317. * @param i defines the facet index
  29318. * @returns a new Vector3
  29319. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29320. */
  29321. getFacetPosition(i: number): Vector3;
  29322. /**
  29323. * Sets the reference Vector3 with the i-th facet position in the world system
  29324. * @param i defines the facet index
  29325. * @param ref defines the target vector
  29326. * @returns the current mesh
  29327. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29328. */
  29329. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  29330. /**
  29331. * Returns the i-th facet normal in the world system.
  29332. * This method allocates a new Vector3 per call
  29333. * @param i defines the facet index
  29334. * @returns a new Vector3
  29335. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29336. */
  29337. getFacetNormal(i: number): Vector3;
  29338. /**
  29339. * Sets the reference Vector3 with the i-th facet normal in the world system
  29340. * @param i defines the facet index
  29341. * @param ref defines the target vector
  29342. * @returns the current mesh
  29343. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29344. */
  29345. getFacetNormalToRef(i: number, ref: Vector3): this;
  29346. /**
  29347. * 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)
  29348. * @param x defines x coordinate
  29349. * @param y defines y coordinate
  29350. * @param z defines z coordinate
  29351. * @returns the array of facet indexes
  29352. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29353. */
  29354. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  29355. /**
  29356. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  29357. * @param projected sets as the (x,y,z) world projection on the facet
  29358. * @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
  29359. * @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
  29360. * @param x defines x coordinate
  29361. * @param y defines y coordinate
  29362. * @param z defines z coordinate
  29363. * @returns the face index if found (or null instead)
  29364. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29365. */
  29366. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29367. /**
  29368. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29369. * @param projected sets as the (x,y,z) local projection on the facet
  29370. * @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
  29371. * @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
  29372. * @param x defines x coordinate
  29373. * @param y defines y coordinate
  29374. * @param z defines z coordinate
  29375. * @returns the face index if found (or null instead)
  29376. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29377. */
  29378. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29379. /**
  29380. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29381. * @returns the parameters
  29382. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29383. */
  29384. getFacetDataParameters(): any;
  29385. /**
  29386. * Disables the feature FacetData and frees the related memory
  29387. * @returns the current mesh
  29388. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29389. */
  29390. disableFacetData(): AbstractMesh;
  29391. /**
  29392. * Updates the AbstractMesh indices array
  29393. * @param indices defines the data source
  29394. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29395. * @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)
  29396. * @returns the current mesh
  29397. */
  29398. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29399. /**
  29400. * Creates new normals data for the mesh
  29401. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  29402. * @returns the current mesh
  29403. */
  29404. createNormals(updatable: boolean): AbstractMesh;
  29405. /**
  29406. * Align the mesh with a normal
  29407. * @param normal defines the normal to use
  29408. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  29409. * @returns the current mesh
  29410. */
  29411. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  29412. /** @hidden */
  29413. _checkOcclusionQuery(): boolean;
  29414. /**
  29415. * Disables the mesh edge rendering mode
  29416. * @returns the currentAbstractMesh
  29417. */
  29418. disableEdgesRendering(): AbstractMesh;
  29419. /**
  29420. * Enables the edge rendering mode on the mesh.
  29421. * This mode makes the mesh edges visible
  29422. * @param epsilon defines the maximal distance between two angles to detect a face
  29423. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29424. * @returns the currentAbstractMesh
  29425. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29426. */
  29427. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29428. }
  29429. }
  29430. declare module "babylonjs/Actions/actionEvent" {
  29431. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29432. import { Nullable } from "babylonjs/types";
  29433. import { Sprite } from "babylonjs/Sprites/sprite";
  29434. import { Scene } from "babylonjs/scene";
  29435. import { Vector2 } from "babylonjs/Maths/math.vector";
  29436. /**
  29437. * Interface used to define ActionEvent
  29438. */
  29439. export interface IActionEvent {
  29440. /** The mesh or sprite that triggered the action */
  29441. source: any;
  29442. /** The X mouse cursor position at the time of the event */
  29443. pointerX: number;
  29444. /** The Y mouse cursor position at the time of the event */
  29445. pointerY: number;
  29446. /** The mesh that is currently pointed at (can be null) */
  29447. meshUnderPointer: Nullable<AbstractMesh>;
  29448. /** the original (browser) event that triggered the ActionEvent */
  29449. sourceEvent?: any;
  29450. /** additional data for the event */
  29451. additionalData?: any;
  29452. }
  29453. /**
  29454. * ActionEvent is the event being sent when an action is triggered.
  29455. */
  29456. export class ActionEvent implements IActionEvent {
  29457. /** The mesh or sprite that triggered the action */
  29458. source: any;
  29459. /** The X mouse cursor position at the time of the event */
  29460. pointerX: number;
  29461. /** The Y mouse cursor position at the time of the event */
  29462. pointerY: number;
  29463. /** The mesh that is currently pointed at (can be null) */
  29464. meshUnderPointer: Nullable<AbstractMesh>;
  29465. /** the original (browser) event that triggered the ActionEvent */
  29466. sourceEvent?: any;
  29467. /** additional data for the event */
  29468. additionalData?: any;
  29469. /**
  29470. * Creates a new ActionEvent
  29471. * @param source The mesh or sprite that triggered the action
  29472. * @param pointerX The X mouse cursor position at the time of the event
  29473. * @param pointerY The Y mouse cursor position at the time of the event
  29474. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  29475. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  29476. * @param additionalData additional data for the event
  29477. */
  29478. constructor(
  29479. /** The mesh or sprite that triggered the action */
  29480. source: any,
  29481. /** The X mouse cursor position at the time of the event */
  29482. pointerX: number,
  29483. /** The Y mouse cursor position at the time of the event */
  29484. pointerY: number,
  29485. /** The mesh that is currently pointed at (can be null) */
  29486. meshUnderPointer: Nullable<AbstractMesh>,
  29487. /** the original (browser) event that triggered the ActionEvent */
  29488. sourceEvent?: any,
  29489. /** additional data for the event */
  29490. additionalData?: any);
  29491. /**
  29492. * Helper function to auto-create an ActionEvent from a source mesh.
  29493. * @param source The source mesh that triggered the event
  29494. * @param evt The original (browser) event
  29495. * @param additionalData additional data for the event
  29496. * @returns the new ActionEvent
  29497. */
  29498. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29499. /**
  29500. * Helper function to auto-create an ActionEvent from a source sprite
  29501. * @param source The source sprite that triggered the event
  29502. * @param scene Scene associated with the sprite
  29503. * @param evt The original (browser) event
  29504. * @param additionalData additional data for the event
  29505. * @returns the new ActionEvent
  29506. */
  29507. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29508. /**
  29509. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29510. * @param scene the scene where the event occurred
  29511. * @param evt The original (browser) event
  29512. * @returns the new ActionEvent
  29513. */
  29514. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29515. /**
  29516. * Helper function to auto-create an ActionEvent from a primitive
  29517. * @param prim defines the target primitive
  29518. * @param pointerPos defines the pointer position
  29519. * @param evt The original (browser) event
  29520. * @param additionalData additional data for the event
  29521. * @returns the new ActionEvent
  29522. */
  29523. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29524. }
  29525. }
  29526. declare module "babylonjs/Actions/abstractActionManager" {
  29527. import { IDisposable } from "babylonjs/scene";
  29528. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  29529. import { IAction } from "babylonjs/Actions/action";
  29530. import { Nullable } from "babylonjs/types";
  29531. /**
  29532. * Abstract class used to decouple action Manager from scene and meshes.
  29533. * Do not instantiate.
  29534. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29535. */
  29536. export abstract class AbstractActionManager implements IDisposable {
  29537. /** Gets the list of active triggers */
  29538. static Triggers: {
  29539. [key: string]: number;
  29540. };
  29541. /** Gets the cursor to use when hovering items */
  29542. hoverCursor: string;
  29543. /** Gets the list of actions */
  29544. actions: IAction[];
  29545. /**
  29546. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29547. */
  29548. isRecursive: boolean;
  29549. /**
  29550. * Releases all associated resources
  29551. */
  29552. abstract dispose(): void;
  29553. /**
  29554. * Does this action manager has pointer triggers
  29555. */
  29556. abstract get hasPointerTriggers(): boolean;
  29557. /**
  29558. * Does this action manager has pick triggers
  29559. */
  29560. abstract get hasPickTriggers(): boolean;
  29561. /**
  29562. * Process a specific trigger
  29563. * @param trigger defines the trigger to process
  29564. * @param evt defines the event details to be processed
  29565. */
  29566. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29567. /**
  29568. * Does this action manager handles actions of any of the given triggers
  29569. * @param triggers defines the triggers to be tested
  29570. * @return a boolean indicating whether one (or more) of the triggers is handled
  29571. */
  29572. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29573. /**
  29574. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29575. * speed.
  29576. * @param triggerA defines the trigger to be tested
  29577. * @param triggerB defines the trigger to be tested
  29578. * @return a boolean indicating whether one (or more) of the triggers is handled
  29579. */
  29580. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29581. /**
  29582. * Does this action manager handles actions of a given trigger
  29583. * @param trigger defines the trigger to be tested
  29584. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29585. * @return whether the trigger is handled
  29586. */
  29587. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29588. /**
  29589. * Serialize this manager to a JSON object
  29590. * @param name defines the property name to store this manager
  29591. * @returns a JSON representation of this manager
  29592. */
  29593. abstract serialize(name: string): any;
  29594. /**
  29595. * Registers an action to this action manager
  29596. * @param action defines the action to be registered
  29597. * @return the action amended (prepared) after registration
  29598. */
  29599. abstract registerAction(action: IAction): Nullable<IAction>;
  29600. /**
  29601. * Unregisters an action to this action manager
  29602. * @param action defines the action to be unregistered
  29603. * @return a boolean indicating whether the action has been unregistered
  29604. */
  29605. abstract unregisterAction(action: IAction): Boolean;
  29606. /**
  29607. * Does exist one action manager with at least one trigger
  29608. **/
  29609. static get HasTriggers(): boolean;
  29610. /**
  29611. * Does exist one action manager with at least one pick trigger
  29612. **/
  29613. static get HasPickTriggers(): boolean;
  29614. /**
  29615. * Does exist one action manager that handles actions of a given trigger
  29616. * @param trigger defines the trigger to be tested
  29617. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29618. **/
  29619. static HasSpecificTrigger(trigger: number): boolean;
  29620. }
  29621. }
  29622. declare module "babylonjs/node" {
  29623. import { Scene } from "babylonjs/scene";
  29624. import { Nullable } from "babylonjs/types";
  29625. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29626. import { Engine } from "babylonjs/Engines/engine";
  29627. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  29628. import { Observable } from "babylonjs/Misc/observable";
  29629. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29630. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29631. import { Animatable } from "babylonjs/Animations/animatable";
  29632. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  29633. import { Animation } from "babylonjs/Animations/animation";
  29634. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29635. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29636. /**
  29637. * Defines how a node can be built from a string name.
  29638. */
  29639. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29640. /**
  29641. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29642. */
  29643. export class Node implements IBehaviorAware<Node> {
  29644. /** @hidden */
  29645. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  29646. private static _NodeConstructors;
  29647. /**
  29648. * Add a new node constructor
  29649. * @param type defines the type name of the node to construct
  29650. * @param constructorFunc defines the constructor function
  29651. */
  29652. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29653. /**
  29654. * Returns a node constructor based on type name
  29655. * @param type defines the type name
  29656. * @param name defines the new node name
  29657. * @param scene defines the hosting scene
  29658. * @param options defines optional options to transmit to constructors
  29659. * @returns the new constructor or null
  29660. */
  29661. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29662. /**
  29663. * Gets or sets the name of the node
  29664. */
  29665. name: string;
  29666. /**
  29667. * Gets or sets the id of the node
  29668. */
  29669. id: string;
  29670. /**
  29671. * Gets or sets the unique id of the node
  29672. */
  29673. uniqueId: number;
  29674. /**
  29675. * Gets or sets a string used to store user defined state for the node
  29676. */
  29677. state: string;
  29678. /**
  29679. * Gets or sets an object used to store user defined information for the node
  29680. */
  29681. metadata: any;
  29682. /**
  29683. * For internal use only. Please do not use.
  29684. */
  29685. reservedDataStore: any;
  29686. /**
  29687. * List of inspectable custom properties (used by the Inspector)
  29688. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29689. */
  29690. inspectableCustomProperties: IInspectable[];
  29691. private _doNotSerialize;
  29692. /**
  29693. * Gets or sets a boolean used to define if the node must be serialized
  29694. */
  29695. get doNotSerialize(): boolean;
  29696. set doNotSerialize(value: boolean);
  29697. /** @hidden */
  29698. _isDisposed: boolean;
  29699. /**
  29700. * Gets a list of Animations associated with the node
  29701. */
  29702. animations: import("babylonjs/Animations/animation").Animation[];
  29703. protected _ranges: {
  29704. [name: string]: Nullable<AnimationRange>;
  29705. };
  29706. /**
  29707. * Callback raised when the node is ready to be used
  29708. */
  29709. onReady: Nullable<(node: Node) => void>;
  29710. private _isEnabled;
  29711. private _isParentEnabled;
  29712. private _isReady;
  29713. /** @hidden */
  29714. _currentRenderId: number;
  29715. private _parentUpdateId;
  29716. /** @hidden */
  29717. _childUpdateId: number;
  29718. /** @hidden */
  29719. _waitingParentId: Nullable<string>;
  29720. /** @hidden */
  29721. _scene: Scene;
  29722. /** @hidden */
  29723. _cache: any;
  29724. private _parentNode;
  29725. private _children;
  29726. /** @hidden */
  29727. _worldMatrix: Matrix;
  29728. /** @hidden */
  29729. _worldMatrixDeterminant: number;
  29730. /** @hidden */
  29731. _worldMatrixDeterminantIsDirty: boolean;
  29732. /** @hidden */
  29733. private _sceneRootNodesIndex;
  29734. /**
  29735. * Gets a boolean indicating if the node has been disposed
  29736. * @returns true if the node was disposed
  29737. */
  29738. isDisposed(): boolean;
  29739. /**
  29740. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29741. * @see https://doc.babylonjs.com/how_to/parenting
  29742. */
  29743. set parent(parent: Nullable<Node>);
  29744. get parent(): Nullable<Node>;
  29745. /** @hidden */
  29746. _addToSceneRootNodes(): void;
  29747. /** @hidden */
  29748. _removeFromSceneRootNodes(): void;
  29749. private _animationPropertiesOverride;
  29750. /**
  29751. * Gets or sets the animation properties override
  29752. */
  29753. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29754. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29755. /**
  29756. * Gets a string idenfifying the name of the class
  29757. * @returns "Node" string
  29758. */
  29759. getClassName(): string;
  29760. /** @hidden */
  29761. readonly _isNode: boolean;
  29762. /**
  29763. * An event triggered when the mesh is disposed
  29764. */
  29765. onDisposeObservable: Observable<Node>;
  29766. private _onDisposeObserver;
  29767. /**
  29768. * Sets a callback that will be raised when the node will be disposed
  29769. */
  29770. set onDispose(callback: () => void);
  29771. /**
  29772. * Creates a new Node
  29773. * @param name the name and id to be given to this node
  29774. * @param scene the scene this node will be added to
  29775. */
  29776. constructor(name: string, scene?: Nullable<Scene>);
  29777. /**
  29778. * Gets the scene of the node
  29779. * @returns a scene
  29780. */
  29781. getScene(): Scene;
  29782. /**
  29783. * Gets the engine of the node
  29784. * @returns a Engine
  29785. */
  29786. getEngine(): Engine;
  29787. private _behaviors;
  29788. /**
  29789. * Attach a behavior to the node
  29790. * @see http://doc.babylonjs.com/features/behaviour
  29791. * @param behavior defines the behavior to attach
  29792. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29793. * @returns the current Node
  29794. */
  29795. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29796. /**
  29797. * Remove an attached behavior
  29798. * @see http://doc.babylonjs.com/features/behaviour
  29799. * @param behavior defines the behavior to attach
  29800. * @returns the current Node
  29801. */
  29802. removeBehavior(behavior: Behavior<Node>): Node;
  29803. /**
  29804. * Gets the list of attached behaviors
  29805. * @see http://doc.babylonjs.com/features/behaviour
  29806. */
  29807. get behaviors(): Behavior<Node>[];
  29808. /**
  29809. * Gets an attached behavior by name
  29810. * @param name defines the name of the behavior to look for
  29811. * @see http://doc.babylonjs.com/features/behaviour
  29812. * @returns null if behavior was not found else the requested behavior
  29813. */
  29814. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29815. /**
  29816. * Returns the latest update of the World matrix
  29817. * @returns a Matrix
  29818. */
  29819. getWorldMatrix(): Matrix;
  29820. /** @hidden */
  29821. _getWorldMatrixDeterminant(): number;
  29822. /**
  29823. * Returns directly the latest state of the mesh World matrix.
  29824. * A Matrix is returned.
  29825. */
  29826. get worldMatrixFromCache(): Matrix;
  29827. /** @hidden */
  29828. _initCache(): void;
  29829. /** @hidden */
  29830. updateCache(force?: boolean): void;
  29831. /** @hidden */
  29832. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29833. /** @hidden */
  29834. _updateCache(ignoreParentClass?: boolean): void;
  29835. /** @hidden */
  29836. _isSynchronized(): boolean;
  29837. /** @hidden */
  29838. _markSyncedWithParent(): void;
  29839. /** @hidden */
  29840. isSynchronizedWithParent(): boolean;
  29841. /** @hidden */
  29842. isSynchronized(): boolean;
  29843. /**
  29844. * Is this node ready to be used/rendered
  29845. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29846. * @return true if the node is ready
  29847. */
  29848. isReady(completeCheck?: boolean): boolean;
  29849. /**
  29850. * Is this node enabled?
  29851. * 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
  29852. * @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
  29853. * @return whether this node (and its parent) is enabled
  29854. */
  29855. isEnabled(checkAncestors?: boolean): boolean;
  29856. /** @hidden */
  29857. protected _syncParentEnabledState(): void;
  29858. /**
  29859. * Set the enabled state of this node
  29860. * @param value defines the new enabled state
  29861. */
  29862. setEnabled(value: boolean): void;
  29863. /**
  29864. * Is this node a descendant of the given node?
  29865. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29866. * @param ancestor defines the parent node to inspect
  29867. * @returns a boolean indicating if this node is a descendant of the given node
  29868. */
  29869. isDescendantOf(ancestor: Node): boolean;
  29870. /** @hidden */
  29871. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29872. /**
  29873. * Will return all nodes that have this node as ascendant
  29874. * @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
  29875. * @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
  29876. * @return all children nodes of all types
  29877. */
  29878. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29879. /**
  29880. * Get all child-meshes of this node
  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: false)
  29882. * @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
  29883. * @returns an array of AbstractMesh
  29884. */
  29885. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29886. /**
  29887. * Get all direct children of this node
  29888. * @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
  29889. * @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)
  29890. * @returns an array of Node
  29891. */
  29892. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29893. /** @hidden */
  29894. _setReady(state: boolean): void;
  29895. /**
  29896. * Get an animation by name
  29897. * @param name defines the name of the animation to look for
  29898. * @returns null if not found else the requested animation
  29899. */
  29900. getAnimationByName(name: string): Nullable<Animation>;
  29901. /**
  29902. * Creates an animation range for this node
  29903. * @param name defines the name of the range
  29904. * @param from defines the starting key
  29905. * @param to defines the end key
  29906. */
  29907. createAnimationRange(name: string, from: number, to: number): void;
  29908. /**
  29909. * Delete a specific animation range
  29910. * @param name defines the name of the range to delete
  29911. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29912. */
  29913. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29914. /**
  29915. * Get an animation range by name
  29916. * @param name defines the name of the animation range to look for
  29917. * @returns null if not found else the requested animation range
  29918. */
  29919. getAnimationRange(name: string): Nullable<AnimationRange>;
  29920. /**
  29921. * Gets the list of all animation ranges defined on this node
  29922. * @returns an array
  29923. */
  29924. getAnimationRanges(): Nullable<AnimationRange>[];
  29925. /**
  29926. * Will start the animation sequence
  29927. * @param name defines the range frames for animation sequence
  29928. * @param loop defines if the animation should loop (false by default)
  29929. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29930. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29931. * @returns the object created for this animation. If range does not exist, it will return null
  29932. */
  29933. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29934. /**
  29935. * Serialize animation ranges into a JSON compatible object
  29936. * @returns serialization object
  29937. */
  29938. serializeAnimationRanges(): any;
  29939. /**
  29940. * Computes the world matrix of the node
  29941. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29942. * @returns the world matrix
  29943. */
  29944. computeWorldMatrix(force?: boolean): Matrix;
  29945. /**
  29946. * Releases resources associated with this node.
  29947. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29948. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29949. */
  29950. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29951. /**
  29952. * Parse animation range data from a serialization object and store them into a given node
  29953. * @param node defines where to store the animation ranges
  29954. * @param parsedNode defines the serialization object to read data from
  29955. * @param scene defines the hosting scene
  29956. */
  29957. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29958. /**
  29959. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29960. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29961. * @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
  29962. * @returns the new bounding vectors
  29963. */
  29964. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29965. min: Vector3;
  29966. max: Vector3;
  29967. };
  29968. }
  29969. }
  29970. declare module "babylonjs/Animations/animation" {
  29971. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  29972. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  29973. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  29974. import { Nullable } from "babylonjs/types";
  29975. import { Scene } from "babylonjs/scene";
  29976. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  29977. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29978. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  29979. import { Node } from "babylonjs/node";
  29980. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29981. import { Size } from "babylonjs/Maths/math.size";
  29982. import { Animatable } from "babylonjs/Animations/animatable";
  29983. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  29984. /**
  29985. * @hidden
  29986. */
  29987. export class _IAnimationState {
  29988. key: number;
  29989. repeatCount: number;
  29990. workValue?: any;
  29991. loopMode?: number;
  29992. offsetValue?: any;
  29993. highLimitValue?: any;
  29994. }
  29995. /**
  29996. * Class used to store any kind of animation
  29997. */
  29998. export class Animation {
  29999. /**Name of the animation */
  30000. name: string;
  30001. /**Property to animate */
  30002. targetProperty: string;
  30003. /**The frames per second of the animation */
  30004. framePerSecond: number;
  30005. /**The data type of the animation */
  30006. dataType: number;
  30007. /**The loop mode of the animation */
  30008. loopMode?: number | undefined;
  30009. /**Specifies if blending should be enabled */
  30010. enableBlending?: boolean | undefined;
  30011. /**
  30012. * Use matrix interpolation instead of using direct key value when animating matrices
  30013. */
  30014. static AllowMatricesInterpolation: boolean;
  30015. /**
  30016. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  30017. */
  30018. static AllowMatrixDecomposeForInterpolation: boolean;
  30019. /**
  30020. * Stores the key frames of the animation
  30021. */
  30022. private _keys;
  30023. /**
  30024. * Stores the easing function of the animation
  30025. */
  30026. private _easingFunction;
  30027. /**
  30028. * @hidden Internal use only
  30029. */
  30030. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  30031. /**
  30032. * The set of event that will be linked to this animation
  30033. */
  30034. private _events;
  30035. /**
  30036. * Stores an array of target property paths
  30037. */
  30038. targetPropertyPath: string[];
  30039. /**
  30040. * Stores the blending speed of the animation
  30041. */
  30042. blendingSpeed: number;
  30043. /**
  30044. * Stores the animation ranges for the animation
  30045. */
  30046. private _ranges;
  30047. /**
  30048. * @hidden Internal use
  30049. */
  30050. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  30051. /**
  30052. * Sets up an animation
  30053. * @param property The property to animate
  30054. * @param animationType The animation type to apply
  30055. * @param framePerSecond The frames per second of the animation
  30056. * @param easingFunction The easing function used in the animation
  30057. * @returns The created animation
  30058. */
  30059. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  30060. /**
  30061. * Create and start an animation on a node
  30062. * @param name defines the name of the global animation that will be run on all nodes
  30063. * @param node defines the root node where the animation will take place
  30064. * @param targetProperty defines property to animate
  30065. * @param framePerSecond defines the number of frame per second yo use
  30066. * @param totalFrame defines the number of frames in total
  30067. * @param from defines the initial value
  30068. * @param to defines the final value
  30069. * @param loopMode defines which loop mode you want to use (off by default)
  30070. * @param easingFunction defines the easing function to use (linear by default)
  30071. * @param onAnimationEnd defines the callback to call when animation end
  30072. * @returns the animatable created for this animation
  30073. */
  30074. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30075. /**
  30076. * Create and start an animation on a node and its descendants
  30077. * @param name defines the name of the global animation that will be run on all nodes
  30078. * @param node defines the root node where the animation will take place
  30079. * @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
  30080. * @param targetProperty defines property to animate
  30081. * @param framePerSecond defines the number of frame per second to use
  30082. * @param totalFrame defines the number of frames in total
  30083. * @param from defines the initial value
  30084. * @param to defines the final value
  30085. * @param loopMode defines which loop mode you want to use (off by default)
  30086. * @param easingFunction defines the easing function to use (linear by default)
  30087. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  30088. * @returns the list of animatables created for all nodes
  30089. * @example https://www.babylonjs-playground.com/#MH0VLI
  30090. */
  30091. 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[]>;
  30092. /**
  30093. * Creates a new animation, merges it with the existing animations and starts it
  30094. * @param name Name of the animation
  30095. * @param node Node which contains the scene that begins the animations
  30096. * @param targetProperty Specifies which property to animate
  30097. * @param framePerSecond The frames per second of the animation
  30098. * @param totalFrame The total number of frames
  30099. * @param from The frame at the beginning of the animation
  30100. * @param to The frame at the end of the animation
  30101. * @param loopMode Specifies the loop mode of the animation
  30102. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  30103. * @param onAnimationEnd Callback to run once the animation is complete
  30104. * @returns Nullable animation
  30105. */
  30106. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30107. /**
  30108. * Transition property of an host to the target Value
  30109. * @param property The property to transition
  30110. * @param targetValue The target Value of the property
  30111. * @param host The object where the property to animate belongs
  30112. * @param scene Scene used to run the animation
  30113. * @param frameRate Framerate (in frame/s) to use
  30114. * @param transition The transition type we want to use
  30115. * @param duration The duration of the animation, in milliseconds
  30116. * @param onAnimationEnd Callback trigger at the end of the animation
  30117. * @returns Nullable animation
  30118. */
  30119. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  30120. /**
  30121. * Return the array of runtime animations currently using this animation
  30122. */
  30123. get runtimeAnimations(): RuntimeAnimation[];
  30124. /**
  30125. * Specifies if any of the runtime animations are currently running
  30126. */
  30127. get hasRunningRuntimeAnimations(): boolean;
  30128. /**
  30129. * Initializes the animation
  30130. * @param name Name of the animation
  30131. * @param targetProperty Property to animate
  30132. * @param framePerSecond The frames per second of the animation
  30133. * @param dataType The data type of the animation
  30134. * @param loopMode The loop mode of the animation
  30135. * @param enableBlending Specifies if blending should be enabled
  30136. */
  30137. constructor(
  30138. /**Name of the animation */
  30139. name: string,
  30140. /**Property to animate */
  30141. targetProperty: string,
  30142. /**The frames per second of the animation */
  30143. framePerSecond: number,
  30144. /**The data type of the animation */
  30145. dataType: number,
  30146. /**The loop mode of the animation */
  30147. loopMode?: number | undefined,
  30148. /**Specifies if blending should be enabled */
  30149. enableBlending?: boolean | undefined);
  30150. /**
  30151. * Converts the animation to a string
  30152. * @param fullDetails support for multiple levels of logging within scene loading
  30153. * @returns String form of the animation
  30154. */
  30155. toString(fullDetails?: boolean): string;
  30156. /**
  30157. * Add an event to this animation
  30158. * @param event Event to add
  30159. */
  30160. addEvent(event: AnimationEvent): void;
  30161. /**
  30162. * Remove all events found at the given frame
  30163. * @param frame The frame to remove events from
  30164. */
  30165. removeEvents(frame: number): void;
  30166. /**
  30167. * Retrieves all the events from the animation
  30168. * @returns Events from the animation
  30169. */
  30170. getEvents(): AnimationEvent[];
  30171. /**
  30172. * Creates an animation range
  30173. * @param name Name of the animation range
  30174. * @param from Starting frame of the animation range
  30175. * @param to Ending frame of the animation
  30176. */
  30177. createRange(name: string, from: number, to: number): void;
  30178. /**
  30179. * Deletes an animation range by name
  30180. * @param name Name of the animation range to delete
  30181. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  30182. */
  30183. deleteRange(name: string, deleteFrames?: boolean): void;
  30184. /**
  30185. * Gets the animation range by name, or null if not defined
  30186. * @param name Name of the animation range
  30187. * @returns Nullable animation range
  30188. */
  30189. getRange(name: string): Nullable<AnimationRange>;
  30190. /**
  30191. * Gets the key frames from the animation
  30192. * @returns The key frames of the animation
  30193. */
  30194. getKeys(): Array<IAnimationKey>;
  30195. /**
  30196. * Gets the highest frame rate of the animation
  30197. * @returns Highest frame rate of the animation
  30198. */
  30199. getHighestFrame(): number;
  30200. /**
  30201. * Gets the easing function of the animation
  30202. * @returns Easing function of the animation
  30203. */
  30204. getEasingFunction(): IEasingFunction;
  30205. /**
  30206. * Sets the easing function of the animation
  30207. * @param easingFunction A custom mathematical formula for animation
  30208. */
  30209. setEasingFunction(easingFunction: EasingFunction): void;
  30210. /**
  30211. * Interpolates a scalar linearly
  30212. * @param startValue Start value of the animation curve
  30213. * @param endValue End value of the animation curve
  30214. * @param gradient Scalar amount to interpolate
  30215. * @returns Interpolated scalar value
  30216. */
  30217. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  30218. /**
  30219. * Interpolates a scalar cubically
  30220. * @param startValue Start value of the animation curve
  30221. * @param outTangent End tangent of the animation
  30222. * @param endValue End value of the animation curve
  30223. * @param inTangent Start tangent of the animation curve
  30224. * @param gradient Scalar amount to interpolate
  30225. * @returns Interpolated scalar value
  30226. */
  30227. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  30228. /**
  30229. * Interpolates a quaternion using a spherical linear interpolation
  30230. * @param startValue Start value of the animation curve
  30231. * @param endValue End value of the animation curve
  30232. * @param gradient Scalar amount to interpolate
  30233. * @returns Interpolated quaternion value
  30234. */
  30235. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  30236. /**
  30237. * Interpolates a quaternion cubically
  30238. * @param startValue Start value of the animation curve
  30239. * @param outTangent End tangent of the animation curve
  30240. * @param endValue End value of the animation curve
  30241. * @param inTangent Start tangent of the animation curve
  30242. * @param gradient Scalar amount to interpolate
  30243. * @returns Interpolated quaternion value
  30244. */
  30245. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  30246. /**
  30247. * Interpolates a Vector3 linearl
  30248. * @param startValue Start value of the animation curve
  30249. * @param endValue End value of the animation curve
  30250. * @param gradient Scalar amount to interpolate
  30251. * @returns Interpolated scalar value
  30252. */
  30253. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  30254. /**
  30255. * Interpolates a Vector3 cubically
  30256. * @param startValue Start value of the animation curve
  30257. * @param outTangent End tangent of the animation
  30258. * @param endValue End value of the animation curve
  30259. * @param inTangent Start tangent of the animation curve
  30260. * @param gradient Scalar amount to interpolate
  30261. * @returns InterpolatedVector3 value
  30262. */
  30263. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  30264. /**
  30265. * Interpolates a Vector2 linearly
  30266. * @param startValue Start value of the animation curve
  30267. * @param endValue End value of the animation curve
  30268. * @param gradient Scalar amount to interpolate
  30269. * @returns Interpolated Vector2 value
  30270. */
  30271. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  30272. /**
  30273. * Interpolates a Vector2 cubically
  30274. * @param startValue Start value of the animation curve
  30275. * @param outTangent End tangent of the animation
  30276. * @param endValue End value of the animation curve
  30277. * @param inTangent Start tangent of the animation curve
  30278. * @param gradient Scalar amount to interpolate
  30279. * @returns Interpolated Vector2 value
  30280. */
  30281. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  30282. /**
  30283. * Interpolates a size 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 Size value
  30288. */
  30289. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  30290. /**
  30291. * Interpolates a Color3 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. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  30298. /**
  30299. * Interpolates a Color4 linearly
  30300. * @param startValue Start value of the animation curve
  30301. * @param endValue End value of the animation curve
  30302. * @param gradient Scalar amount to interpolate
  30303. * @returns Interpolated Color3 value
  30304. */
  30305. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  30306. /**
  30307. * @hidden Internal use only
  30308. */
  30309. _getKeyValue(value: any): any;
  30310. /**
  30311. * @hidden Internal use only
  30312. */
  30313. _interpolate(currentFrame: number, state: _IAnimationState): any;
  30314. /**
  30315. * Defines the function to use to interpolate matrices
  30316. * @param startValue defines the start matrix
  30317. * @param endValue defines the end matrix
  30318. * @param gradient defines the gradient between both matrices
  30319. * @param result defines an optional target matrix where to store the interpolation
  30320. * @returns the interpolated matrix
  30321. */
  30322. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  30323. /**
  30324. * Makes a copy of the animation
  30325. * @returns Cloned animation
  30326. */
  30327. clone(): Animation;
  30328. /**
  30329. * Sets the key frames of the animation
  30330. * @param values The animation key frames to set
  30331. */
  30332. setKeys(values: Array<IAnimationKey>): void;
  30333. /**
  30334. * Serializes the animation to an object
  30335. * @returns Serialized object
  30336. */
  30337. serialize(): any;
  30338. /**
  30339. * Float animation type
  30340. */
  30341. static readonly ANIMATIONTYPE_FLOAT: number;
  30342. /**
  30343. * Vector3 animation type
  30344. */
  30345. static readonly ANIMATIONTYPE_VECTOR3: number;
  30346. /**
  30347. * Quaternion animation type
  30348. */
  30349. static readonly ANIMATIONTYPE_QUATERNION: number;
  30350. /**
  30351. * Matrix animation type
  30352. */
  30353. static readonly ANIMATIONTYPE_MATRIX: number;
  30354. /**
  30355. * Color3 animation type
  30356. */
  30357. static readonly ANIMATIONTYPE_COLOR3: number;
  30358. /**
  30359. * Color3 animation type
  30360. */
  30361. static readonly ANIMATIONTYPE_COLOR4: number;
  30362. /**
  30363. * Vector2 animation type
  30364. */
  30365. static readonly ANIMATIONTYPE_VECTOR2: number;
  30366. /**
  30367. * Size animation type
  30368. */
  30369. static readonly ANIMATIONTYPE_SIZE: number;
  30370. /**
  30371. * Relative Loop Mode
  30372. */
  30373. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  30374. /**
  30375. * Cycle Loop Mode
  30376. */
  30377. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  30378. /**
  30379. * Constant Loop Mode
  30380. */
  30381. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  30382. /** @hidden */
  30383. static _UniversalLerp(left: any, right: any, amount: number): any;
  30384. /**
  30385. * Parses an animation object and creates an animation
  30386. * @param parsedAnimation Parsed animation object
  30387. * @returns Animation object
  30388. */
  30389. static Parse(parsedAnimation: any): Animation;
  30390. /**
  30391. * Appends the serialized animations from the source animations
  30392. * @param source Source containing the animations
  30393. * @param destination Target to store the animations
  30394. */
  30395. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30396. }
  30397. }
  30398. declare module "babylonjs/Animations/animatable.interface" {
  30399. import { Nullable } from "babylonjs/types";
  30400. import { Animation } from "babylonjs/Animations/animation";
  30401. /**
  30402. * Interface containing an array of animations
  30403. */
  30404. export interface IAnimatable {
  30405. /**
  30406. * Array of animations
  30407. */
  30408. animations: Nullable<Array<Animation>>;
  30409. }
  30410. }
  30411. declare module "babylonjs/Misc/decorators" {
  30412. import { Nullable } from "babylonjs/types";
  30413. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30414. import { Scene } from "babylonjs/scene";
  30415. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30416. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30417. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30418. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30419. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30420. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30421. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30422. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30423. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30424. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30425. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30426. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30427. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30428. /**
  30429. * Decorator used to define property that can be serialized as reference to a camera
  30430. * @param sourceName defines the name of the property to decorate
  30431. */
  30432. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30433. /**
  30434. * Class used to help serialization objects
  30435. */
  30436. export class SerializationHelper {
  30437. /** @hidden */
  30438. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30439. /** @hidden */
  30440. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30441. /** @hidden */
  30442. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30443. /** @hidden */
  30444. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30445. /**
  30446. * Appends the serialized animations from the source animations
  30447. * @param source Source containing the animations
  30448. * @param destination Target to store the animations
  30449. */
  30450. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30451. /**
  30452. * Static function used to serialized a specific entity
  30453. * @param entity defines the entity to serialize
  30454. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30455. * @returns a JSON compatible object representing the serialization of the entity
  30456. */
  30457. static Serialize<T>(entity: T, serializationObject?: any): any;
  30458. /**
  30459. * Creates a new entity from a serialization data object
  30460. * @param creationFunction defines a function used to instanciated the new entity
  30461. * @param source defines the source serialization data
  30462. * @param scene defines the hosting scene
  30463. * @param rootUrl defines the root url for resources
  30464. * @returns a new entity
  30465. */
  30466. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30467. /**
  30468. * Clones an object
  30469. * @param creationFunction defines the function used to instanciate the new object
  30470. * @param source defines the source object
  30471. * @returns the cloned object
  30472. */
  30473. static Clone<T>(creationFunction: () => T, source: T): T;
  30474. /**
  30475. * Instanciates a new object based on a source one (some data will be shared between both object)
  30476. * @param creationFunction defines the function used to instanciate the new object
  30477. * @param source defines the source object
  30478. * @returns the new object
  30479. */
  30480. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30481. }
  30482. }
  30483. declare module "babylonjs/Misc/guid" {
  30484. /**
  30485. * Class used to manipulate GUIDs
  30486. */
  30487. export class GUID {
  30488. /**
  30489. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30490. * Be aware Math.random() could cause collisions, but:
  30491. * "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"
  30492. * @returns a pseudo random id
  30493. */
  30494. static RandomId(): string;
  30495. }
  30496. }
  30497. declare module "babylonjs/Materials/Textures/baseTexture" {
  30498. import { Observable } from "babylonjs/Misc/observable";
  30499. import { Nullable } from "babylonjs/types";
  30500. import { Scene } from "babylonjs/scene";
  30501. import { Matrix } from "babylonjs/Maths/math.vector";
  30502. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30503. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30504. import { ISize } from "babylonjs/Maths/math.size";
  30505. import "babylonjs/Misc/fileTools";
  30506. /**
  30507. * Base class of all the textures in babylon.
  30508. * It groups all the common properties the materials, post process, lights... might need
  30509. * in order to make a correct use of the texture.
  30510. */
  30511. export class BaseTexture implements IAnimatable {
  30512. /**
  30513. * Default anisotropic filtering level for the application.
  30514. * It is set to 4 as a good tradeoff between perf and quality.
  30515. */
  30516. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30517. /**
  30518. * Gets or sets the unique id of the texture
  30519. */
  30520. uniqueId: number;
  30521. /**
  30522. * Define the name of the texture.
  30523. */
  30524. name: string;
  30525. /**
  30526. * Gets or sets an object used to store user defined information.
  30527. */
  30528. metadata: any;
  30529. /**
  30530. * For internal use only. Please do not use.
  30531. */
  30532. reservedDataStore: any;
  30533. private _hasAlpha;
  30534. /**
  30535. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30536. */
  30537. set hasAlpha(value: boolean);
  30538. get hasAlpha(): boolean;
  30539. /**
  30540. * Defines if the alpha value should be determined via the rgb values.
  30541. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30542. */
  30543. getAlphaFromRGB: boolean;
  30544. /**
  30545. * Intensity or strength of the texture.
  30546. * It is commonly used by materials to fine tune the intensity of the texture
  30547. */
  30548. level: number;
  30549. /**
  30550. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30551. * This is part of the texture as textures usually maps to one uv set.
  30552. */
  30553. coordinatesIndex: number;
  30554. private _coordinatesMode;
  30555. /**
  30556. * How a texture is mapped.
  30557. *
  30558. * | Value | Type | Description |
  30559. * | ----- | ----------------------------------- | ----------- |
  30560. * | 0 | EXPLICIT_MODE | |
  30561. * | 1 | SPHERICAL_MODE | |
  30562. * | 2 | PLANAR_MODE | |
  30563. * | 3 | CUBIC_MODE | |
  30564. * | 4 | PROJECTION_MODE | |
  30565. * | 5 | SKYBOX_MODE | |
  30566. * | 6 | INVCUBIC_MODE | |
  30567. * | 7 | EQUIRECTANGULAR_MODE | |
  30568. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30569. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30570. */
  30571. set coordinatesMode(value: number);
  30572. get coordinatesMode(): number;
  30573. /**
  30574. * | Value | Type | Description |
  30575. * | ----- | ------------------ | ----------- |
  30576. * | 0 | CLAMP_ADDRESSMODE | |
  30577. * | 1 | WRAP_ADDRESSMODE | |
  30578. * | 2 | MIRROR_ADDRESSMODE | |
  30579. */
  30580. wrapU: number;
  30581. /**
  30582. * | Value | Type | Description |
  30583. * | ----- | ------------------ | ----------- |
  30584. * | 0 | CLAMP_ADDRESSMODE | |
  30585. * | 1 | WRAP_ADDRESSMODE | |
  30586. * | 2 | MIRROR_ADDRESSMODE | |
  30587. */
  30588. wrapV: number;
  30589. /**
  30590. * | Value | Type | Description |
  30591. * | ----- | ------------------ | ----------- |
  30592. * | 0 | CLAMP_ADDRESSMODE | |
  30593. * | 1 | WRAP_ADDRESSMODE | |
  30594. * | 2 | MIRROR_ADDRESSMODE | |
  30595. */
  30596. wrapR: number;
  30597. /**
  30598. * With compliant hardware and browser (supporting anisotropic filtering)
  30599. * this defines the level of anisotropic filtering in the texture.
  30600. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30601. */
  30602. anisotropicFilteringLevel: number;
  30603. /**
  30604. * Define if the texture is a cube texture or if false a 2d texture.
  30605. */
  30606. get isCube(): boolean;
  30607. set isCube(value: boolean);
  30608. /**
  30609. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30610. */
  30611. get is3D(): boolean;
  30612. set is3D(value: boolean);
  30613. /**
  30614. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30615. */
  30616. get is2DArray(): boolean;
  30617. set is2DArray(value: boolean);
  30618. /**
  30619. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30620. * HDR texture are usually stored in linear space.
  30621. * This only impacts the PBR and Background materials
  30622. */
  30623. gammaSpace: boolean;
  30624. /**
  30625. * Gets or sets whether or not the texture contains RGBD data.
  30626. */
  30627. get isRGBD(): boolean;
  30628. set isRGBD(value: boolean);
  30629. /**
  30630. * Is Z inverted in the texture (useful in a cube texture).
  30631. */
  30632. invertZ: boolean;
  30633. /**
  30634. * Are mip maps generated for this texture or not.
  30635. */
  30636. get noMipmap(): boolean;
  30637. /**
  30638. * @hidden
  30639. */
  30640. lodLevelInAlpha: boolean;
  30641. /**
  30642. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30643. */
  30644. get lodGenerationOffset(): number;
  30645. set lodGenerationOffset(value: number);
  30646. /**
  30647. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30648. */
  30649. get lodGenerationScale(): number;
  30650. set lodGenerationScale(value: number);
  30651. /**
  30652. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30653. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30654. * average roughness values.
  30655. */
  30656. get linearSpecularLOD(): boolean;
  30657. set linearSpecularLOD(value: boolean);
  30658. /**
  30659. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30660. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30661. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30662. */
  30663. get irradianceTexture(): Nullable<BaseTexture>;
  30664. set irradianceTexture(value: Nullable<BaseTexture>);
  30665. /**
  30666. * Define if the texture is a render target.
  30667. */
  30668. isRenderTarget: boolean;
  30669. /**
  30670. * Define the unique id of the texture in the scene.
  30671. */
  30672. get uid(): string;
  30673. /**
  30674. * Return a string representation of the texture.
  30675. * @returns the texture as a string
  30676. */
  30677. toString(): string;
  30678. /**
  30679. * Get the class name of the texture.
  30680. * @returns "BaseTexture"
  30681. */
  30682. getClassName(): string;
  30683. /**
  30684. * Define the list of animation attached to the texture.
  30685. */
  30686. animations: import("babylonjs/Animations/animation").Animation[];
  30687. /**
  30688. * An event triggered when the texture is disposed.
  30689. */
  30690. onDisposeObservable: Observable<BaseTexture>;
  30691. private _onDisposeObserver;
  30692. /**
  30693. * Callback triggered when the texture has been disposed.
  30694. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30695. */
  30696. set onDispose(callback: () => void);
  30697. /**
  30698. * Define the current state of the loading sequence when in delayed load mode.
  30699. */
  30700. delayLoadState: number;
  30701. private _scene;
  30702. /** @hidden */
  30703. _texture: Nullable<InternalTexture>;
  30704. private _uid;
  30705. /**
  30706. * Define if the texture is preventinga material to render or not.
  30707. * If not and the texture is not ready, the engine will use a default black texture instead.
  30708. */
  30709. get isBlocking(): boolean;
  30710. /**
  30711. * Instantiates a new BaseTexture.
  30712. * Base class of all the textures in babylon.
  30713. * It groups all the common properties the materials, post process, lights... might need
  30714. * in order to make a correct use of the texture.
  30715. * @param scene Define the scene the texture blongs to
  30716. */
  30717. constructor(scene: Nullable<Scene>);
  30718. /**
  30719. * Get the scene the texture belongs to.
  30720. * @returns the scene or null if undefined
  30721. */
  30722. getScene(): Nullable<Scene>;
  30723. /**
  30724. * Get the texture transform matrix used to offset tile the texture for istance.
  30725. * @returns the transformation matrix
  30726. */
  30727. getTextureMatrix(): Matrix;
  30728. /**
  30729. * Get the texture reflection matrix used to rotate/transform the reflection.
  30730. * @returns the reflection matrix
  30731. */
  30732. getReflectionTextureMatrix(): Matrix;
  30733. /**
  30734. * Get the underlying lower level texture from Babylon.
  30735. * @returns the insternal texture
  30736. */
  30737. getInternalTexture(): Nullable<InternalTexture>;
  30738. /**
  30739. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30740. * @returns true if ready or not blocking
  30741. */
  30742. isReadyOrNotBlocking(): boolean;
  30743. /**
  30744. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30745. * @returns true if fully ready
  30746. */
  30747. isReady(): boolean;
  30748. private _cachedSize;
  30749. /**
  30750. * Get the size of the texture.
  30751. * @returns the texture size.
  30752. */
  30753. getSize(): ISize;
  30754. /**
  30755. * Get the base size of the texture.
  30756. * It can be different from the size if the texture has been resized for POT for instance
  30757. * @returns the base size
  30758. */
  30759. getBaseSize(): ISize;
  30760. /**
  30761. * Update the sampling mode of the texture.
  30762. * Default is Trilinear mode.
  30763. *
  30764. * | Value | Type | Description |
  30765. * | ----- | ------------------ | ----------- |
  30766. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30767. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30768. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30769. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30770. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30771. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30772. * | 7 | NEAREST_LINEAR | |
  30773. * | 8 | NEAREST_NEAREST | |
  30774. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30775. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30776. * | 11 | LINEAR_LINEAR | |
  30777. * | 12 | LINEAR_NEAREST | |
  30778. *
  30779. * > _mag_: magnification filter (close to the viewer)
  30780. * > _min_: minification filter (far from the viewer)
  30781. * > _mip_: filter used between mip map levels
  30782. *@param samplingMode Define the new sampling mode of the texture
  30783. */
  30784. updateSamplingMode(samplingMode: number): void;
  30785. /**
  30786. * Scales the texture if is `canRescale()`
  30787. * @param ratio the resize factor we want to use to rescale
  30788. */
  30789. scale(ratio: number): void;
  30790. /**
  30791. * Get if the texture can rescale.
  30792. */
  30793. get canRescale(): boolean;
  30794. /** @hidden */
  30795. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30796. /** @hidden */
  30797. _rebuild(): void;
  30798. /**
  30799. * Triggers the load sequence in delayed load mode.
  30800. */
  30801. delayLoad(): void;
  30802. /**
  30803. * Clones the texture.
  30804. * @returns the cloned texture
  30805. */
  30806. clone(): Nullable<BaseTexture>;
  30807. /**
  30808. * Get the texture underlying type (INT, FLOAT...)
  30809. */
  30810. get textureType(): number;
  30811. /**
  30812. * Get the texture underlying format (RGB, RGBA...)
  30813. */
  30814. get textureFormat(): number;
  30815. /**
  30816. * Indicates that textures need to be re-calculated for all materials
  30817. */
  30818. protected _markAllSubMeshesAsTexturesDirty(): void;
  30819. /**
  30820. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30821. * This will returns an RGBA array buffer containing either in values (0-255) or
  30822. * float values (0-1) depending of the underlying buffer type.
  30823. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30824. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30825. * @param buffer defines a user defined buffer to fill with data (can be null)
  30826. * @returns The Array buffer containing the pixels data.
  30827. */
  30828. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30829. /**
  30830. * Release and destroy the underlying lower level texture aka internalTexture.
  30831. */
  30832. releaseInternalTexture(): void;
  30833. /** @hidden */
  30834. get _lodTextureHigh(): Nullable<BaseTexture>;
  30835. /** @hidden */
  30836. get _lodTextureMid(): Nullable<BaseTexture>;
  30837. /** @hidden */
  30838. get _lodTextureLow(): Nullable<BaseTexture>;
  30839. /**
  30840. * Dispose the texture and release its associated resources.
  30841. */
  30842. dispose(): void;
  30843. /**
  30844. * Serialize the texture into a JSON representation that can be parsed later on.
  30845. * @returns the JSON representation of the texture
  30846. */
  30847. serialize(): any;
  30848. /**
  30849. * Helper function to be called back once a list of texture contains only ready textures.
  30850. * @param textures Define the list of textures to wait for
  30851. * @param callback Define the callback triggered once the entire list will be ready
  30852. */
  30853. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30854. }
  30855. }
  30856. declare module "babylonjs/Materials/effect" {
  30857. import { Observable } from "babylonjs/Misc/observable";
  30858. import { Nullable } from "babylonjs/types";
  30859. import { IDisposable } from "babylonjs/scene";
  30860. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30861. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30862. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  30863. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  30864. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30865. import { Engine } from "babylonjs/Engines/engine";
  30866. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30867. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30868. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30869. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30870. /**
  30871. * Options to be used when creating an effect.
  30872. */
  30873. export interface IEffectCreationOptions {
  30874. /**
  30875. * Atrributes that will be used in the shader.
  30876. */
  30877. attributes: string[];
  30878. /**
  30879. * Uniform varible names that will be set in the shader.
  30880. */
  30881. uniformsNames: string[];
  30882. /**
  30883. * Uniform buffer variable names that will be set in the shader.
  30884. */
  30885. uniformBuffersNames: string[];
  30886. /**
  30887. * Sampler texture variable names that will be set in the shader.
  30888. */
  30889. samplers: string[];
  30890. /**
  30891. * Define statements that will be set in the shader.
  30892. */
  30893. defines: any;
  30894. /**
  30895. * Possible fallbacks for this effect to improve performance when needed.
  30896. */
  30897. fallbacks: Nullable<IEffectFallbacks>;
  30898. /**
  30899. * Callback that will be called when the shader is compiled.
  30900. */
  30901. onCompiled: Nullable<(effect: Effect) => void>;
  30902. /**
  30903. * Callback that will be called if an error occurs during shader compilation.
  30904. */
  30905. onError: Nullable<(effect: Effect, errors: string) => void>;
  30906. /**
  30907. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30908. */
  30909. indexParameters?: any;
  30910. /**
  30911. * Max number of lights that can be used in the shader.
  30912. */
  30913. maxSimultaneousLights?: number;
  30914. /**
  30915. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30916. */
  30917. transformFeedbackVaryings?: Nullable<string[]>;
  30918. }
  30919. /**
  30920. * Effect containing vertex and fragment shader that can be executed on an object.
  30921. */
  30922. export class Effect implements IDisposable {
  30923. /**
  30924. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30925. */
  30926. static ShadersRepository: string;
  30927. /**
  30928. * Name of the effect.
  30929. */
  30930. name: any;
  30931. /**
  30932. * String container all the define statements that should be set on the shader.
  30933. */
  30934. defines: string;
  30935. /**
  30936. * Callback that will be called when the shader is compiled.
  30937. */
  30938. onCompiled: Nullable<(effect: Effect) => void>;
  30939. /**
  30940. * Callback that will be called if an error occurs during shader compilation.
  30941. */
  30942. onError: Nullable<(effect: Effect, errors: string) => void>;
  30943. /**
  30944. * Callback that will be called when effect is bound.
  30945. */
  30946. onBind: Nullable<(effect: Effect) => void>;
  30947. /**
  30948. * Unique ID of the effect.
  30949. */
  30950. uniqueId: number;
  30951. /**
  30952. * Observable that will be called when the shader is compiled.
  30953. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30954. */
  30955. onCompileObservable: Observable<Effect>;
  30956. /**
  30957. * Observable that will be called if an error occurs during shader compilation.
  30958. */
  30959. onErrorObservable: Observable<Effect>;
  30960. /** @hidden */
  30961. _onBindObservable: Nullable<Observable<Effect>>;
  30962. /**
  30963. * @hidden
  30964. * Specifies if the effect was previously ready
  30965. */
  30966. _wasPreviouslyReady: boolean;
  30967. /**
  30968. * Observable that will be called when effect is bound.
  30969. */
  30970. get onBindObservable(): Observable<Effect>;
  30971. /** @hidden */
  30972. _bonesComputationForcedToCPU: boolean;
  30973. private static _uniqueIdSeed;
  30974. private _engine;
  30975. private _uniformBuffersNames;
  30976. private _uniformsNames;
  30977. private _samplerList;
  30978. private _samplers;
  30979. private _isReady;
  30980. private _compilationError;
  30981. private _allFallbacksProcessed;
  30982. private _attributesNames;
  30983. private _attributes;
  30984. private _attributeLocationByName;
  30985. private _uniforms;
  30986. /**
  30987. * Key for the effect.
  30988. * @hidden
  30989. */
  30990. _key: string;
  30991. private _indexParameters;
  30992. private _fallbacks;
  30993. private _vertexSourceCode;
  30994. private _fragmentSourceCode;
  30995. private _vertexSourceCodeOverride;
  30996. private _fragmentSourceCodeOverride;
  30997. private _transformFeedbackVaryings;
  30998. /**
  30999. * Compiled shader to webGL program.
  31000. * @hidden
  31001. */
  31002. _pipelineContext: Nullable<IPipelineContext>;
  31003. private _valueCache;
  31004. private static _baseCache;
  31005. /**
  31006. * Instantiates an effect.
  31007. * An effect can be used to create/manage/execute vertex and fragment shaders.
  31008. * @param baseName Name of the effect.
  31009. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  31010. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  31011. * @param samplers List of sampler variables that will be passed to the shader.
  31012. * @param engine Engine to be used to render the effect
  31013. * @param defines Define statements to be added to the shader.
  31014. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  31015. * @param onCompiled Callback that will be called when the shader is compiled.
  31016. * @param onError Callback that will be called if an error occurs during shader compilation.
  31017. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  31018. */
  31019. 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);
  31020. private _useFinalCode;
  31021. /**
  31022. * Unique key for this effect
  31023. */
  31024. get key(): string;
  31025. /**
  31026. * If the effect has been compiled and prepared.
  31027. * @returns if the effect is compiled and prepared.
  31028. */
  31029. isReady(): boolean;
  31030. private _isReadyInternal;
  31031. /**
  31032. * The engine the effect was initialized with.
  31033. * @returns the engine.
  31034. */
  31035. getEngine(): Engine;
  31036. /**
  31037. * The pipeline context for this effect
  31038. * @returns the associated pipeline context
  31039. */
  31040. getPipelineContext(): Nullable<IPipelineContext>;
  31041. /**
  31042. * The set of names of attribute variables for the shader.
  31043. * @returns An array of attribute names.
  31044. */
  31045. getAttributesNames(): string[];
  31046. /**
  31047. * Returns the attribute at the given index.
  31048. * @param index The index of the attribute.
  31049. * @returns The location of the attribute.
  31050. */
  31051. getAttributeLocation(index: number): number;
  31052. /**
  31053. * Returns the attribute based on the name of the variable.
  31054. * @param name of the attribute to look up.
  31055. * @returns the attribute location.
  31056. */
  31057. getAttributeLocationByName(name: string): number;
  31058. /**
  31059. * The number of attributes.
  31060. * @returns the numnber of attributes.
  31061. */
  31062. getAttributesCount(): number;
  31063. /**
  31064. * Gets the index of a uniform variable.
  31065. * @param uniformName of the uniform to look up.
  31066. * @returns the index.
  31067. */
  31068. getUniformIndex(uniformName: string): number;
  31069. /**
  31070. * Returns the attribute based on the name of the variable.
  31071. * @param uniformName of the uniform to look up.
  31072. * @returns the location of the uniform.
  31073. */
  31074. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  31075. /**
  31076. * Returns an array of sampler variable names
  31077. * @returns The array of sampler variable neames.
  31078. */
  31079. getSamplers(): string[];
  31080. /**
  31081. * The error from the last compilation.
  31082. * @returns the error string.
  31083. */
  31084. getCompilationError(): string;
  31085. /**
  31086. * Gets a boolean indicating that all fallbacks were used during compilation
  31087. * @returns true if all fallbacks were used
  31088. */
  31089. allFallbacksProcessed(): boolean;
  31090. /**
  31091. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  31092. * @param func The callback to be used.
  31093. */
  31094. executeWhenCompiled(func: (effect: Effect) => void): void;
  31095. private _checkIsReady;
  31096. private _loadShader;
  31097. /**
  31098. * Recompiles the webGL program
  31099. * @param vertexSourceCode The source code for the vertex shader.
  31100. * @param fragmentSourceCode The source code for the fragment shader.
  31101. * @param onCompiled Callback called when completed.
  31102. * @param onError Callback called on error.
  31103. * @hidden
  31104. */
  31105. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  31106. /**
  31107. * Prepares the effect
  31108. * @hidden
  31109. */
  31110. _prepareEffect(): void;
  31111. private _processCompilationErrors;
  31112. /**
  31113. * Checks if the effect is supported. (Must be called after compilation)
  31114. */
  31115. get isSupported(): boolean;
  31116. /**
  31117. * Binds a texture to the engine to be used as output of the shader.
  31118. * @param channel Name of the output variable.
  31119. * @param texture Texture to bind.
  31120. * @hidden
  31121. */
  31122. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  31123. /**
  31124. * Sets a texture on the engine to be used in the shader.
  31125. * @param channel Name of the sampler variable.
  31126. * @param texture Texture to set.
  31127. */
  31128. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  31129. /**
  31130. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  31131. * @param channel Name of the sampler variable.
  31132. * @param texture Texture to set.
  31133. */
  31134. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  31135. /**
  31136. * Sets an array of textures on the engine to be used in the shader.
  31137. * @param channel Name of the variable.
  31138. * @param textures Textures to set.
  31139. */
  31140. setTextureArray(channel: string, textures: BaseTexture[]): void;
  31141. /**
  31142. * 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)
  31143. * @param channel Name of the sampler variable.
  31144. * @param postProcess Post process to get the input texture from.
  31145. */
  31146. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  31147. /**
  31148. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  31149. * 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)
  31150. * @param channel Name of the sampler variable.
  31151. * @param postProcess Post process to get the output texture from.
  31152. */
  31153. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  31154. /** @hidden */
  31155. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  31156. /** @hidden */
  31157. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  31158. /** @hidden */
  31159. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  31160. /** @hidden */
  31161. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  31162. /**
  31163. * Binds a buffer to a uniform.
  31164. * @param buffer Buffer to bind.
  31165. * @param name Name of the uniform variable to bind to.
  31166. */
  31167. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  31168. /**
  31169. * Binds block to a uniform.
  31170. * @param blockName Name of the block to bind.
  31171. * @param index Index to bind.
  31172. */
  31173. bindUniformBlock(blockName: string, index: number): void;
  31174. /**
  31175. * Sets an interger value on a uniform variable.
  31176. * @param uniformName Name of the variable.
  31177. * @param value Value to be set.
  31178. * @returns this effect.
  31179. */
  31180. setInt(uniformName: string, value: number): Effect;
  31181. /**
  31182. * Sets an int array on a uniform variable.
  31183. * @param uniformName Name of the variable.
  31184. * @param array array to be set.
  31185. * @returns this effect.
  31186. */
  31187. setIntArray(uniformName: string, array: Int32Array): Effect;
  31188. /**
  31189. * 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)
  31190. * @param uniformName Name of the variable.
  31191. * @param array array to be set.
  31192. * @returns this effect.
  31193. */
  31194. setIntArray2(uniformName: string, array: Int32Array): Effect;
  31195. /**
  31196. * 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)
  31197. * @param uniformName Name of the variable.
  31198. * @param array array to be set.
  31199. * @returns this effect.
  31200. */
  31201. setIntArray3(uniformName: string, array: Int32Array): Effect;
  31202. /**
  31203. * 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)
  31204. * @param uniformName Name of the variable.
  31205. * @param array array to be set.
  31206. * @returns this effect.
  31207. */
  31208. setIntArray4(uniformName: string, array: Int32Array): Effect;
  31209. /**
  31210. * Sets an float array on a uniform variable.
  31211. * @param uniformName Name of the variable.
  31212. * @param array array to be set.
  31213. * @returns this effect.
  31214. */
  31215. setFloatArray(uniformName: string, array: Float32Array): Effect;
  31216. /**
  31217. * 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)
  31218. * @param uniformName Name of the variable.
  31219. * @param array array to be set.
  31220. * @returns this effect.
  31221. */
  31222. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  31223. /**
  31224. * 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)
  31225. * @param uniformName Name of the variable.
  31226. * @param array array to be set.
  31227. * @returns this effect.
  31228. */
  31229. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  31230. /**
  31231. * 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)
  31232. * @param uniformName Name of the variable.
  31233. * @param array array to be set.
  31234. * @returns this effect.
  31235. */
  31236. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  31237. /**
  31238. * Sets an array on a uniform variable.
  31239. * @param uniformName Name of the variable.
  31240. * @param array array to be set.
  31241. * @returns this effect.
  31242. */
  31243. setArray(uniformName: string, array: number[]): Effect;
  31244. /**
  31245. * 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)
  31246. * @param uniformName Name of the variable.
  31247. * @param array array to be set.
  31248. * @returns this effect.
  31249. */
  31250. setArray2(uniformName: string, array: number[]): Effect;
  31251. /**
  31252. * 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)
  31253. * @param uniformName Name of the variable.
  31254. * @param array array to be set.
  31255. * @returns this effect.
  31256. */
  31257. setArray3(uniformName: string, array: number[]): Effect;
  31258. /**
  31259. * 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)
  31260. * @param uniformName Name of the variable.
  31261. * @param array array to be set.
  31262. * @returns this effect.
  31263. */
  31264. setArray4(uniformName: string, array: number[]): Effect;
  31265. /**
  31266. * Sets matrices on a uniform variable.
  31267. * @param uniformName Name of the variable.
  31268. * @param matrices matrices to be set.
  31269. * @returns this effect.
  31270. */
  31271. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  31272. /**
  31273. * Sets matrix on a uniform variable.
  31274. * @param uniformName Name of the variable.
  31275. * @param matrix matrix to be set.
  31276. * @returns this effect.
  31277. */
  31278. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  31279. /**
  31280. * 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)
  31281. * @param uniformName Name of the variable.
  31282. * @param matrix matrix to be set.
  31283. * @returns this effect.
  31284. */
  31285. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  31286. /**
  31287. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  31288. * @param uniformName Name of the variable.
  31289. * @param matrix matrix to be set.
  31290. * @returns this effect.
  31291. */
  31292. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  31293. /**
  31294. * Sets a float on a uniform variable.
  31295. * @param uniformName Name of the variable.
  31296. * @param value value to be set.
  31297. * @returns this effect.
  31298. */
  31299. setFloat(uniformName: string, value: number): Effect;
  31300. /**
  31301. * Sets a boolean on a uniform variable.
  31302. * @param uniformName Name of the variable.
  31303. * @param bool value to be set.
  31304. * @returns this effect.
  31305. */
  31306. setBool(uniformName: string, bool: boolean): Effect;
  31307. /**
  31308. * Sets a Vector2 on a uniform variable.
  31309. * @param uniformName Name of the variable.
  31310. * @param vector2 vector2 to be set.
  31311. * @returns this effect.
  31312. */
  31313. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  31314. /**
  31315. * Sets a float2 on a uniform variable.
  31316. * @param uniformName Name of the variable.
  31317. * @param x First float in float2.
  31318. * @param y Second float in float2.
  31319. * @returns this effect.
  31320. */
  31321. setFloat2(uniformName: string, x: number, y: number): Effect;
  31322. /**
  31323. * Sets a Vector3 on a uniform variable.
  31324. * @param uniformName Name of the variable.
  31325. * @param vector3 Value to be set.
  31326. * @returns this effect.
  31327. */
  31328. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  31329. /**
  31330. * Sets a float3 on a uniform variable.
  31331. * @param uniformName Name of the variable.
  31332. * @param x First float in float3.
  31333. * @param y Second float in float3.
  31334. * @param z Third float in float3.
  31335. * @returns this effect.
  31336. */
  31337. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  31338. /**
  31339. * Sets a Vector4 on a uniform variable.
  31340. * @param uniformName Name of the variable.
  31341. * @param vector4 Value to be set.
  31342. * @returns this effect.
  31343. */
  31344. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  31345. /**
  31346. * Sets a float4 on a uniform variable.
  31347. * @param uniformName Name of the variable.
  31348. * @param x First float in float4.
  31349. * @param y Second float in float4.
  31350. * @param z Third float in float4.
  31351. * @param w Fourth float in float4.
  31352. * @returns this effect.
  31353. */
  31354. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  31355. /**
  31356. * Sets a Color3 on a uniform variable.
  31357. * @param uniformName Name of the variable.
  31358. * @param color3 Value to be set.
  31359. * @returns this effect.
  31360. */
  31361. setColor3(uniformName: string, color3: IColor3Like): Effect;
  31362. /**
  31363. * Sets a Color4 on a uniform variable.
  31364. * @param uniformName Name of the variable.
  31365. * @param color3 Value to be set.
  31366. * @param alpha Alpha value to be set.
  31367. * @returns this effect.
  31368. */
  31369. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  31370. /**
  31371. * Sets a Color4 on a uniform variable
  31372. * @param uniformName defines the name of the variable
  31373. * @param color4 defines the value to be set
  31374. * @returns this effect.
  31375. */
  31376. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  31377. /** Release all associated resources */
  31378. dispose(): void;
  31379. /**
  31380. * This function will add a new shader to the shader store
  31381. * @param name the name of the shader
  31382. * @param pixelShader optional pixel shader content
  31383. * @param vertexShader optional vertex shader content
  31384. */
  31385. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  31386. /**
  31387. * Store of each shader (The can be looked up using effect.key)
  31388. */
  31389. static ShadersStore: {
  31390. [key: string]: string;
  31391. };
  31392. /**
  31393. * Store of each included file for a shader (The can be looked up using effect.key)
  31394. */
  31395. static IncludesShadersStore: {
  31396. [key: string]: string;
  31397. };
  31398. /**
  31399. * Resets the cache of effects.
  31400. */
  31401. static ResetCache(): void;
  31402. }
  31403. }
  31404. declare module "babylonjs/Engines/engineCapabilities" {
  31405. /**
  31406. * Interface used to describe the capabilities of the engine relatively to the current browser
  31407. */
  31408. export interface EngineCapabilities {
  31409. /** Maximum textures units per fragment shader */
  31410. maxTexturesImageUnits: number;
  31411. /** Maximum texture units per vertex shader */
  31412. maxVertexTextureImageUnits: number;
  31413. /** Maximum textures units in the entire pipeline */
  31414. maxCombinedTexturesImageUnits: number;
  31415. /** Maximum texture size */
  31416. maxTextureSize: number;
  31417. /** Maximum texture samples */
  31418. maxSamples?: number;
  31419. /** Maximum cube texture size */
  31420. maxCubemapTextureSize: number;
  31421. /** Maximum render texture size */
  31422. maxRenderTextureSize: number;
  31423. /** Maximum number of vertex attributes */
  31424. maxVertexAttribs: number;
  31425. /** Maximum number of varyings */
  31426. maxVaryingVectors: number;
  31427. /** Maximum number of uniforms per vertex shader */
  31428. maxVertexUniformVectors: number;
  31429. /** Maximum number of uniforms per fragment shader */
  31430. maxFragmentUniformVectors: number;
  31431. /** Defines if standard derivates (dx/dy) are supported */
  31432. standardDerivatives: boolean;
  31433. /** Defines if s3tc texture compression is supported */
  31434. s3tc?: WEBGL_compressed_texture_s3tc;
  31435. /** Defines if pvrtc texture compression is supported */
  31436. pvrtc: any;
  31437. /** Defines if etc1 texture compression is supported */
  31438. etc1: any;
  31439. /** Defines if etc2 texture compression is supported */
  31440. etc2: any;
  31441. /** Defines if astc texture compression is supported */
  31442. astc: any;
  31443. /** Defines if float textures are supported */
  31444. textureFloat: boolean;
  31445. /** Defines if vertex array objects are supported */
  31446. vertexArrayObject: boolean;
  31447. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  31448. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  31449. /** Gets the maximum level of anisotropy supported */
  31450. maxAnisotropy: number;
  31451. /** Defines if instancing is supported */
  31452. instancedArrays: boolean;
  31453. /** Defines if 32 bits indices are supported */
  31454. uintIndices: boolean;
  31455. /** Defines if high precision shaders are supported */
  31456. highPrecisionShaderSupported: boolean;
  31457. /** Defines if depth reading in the fragment shader is supported */
  31458. fragmentDepthSupported: boolean;
  31459. /** Defines if float texture linear filtering is supported*/
  31460. textureFloatLinearFiltering: boolean;
  31461. /** Defines if rendering to float textures is supported */
  31462. textureFloatRender: boolean;
  31463. /** Defines if half float textures are supported*/
  31464. textureHalfFloat: boolean;
  31465. /** Defines if half float texture linear filtering is supported*/
  31466. textureHalfFloatLinearFiltering: boolean;
  31467. /** Defines if rendering to half float textures is supported */
  31468. textureHalfFloatRender: boolean;
  31469. /** Defines if textureLOD shader command is supported */
  31470. textureLOD: boolean;
  31471. /** Defines if draw buffers extension is supported */
  31472. drawBuffersExtension: boolean;
  31473. /** Defines if depth textures are supported */
  31474. depthTextureExtension: boolean;
  31475. /** Defines if float color buffer are supported */
  31476. colorBufferFloat: boolean;
  31477. /** Gets disjoint timer query extension (null if not supported) */
  31478. timerQuery?: EXT_disjoint_timer_query;
  31479. /** Defines if timestamp can be used with timer query */
  31480. canUseTimestampForTimerQuery: boolean;
  31481. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  31482. multiview?: any;
  31483. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  31484. oculusMultiview?: any;
  31485. /** Function used to let the system compiles shaders in background */
  31486. parallelShaderCompile?: {
  31487. COMPLETION_STATUS_KHR: number;
  31488. };
  31489. /** Max number of texture samples for MSAA */
  31490. maxMSAASamples: number;
  31491. /** Defines if the blend min max extension is supported */
  31492. blendMinMax: boolean;
  31493. }
  31494. }
  31495. declare module "babylonjs/States/depthCullingState" {
  31496. import { Nullable } from "babylonjs/types";
  31497. /**
  31498. * @hidden
  31499. **/
  31500. export class DepthCullingState {
  31501. private _isDepthTestDirty;
  31502. private _isDepthMaskDirty;
  31503. private _isDepthFuncDirty;
  31504. private _isCullFaceDirty;
  31505. private _isCullDirty;
  31506. private _isZOffsetDirty;
  31507. private _isFrontFaceDirty;
  31508. private _depthTest;
  31509. private _depthMask;
  31510. private _depthFunc;
  31511. private _cull;
  31512. private _cullFace;
  31513. private _zOffset;
  31514. private _frontFace;
  31515. /**
  31516. * Initializes the state.
  31517. */
  31518. constructor();
  31519. get isDirty(): boolean;
  31520. get zOffset(): number;
  31521. set zOffset(value: number);
  31522. get cullFace(): Nullable<number>;
  31523. set cullFace(value: Nullable<number>);
  31524. get cull(): Nullable<boolean>;
  31525. set cull(value: Nullable<boolean>);
  31526. get depthFunc(): Nullable<number>;
  31527. set depthFunc(value: Nullable<number>);
  31528. get depthMask(): boolean;
  31529. set depthMask(value: boolean);
  31530. get depthTest(): boolean;
  31531. set depthTest(value: boolean);
  31532. get frontFace(): Nullable<number>;
  31533. set frontFace(value: Nullable<number>);
  31534. reset(): void;
  31535. apply(gl: WebGLRenderingContext): void;
  31536. }
  31537. }
  31538. declare module "babylonjs/States/stencilState" {
  31539. /**
  31540. * @hidden
  31541. **/
  31542. export class StencilState {
  31543. /** 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 */
  31544. static readonly ALWAYS: number;
  31545. /** Passed to stencilOperation to specify that stencil value must be kept */
  31546. static readonly KEEP: number;
  31547. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31548. static readonly REPLACE: number;
  31549. private _isStencilTestDirty;
  31550. private _isStencilMaskDirty;
  31551. private _isStencilFuncDirty;
  31552. private _isStencilOpDirty;
  31553. private _stencilTest;
  31554. private _stencilMask;
  31555. private _stencilFunc;
  31556. private _stencilFuncRef;
  31557. private _stencilFuncMask;
  31558. private _stencilOpStencilFail;
  31559. private _stencilOpDepthFail;
  31560. private _stencilOpStencilDepthPass;
  31561. get isDirty(): boolean;
  31562. get stencilFunc(): number;
  31563. set stencilFunc(value: number);
  31564. get stencilFuncRef(): number;
  31565. set stencilFuncRef(value: number);
  31566. get stencilFuncMask(): number;
  31567. set stencilFuncMask(value: number);
  31568. get stencilOpStencilFail(): number;
  31569. set stencilOpStencilFail(value: number);
  31570. get stencilOpDepthFail(): number;
  31571. set stencilOpDepthFail(value: number);
  31572. get stencilOpStencilDepthPass(): number;
  31573. set stencilOpStencilDepthPass(value: number);
  31574. get stencilMask(): number;
  31575. set stencilMask(value: number);
  31576. get stencilTest(): boolean;
  31577. set stencilTest(value: boolean);
  31578. constructor();
  31579. reset(): void;
  31580. apply(gl: WebGLRenderingContext): void;
  31581. }
  31582. }
  31583. declare module "babylonjs/States/alphaCullingState" {
  31584. /**
  31585. * @hidden
  31586. **/
  31587. export class AlphaState {
  31588. private _isAlphaBlendDirty;
  31589. private _isBlendFunctionParametersDirty;
  31590. private _isBlendEquationParametersDirty;
  31591. private _isBlendConstantsDirty;
  31592. private _alphaBlend;
  31593. private _blendFunctionParameters;
  31594. private _blendEquationParameters;
  31595. private _blendConstants;
  31596. /**
  31597. * Initializes the state.
  31598. */
  31599. constructor();
  31600. get isDirty(): boolean;
  31601. get alphaBlend(): boolean;
  31602. set alphaBlend(value: boolean);
  31603. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31604. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31605. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31606. reset(): void;
  31607. apply(gl: WebGLRenderingContext): void;
  31608. }
  31609. }
  31610. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  31611. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31612. /** @hidden */
  31613. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31614. attributeProcessor(attribute: string): string;
  31615. varyingProcessor(varying: string, isFragment: boolean): string;
  31616. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31617. }
  31618. }
  31619. declare module "babylonjs/Engines/instancingAttributeInfo" {
  31620. /**
  31621. * Interface for attribute information associated with buffer instanciation
  31622. */
  31623. export interface InstancingAttributeInfo {
  31624. /**
  31625. * Name of the GLSL attribute
  31626. * if attribute index is not specified, this is used to retrieve the index from the effect
  31627. */
  31628. attributeName: string;
  31629. /**
  31630. * Index/offset of the attribute in the vertex shader
  31631. * if not specified, this will be computes from the name.
  31632. */
  31633. index?: number;
  31634. /**
  31635. * size of the attribute, 1, 2, 3 or 4
  31636. */
  31637. attributeSize: number;
  31638. /**
  31639. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31640. */
  31641. offset: number;
  31642. /**
  31643. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31644. * default to 1
  31645. */
  31646. divisor?: number;
  31647. /**
  31648. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31649. * default is FLOAT
  31650. */
  31651. attributeType?: number;
  31652. /**
  31653. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31654. */
  31655. normalized?: boolean;
  31656. }
  31657. }
  31658. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  31659. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31660. import { Nullable } from "babylonjs/types";
  31661. module "babylonjs/Engines/thinEngine" {
  31662. interface ThinEngine {
  31663. /**
  31664. * Update a video texture
  31665. * @param texture defines the texture to update
  31666. * @param video defines the video element to use
  31667. * @param invertY defines if data must be stored with Y axis inverted
  31668. */
  31669. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31670. }
  31671. }
  31672. }
  31673. declare module "babylonjs/Materials/Textures/videoTexture" {
  31674. import { Observable } from "babylonjs/Misc/observable";
  31675. import { Nullable } from "babylonjs/types";
  31676. import { Scene } from "babylonjs/scene";
  31677. import { Texture } from "babylonjs/Materials/Textures/texture";
  31678. import "babylonjs/Engines/Extensions/engine.videoTexture";
  31679. /**
  31680. * Settings for finer control over video usage
  31681. */
  31682. export interface VideoTextureSettings {
  31683. /**
  31684. * Applies `autoplay` to video, if specified
  31685. */
  31686. autoPlay?: boolean;
  31687. /**
  31688. * Applies `loop` to video, if specified
  31689. */
  31690. loop?: boolean;
  31691. /**
  31692. * Automatically updates internal texture from video at every frame in the render loop
  31693. */
  31694. autoUpdateTexture: boolean;
  31695. /**
  31696. * Image src displayed during the video loading or until the user interacts with the video.
  31697. */
  31698. poster?: string;
  31699. }
  31700. /**
  31701. * If you want to display a video in your scene, this is the special texture for that.
  31702. * This special texture works similar to other textures, with the exception of a few parameters.
  31703. * @see https://doc.babylonjs.com/how_to/video_texture
  31704. */
  31705. export class VideoTexture extends Texture {
  31706. /**
  31707. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31708. */
  31709. readonly autoUpdateTexture: boolean;
  31710. /**
  31711. * The video instance used by the texture internally
  31712. */
  31713. readonly video: HTMLVideoElement;
  31714. private _onUserActionRequestedObservable;
  31715. /**
  31716. * Event triggerd when a dom action is required by the user to play the video.
  31717. * This happens due to recent changes in browser policies preventing video to auto start.
  31718. */
  31719. get onUserActionRequestedObservable(): Observable<Texture>;
  31720. private _generateMipMaps;
  31721. private _engine;
  31722. private _stillImageCaptured;
  31723. private _displayingPosterTexture;
  31724. private _settings;
  31725. private _createInternalTextureOnEvent;
  31726. private _frameId;
  31727. private _currentSrc;
  31728. /**
  31729. * Creates a video texture.
  31730. * If you want to display a video in your scene, this is the special texture for that.
  31731. * This special texture works similar to other textures, with the exception of a few parameters.
  31732. * @see https://doc.babylonjs.com/how_to/video_texture
  31733. * @param name optional name, will detect from video source, if not defined
  31734. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31735. * @param scene is obviously the current scene.
  31736. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31737. * @param invertY is false by default but can be used to invert video on Y axis
  31738. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31739. * @param settings allows finer control over video usage
  31740. */
  31741. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31742. private _getName;
  31743. private _getVideo;
  31744. private _createInternalTexture;
  31745. private reset;
  31746. /**
  31747. * @hidden Internal method to initiate `update`.
  31748. */
  31749. _rebuild(): void;
  31750. /**
  31751. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31752. */
  31753. update(): void;
  31754. /**
  31755. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31756. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31757. */
  31758. updateTexture(isVisible: boolean): void;
  31759. protected _updateInternalTexture: () => void;
  31760. /**
  31761. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31762. * @param url New url.
  31763. */
  31764. updateURL(url: string): void;
  31765. /**
  31766. * Clones the texture.
  31767. * @returns the cloned texture
  31768. */
  31769. clone(): VideoTexture;
  31770. /**
  31771. * Dispose the texture and release its associated resources.
  31772. */
  31773. dispose(): void;
  31774. /**
  31775. * Creates a video texture straight from a stream.
  31776. * @param scene Define the scene the texture should be created in
  31777. * @param stream Define the stream the texture should be created from
  31778. * @returns The created video texture as a promise
  31779. */
  31780. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31781. /**
  31782. * Creates a video texture straight from your WebCam video feed.
  31783. * @param scene Define the scene the texture should be created in
  31784. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31785. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31786. * @returns The created video texture as a promise
  31787. */
  31788. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31789. minWidth: number;
  31790. maxWidth: number;
  31791. minHeight: number;
  31792. maxHeight: number;
  31793. deviceId: string;
  31794. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31795. /**
  31796. * Creates a video texture straight from your WebCam video feed.
  31797. * @param scene Define the scene the texture should be created in
  31798. * @param onReady Define a callback to triggered once the texture will be ready
  31799. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31800. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31801. */
  31802. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31803. minWidth: number;
  31804. maxWidth: number;
  31805. minHeight: number;
  31806. maxHeight: number;
  31807. deviceId: string;
  31808. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31809. }
  31810. }
  31811. declare module "babylonjs/Engines/thinEngine" {
  31812. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  31813. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  31814. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31815. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31816. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  31817. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  31818. import { Observable } from "babylonjs/Misc/observable";
  31819. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  31820. import { StencilState } from "babylonjs/States/stencilState";
  31821. import { AlphaState } from "babylonjs/States/alphaCullingState";
  31822. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31823. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31824. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31825. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  31826. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31827. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31828. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31829. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  31830. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31831. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31832. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31833. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  31834. import { WebRequest } from "babylonjs/Misc/webRequest";
  31835. import { LoadFileError } from "babylonjs/Misc/fileTools";
  31836. /**
  31837. * Defines the interface used by objects working like Scene
  31838. * @hidden
  31839. */
  31840. interface ISceneLike {
  31841. _addPendingData(data: any): void;
  31842. _removePendingData(data: any): void;
  31843. offlineProvider: IOfflineProvider;
  31844. }
  31845. /** Interface defining initialization parameters for Engine class */
  31846. export interface EngineOptions extends WebGLContextAttributes {
  31847. /**
  31848. * Defines if the engine should no exceed a specified device ratio
  31849. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31850. */
  31851. limitDeviceRatio?: number;
  31852. /**
  31853. * Defines if webvr should be enabled automatically
  31854. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31855. */
  31856. autoEnableWebVR?: boolean;
  31857. /**
  31858. * Defines if webgl2 should be turned off even if supported
  31859. * @see http://doc.babylonjs.com/features/webgl2
  31860. */
  31861. disableWebGL2Support?: boolean;
  31862. /**
  31863. * Defines if webaudio should be initialized as well
  31864. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31865. */
  31866. audioEngine?: boolean;
  31867. /**
  31868. * Defines if animations should run using a deterministic lock step
  31869. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31870. */
  31871. deterministicLockstep?: boolean;
  31872. /** Defines the maximum steps to use with deterministic lock step mode */
  31873. lockstepMaxSteps?: number;
  31874. /** Defines the seconds between each deterministic lock step */
  31875. timeStep?: number;
  31876. /**
  31877. * Defines that engine should ignore context lost events
  31878. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31879. */
  31880. doNotHandleContextLost?: boolean;
  31881. /**
  31882. * Defines that engine should ignore modifying touch action attribute and style
  31883. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31884. */
  31885. doNotHandleTouchAction?: boolean;
  31886. /**
  31887. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31888. */
  31889. useHighPrecisionFloats?: boolean;
  31890. }
  31891. /**
  31892. * The base engine class (root of all engines)
  31893. */
  31894. export class ThinEngine {
  31895. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31896. static ExceptionList: ({
  31897. key: string;
  31898. capture: string;
  31899. captureConstraint: number;
  31900. targets: string[];
  31901. } | {
  31902. key: string;
  31903. capture: null;
  31904. captureConstraint: null;
  31905. targets: string[];
  31906. })[];
  31907. /** @hidden */
  31908. static _TextureLoaders: IInternalTextureLoader[];
  31909. /**
  31910. * Returns the current npm package of the sdk
  31911. */
  31912. static get NpmPackage(): string;
  31913. /**
  31914. * Returns the current version of the framework
  31915. */
  31916. static get Version(): string;
  31917. /**
  31918. * Returns a string describing the current engine
  31919. */
  31920. get description(): string;
  31921. /**
  31922. * Gets or sets the epsilon value used by collision engine
  31923. */
  31924. static CollisionsEpsilon: number;
  31925. /**
  31926. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31927. */
  31928. static get ShadersRepository(): string;
  31929. static set ShadersRepository(value: string);
  31930. /**
  31931. * Gets or sets the textures that the engine should not attempt to load as compressed
  31932. */
  31933. protected _excludedCompressedTextures: string[];
  31934. /**
  31935. * Filters the compressed texture formats to only include
  31936. * files that are not included in the skippable list
  31937. *
  31938. * @param url the current extension
  31939. * @param textureFormatInUse the current compressed texture format
  31940. * @returns "format" string
  31941. */
  31942. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  31943. /** @hidden */
  31944. _shaderProcessor: IShaderProcessor;
  31945. /**
  31946. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31947. */
  31948. forcePOTTextures: boolean;
  31949. /**
  31950. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31951. */
  31952. isFullscreen: boolean;
  31953. /**
  31954. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31955. */
  31956. cullBackFaces: boolean;
  31957. /**
  31958. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31959. */
  31960. renderEvenInBackground: boolean;
  31961. /**
  31962. * Gets or sets a boolean indicating that cache can be kept between frames
  31963. */
  31964. preventCacheWipeBetweenFrames: boolean;
  31965. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31966. validateShaderPrograms: boolean;
  31967. /**
  31968. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31969. * This can provide greater z depth for distant objects.
  31970. */
  31971. useReverseDepthBuffer: boolean;
  31972. /**
  31973. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31974. */
  31975. disableUniformBuffers: boolean;
  31976. /** @hidden */
  31977. _uniformBuffers: UniformBuffer[];
  31978. /**
  31979. * Gets a boolean indicating that the engine supports uniform buffers
  31980. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31981. */
  31982. get supportsUniformBuffers(): boolean;
  31983. /** @hidden */
  31984. _gl: WebGLRenderingContext;
  31985. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31986. protected _windowIsBackground: boolean;
  31987. protected _webGLVersion: number;
  31988. protected _creationOptions: EngineOptions;
  31989. protected _highPrecisionShadersAllowed: boolean;
  31990. /** @hidden */
  31991. get _shouldUseHighPrecisionShader(): boolean;
  31992. /**
  31993. * Gets a boolean indicating that only power of 2 textures are supported
  31994. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31995. */
  31996. get needPOTTextures(): boolean;
  31997. /** @hidden */
  31998. _badOS: boolean;
  31999. /** @hidden */
  32000. _badDesktopOS: boolean;
  32001. private _hardwareScalingLevel;
  32002. /** @hidden */
  32003. _caps: EngineCapabilities;
  32004. private _isStencilEnable;
  32005. private _glVersion;
  32006. private _glRenderer;
  32007. private _glVendor;
  32008. /** @hidden */
  32009. _videoTextureSupported: boolean;
  32010. protected _renderingQueueLaunched: boolean;
  32011. protected _activeRenderLoops: (() => void)[];
  32012. /**
  32013. * Observable signaled when a context lost event is raised
  32014. */
  32015. onContextLostObservable: Observable<ThinEngine>;
  32016. /**
  32017. * Observable signaled when a context restored event is raised
  32018. */
  32019. onContextRestoredObservable: Observable<ThinEngine>;
  32020. private _onContextLost;
  32021. private _onContextRestored;
  32022. protected _contextWasLost: boolean;
  32023. /** @hidden */
  32024. _doNotHandleContextLost: boolean;
  32025. /**
  32026. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  32027. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  32028. */
  32029. get doNotHandleContextLost(): boolean;
  32030. set doNotHandleContextLost(value: boolean);
  32031. /**
  32032. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  32033. */
  32034. disableVertexArrayObjects: boolean;
  32035. /** @hidden */
  32036. protected _colorWrite: boolean;
  32037. /** @hidden */
  32038. protected _colorWriteChanged: boolean;
  32039. /** @hidden */
  32040. protected _depthCullingState: DepthCullingState;
  32041. /** @hidden */
  32042. protected _stencilState: StencilState;
  32043. /** @hidden */
  32044. _alphaState: AlphaState;
  32045. /** @hidden */
  32046. _alphaMode: number;
  32047. /** @hidden */
  32048. _alphaEquation: number;
  32049. /** @hidden */
  32050. _internalTexturesCache: InternalTexture[];
  32051. /** @hidden */
  32052. protected _activeChannel: number;
  32053. private _currentTextureChannel;
  32054. /** @hidden */
  32055. protected _boundTexturesCache: {
  32056. [key: string]: Nullable<InternalTexture>;
  32057. };
  32058. /** @hidden */
  32059. protected _currentEffect: Nullable<Effect>;
  32060. /** @hidden */
  32061. protected _currentProgram: Nullable<WebGLProgram>;
  32062. private _compiledEffects;
  32063. private _vertexAttribArraysEnabled;
  32064. /** @hidden */
  32065. protected _cachedViewport: Nullable<IViewportLike>;
  32066. private _cachedVertexArrayObject;
  32067. /** @hidden */
  32068. protected _cachedVertexBuffers: any;
  32069. /** @hidden */
  32070. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  32071. /** @hidden */
  32072. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  32073. /** @hidden */
  32074. _currentRenderTarget: Nullable<InternalTexture>;
  32075. private _uintIndicesCurrentlySet;
  32076. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  32077. /** @hidden */
  32078. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  32079. private _currentBufferPointers;
  32080. private _currentInstanceLocations;
  32081. private _currentInstanceBuffers;
  32082. private _textureUnits;
  32083. /** @hidden */
  32084. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32085. /** @hidden */
  32086. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32087. /** @hidden */
  32088. _boundRenderFunction: any;
  32089. private _vaoRecordInProgress;
  32090. private _mustWipeVertexAttributes;
  32091. private _emptyTexture;
  32092. private _emptyCubeTexture;
  32093. private _emptyTexture3D;
  32094. private _emptyTexture2DArray;
  32095. /** @hidden */
  32096. _frameHandler: number;
  32097. private _nextFreeTextureSlots;
  32098. private _maxSimultaneousTextures;
  32099. private _activeRequests;
  32100. protected _texturesSupported: string[];
  32101. /** @hidden */
  32102. _textureFormatInUse: Nullable<string>;
  32103. protected get _supportsHardwareTextureRescaling(): boolean;
  32104. /**
  32105. * Gets the list of texture formats supported
  32106. */
  32107. get texturesSupported(): Array<string>;
  32108. /**
  32109. * Gets the list of texture formats in use
  32110. */
  32111. get textureFormatInUse(): Nullable<string>;
  32112. /**
  32113. * Gets the current viewport
  32114. */
  32115. get currentViewport(): Nullable<IViewportLike>;
  32116. /**
  32117. * Gets the default empty texture
  32118. */
  32119. get emptyTexture(): InternalTexture;
  32120. /**
  32121. * Gets the default empty 3D texture
  32122. */
  32123. get emptyTexture3D(): InternalTexture;
  32124. /**
  32125. * Gets the default empty 2D array texture
  32126. */
  32127. get emptyTexture2DArray(): InternalTexture;
  32128. /**
  32129. * Gets the default empty cube texture
  32130. */
  32131. get emptyCubeTexture(): InternalTexture;
  32132. /**
  32133. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  32134. */
  32135. readonly premultipliedAlpha: boolean;
  32136. /**
  32137. * Observable event triggered before each texture is initialized
  32138. */
  32139. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  32140. /**
  32141. * Creates a new engine
  32142. * @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
  32143. * @param antialias defines enable antialiasing (default: false)
  32144. * @param options defines further options to be sent to the getContext() function
  32145. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32146. */
  32147. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32148. private _rebuildInternalTextures;
  32149. private _rebuildEffects;
  32150. /**
  32151. * Gets a boolean indicating if all created effects are ready
  32152. * @returns true if all effects are ready
  32153. */
  32154. areAllEffectsReady(): boolean;
  32155. protected _rebuildBuffers(): void;
  32156. private _initGLContext;
  32157. /**
  32158. * Gets version of the current webGL context
  32159. */
  32160. get webGLVersion(): number;
  32161. /**
  32162. * Gets a string idenfifying the name of the class
  32163. * @returns "Engine" string
  32164. */
  32165. getClassName(): string;
  32166. /**
  32167. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  32168. */
  32169. get isStencilEnable(): boolean;
  32170. /** @hidden */
  32171. _prepareWorkingCanvas(): void;
  32172. /**
  32173. * Reset the texture cache to empty state
  32174. */
  32175. resetTextureCache(): void;
  32176. /**
  32177. * Gets an object containing information about the current webGL context
  32178. * @returns an object containing the vender, the renderer and the version of the current webGL context
  32179. */
  32180. getGlInfo(): {
  32181. vendor: string;
  32182. renderer: string;
  32183. version: string;
  32184. };
  32185. /**
  32186. * Defines the hardware scaling level.
  32187. * By default the hardware scaling level is computed from the window device ratio.
  32188. * 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.
  32189. * @param level defines the level to use
  32190. */
  32191. setHardwareScalingLevel(level: number): void;
  32192. /**
  32193. * Gets the current hardware scaling level.
  32194. * By default the hardware scaling level is computed from the window device ratio.
  32195. * 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.
  32196. * @returns a number indicating the current hardware scaling level
  32197. */
  32198. getHardwareScalingLevel(): number;
  32199. /**
  32200. * Gets the list of loaded textures
  32201. * @returns an array containing all loaded textures
  32202. */
  32203. getLoadedTexturesCache(): InternalTexture[];
  32204. /**
  32205. * Gets the object containing all engine capabilities
  32206. * @returns the EngineCapabilities object
  32207. */
  32208. getCaps(): EngineCapabilities;
  32209. /**
  32210. * stop executing a render loop function and remove it from the execution array
  32211. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  32212. */
  32213. stopRenderLoop(renderFunction?: () => void): void;
  32214. /** @hidden */
  32215. _renderLoop(): void;
  32216. /**
  32217. * Gets the HTML canvas attached with the current webGL context
  32218. * @returns a HTML canvas
  32219. */
  32220. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  32221. /**
  32222. * Gets host window
  32223. * @returns the host window object
  32224. */
  32225. getHostWindow(): Nullable<Window>;
  32226. /**
  32227. * Gets the current render width
  32228. * @param useScreen defines if screen size must be used (or the current render target if any)
  32229. * @returns a number defining the current render width
  32230. */
  32231. getRenderWidth(useScreen?: boolean): number;
  32232. /**
  32233. * Gets the current render height
  32234. * @param useScreen defines if screen size must be used (or the current render target if any)
  32235. * @returns a number defining the current render height
  32236. */
  32237. getRenderHeight(useScreen?: boolean): number;
  32238. /**
  32239. * Can be used to override the current requestAnimationFrame requester.
  32240. * @hidden
  32241. */
  32242. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  32243. /**
  32244. * Register and execute a render loop. The engine can have more than one render function
  32245. * @param renderFunction defines the function to continuously execute
  32246. */
  32247. runRenderLoop(renderFunction: () => void): void;
  32248. /**
  32249. * Clear the current render buffer or the current render target (if any is set up)
  32250. * @param color defines the color to use
  32251. * @param backBuffer defines if the back buffer must be cleared
  32252. * @param depth defines if the depth buffer must be cleared
  32253. * @param stencil defines if the stencil buffer must be cleared
  32254. */
  32255. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  32256. private _viewportCached;
  32257. /** @hidden */
  32258. _viewport(x: number, y: number, width: number, height: number): void;
  32259. /**
  32260. * Set the WebGL's viewport
  32261. * @param viewport defines the viewport element to be used
  32262. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  32263. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  32264. */
  32265. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  32266. /**
  32267. * Begin a new frame
  32268. */
  32269. beginFrame(): void;
  32270. /**
  32271. * Enf the current frame
  32272. */
  32273. endFrame(): void;
  32274. /**
  32275. * Resize the view according to the canvas' size
  32276. */
  32277. resize(): void;
  32278. /**
  32279. * Force a specific size of the canvas
  32280. * @param width defines the new canvas' width
  32281. * @param height defines the new canvas' height
  32282. */
  32283. setSize(width: number, height: number): void;
  32284. /**
  32285. * Binds the frame buffer to the specified texture.
  32286. * @param texture The texture to render to or null for the default canvas
  32287. * @param faceIndex The face of the texture to render to in case of cube texture
  32288. * @param requiredWidth The width of the target to render to
  32289. * @param requiredHeight The height of the target to render to
  32290. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  32291. * @param lodLevel defines the lod level to bind to the frame buffer
  32292. * @param layer defines the 2d array index to bind to frame buffer to
  32293. */
  32294. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  32295. /** @hidden */
  32296. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  32297. /**
  32298. * Unbind the current render target texture from the webGL context
  32299. * @param texture defines the render target texture to unbind
  32300. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  32301. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  32302. */
  32303. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  32304. /**
  32305. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  32306. */
  32307. flushFramebuffer(): void;
  32308. /**
  32309. * Unbind the current render target and bind the default framebuffer
  32310. */
  32311. restoreDefaultFramebuffer(): void;
  32312. /** @hidden */
  32313. protected _resetVertexBufferBinding(): void;
  32314. /**
  32315. * Creates a vertex buffer
  32316. * @param data the data for the vertex buffer
  32317. * @returns the new WebGL static buffer
  32318. */
  32319. createVertexBuffer(data: DataArray): DataBuffer;
  32320. private _createVertexBuffer;
  32321. /**
  32322. * Creates a dynamic vertex buffer
  32323. * @param data the data for the dynamic vertex buffer
  32324. * @returns the new WebGL dynamic buffer
  32325. */
  32326. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  32327. protected _resetIndexBufferBinding(): void;
  32328. /**
  32329. * Creates a new index buffer
  32330. * @param indices defines the content of the index buffer
  32331. * @param updatable defines if the index buffer must be updatable
  32332. * @returns a new webGL buffer
  32333. */
  32334. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  32335. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  32336. /**
  32337. * Bind a webGL buffer to the webGL context
  32338. * @param buffer defines the buffer to bind
  32339. */
  32340. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  32341. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  32342. private bindBuffer;
  32343. /**
  32344. * update the bound buffer with the given data
  32345. * @param data defines the data to update
  32346. */
  32347. updateArrayBuffer(data: Float32Array): void;
  32348. private _vertexAttribPointer;
  32349. /** @hidden */
  32350. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  32351. private _bindVertexBuffersAttributes;
  32352. /**
  32353. * Records a vertex array object
  32354. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32355. * @param vertexBuffers defines the list of vertex buffers to store
  32356. * @param indexBuffer defines the index buffer to store
  32357. * @param effect defines the effect to store
  32358. * @returns the new vertex array object
  32359. */
  32360. recordVertexArrayObject(vertexBuffers: {
  32361. [key: string]: VertexBuffer;
  32362. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  32363. /**
  32364. * Bind a specific vertex array object
  32365. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32366. * @param vertexArrayObject defines the vertex array object to bind
  32367. * @param indexBuffer defines the index buffer to bind
  32368. */
  32369. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  32370. /**
  32371. * Bind webGl buffers directly to the webGL context
  32372. * @param vertexBuffer defines the vertex buffer to bind
  32373. * @param indexBuffer defines the index buffer to bind
  32374. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  32375. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  32376. * @param effect defines the effect associated with the vertex buffer
  32377. */
  32378. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  32379. private _unbindVertexArrayObject;
  32380. /**
  32381. * Bind a list of vertex buffers to the webGL context
  32382. * @param vertexBuffers defines the list of vertex buffers to bind
  32383. * @param indexBuffer defines the index buffer to bind
  32384. * @param effect defines the effect associated with the vertex buffers
  32385. */
  32386. bindBuffers(vertexBuffers: {
  32387. [key: string]: Nullable<VertexBuffer>;
  32388. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  32389. /**
  32390. * Unbind all instance attributes
  32391. */
  32392. unbindInstanceAttributes(): void;
  32393. /**
  32394. * Release and free the memory of a vertex array object
  32395. * @param vao defines the vertex array object to delete
  32396. */
  32397. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  32398. /** @hidden */
  32399. _releaseBuffer(buffer: DataBuffer): boolean;
  32400. protected _deleteBuffer(buffer: DataBuffer): void;
  32401. /**
  32402. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  32403. * @param instancesBuffer defines the webGL buffer to update and bind
  32404. * @param data defines the data to store in the buffer
  32405. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  32406. */
  32407. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  32408. /**
  32409. * Bind the content of a webGL buffer used with instantiation
  32410. * @param instancesBuffer defines the webGL buffer to bind
  32411. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  32412. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  32413. */
  32414. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  32415. /**
  32416. * Disable the instance attribute corresponding to the name in parameter
  32417. * @param name defines the name of the attribute to disable
  32418. */
  32419. disableInstanceAttributeByName(name: string): void;
  32420. /**
  32421. * Disable the instance attribute corresponding to the location in parameter
  32422. * @param attributeLocation defines the attribute location of the attribute to disable
  32423. */
  32424. disableInstanceAttribute(attributeLocation: number): void;
  32425. /**
  32426. * Disable the attribute corresponding to the location in parameter
  32427. * @param attributeLocation defines the attribute location of the attribute to disable
  32428. */
  32429. disableAttributeByIndex(attributeLocation: number): void;
  32430. /**
  32431. * Send a draw order
  32432. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32433. * @param indexStart defines the starting index
  32434. * @param indexCount defines the number of index to draw
  32435. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32436. */
  32437. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  32438. /**
  32439. * Draw a list of points
  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. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32445. /**
  32446. * Draw a list of unindexed primitives
  32447. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32448. * @param verticesStart defines the index of first vertex to draw
  32449. * @param verticesCount defines the count of vertices to draw
  32450. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32451. */
  32452. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32453. /**
  32454. * Draw a list of indexed primitives
  32455. * @param fillMode defines the primitive to use
  32456. * @param indexStart defines the starting index
  32457. * @param indexCount defines the number of index to draw
  32458. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32459. */
  32460. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  32461. /**
  32462. * Draw a list of unindexed primitives
  32463. * @param fillMode defines the primitive to use
  32464. * @param verticesStart defines the index of first vertex to draw
  32465. * @param verticesCount defines the count of vertices to draw
  32466. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32467. */
  32468. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32469. private _drawMode;
  32470. /** @hidden */
  32471. protected _reportDrawCall(): void;
  32472. /** @hidden */
  32473. _releaseEffect(effect: Effect): void;
  32474. /** @hidden */
  32475. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32476. /**
  32477. * Create a new effect (used to store vertex/fragment shaders)
  32478. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  32479. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  32480. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  32481. * @param samplers defines an array of string used to represent textures
  32482. * @param defines defines the string containing the defines to use to compile the shaders
  32483. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32484. * @param onCompiled defines a function to call when the effect creation is successful
  32485. * @param onError defines a function to call when the effect creation has failed
  32486. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  32487. * @returns the new Effect
  32488. */
  32489. 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;
  32490. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  32491. private _compileShader;
  32492. private _compileRawShader;
  32493. /**
  32494. * Directly creates a webGL program
  32495. * @param pipelineContext defines the pipeline context to attach to
  32496. * @param vertexCode defines the vertex shader code to use
  32497. * @param fragmentCode defines the fragment shader code to use
  32498. * @param context defines the webGL context to use (if not set, the current one will be used)
  32499. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32500. * @returns the new webGL program
  32501. */
  32502. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32503. /**
  32504. * Creates a webGL program
  32505. * @param pipelineContext defines the pipeline context to attach to
  32506. * @param vertexCode defines the vertex shader code to use
  32507. * @param fragmentCode defines the fragment shader code to use
  32508. * @param defines defines the string containing the defines to use to compile the shaders
  32509. * @param context defines the webGL context to use (if not set, the current one will be used)
  32510. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32511. * @returns the new webGL program
  32512. */
  32513. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32514. /**
  32515. * Creates a new pipeline context
  32516. * @returns the new pipeline
  32517. */
  32518. createPipelineContext(): IPipelineContext;
  32519. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32520. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  32521. /** @hidden */
  32522. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  32523. /** @hidden */
  32524. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  32525. /** @hidden */
  32526. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  32527. /**
  32528. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32529. * @param pipelineContext defines the pipeline context to use
  32530. * @param uniformsNames defines the list of uniform names
  32531. * @returns an array of webGL uniform locations
  32532. */
  32533. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32534. /**
  32535. * Gets the lsit of active attributes for a given webGL program
  32536. * @param pipelineContext defines the pipeline context to use
  32537. * @param attributesNames defines the list of attribute names to get
  32538. * @returns an array of indices indicating the offset of each attribute
  32539. */
  32540. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32541. /**
  32542. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32543. * @param effect defines the effect to activate
  32544. */
  32545. enableEffect(effect: Nullable<Effect>): void;
  32546. /**
  32547. * Set the value of an uniform to a number (int)
  32548. * @param uniform defines the webGL uniform location where to store the value
  32549. * @param value defines the int number to store
  32550. */
  32551. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32552. /**
  32553. * Set the value of an uniform to an array of int32
  32554. * @param uniform defines the webGL uniform location where to store the value
  32555. * @param array defines the array of int32 to store
  32556. */
  32557. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32558. /**
  32559. * Set the value of an uniform to an array of int32 (stored as vec2)
  32560. * @param uniform defines the webGL uniform location where to store the value
  32561. * @param array defines the array of int32 to store
  32562. */
  32563. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32564. /**
  32565. * Set the value of an uniform to an array of int32 (stored as vec3)
  32566. * @param uniform defines the webGL uniform location where to store the value
  32567. * @param array defines the array of int32 to store
  32568. */
  32569. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32570. /**
  32571. * Set the value of an uniform to an array of int32 (stored as vec4)
  32572. * @param uniform defines the webGL uniform location where to store the value
  32573. * @param array defines the array of int32 to store
  32574. */
  32575. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32576. /**
  32577. * Set the value of an uniform to an array of number
  32578. * @param uniform defines the webGL uniform location where to store the value
  32579. * @param array defines the array of number to store
  32580. */
  32581. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32582. /**
  32583. * Set the value of an uniform to an array of number (stored as vec2)
  32584. * @param uniform defines the webGL uniform location where to store the value
  32585. * @param array defines the array of number to store
  32586. */
  32587. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32588. /**
  32589. * Set the value of an uniform to an array of number (stored as vec3)
  32590. * @param uniform defines the webGL uniform location where to store the value
  32591. * @param array defines the array of number to store
  32592. */
  32593. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32594. /**
  32595. * Set the value of an uniform to an array of number (stored as vec4)
  32596. * @param uniform defines the webGL uniform location where to store the value
  32597. * @param array defines the array of number to store
  32598. */
  32599. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32600. /**
  32601. * Set the value of an uniform to an array of float32 (stored as matrices)
  32602. * @param uniform defines the webGL uniform location where to store the value
  32603. * @param matrices defines the array of float32 to store
  32604. */
  32605. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32606. /**
  32607. * Set the value of an uniform to a matrix (3x3)
  32608. * @param uniform defines the webGL uniform location where to store the value
  32609. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32610. */
  32611. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32612. /**
  32613. * Set the value of an uniform to a matrix (2x2)
  32614. * @param uniform defines the webGL uniform location where to store the value
  32615. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32616. */
  32617. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32618. /**
  32619. * Set the value of an uniform to a number (float)
  32620. * @param uniform defines the webGL uniform location where to store the value
  32621. * @param value defines the float number to store
  32622. */
  32623. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32624. /**
  32625. * Set the value of an uniform to a vec2
  32626. * @param uniform defines the webGL uniform location where to store the value
  32627. * @param x defines the 1st component of the value
  32628. * @param y defines the 2nd component of the value
  32629. */
  32630. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32631. /**
  32632. * Set the value of an uniform to a vec3
  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. */
  32638. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32639. /**
  32640. * Set the value of an uniform to a vec4
  32641. * @param uniform defines the webGL uniform location where to store the value
  32642. * @param x defines the 1st component of the value
  32643. * @param y defines the 2nd component of the value
  32644. * @param z defines the 3rd component of the value
  32645. * @param w defines the 4th component of the value
  32646. */
  32647. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32648. /**
  32649. * Apply all cached states (depth, culling, stencil and alpha)
  32650. */
  32651. applyStates(): void;
  32652. /**
  32653. * Enable or disable color writing
  32654. * @param enable defines the state to set
  32655. */
  32656. setColorWrite(enable: boolean): void;
  32657. /**
  32658. * Gets a boolean indicating if color writing is enabled
  32659. * @returns the current color writing state
  32660. */
  32661. getColorWrite(): boolean;
  32662. /**
  32663. * Gets the depth culling state manager
  32664. */
  32665. get depthCullingState(): DepthCullingState;
  32666. /**
  32667. * Gets the alpha state manager
  32668. */
  32669. get alphaState(): AlphaState;
  32670. /**
  32671. * Gets the stencil state manager
  32672. */
  32673. get stencilState(): StencilState;
  32674. /**
  32675. * Clears the list of texture accessible through engine.
  32676. * This can help preventing texture load conflict due to name collision.
  32677. */
  32678. clearInternalTexturesCache(): void;
  32679. /**
  32680. * Force the entire cache to be cleared
  32681. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32682. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32683. */
  32684. wipeCaches(bruteForce?: boolean): void;
  32685. /** @hidden */
  32686. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32687. min: number;
  32688. mag: number;
  32689. };
  32690. /** @hidden */
  32691. _createTexture(): WebGLTexture;
  32692. /**
  32693. * Usually called from Texture.ts.
  32694. * Passed information to create a WebGLTexture
  32695. * @param urlArg defines a value which contains one of the following:
  32696. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32697. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32698. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32699. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32700. * @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)
  32701. * @param scene needed for loading to the correct scene
  32702. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32703. * @param onLoad optional callback to be called upon successful completion
  32704. * @param onError optional callback to be called upon failure
  32705. * @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
  32706. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32707. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32708. * @param forcedExtension defines the extension to use to pick the right loader
  32709. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32710. * @param mimeType defines an optional mime type
  32711. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32712. */
  32713. 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;
  32714. /**
  32715. * Loads an image as an HTMLImageElement.
  32716. * @param input url string, ArrayBuffer, or Blob to load
  32717. * @param onLoad callback called when the image successfully loads
  32718. * @param onError callback called when the image fails to load
  32719. * @param offlineProvider offline provider for caching
  32720. * @param mimeType optional mime type
  32721. * @returns the HTMLImageElement of the loaded image
  32722. * @hidden
  32723. */
  32724. 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>;
  32725. /**
  32726. * @hidden
  32727. */
  32728. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32729. /**
  32730. * Creates a raw texture
  32731. * @param data defines the data to store in the texture
  32732. * @param width defines the width of the texture
  32733. * @param height defines the height of the texture
  32734. * @param format defines the format of the data
  32735. * @param generateMipMaps defines if the engine should generate the mip levels
  32736. * @param invertY defines if data must be stored with Y axis inverted
  32737. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32738. * @param compression defines the compression used (null by default)
  32739. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32740. * @returns the raw texture inside an InternalTexture
  32741. */
  32742. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32743. /**
  32744. * Creates a new raw cube texture
  32745. * @param data defines the array of data to use to create each face
  32746. * @param size defines the size of the textures
  32747. * @param format defines the format of the data
  32748. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32749. * @param generateMipMaps defines if the engine should generate the mip levels
  32750. * @param invertY defines if data must be stored with Y axis inverted
  32751. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32752. * @param compression defines the compression used (null by default)
  32753. * @returns the cube texture as an InternalTexture
  32754. */
  32755. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32756. /**
  32757. * Creates a new raw 3D texture
  32758. * @param data defines the data used to create the texture
  32759. * @param width defines the width of the texture
  32760. * @param height defines the height of the texture
  32761. * @param depth defines the depth of the texture
  32762. * @param format defines the format of the texture
  32763. * @param generateMipMaps defines if the engine must generate mip levels
  32764. * @param invertY defines if data must be stored with Y axis inverted
  32765. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32766. * @param compression defines the compressed used (can be null)
  32767. * @param textureType defines the compressed used (can be null)
  32768. * @returns a new raw 3D texture (stored in an InternalTexture)
  32769. */
  32770. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32771. /**
  32772. * Creates a new raw 2D array texture
  32773. * @param data defines the data used to create the texture
  32774. * @param width defines the width of the texture
  32775. * @param height defines the height of the texture
  32776. * @param depth defines the number of layers of the texture
  32777. * @param format defines the format of the texture
  32778. * @param generateMipMaps defines if the engine must generate mip levels
  32779. * @param invertY defines if data must be stored with Y axis inverted
  32780. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32781. * @param compression defines the compressed used (can be null)
  32782. * @param textureType defines the compressed used (can be null)
  32783. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32784. */
  32785. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32786. private _unpackFlipYCached;
  32787. /**
  32788. * In case you are sharing the context with other applications, it might
  32789. * be interested to not cache the unpack flip y state to ensure a consistent
  32790. * value would be set.
  32791. */
  32792. enableUnpackFlipYCached: boolean;
  32793. /** @hidden */
  32794. _unpackFlipY(value: boolean): void;
  32795. /** @hidden */
  32796. _getUnpackAlignement(): number;
  32797. private _getTextureTarget;
  32798. /**
  32799. * Update the sampling mode of a given texture
  32800. * @param samplingMode defines the required sampling mode
  32801. * @param texture defines the texture to update
  32802. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32803. */
  32804. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32805. /**
  32806. * Update the sampling mode of a given texture
  32807. * @param texture defines the texture to update
  32808. * @param wrapU defines the texture wrap mode of the u coordinates
  32809. * @param wrapV defines the texture wrap mode of the v coordinates
  32810. * @param wrapR defines the texture wrap mode of the r coordinates
  32811. */
  32812. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32813. /** @hidden */
  32814. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32815. width: number;
  32816. height: number;
  32817. layers?: number;
  32818. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32819. /** @hidden */
  32820. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32821. /** @hidden */
  32822. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32823. /**
  32824. * Update a portion of an internal texture
  32825. * @param texture defines the texture to update
  32826. * @param imageData defines the data to store into the texture
  32827. * @param xOffset defines the x coordinates of the update rectangle
  32828. * @param yOffset defines the y coordinates of the update rectangle
  32829. * @param width defines the width of the update rectangle
  32830. * @param height defines the height of the update rectangle
  32831. * @param faceIndex defines the face index if texture is a cube (0 by default)
  32832. * @param lod defines the lod level to update (0 by default)
  32833. */
  32834. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  32835. /** @hidden */
  32836. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32837. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32838. private _prepareWebGLTexture;
  32839. /** @hidden */
  32840. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32841. private _getDepthStencilBuffer;
  32842. /** @hidden */
  32843. _releaseFramebufferObjects(texture: InternalTexture): void;
  32844. /** @hidden */
  32845. _releaseTexture(texture: InternalTexture): void;
  32846. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32847. protected _setProgram(program: WebGLProgram): void;
  32848. protected _boundUniforms: {
  32849. [key: number]: WebGLUniformLocation;
  32850. };
  32851. /**
  32852. * Binds an effect to the webGL context
  32853. * @param effect defines the effect to bind
  32854. */
  32855. bindSamplers(effect: Effect): void;
  32856. private _activateCurrentTexture;
  32857. /** @hidden */
  32858. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32859. /** @hidden */
  32860. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32861. /**
  32862. * Unbind all textures from the webGL context
  32863. */
  32864. unbindAllTextures(): void;
  32865. /**
  32866. * Sets a texture to the according uniform.
  32867. * @param channel The texture channel
  32868. * @param uniform The uniform to set
  32869. * @param texture The texture to apply
  32870. */
  32871. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32872. private _bindSamplerUniformToChannel;
  32873. private _getTextureWrapMode;
  32874. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32875. /**
  32876. * Sets an array of texture to the webGL context
  32877. * @param channel defines the channel where the texture array must be set
  32878. * @param uniform defines the associated uniform location
  32879. * @param textures defines the array of textures to bind
  32880. */
  32881. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32882. /** @hidden */
  32883. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  32884. private _setTextureParameterFloat;
  32885. private _setTextureParameterInteger;
  32886. /**
  32887. * Unbind all vertex attributes from the webGL context
  32888. */
  32889. unbindAllAttributes(): void;
  32890. /**
  32891. * 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
  32892. */
  32893. releaseEffects(): void;
  32894. /**
  32895. * Dispose and release all associated resources
  32896. */
  32897. dispose(): void;
  32898. /**
  32899. * Attach a new callback raised when context lost event is fired
  32900. * @param callback defines the callback to call
  32901. */
  32902. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32903. /**
  32904. * Attach a new callback raised when context restored event is fired
  32905. * @param callback defines the callback to call
  32906. */
  32907. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32908. /**
  32909. * Get the current error code of the webGL context
  32910. * @returns the error code
  32911. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32912. */
  32913. getError(): number;
  32914. private _canRenderToFloatFramebuffer;
  32915. private _canRenderToHalfFloatFramebuffer;
  32916. private _canRenderToFramebuffer;
  32917. /** @hidden */
  32918. _getWebGLTextureType(type: number): number;
  32919. /** @hidden */
  32920. _getInternalFormat(format: number): number;
  32921. /** @hidden */
  32922. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32923. /** @hidden */
  32924. _getRGBAMultiSampleBufferFormat(type: number): number;
  32925. /** @hidden */
  32926. _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;
  32927. /**
  32928. * Loads a file from a url
  32929. * @param url url to load
  32930. * @param onSuccess callback called when the file successfully loads
  32931. * @param onProgress callback called while file is loading (if the server supports this mode)
  32932. * @param offlineProvider defines the offline provider for caching
  32933. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32934. * @param onError callback called when the file fails to load
  32935. * @returns a file request object
  32936. * @hidden
  32937. */
  32938. 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;
  32939. /**
  32940. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32941. * @param x defines the x coordinate of the rectangle where pixels must be read
  32942. * @param y defines the y coordinate of the rectangle where pixels must be read
  32943. * @param width defines the width of the rectangle where pixels must be read
  32944. * @param height defines the height of the rectangle where pixels must be read
  32945. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  32946. * @returns a Uint8Array containing RGBA colors
  32947. */
  32948. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32949. private static _isSupported;
  32950. /**
  32951. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32952. * @returns true if the engine can be created
  32953. * @ignorenaming
  32954. */
  32955. static isSupported(): boolean;
  32956. /**
  32957. * Find the next highest power of two.
  32958. * @param x Number to start search from.
  32959. * @return Next highest power of two.
  32960. */
  32961. static CeilingPOT(x: number): number;
  32962. /**
  32963. * Find the next lowest power of two.
  32964. * @param x Number to start search from.
  32965. * @return Next lowest power of two.
  32966. */
  32967. static FloorPOT(x: number): number;
  32968. /**
  32969. * Find the nearest power of two.
  32970. * @param x Number to start search from.
  32971. * @return Next nearest power of two.
  32972. */
  32973. static NearestPOT(x: number): number;
  32974. /**
  32975. * Get the closest exponent of two
  32976. * @param value defines the value to approximate
  32977. * @param max defines the maximum value to return
  32978. * @param mode defines how to define the closest value
  32979. * @returns closest exponent of two of the given value
  32980. */
  32981. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32982. /**
  32983. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32984. * @param func - the function to be called
  32985. * @param requester - the object that will request the next frame. Falls back to window.
  32986. * @returns frame number
  32987. */
  32988. static QueueNewFrame(func: () => void, requester?: any): number;
  32989. /**
  32990. * Gets host document
  32991. * @returns the host document object
  32992. */
  32993. getHostDocument(): Nullable<Document>;
  32994. }
  32995. }
  32996. declare module "babylonjs/Maths/sphericalPolynomial" {
  32997. import { Vector3 } from "babylonjs/Maths/math.vector";
  32998. import { Color3 } from "babylonjs/Maths/math.color";
  32999. /**
  33000. * Class representing spherical harmonics coefficients to the 3rd degree
  33001. */
  33002. export class SphericalHarmonics {
  33003. /**
  33004. * Defines whether or not the harmonics have been prescaled for rendering.
  33005. */
  33006. preScaled: boolean;
  33007. /**
  33008. * The l0,0 coefficients of the spherical harmonics
  33009. */
  33010. l00: Vector3;
  33011. /**
  33012. * The l1,-1 coefficients of the spherical harmonics
  33013. */
  33014. l1_1: Vector3;
  33015. /**
  33016. * The l1,0 coefficients of the spherical harmonics
  33017. */
  33018. l10: Vector3;
  33019. /**
  33020. * The l1,1 coefficients of the spherical harmonics
  33021. */
  33022. l11: Vector3;
  33023. /**
  33024. * The l2,-2 coefficients of the spherical harmonics
  33025. */
  33026. l2_2: Vector3;
  33027. /**
  33028. * The l2,-1 coefficients of the spherical harmonics
  33029. */
  33030. l2_1: Vector3;
  33031. /**
  33032. * The l2,0 coefficients of the spherical harmonics
  33033. */
  33034. l20: Vector3;
  33035. /**
  33036. * The l2,1 coefficients of the spherical harmonics
  33037. */
  33038. l21: Vector3;
  33039. /**
  33040. * The l2,2 coefficients of the spherical harmonics
  33041. */
  33042. l22: Vector3;
  33043. /**
  33044. * Adds a light to the spherical harmonics
  33045. * @param direction the direction of the light
  33046. * @param color the color of the light
  33047. * @param deltaSolidAngle the delta solid angle of the light
  33048. */
  33049. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  33050. /**
  33051. * Scales the spherical harmonics by the given amount
  33052. * @param scale the amount to scale
  33053. */
  33054. scaleInPlace(scale: number): void;
  33055. /**
  33056. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  33057. *
  33058. * ```
  33059. * E_lm = A_l * L_lm
  33060. * ```
  33061. *
  33062. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  33063. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  33064. * the scaling factors are given in equation 9.
  33065. */
  33066. convertIncidentRadianceToIrradiance(): void;
  33067. /**
  33068. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  33069. *
  33070. * ```
  33071. * L = (1/pi) * E * rho
  33072. * ```
  33073. *
  33074. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  33075. */
  33076. convertIrradianceToLambertianRadiance(): void;
  33077. /**
  33078. * Integrates the reconstruction coefficients directly in to the SH preventing further
  33079. * required operations at run time.
  33080. *
  33081. * This is simply done by scaling back the SH with Ylm constants parameter.
  33082. * The trigonometric part being applied by the shader at run time.
  33083. */
  33084. preScaleForRendering(): void;
  33085. /**
  33086. * Constructs a spherical harmonics from an array.
  33087. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  33088. * @returns the spherical harmonics
  33089. */
  33090. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  33091. /**
  33092. * Gets the spherical harmonics from polynomial
  33093. * @param polynomial the spherical polynomial
  33094. * @returns the spherical harmonics
  33095. */
  33096. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  33097. }
  33098. /**
  33099. * Class representing spherical polynomial coefficients to the 3rd degree
  33100. */
  33101. export class SphericalPolynomial {
  33102. private _harmonics;
  33103. /**
  33104. * The spherical harmonics used to create the polynomials.
  33105. */
  33106. get preScaledHarmonics(): SphericalHarmonics;
  33107. /**
  33108. * The x coefficients of the spherical polynomial
  33109. */
  33110. x: Vector3;
  33111. /**
  33112. * The y coefficients of the spherical polynomial
  33113. */
  33114. y: Vector3;
  33115. /**
  33116. * The z coefficients of the spherical polynomial
  33117. */
  33118. z: Vector3;
  33119. /**
  33120. * The xx coefficients of the spherical polynomial
  33121. */
  33122. xx: Vector3;
  33123. /**
  33124. * The yy coefficients of the spherical polynomial
  33125. */
  33126. yy: Vector3;
  33127. /**
  33128. * The zz coefficients of the spherical polynomial
  33129. */
  33130. zz: Vector3;
  33131. /**
  33132. * The xy coefficients of the spherical polynomial
  33133. */
  33134. xy: Vector3;
  33135. /**
  33136. * The yz coefficients of the spherical polynomial
  33137. */
  33138. yz: Vector3;
  33139. /**
  33140. * The zx coefficients of the spherical polynomial
  33141. */
  33142. zx: Vector3;
  33143. /**
  33144. * Adds an ambient color to the spherical polynomial
  33145. * @param color the color to add
  33146. */
  33147. addAmbient(color: Color3): void;
  33148. /**
  33149. * Scales the spherical polynomial by the given amount
  33150. * @param scale the amount to scale
  33151. */
  33152. scaleInPlace(scale: number): void;
  33153. /**
  33154. * Gets the spherical polynomial from harmonics
  33155. * @param harmonics the spherical harmonics
  33156. * @returns the spherical polynomial
  33157. */
  33158. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  33159. /**
  33160. * Constructs a spherical polynomial from an array.
  33161. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  33162. * @returns the spherical polynomial
  33163. */
  33164. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  33165. }
  33166. }
  33167. declare module "babylonjs/Materials/Textures/internalTexture" {
  33168. import { Observable } from "babylonjs/Misc/observable";
  33169. import { Nullable, int } from "babylonjs/types";
  33170. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  33171. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33172. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  33173. /**
  33174. * Defines the source of the internal texture
  33175. */
  33176. export enum InternalTextureSource {
  33177. /**
  33178. * The source of the texture data is unknown
  33179. */
  33180. Unknown = 0,
  33181. /**
  33182. * Texture data comes from an URL
  33183. */
  33184. Url = 1,
  33185. /**
  33186. * Texture data is only used for temporary storage
  33187. */
  33188. Temp = 2,
  33189. /**
  33190. * Texture data comes from raw data (ArrayBuffer)
  33191. */
  33192. Raw = 3,
  33193. /**
  33194. * Texture content is dynamic (video or dynamic texture)
  33195. */
  33196. Dynamic = 4,
  33197. /**
  33198. * Texture content is generated by rendering to it
  33199. */
  33200. RenderTarget = 5,
  33201. /**
  33202. * Texture content is part of a multi render target process
  33203. */
  33204. MultiRenderTarget = 6,
  33205. /**
  33206. * Texture data comes from a cube data file
  33207. */
  33208. Cube = 7,
  33209. /**
  33210. * Texture data comes from a raw cube data
  33211. */
  33212. CubeRaw = 8,
  33213. /**
  33214. * Texture data come from a prefiltered cube data file
  33215. */
  33216. CubePrefiltered = 9,
  33217. /**
  33218. * Texture content is raw 3D data
  33219. */
  33220. Raw3D = 10,
  33221. /**
  33222. * Texture content is raw 2D array data
  33223. */
  33224. Raw2DArray = 11,
  33225. /**
  33226. * Texture content is a depth texture
  33227. */
  33228. Depth = 12,
  33229. /**
  33230. * Texture data comes from a raw cube data encoded with RGBD
  33231. */
  33232. CubeRawRGBD = 13
  33233. }
  33234. /**
  33235. * Class used to store data associated with WebGL texture data for the engine
  33236. * This class should not be used directly
  33237. */
  33238. export class InternalTexture {
  33239. /** @hidden */
  33240. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  33241. /**
  33242. * Defines if the texture is ready
  33243. */
  33244. isReady: boolean;
  33245. /**
  33246. * Defines if the texture is a cube texture
  33247. */
  33248. isCube: boolean;
  33249. /**
  33250. * Defines if the texture contains 3D data
  33251. */
  33252. is3D: boolean;
  33253. /**
  33254. * Defines if the texture contains 2D array data
  33255. */
  33256. is2DArray: boolean;
  33257. /**
  33258. * Defines if the texture contains multiview data
  33259. */
  33260. isMultiview: boolean;
  33261. /**
  33262. * Gets the URL used to load this texture
  33263. */
  33264. url: string;
  33265. /**
  33266. * Gets the sampling mode of the texture
  33267. */
  33268. samplingMode: number;
  33269. /**
  33270. * Gets a boolean indicating if the texture needs mipmaps generation
  33271. */
  33272. generateMipMaps: boolean;
  33273. /**
  33274. * Gets the number of samples used by the texture (WebGL2+ only)
  33275. */
  33276. samples: number;
  33277. /**
  33278. * Gets the type of the texture (int, float...)
  33279. */
  33280. type: number;
  33281. /**
  33282. * Gets the format of the texture (RGB, RGBA...)
  33283. */
  33284. format: number;
  33285. /**
  33286. * Observable called when the texture is loaded
  33287. */
  33288. onLoadedObservable: Observable<InternalTexture>;
  33289. /**
  33290. * Gets the width of the texture
  33291. */
  33292. width: number;
  33293. /**
  33294. * Gets the height of the texture
  33295. */
  33296. height: number;
  33297. /**
  33298. * Gets the depth of the texture
  33299. */
  33300. depth: number;
  33301. /**
  33302. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  33303. */
  33304. baseWidth: number;
  33305. /**
  33306. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  33307. */
  33308. baseHeight: number;
  33309. /**
  33310. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33311. */
  33312. baseDepth: number;
  33313. /**
  33314. * Gets a boolean indicating if the texture is inverted on Y axis
  33315. */
  33316. invertY: boolean;
  33317. /** @hidden */
  33318. _invertVScale: boolean;
  33319. /** @hidden */
  33320. _associatedChannel: number;
  33321. /** @hidden */
  33322. _source: InternalTextureSource;
  33323. /** @hidden */
  33324. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  33325. /** @hidden */
  33326. _bufferView: Nullable<ArrayBufferView>;
  33327. /** @hidden */
  33328. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33329. /** @hidden */
  33330. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  33331. /** @hidden */
  33332. _size: number;
  33333. /** @hidden */
  33334. _extension: string;
  33335. /** @hidden */
  33336. _files: Nullable<string[]>;
  33337. /** @hidden */
  33338. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  33339. /** @hidden */
  33340. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  33341. /** @hidden */
  33342. _framebuffer: Nullable<WebGLFramebuffer>;
  33343. /** @hidden */
  33344. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33345. /** @hidden */
  33346. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33347. /** @hidden */
  33348. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33349. /** @hidden */
  33350. _attachments: Nullable<number[]>;
  33351. /** @hidden */
  33352. _cachedCoordinatesMode: Nullable<number>;
  33353. /** @hidden */
  33354. _cachedWrapU: Nullable<number>;
  33355. /** @hidden */
  33356. _cachedWrapV: Nullable<number>;
  33357. /** @hidden */
  33358. _cachedWrapR: Nullable<number>;
  33359. /** @hidden */
  33360. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33361. /** @hidden */
  33362. _isDisabled: boolean;
  33363. /** @hidden */
  33364. _compression: Nullable<string>;
  33365. /** @hidden */
  33366. _generateStencilBuffer: boolean;
  33367. /** @hidden */
  33368. _generateDepthBuffer: boolean;
  33369. /** @hidden */
  33370. _comparisonFunction: number;
  33371. /** @hidden */
  33372. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33373. /** @hidden */
  33374. _lodGenerationScale: number;
  33375. /** @hidden */
  33376. _lodGenerationOffset: number;
  33377. /** @hidden */
  33378. _depthStencilTexture: Nullable<InternalTexture>;
  33379. /** @hidden */
  33380. _colorTextureArray: Nullable<WebGLTexture>;
  33381. /** @hidden */
  33382. _depthStencilTextureArray: Nullable<WebGLTexture>;
  33383. /** @hidden */
  33384. _lodTextureHigh: Nullable<BaseTexture>;
  33385. /** @hidden */
  33386. _lodTextureMid: Nullable<BaseTexture>;
  33387. /** @hidden */
  33388. _lodTextureLow: Nullable<BaseTexture>;
  33389. /** @hidden */
  33390. _isRGBD: boolean;
  33391. /** @hidden */
  33392. _linearSpecularLOD: boolean;
  33393. /** @hidden */
  33394. _irradianceTexture: Nullable<BaseTexture>;
  33395. /** @hidden */
  33396. _webGLTexture: Nullable<WebGLTexture>;
  33397. /** @hidden */
  33398. _references: number;
  33399. private _engine;
  33400. /**
  33401. * Gets the Engine the texture belongs to.
  33402. * @returns The babylon engine
  33403. */
  33404. getEngine(): ThinEngine;
  33405. /**
  33406. * Gets the data source type of the texture
  33407. */
  33408. get source(): InternalTextureSource;
  33409. /**
  33410. * Creates a new InternalTexture
  33411. * @param engine defines the engine to use
  33412. * @param source defines the type of data that will be used
  33413. * @param delayAllocation if the texture allocation should be delayed (default: false)
  33414. */
  33415. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  33416. /**
  33417. * Increments the number of references (ie. the number of Texture that point to it)
  33418. */
  33419. incrementReferences(): void;
  33420. /**
  33421. * Change the size of the texture (not the size of the content)
  33422. * @param width defines the new width
  33423. * @param height defines the new height
  33424. * @param depth defines the new depth (1 by default)
  33425. */
  33426. updateSize(width: int, height: int, depth?: int): void;
  33427. /** @hidden */
  33428. _rebuild(): void;
  33429. /** @hidden */
  33430. _swapAndDie(target: InternalTexture): void;
  33431. /**
  33432. * Dispose the current allocated resources
  33433. */
  33434. dispose(): void;
  33435. }
  33436. }
  33437. declare module "babylonjs/Audio/analyser" {
  33438. import { Scene } from "babylonjs/scene";
  33439. /**
  33440. * Class used to work with sound analyzer using fast fourier transform (FFT)
  33441. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33442. */
  33443. export class Analyser {
  33444. /**
  33445. * Gets or sets the smoothing
  33446. * @ignorenaming
  33447. */
  33448. SMOOTHING: number;
  33449. /**
  33450. * Gets or sets the FFT table size
  33451. * @ignorenaming
  33452. */
  33453. FFT_SIZE: number;
  33454. /**
  33455. * Gets or sets the bar graph amplitude
  33456. * @ignorenaming
  33457. */
  33458. BARGRAPHAMPLITUDE: number;
  33459. /**
  33460. * Gets or sets the position of the debug canvas
  33461. * @ignorenaming
  33462. */
  33463. DEBUGCANVASPOS: {
  33464. x: number;
  33465. y: number;
  33466. };
  33467. /**
  33468. * Gets or sets the debug canvas size
  33469. * @ignorenaming
  33470. */
  33471. DEBUGCANVASSIZE: {
  33472. width: number;
  33473. height: number;
  33474. };
  33475. private _byteFreqs;
  33476. private _byteTime;
  33477. private _floatFreqs;
  33478. private _webAudioAnalyser;
  33479. private _debugCanvas;
  33480. private _debugCanvasContext;
  33481. private _scene;
  33482. private _registerFunc;
  33483. private _audioEngine;
  33484. /**
  33485. * Creates a new analyser
  33486. * @param scene defines hosting scene
  33487. */
  33488. constructor(scene: Scene);
  33489. /**
  33490. * Get the number of data values you will have to play with for the visualization
  33491. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  33492. * @returns a number
  33493. */
  33494. getFrequencyBinCount(): number;
  33495. /**
  33496. * Gets the current frequency data as a byte array
  33497. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33498. * @returns a Uint8Array
  33499. */
  33500. getByteFrequencyData(): Uint8Array;
  33501. /**
  33502. * Gets the current waveform as a byte array
  33503. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  33504. * @returns a Uint8Array
  33505. */
  33506. getByteTimeDomainData(): Uint8Array;
  33507. /**
  33508. * Gets the current frequency data as a float array
  33509. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33510. * @returns a Float32Array
  33511. */
  33512. getFloatFrequencyData(): Float32Array;
  33513. /**
  33514. * Renders the debug canvas
  33515. */
  33516. drawDebugCanvas(): void;
  33517. /**
  33518. * Stops rendering the debug canvas and removes it
  33519. */
  33520. stopDebugCanvas(): void;
  33521. /**
  33522. * Connects two audio nodes
  33523. * @param inputAudioNode defines first node to connect
  33524. * @param outputAudioNode defines second node to connect
  33525. */
  33526. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  33527. /**
  33528. * Releases all associated resources
  33529. */
  33530. dispose(): void;
  33531. }
  33532. }
  33533. declare module "babylonjs/Audio/audioEngine" {
  33534. import { IDisposable } from "babylonjs/scene";
  33535. import { Analyser } from "babylonjs/Audio/analyser";
  33536. import { Nullable } from "babylonjs/types";
  33537. import { Observable } from "babylonjs/Misc/observable";
  33538. /**
  33539. * This represents an audio engine and it is responsible
  33540. * to play, synchronize and analyse sounds throughout the application.
  33541. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33542. */
  33543. export interface IAudioEngine extends IDisposable {
  33544. /**
  33545. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33546. */
  33547. readonly canUseWebAudio: boolean;
  33548. /**
  33549. * Gets the current AudioContext if available.
  33550. */
  33551. readonly audioContext: Nullable<AudioContext>;
  33552. /**
  33553. * The master gain node defines the global audio volume of your audio engine.
  33554. */
  33555. readonly masterGain: GainNode;
  33556. /**
  33557. * Gets whether or not mp3 are supported by your browser.
  33558. */
  33559. readonly isMP3supported: boolean;
  33560. /**
  33561. * Gets whether or not ogg are supported by your browser.
  33562. */
  33563. readonly isOGGsupported: boolean;
  33564. /**
  33565. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33566. * @ignoreNaming
  33567. */
  33568. WarnedWebAudioUnsupported: boolean;
  33569. /**
  33570. * Defines if the audio engine relies on a custom unlocked button.
  33571. * In this case, the embedded button will not be displayed.
  33572. */
  33573. useCustomUnlockedButton: boolean;
  33574. /**
  33575. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33576. */
  33577. readonly unlocked: boolean;
  33578. /**
  33579. * Event raised when audio has been unlocked on the browser.
  33580. */
  33581. onAudioUnlockedObservable: Observable<AudioEngine>;
  33582. /**
  33583. * Event raised when audio has been locked on the browser.
  33584. */
  33585. onAudioLockedObservable: Observable<AudioEngine>;
  33586. /**
  33587. * Flags the audio engine in Locked state.
  33588. * This happens due to new browser policies preventing audio to autoplay.
  33589. */
  33590. lock(): void;
  33591. /**
  33592. * Unlocks the audio engine once a user action has been done on the dom.
  33593. * This is helpful to resume play once browser policies have been satisfied.
  33594. */
  33595. unlock(): void;
  33596. }
  33597. /**
  33598. * This represents the default audio engine used in babylon.
  33599. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33600. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33601. */
  33602. export class AudioEngine implements IAudioEngine {
  33603. private _audioContext;
  33604. private _audioContextInitialized;
  33605. private _muteButton;
  33606. private _hostElement;
  33607. /**
  33608. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33609. */
  33610. canUseWebAudio: boolean;
  33611. /**
  33612. * The master gain node defines the global audio volume of your audio engine.
  33613. */
  33614. masterGain: GainNode;
  33615. /**
  33616. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33617. * @ignoreNaming
  33618. */
  33619. WarnedWebAudioUnsupported: boolean;
  33620. /**
  33621. * Gets whether or not mp3 are supported by your browser.
  33622. */
  33623. isMP3supported: boolean;
  33624. /**
  33625. * Gets whether or not ogg are supported by your browser.
  33626. */
  33627. isOGGsupported: boolean;
  33628. /**
  33629. * Gets whether audio has been unlocked on the device.
  33630. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33631. * a user interaction has happened.
  33632. */
  33633. unlocked: boolean;
  33634. /**
  33635. * Defines if the audio engine relies on a custom unlocked button.
  33636. * In this case, the embedded button will not be displayed.
  33637. */
  33638. useCustomUnlockedButton: boolean;
  33639. /**
  33640. * Event raised when audio has been unlocked on the browser.
  33641. */
  33642. onAudioUnlockedObservable: Observable<AudioEngine>;
  33643. /**
  33644. * Event raised when audio has been locked on the browser.
  33645. */
  33646. onAudioLockedObservable: Observable<AudioEngine>;
  33647. /**
  33648. * Gets the current AudioContext if available.
  33649. */
  33650. get audioContext(): Nullable<AudioContext>;
  33651. private _connectedAnalyser;
  33652. /**
  33653. * Instantiates a new audio engine.
  33654. *
  33655. * There should be only one per page as some browsers restrict the number
  33656. * of audio contexts you can create.
  33657. * @param hostElement defines the host element where to display the mute icon if necessary
  33658. */
  33659. constructor(hostElement?: Nullable<HTMLElement>);
  33660. /**
  33661. * Flags the audio engine in Locked state.
  33662. * This happens due to new browser policies preventing audio to autoplay.
  33663. */
  33664. lock(): void;
  33665. /**
  33666. * Unlocks the audio engine once a user action has been done on the dom.
  33667. * This is helpful to resume play once browser policies have been satisfied.
  33668. */
  33669. unlock(): void;
  33670. private _resumeAudioContext;
  33671. private _initializeAudioContext;
  33672. private _tryToRun;
  33673. private _triggerRunningState;
  33674. private _triggerSuspendedState;
  33675. private _displayMuteButton;
  33676. private _moveButtonToTopLeft;
  33677. private _onResize;
  33678. private _hideMuteButton;
  33679. /**
  33680. * Destroy and release the resources associated with the audio ccontext.
  33681. */
  33682. dispose(): void;
  33683. /**
  33684. * Gets the global volume sets on the master gain.
  33685. * @returns the global volume if set or -1 otherwise
  33686. */
  33687. getGlobalVolume(): number;
  33688. /**
  33689. * Sets the global volume of your experience (sets on the master gain).
  33690. * @param newVolume Defines the new global volume of the application
  33691. */
  33692. setGlobalVolume(newVolume: number): void;
  33693. /**
  33694. * Connect the audio engine to an audio analyser allowing some amazing
  33695. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33696. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33697. * @param analyser The analyser to connect to the engine
  33698. */
  33699. connectToAnalyser(analyser: Analyser): void;
  33700. }
  33701. }
  33702. declare module "babylonjs/Loading/loadingScreen" {
  33703. /**
  33704. * Interface used to present a loading screen while loading a scene
  33705. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33706. */
  33707. export interface ILoadingScreen {
  33708. /**
  33709. * Function called to display the loading screen
  33710. */
  33711. displayLoadingUI: () => void;
  33712. /**
  33713. * Function called to hide the loading screen
  33714. */
  33715. hideLoadingUI: () => void;
  33716. /**
  33717. * Gets or sets the color to use for the background
  33718. */
  33719. loadingUIBackgroundColor: string;
  33720. /**
  33721. * Gets or sets the text to display while loading
  33722. */
  33723. loadingUIText: string;
  33724. }
  33725. /**
  33726. * Class used for the default loading screen
  33727. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33728. */
  33729. export class DefaultLoadingScreen implements ILoadingScreen {
  33730. private _renderingCanvas;
  33731. private _loadingText;
  33732. private _loadingDivBackgroundColor;
  33733. private _loadingDiv;
  33734. private _loadingTextDiv;
  33735. /** Gets or sets the logo url to use for the default loading screen */
  33736. static DefaultLogoUrl: string;
  33737. /** Gets or sets the spinner url to use for the default loading screen */
  33738. static DefaultSpinnerUrl: string;
  33739. /**
  33740. * Creates a new default loading screen
  33741. * @param _renderingCanvas defines the canvas used to render the scene
  33742. * @param _loadingText defines the default text to display
  33743. * @param _loadingDivBackgroundColor defines the default background color
  33744. */
  33745. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33746. /**
  33747. * Function called to display the loading screen
  33748. */
  33749. displayLoadingUI(): void;
  33750. /**
  33751. * Function called to hide the loading screen
  33752. */
  33753. hideLoadingUI(): void;
  33754. /**
  33755. * Gets or sets the text to display while loading
  33756. */
  33757. set loadingUIText(text: string);
  33758. get loadingUIText(): string;
  33759. /**
  33760. * Gets or sets the color to use for the background
  33761. */
  33762. get loadingUIBackgroundColor(): string;
  33763. set loadingUIBackgroundColor(color: string);
  33764. private _resizeLoadingUI;
  33765. }
  33766. }
  33767. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  33768. /**
  33769. * Interface for any object that can request an animation frame
  33770. */
  33771. export interface ICustomAnimationFrameRequester {
  33772. /**
  33773. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33774. */
  33775. renderFunction?: Function;
  33776. /**
  33777. * Called to request the next frame to render to
  33778. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33779. */
  33780. requestAnimationFrame: Function;
  33781. /**
  33782. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33783. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33784. */
  33785. requestID?: number;
  33786. }
  33787. }
  33788. declare module "babylonjs/Misc/performanceMonitor" {
  33789. /**
  33790. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33791. */
  33792. export class PerformanceMonitor {
  33793. private _enabled;
  33794. private _rollingFrameTime;
  33795. private _lastFrameTimeMs;
  33796. /**
  33797. * constructor
  33798. * @param frameSampleSize The number of samples required to saturate the sliding window
  33799. */
  33800. constructor(frameSampleSize?: number);
  33801. /**
  33802. * Samples current frame
  33803. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33804. */
  33805. sampleFrame(timeMs?: number): void;
  33806. /**
  33807. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33808. */
  33809. get averageFrameTime(): number;
  33810. /**
  33811. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33812. */
  33813. get averageFrameTimeVariance(): number;
  33814. /**
  33815. * Returns the frame time of the most recent frame
  33816. */
  33817. get instantaneousFrameTime(): number;
  33818. /**
  33819. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33820. */
  33821. get averageFPS(): number;
  33822. /**
  33823. * Returns the average framerate in frames per second using the most recent frame time
  33824. */
  33825. get instantaneousFPS(): number;
  33826. /**
  33827. * Returns true if enough samples have been taken to completely fill the sliding window
  33828. */
  33829. get isSaturated(): boolean;
  33830. /**
  33831. * Enables contributions to the sliding window sample set
  33832. */
  33833. enable(): void;
  33834. /**
  33835. * Disables contributions to the sliding window sample set
  33836. * Samples will not be interpolated over the disabled period
  33837. */
  33838. disable(): void;
  33839. /**
  33840. * Returns true if sampling is enabled
  33841. */
  33842. get isEnabled(): boolean;
  33843. /**
  33844. * Resets performance monitor
  33845. */
  33846. reset(): void;
  33847. }
  33848. /**
  33849. * RollingAverage
  33850. *
  33851. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33852. */
  33853. export class RollingAverage {
  33854. /**
  33855. * Current average
  33856. */
  33857. average: number;
  33858. /**
  33859. * Current variance
  33860. */
  33861. variance: number;
  33862. protected _samples: Array<number>;
  33863. protected _sampleCount: number;
  33864. protected _pos: number;
  33865. protected _m2: number;
  33866. /**
  33867. * constructor
  33868. * @param length The number of samples required to saturate the sliding window
  33869. */
  33870. constructor(length: number);
  33871. /**
  33872. * Adds a sample to the sample set
  33873. * @param v The sample value
  33874. */
  33875. add(v: number): void;
  33876. /**
  33877. * Returns previously added values or null if outside of history or outside the sliding window domain
  33878. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33879. * @return Value previously recorded with add() or null if outside of range
  33880. */
  33881. history(i: number): number;
  33882. /**
  33883. * Returns true if enough samples have been taken to completely fill the sliding window
  33884. * @return true if sample-set saturated
  33885. */
  33886. isSaturated(): boolean;
  33887. /**
  33888. * Resets the rolling average (equivalent to 0 samples taken so far)
  33889. */
  33890. reset(): void;
  33891. /**
  33892. * Wraps a value around the sample range boundaries
  33893. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33894. * @return Wrapped position in sample range
  33895. */
  33896. protected _wrapPosition(i: number): number;
  33897. }
  33898. }
  33899. declare module "babylonjs/Misc/perfCounter" {
  33900. /**
  33901. * This class is used to track a performance counter which is number based.
  33902. * The user has access to many properties which give statistics of different nature.
  33903. *
  33904. * The implementer can track two kinds of Performance Counter: time and count.
  33905. * 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.
  33906. * 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.
  33907. */
  33908. export class PerfCounter {
  33909. /**
  33910. * Gets or sets a global boolean to turn on and off all the counters
  33911. */
  33912. static Enabled: boolean;
  33913. /**
  33914. * Returns the smallest value ever
  33915. */
  33916. get min(): number;
  33917. /**
  33918. * Returns the biggest value ever
  33919. */
  33920. get max(): number;
  33921. /**
  33922. * Returns the average value since the performance counter is running
  33923. */
  33924. get average(): number;
  33925. /**
  33926. * Returns the average value of the last second the counter was monitored
  33927. */
  33928. get lastSecAverage(): number;
  33929. /**
  33930. * Returns the current value
  33931. */
  33932. get current(): number;
  33933. /**
  33934. * Gets the accumulated total
  33935. */
  33936. get total(): number;
  33937. /**
  33938. * Gets the total value count
  33939. */
  33940. get count(): number;
  33941. /**
  33942. * Creates a new counter
  33943. */
  33944. constructor();
  33945. /**
  33946. * Call this method to start monitoring a new frame.
  33947. * 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.
  33948. */
  33949. fetchNewFrame(): void;
  33950. /**
  33951. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33952. * @param newCount the count value to add to the monitored count
  33953. * @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.
  33954. */
  33955. addCount(newCount: number, fetchResult: boolean): void;
  33956. /**
  33957. * Start monitoring this performance counter
  33958. */
  33959. beginMonitoring(): void;
  33960. /**
  33961. * Compute the time lapsed since the previous beginMonitoring() call.
  33962. * @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
  33963. */
  33964. endMonitoring(newFrame?: boolean): void;
  33965. private _fetchResult;
  33966. private _startMonitoringTime;
  33967. private _min;
  33968. private _max;
  33969. private _average;
  33970. private _current;
  33971. private _totalValueCount;
  33972. private _totalAccumulated;
  33973. private _lastSecAverage;
  33974. private _lastSecAccumulated;
  33975. private _lastSecTime;
  33976. private _lastSecValueCount;
  33977. }
  33978. }
  33979. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  33980. module "babylonjs/Engines/thinEngine" {
  33981. interface ThinEngine {
  33982. /**
  33983. * Sets alpha constants used by some alpha blending modes
  33984. * @param r defines the red component
  33985. * @param g defines the green component
  33986. * @param b defines the blue component
  33987. * @param a defines the alpha component
  33988. */
  33989. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33990. /**
  33991. * Sets the current alpha mode
  33992. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33993. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33994. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33995. */
  33996. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33997. /**
  33998. * Gets the current alpha mode
  33999. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  34000. * @returns the current alpha mode
  34001. */
  34002. getAlphaMode(): number;
  34003. /**
  34004. * Sets the current alpha equation
  34005. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  34006. */
  34007. setAlphaEquation(equation: number): void;
  34008. /**
  34009. * Gets the current alpha equation.
  34010. * @returns the current alpha equation
  34011. */
  34012. getAlphaEquation(): number;
  34013. }
  34014. }
  34015. }
  34016. declare module "babylonjs/Engines/engine" {
  34017. import { Observable } from "babylonjs/Misc/observable";
  34018. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  34019. import { Scene } from "babylonjs/scene";
  34020. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34021. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  34022. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34023. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  34024. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  34025. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  34026. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  34027. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  34028. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  34029. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34030. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  34031. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  34032. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  34033. import "babylonjs/Engines/Extensions/engine.alpha";
  34034. import { Material } from "babylonjs/Materials/material";
  34035. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34036. /**
  34037. * Defines the interface used by display changed events
  34038. */
  34039. export interface IDisplayChangedEventArgs {
  34040. /** Gets the vrDisplay object (if any) */
  34041. vrDisplay: Nullable<any>;
  34042. /** Gets a boolean indicating if webVR is supported */
  34043. vrSupported: boolean;
  34044. }
  34045. /**
  34046. * Defines the interface used by objects containing a viewport (like a camera)
  34047. */
  34048. interface IViewportOwnerLike {
  34049. /**
  34050. * Gets or sets the viewport
  34051. */
  34052. viewport: IViewportLike;
  34053. }
  34054. /**
  34055. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  34056. */
  34057. export class Engine extends ThinEngine {
  34058. /** Defines that alpha blending is disabled */
  34059. static readonly ALPHA_DISABLE: number;
  34060. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  34061. static readonly ALPHA_ADD: number;
  34062. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  34063. static readonly ALPHA_COMBINE: number;
  34064. /** Defines that alpha blending to DEST - SRC * DEST */
  34065. static readonly ALPHA_SUBTRACT: number;
  34066. /** Defines that alpha blending to SRC * DEST */
  34067. static readonly ALPHA_MULTIPLY: number;
  34068. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  34069. static readonly ALPHA_MAXIMIZED: number;
  34070. /** Defines that alpha blending to SRC + DEST */
  34071. static readonly ALPHA_ONEONE: number;
  34072. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  34073. static readonly ALPHA_PREMULTIPLIED: number;
  34074. /**
  34075. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  34076. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  34077. */
  34078. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  34079. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  34080. static readonly ALPHA_INTERPOLATE: number;
  34081. /**
  34082. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  34083. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  34084. */
  34085. static readonly ALPHA_SCREENMODE: number;
  34086. /** Defines that the ressource is not delayed*/
  34087. static readonly DELAYLOADSTATE_NONE: number;
  34088. /** Defines that the ressource was successfully delay loaded */
  34089. static readonly DELAYLOADSTATE_LOADED: number;
  34090. /** Defines that the ressource is currently delay loading */
  34091. static readonly DELAYLOADSTATE_LOADING: number;
  34092. /** Defines that the ressource is delayed and has not started loading */
  34093. static readonly DELAYLOADSTATE_NOTLOADED: number;
  34094. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  34095. static readonly NEVER: number;
  34096. /** 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 */
  34097. static readonly ALWAYS: number;
  34098. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  34099. static readonly LESS: number;
  34100. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  34101. static readonly EQUAL: number;
  34102. /** 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 */
  34103. static readonly LEQUAL: number;
  34104. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  34105. static readonly GREATER: number;
  34106. /** 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 */
  34107. static readonly GEQUAL: number;
  34108. /** 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 */
  34109. static readonly NOTEQUAL: number;
  34110. /** Passed to stencilOperation to specify that stencil value must be kept */
  34111. static readonly KEEP: number;
  34112. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34113. static readonly REPLACE: number;
  34114. /** Passed to stencilOperation to specify that stencil value must be incremented */
  34115. static readonly INCR: number;
  34116. /** Passed to stencilOperation to specify that stencil value must be decremented */
  34117. static readonly DECR: number;
  34118. /** Passed to stencilOperation to specify that stencil value must be inverted */
  34119. static readonly INVERT: number;
  34120. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  34121. static readonly INCR_WRAP: number;
  34122. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  34123. static readonly DECR_WRAP: number;
  34124. /** Texture is not repeating outside of 0..1 UVs */
  34125. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  34126. /** Texture is repeating outside of 0..1 UVs */
  34127. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  34128. /** Texture is repeating and mirrored */
  34129. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  34130. /** ALPHA */
  34131. static readonly TEXTUREFORMAT_ALPHA: number;
  34132. /** LUMINANCE */
  34133. static readonly TEXTUREFORMAT_LUMINANCE: number;
  34134. /** LUMINANCE_ALPHA */
  34135. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  34136. /** RGB */
  34137. static readonly TEXTUREFORMAT_RGB: number;
  34138. /** RGBA */
  34139. static readonly TEXTUREFORMAT_RGBA: number;
  34140. /** RED */
  34141. static readonly TEXTUREFORMAT_RED: number;
  34142. /** RED (2nd reference) */
  34143. static readonly TEXTUREFORMAT_R: number;
  34144. /** RG */
  34145. static readonly TEXTUREFORMAT_RG: number;
  34146. /** RED_INTEGER */
  34147. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  34148. /** RED_INTEGER (2nd reference) */
  34149. static readonly TEXTUREFORMAT_R_INTEGER: number;
  34150. /** RG_INTEGER */
  34151. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  34152. /** RGB_INTEGER */
  34153. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  34154. /** RGBA_INTEGER */
  34155. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  34156. /** UNSIGNED_BYTE */
  34157. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  34158. /** UNSIGNED_BYTE (2nd reference) */
  34159. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  34160. /** FLOAT */
  34161. static readonly TEXTURETYPE_FLOAT: number;
  34162. /** HALF_FLOAT */
  34163. static readonly TEXTURETYPE_HALF_FLOAT: number;
  34164. /** BYTE */
  34165. static readonly TEXTURETYPE_BYTE: number;
  34166. /** SHORT */
  34167. static readonly TEXTURETYPE_SHORT: number;
  34168. /** UNSIGNED_SHORT */
  34169. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  34170. /** INT */
  34171. static readonly TEXTURETYPE_INT: number;
  34172. /** UNSIGNED_INT */
  34173. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  34174. /** UNSIGNED_SHORT_4_4_4_4 */
  34175. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  34176. /** UNSIGNED_SHORT_5_5_5_1 */
  34177. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  34178. /** UNSIGNED_SHORT_5_6_5 */
  34179. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  34180. /** UNSIGNED_INT_2_10_10_10_REV */
  34181. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  34182. /** UNSIGNED_INT_24_8 */
  34183. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  34184. /** UNSIGNED_INT_10F_11F_11F_REV */
  34185. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  34186. /** UNSIGNED_INT_5_9_9_9_REV */
  34187. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  34188. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  34189. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  34190. /** nearest is mag = nearest and min = nearest and mip = linear */
  34191. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  34192. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34193. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  34194. /** Trilinear is mag = linear and min = linear and mip = linear */
  34195. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  34196. /** nearest is mag = nearest and min = nearest and mip = linear */
  34197. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  34198. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34199. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  34200. /** Trilinear is mag = linear and min = linear and mip = linear */
  34201. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  34202. /** mag = nearest and min = nearest and mip = nearest */
  34203. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  34204. /** mag = nearest and min = linear and mip = nearest */
  34205. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  34206. /** mag = nearest and min = linear and mip = linear */
  34207. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  34208. /** mag = nearest and min = linear and mip = none */
  34209. static readonly TEXTURE_NEAREST_LINEAR: number;
  34210. /** mag = nearest and min = nearest and mip = none */
  34211. static readonly TEXTURE_NEAREST_NEAREST: number;
  34212. /** mag = linear and min = nearest and mip = nearest */
  34213. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  34214. /** mag = linear and min = nearest and mip = linear */
  34215. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  34216. /** mag = linear and min = linear and mip = none */
  34217. static readonly TEXTURE_LINEAR_LINEAR: number;
  34218. /** mag = linear and min = nearest and mip = none */
  34219. static readonly TEXTURE_LINEAR_NEAREST: number;
  34220. /** Explicit coordinates mode */
  34221. static readonly TEXTURE_EXPLICIT_MODE: number;
  34222. /** Spherical coordinates mode */
  34223. static readonly TEXTURE_SPHERICAL_MODE: number;
  34224. /** Planar coordinates mode */
  34225. static readonly TEXTURE_PLANAR_MODE: number;
  34226. /** Cubic coordinates mode */
  34227. static readonly TEXTURE_CUBIC_MODE: number;
  34228. /** Projection coordinates mode */
  34229. static readonly TEXTURE_PROJECTION_MODE: number;
  34230. /** Skybox coordinates mode */
  34231. static readonly TEXTURE_SKYBOX_MODE: number;
  34232. /** Inverse Cubic coordinates mode */
  34233. static readonly TEXTURE_INVCUBIC_MODE: number;
  34234. /** Equirectangular coordinates mode */
  34235. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  34236. /** Equirectangular Fixed coordinates mode */
  34237. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  34238. /** Equirectangular Fixed Mirrored coordinates mode */
  34239. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  34240. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  34241. static readonly SCALEMODE_FLOOR: number;
  34242. /** Defines that texture rescaling will look for the nearest power of 2 size */
  34243. static readonly SCALEMODE_NEAREST: number;
  34244. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  34245. static readonly SCALEMODE_CEILING: number;
  34246. /**
  34247. * Returns the current npm package of the sdk
  34248. */
  34249. static get NpmPackage(): string;
  34250. /**
  34251. * Returns the current version of the framework
  34252. */
  34253. static get Version(): string;
  34254. /** Gets the list of created engines */
  34255. static get Instances(): Engine[];
  34256. /**
  34257. * Gets the latest created engine
  34258. */
  34259. static get LastCreatedEngine(): Nullable<Engine>;
  34260. /**
  34261. * Gets the latest created scene
  34262. */
  34263. static get LastCreatedScene(): Nullable<Scene>;
  34264. /**
  34265. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  34266. * @param flag defines which part of the materials must be marked as dirty
  34267. * @param predicate defines a predicate used to filter which materials should be affected
  34268. */
  34269. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34270. /**
  34271. * Method called to create the default loading screen.
  34272. * This can be overriden in your own app.
  34273. * @param canvas The rendering canvas element
  34274. * @returns The loading screen
  34275. */
  34276. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  34277. /**
  34278. * Method called to create the default rescale post process on each engine.
  34279. */
  34280. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  34281. /**
  34282. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  34283. **/
  34284. enableOfflineSupport: boolean;
  34285. /**
  34286. * 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)
  34287. **/
  34288. disableManifestCheck: boolean;
  34289. /**
  34290. * Gets the list of created scenes
  34291. */
  34292. scenes: Scene[];
  34293. /**
  34294. * Event raised when a new scene is created
  34295. */
  34296. onNewSceneAddedObservable: Observable<Scene>;
  34297. /**
  34298. * Gets the list of created postprocesses
  34299. */
  34300. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  34301. /**
  34302. * Gets a boolean indicating if the pointer is currently locked
  34303. */
  34304. isPointerLock: boolean;
  34305. /**
  34306. * Observable event triggered each time the rendering canvas is resized
  34307. */
  34308. onResizeObservable: Observable<Engine>;
  34309. /**
  34310. * Observable event triggered each time the canvas loses focus
  34311. */
  34312. onCanvasBlurObservable: Observable<Engine>;
  34313. /**
  34314. * Observable event triggered each time the canvas gains focus
  34315. */
  34316. onCanvasFocusObservable: Observable<Engine>;
  34317. /**
  34318. * Observable event triggered each time the canvas receives pointerout event
  34319. */
  34320. onCanvasPointerOutObservable: Observable<PointerEvent>;
  34321. /**
  34322. * Observable raised when the engine begins a new frame
  34323. */
  34324. onBeginFrameObservable: Observable<Engine>;
  34325. /**
  34326. * If set, will be used to request the next animation frame for the render loop
  34327. */
  34328. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  34329. /**
  34330. * Observable raised when the engine ends the current frame
  34331. */
  34332. onEndFrameObservable: Observable<Engine>;
  34333. /**
  34334. * Observable raised when the engine is about to compile a shader
  34335. */
  34336. onBeforeShaderCompilationObservable: Observable<Engine>;
  34337. /**
  34338. * Observable raised when the engine has jsut compiled a shader
  34339. */
  34340. onAfterShaderCompilationObservable: Observable<Engine>;
  34341. /**
  34342. * Gets the audio engine
  34343. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34344. * @ignorenaming
  34345. */
  34346. static audioEngine: IAudioEngine;
  34347. /**
  34348. * Default AudioEngine factory responsible of creating the Audio Engine.
  34349. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  34350. */
  34351. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  34352. /**
  34353. * Default offline support factory responsible of creating a tool used to store data locally.
  34354. * By default, this will create a Database object if the workload has been embedded.
  34355. */
  34356. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  34357. private _loadingScreen;
  34358. private _pointerLockRequested;
  34359. private _dummyFramebuffer;
  34360. private _rescalePostProcess;
  34361. private _deterministicLockstep;
  34362. private _lockstepMaxSteps;
  34363. private _timeStep;
  34364. protected get _supportsHardwareTextureRescaling(): boolean;
  34365. private _fps;
  34366. private _deltaTime;
  34367. /** @hidden */
  34368. _drawCalls: PerfCounter;
  34369. /** 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 */
  34370. canvasTabIndex: number;
  34371. /**
  34372. * Turn this value on if you want to pause FPS computation when in background
  34373. */
  34374. disablePerformanceMonitorInBackground: boolean;
  34375. private _performanceMonitor;
  34376. /**
  34377. * Gets the performance monitor attached to this engine
  34378. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  34379. */
  34380. get performanceMonitor(): PerformanceMonitor;
  34381. private _onFocus;
  34382. private _onBlur;
  34383. private _onCanvasPointerOut;
  34384. private _onCanvasBlur;
  34385. private _onCanvasFocus;
  34386. private _onFullscreenChange;
  34387. private _onPointerLockChange;
  34388. /**
  34389. * Gets the HTML element used to attach event listeners
  34390. * @returns a HTML element
  34391. */
  34392. getInputElement(): Nullable<HTMLElement>;
  34393. /**
  34394. * Creates a new engine
  34395. * @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
  34396. * @param antialias defines enable antialiasing (default: false)
  34397. * @param options defines further options to be sent to the getContext() function
  34398. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34399. */
  34400. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34401. /**
  34402. * Gets current aspect ratio
  34403. * @param viewportOwner defines the camera to use to get the aspect ratio
  34404. * @param useScreen defines if screen size must be used (or the current render target if any)
  34405. * @returns a number defining the aspect ratio
  34406. */
  34407. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  34408. /**
  34409. * Gets current screen aspect ratio
  34410. * @returns a number defining the aspect ratio
  34411. */
  34412. getScreenAspectRatio(): number;
  34413. /**
  34414. * Gets the client rect of the HTML canvas attached with the current webGL context
  34415. * @returns a client rectanglee
  34416. */
  34417. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  34418. /**
  34419. * Gets the client rect of the HTML element used for events
  34420. * @returns a client rectanglee
  34421. */
  34422. getInputElementClientRect(): Nullable<ClientRect>;
  34423. /**
  34424. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  34425. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34426. * @returns true if engine is in deterministic lock step mode
  34427. */
  34428. isDeterministicLockStep(): boolean;
  34429. /**
  34430. * Gets the max steps when engine is running in deterministic lock step
  34431. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34432. * @returns the max steps
  34433. */
  34434. getLockstepMaxSteps(): number;
  34435. /**
  34436. * Returns the time in ms between steps when using deterministic lock step.
  34437. * @returns time step in (ms)
  34438. */
  34439. getTimeStep(): number;
  34440. /**
  34441. * Force the mipmap generation for the given render target texture
  34442. * @param texture defines the render target texture to use
  34443. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  34444. */
  34445. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  34446. /** States */
  34447. /**
  34448. * Set various states to the webGL context
  34449. * @param culling defines backface culling state
  34450. * @param zOffset defines the value to apply to zOffset (0 by default)
  34451. * @param force defines if states must be applied even if cache is up to date
  34452. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  34453. */
  34454. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  34455. /**
  34456. * Set the z offset to apply to current rendering
  34457. * @param value defines the offset to apply
  34458. */
  34459. setZOffset(value: number): void;
  34460. /**
  34461. * Gets the current value of the zOffset
  34462. * @returns the current zOffset state
  34463. */
  34464. getZOffset(): number;
  34465. /**
  34466. * Enable or disable depth buffering
  34467. * @param enable defines the state to set
  34468. */
  34469. setDepthBuffer(enable: boolean): void;
  34470. /**
  34471. * Gets a boolean indicating if depth writing is enabled
  34472. * @returns the current depth writing state
  34473. */
  34474. getDepthWrite(): boolean;
  34475. /**
  34476. * Enable or disable depth writing
  34477. * @param enable defines the state to set
  34478. */
  34479. setDepthWrite(enable: boolean): void;
  34480. /**
  34481. * Gets a boolean indicating if stencil buffer is enabled
  34482. * @returns the current stencil buffer state
  34483. */
  34484. getStencilBuffer(): boolean;
  34485. /**
  34486. * Enable or disable the stencil buffer
  34487. * @param enable defines if the stencil buffer must be enabled or disabled
  34488. */
  34489. setStencilBuffer(enable: boolean): void;
  34490. /**
  34491. * Gets the current stencil mask
  34492. * @returns a number defining the new stencil mask to use
  34493. */
  34494. getStencilMask(): number;
  34495. /**
  34496. * Sets the current stencil mask
  34497. * @param mask defines the new stencil mask to use
  34498. */
  34499. setStencilMask(mask: number): void;
  34500. /**
  34501. * Gets the current stencil function
  34502. * @returns a number defining the stencil function to use
  34503. */
  34504. getStencilFunction(): number;
  34505. /**
  34506. * Gets the current stencil reference value
  34507. * @returns a number defining the stencil reference value to use
  34508. */
  34509. getStencilFunctionReference(): number;
  34510. /**
  34511. * Gets the current stencil mask
  34512. * @returns a number defining the stencil mask to use
  34513. */
  34514. getStencilFunctionMask(): number;
  34515. /**
  34516. * Sets the current stencil function
  34517. * @param stencilFunc defines the new stencil function to use
  34518. */
  34519. setStencilFunction(stencilFunc: number): void;
  34520. /**
  34521. * Sets the current stencil reference
  34522. * @param reference defines the new stencil reference to use
  34523. */
  34524. setStencilFunctionReference(reference: number): void;
  34525. /**
  34526. * Sets the current stencil mask
  34527. * @param mask defines the new stencil mask to use
  34528. */
  34529. setStencilFunctionMask(mask: number): void;
  34530. /**
  34531. * Gets the current stencil operation when stencil fails
  34532. * @returns a number defining stencil operation to use when stencil fails
  34533. */
  34534. getStencilOperationFail(): number;
  34535. /**
  34536. * Gets the current stencil operation when depth fails
  34537. * @returns a number defining stencil operation to use when depth fails
  34538. */
  34539. getStencilOperationDepthFail(): number;
  34540. /**
  34541. * Gets the current stencil operation when stencil passes
  34542. * @returns a number defining stencil operation to use when stencil passes
  34543. */
  34544. getStencilOperationPass(): number;
  34545. /**
  34546. * Sets the stencil operation to use when stencil fails
  34547. * @param operation defines the stencil operation to use when stencil fails
  34548. */
  34549. setStencilOperationFail(operation: number): void;
  34550. /**
  34551. * Sets the stencil operation to use when depth fails
  34552. * @param operation defines the stencil operation to use when depth fails
  34553. */
  34554. setStencilOperationDepthFail(operation: number): void;
  34555. /**
  34556. * Sets the stencil operation to use when stencil passes
  34557. * @param operation defines the stencil operation to use when stencil passes
  34558. */
  34559. setStencilOperationPass(operation: number): void;
  34560. /**
  34561. * Sets a boolean indicating if the dithering state is enabled or disabled
  34562. * @param value defines the dithering state
  34563. */
  34564. setDitheringState(value: boolean): void;
  34565. /**
  34566. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  34567. * @param value defines the rasterizer state
  34568. */
  34569. setRasterizerState(value: boolean): void;
  34570. /**
  34571. * Gets the current depth function
  34572. * @returns a number defining the depth function
  34573. */
  34574. getDepthFunction(): Nullable<number>;
  34575. /**
  34576. * Sets the current depth function
  34577. * @param depthFunc defines the function to use
  34578. */
  34579. setDepthFunction(depthFunc: number): void;
  34580. /**
  34581. * Sets the current depth function to GREATER
  34582. */
  34583. setDepthFunctionToGreater(): void;
  34584. /**
  34585. * Sets the current depth function to GEQUAL
  34586. */
  34587. setDepthFunctionToGreaterOrEqual(): void;
  34588. /**
  34589. * Sets the current depth function to LESS
  34590. */
  34591. setDepthFunctionToLess(): void;
  34592. /**
  34593. * Sets the current depth function to LEQUAL
  34594. */
  34595. setDepthFunctionToLessOrEqual(): void;
  34596. private _cachedStencilBuffer;
  34597. private _cachedStencilFunction;
  34598. private _cachedStencilMask;
  34599. private _cachedStencilOperationPass;
  34600. private _cachedStencilOperationFail;
  34601. private _cachedStencilOperationDepthFail;
  34602. private _cachedStencilReference;
  34603. /**
  34604. * Caches the the state of the stencil buffer
  34605. */
  34606. cacheStencilState(): void;
  34607. /**
  34608. * Restores the state of the stencil buffer
  34609. */
  34610. restoreStencilState(): void;
  34611. /**
  34612. * Directly set the WebGL Viewport
  34613. * @param x defines the x coordinate of the viewport (in screen space)
  34614. * @param y defines the y coordinate of the viewport (in screen space)
  34615. * @param width defines the width of the viewport (in screen space)
  34616. * @param height defines the height of the viewport (in screen space)
  34617. * @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
  34618. */
  34619. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34620. /**
  34621. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34622. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34623. * @param y defines the y-coordinate of the corner of the clear rectangle
  34624. * @param width defines the width of the clear rectangle
  34625. * @param height defines the height of the clear rectangle
  34626. * @param clearColor defines the clear color
  34627. */
  34628. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34629. /**
  34630. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34631. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34632. * @param y defines the y-coordinate of the corner of the clear rectangle
  34633. * @param width defines the width of the clear rectangle
  34634. * @param height defines the height of the clear rectangle
  34635. */
  34636. enableScissor(x: number, y: number, width: number, height: number): void;
  34637. /**
  34638. * Disable previously set scissor test rectangle
  34639. */
  34640. disableScissor(): void;
  34641. protected _reportDrawCall(): void;
  34642. /**
  34643. * Initializes a webVR display and starts listening to display change events
  34644. * The onVRDisplayChangedObservable will be notified upon these changes
  34645. * @returns The onVRDisplayChangedObservable
  34646. */
  34647. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34648. /** @hidden */
  34649. _prepareVRComponent(): void;
  34650. /** @hidden */
  34651. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34652. /** @hidden */
  34653. _submitVRFrame(): void;
  34654. /**
  34655. * Call this function to leave webVR mode
  34656. * Will do nothing if webVR is not supported or if there is no webVR device
  34657. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34658. */
  34659. disableVR(): void;
  34660. /**
  34661. * Gets a boolean indicating that the system is in VR mode and is presenting
  34662. * @returns true if VR mode is engaged
  34663. */
  34664. isVRPresenting(): boolean;
  34665. /** @hidden */
  34666. _requestVRFrame(): void;
  34667. /** @hidden */
  34668. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34669. /**
  34670. * Gets the source code of the vertex shader associated with a specific webGL program
  34671. * @param program defines the program to use
  34672. * @returns a string containing the source code of the vertex shader associated with the program
  34673. */
  34674. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34675. /**
  34676. * Gets the source code of the fragment shader associated with a specific webGL program
  34677. * @param program defines the program to use
  34678. * @returns a string containing the source code of the fragment shader associated with the program
  34679. */
  34680. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34681. /**
  34682. * Sets a depth stencil texture from a render target to the according uniform.
  34683. * @param channel The texture channel
  34684. * @param uniform The uniform to set
  34685. * @param texture The render target texture containing the depth stencil texture to apply
  34686. */
  34687. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34688. /**
  34689. * Sets a texture to the webGL context from a postprocess
  34690. * @param channel defines the channel to use
  34691. * @param postProcess defines the source postprocess
  34692. */
  34693. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34694. /**
  34695. * Binds the output of the passed in post process to the texture channel specified
  34696. * @param channel The channel the texture should be bound to
  34697. * @param postProcess The post process which's output should be bound
  34698. */
  34699. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34700. /** @hidden */
  34701. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34702. protected _rebuildBuffers(): void;
  34703. /** @hidden */
  34704. _renderFrame(): void;
  34705. _renderLoop(): void;
  34706. /** @hidden */
  34707. _renderViews(): boolean;
  34708. /**
  34709. * Toggle full screen mode
  34710. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34711. */
  34712. switchFullscreen(requestPointerLock: boolean): void;
  34713. /**
  34714. * Enters full screen mode
  34715. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34716. */
  34717. enterFullscreen(requestPointerLock: boolean): void;
  34718. /**
  34719. * Exits full screen mode
  34720. */
  34721. exitFullscreen(): void;
  34722. /**
  34723. * Enters Pointerlock mode
  34724. */
  34725. enterPointerlock(): void;
  34726. /**
  34727. * Exits Pointerlock mode
  34728. */
  34729. exitPointerlock(): void;
  34730. /**
  34731. * Begin a new frame
  34732. */
  34733. beginFrame(): void;
  34734. /**
  34735. * Enf the current frame
  34736. */
  34737. endFrame(): void;
  34738. resize(): void;
  34739. /**
  34740. * Set the compressed texture format to use, based on the formats you have, and the formats
  34741. * supported by the hardware / browser.
  34742. *
  34743. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  34744. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  34745. * to API arguments needed to compressed textures. This puts the burden on the container
  34746. * generator to house the arcane code for determining these for current & future formats.
  34747. *
  34748. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  34749. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  34750. *
  34751. * Note: The result of this call is not taken into account when a texture is base64.
  34752. *
  34753. * @param formatsAvailable defines the list of those format families you have created
  34754. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  34755. *
  34756. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  34757. * @returns The extension selected.
  34758. */
  34759. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  34760. /**
  34761. * Set the compressed texture extensions or file names to skip.
  34762. *
  34763. * @param skippedFiles defines the list of those texture files you want to skip
  34764. * Example: [".dds", ".env", "myfile.png"]
  34765. */
  34766. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  34767. /**
  34768. * Force a specific size of the canvas
  34769. * @param width defines the new canvas' width
  34770. * @param height defines the new canvas' height
  34771. */
  34772. setSize(width: number, height: number): void;
  34773. /**
  34774. * Updates a dynamic vertex buffer.
  34775. * @param vertexBuffer the vertex buffer to update
  34776. * @param data the data used to update the vertex buffer
  34777. * @param byteOffset the byte offset of the data
  34778. * @param byteLength the byte length of the data
  34779. */
  34780. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34781. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34782. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34783. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34784. _releaseTexture(texture: InternalTexture): void;
  34785. /**
  34786. * @hidden
  34787. * Rescales a texture
  34788. * @param source input texutre
  34789. * @param destination destination texture
  34790. * @param scene scene to use to render the resize
  34791. * @param internalFormat format to use when resizing
  34792. * @param onComplete callback to be called when resize has completed
  34793. */
  34794. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34795. /**
  34796. * Gets the current framerate
  34797. * @returns a number representing the framerate
  34798. */
  34799. getFps(): number;
  34800. /**
  34801. * Gets the time spent between current and previous frame
  34802. * @returns a number representing the delta time in ms
  34803. */
  34804. getDeltaTime(): number;
  34805. private _measureFps;
  34806. /** @hidden */
  34807. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34808. /**
  34809. * Update a dynamic index buffer
  34810. * @param indexBuffer defines the target index buffer
  34811. * @param indices defines the data to update
  34812. * @param offset defines the offset in the target index buffer where update should start
  34813. */
  34814. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34815. /**
  34816. * Updates the sample count of a render target texture
  34817. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34818. * @param texture defines the texture to update
  34819. * @param samples defines the sample count to set
  34820. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34821. */
  34822. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34823. /**
  34824. * Updates a depth texture Comparison Mode and Function.
  34825. * If the comparison Function is equal to 0, the mode will be set to none.
  34826. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34827. * @param texture The texture to set the comparison function for
  34828. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34829. */
  34830. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34831. /**
  34832. * Creates a webGL buffer to use with instanciation
  34833. * @param capacity defines the size of the buffer
  34834. * @returns the webGL buffer
  34835. */
  34836. createInstancesBuffer(capacity: number): DataBuffer;
  34837. /**
  34838. * Delete a webGL buffer used with instanciation
  34839. * @param buffer defines the webGL buffer to delete
  34840. */
  34841. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34842. private _clientWaitAsync;
  34843. /** @hidden */
  34844. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  34845. /** @hidden */
  34846. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34847. dispose(): void;
  34848. private _disableTouchAction;
  34849. /**
  34850. * Display the loading screen
  34851. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34852. */
  34853. displayLoadingUI(): void;
  34854. /**
  34855. * Hide the loading screen
  34856. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34857. */
  34858. hideLoadingUI(): void;
  34859. /**
  34860. * Gets the current loading screen object
  34861. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34862. */
  34863. get loadingScreen(): ILoadingScreen;
  34864. /**
  34865. * Sets the current loading screen object
  34866. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34867. */
  34868. set loadingScreen(loadingScreen: ILoadingScreen);
  34869. /**
  34870. * Sets the current loading screen text
  34871. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34872. */
  34873. set loadingUIText(text: string);
  34874. /**
  34875. * Sets the current loading screen background color
  34876. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34877. */
  34878. set loadingUIBackgroundColor(color: string);
  34879. /** Pointerlock and fullscreen */
  34880. /**
  34881. * Ask the browser to promote the current element to pointerlock mode
  34882. * @param element defines the DOM element to promote
  34883. */
  34884. static _RequestPointerlock(element: HTMLElement): void;
  34885. /**
  34886. * Asks the browser to exit pointerlock mode
  34887. */
  34888. static _ExitPointerlock(): void;
  34889. /**
  34890. * Ask the browser to promote the current element to fullscreen rendering mode
  34891. * @param element defines the DOM element to promote
  34892. */
  34893. static _RequestFullscreen(element: HTMLElement): void;
  34894. /**
  34895. * Asks the browser to exit fullscreen mode
  34896. */
  34897. static _ExitFullscreen(): void;
  34898. }
  34899. }
  34900. declare module "babylonjs/Engines/engineStore" {
  34901. import { Nullable } from "babylonjs/types";
  34902. import { Engine } from "babylonjs/Engines/engine";
  34903. import { Scene } from "babylonjs/scene";
  34904. /**
  34905. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34906. * during the life time of the application.
  34907. */
  34908. export class EngineStore {
  34909. /** Gets the list of created engines */
  34910. static Instances: import("babylonjs/Engines/engine").Engine[];
  34911. /** @hidden */
  34912. static _LastCreatedScene: Nullable<Scene>;
  34913. /**
  34914. * Gets the latest created engine
  34915. */
  34916. static get LastCreatedEngine(): Nullable<Engine>;
  34917. /**
  34918. * Gets the latest created scene
  34919. */
  34920. static get LastCreatedScene(): Nullable<Scene>;
  34921. /**
  34922. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34923. * @ignorenaming
  34924. */
  34925. static UseFallbackTexture: boolean;
  34926. /**
  34927. * Texture content used if a texture cannot loaded
  34928. * @ignorenaming
  34929. */
  34930. static FallbackTexture: string;
  34931. }
  34932. }
  34933. declare module "babylonjs/Misc/promise" {
  34934. /**
  34935. * Helper class that provides a small promise polyfill
  34936. */
  34937. export class PromisePolyfill {
  34938. /**
  34939. * Static function used to check if the polyfill is required
  34940. * If this is the case then the function will inject the polyfill to window.Promise
  34941. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34942. */
  34943. static Apply(force?: boolean): void;
  34944. }
  34945. }
  34946. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  34947. /**
  34948. * Interface for screenshot methods with describe argument called `size` as object with options
  34949. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34950. */
  34951. export interface IScreenshotSize {
  34952. /**
  34953. * number in pixels for canvas height
  34954. */
  34955. height?: number;
  34956. /**
  34957. * multiplier allowing render at a higher or lower resolution
  34958. * If value is defined then height and width will be ignored and taken from camera
  34959. */
  34960. precision?: number;
  34961. /**
  34962. * number in pixels for canvas width
  34963. */
  34964. width?: number;
  34965. }
  34966. }
  34967. declare module "babylonjs/Misc/tools" {
  34968. import { Nullable, float } from "babylonjs/types";
  34969. import { DomManagement } from "babylonjs/Misc/domManagement";
  34970. import { WebRequest } from "babylonjs/Misc/webRequest";
  34971. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34972. import { ReadFileError } from "babylonjs/Misc/fileTools";
  34973. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34974. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  34975. import { Camera } from "babylonjs/Cameras/camera";
  34976. import { Engine } from "babylonjs/Engines/engine";
  34977. interface IColor4Like {
  34978. r: float;
  34979. g: float;
  34980. b: float;
  34981. a: float;
  34982. }
  34983. /**
  34984. * Class containing a set of static utilities functions
  34985. */
  34986. export class Tools {
  34987. /**
  34988. * Gets or sets the base URL to use to load assets
  34989. */
  34990. static get BaseUrl(): string;
  34991. static set BaseUrl(value: string);
  34992. /**
  34993. * Enable/Disable Custom HTTP Request Headers globally.
  34994. * default = false
  34995. * @see CustomRequestHeaders
  34996. */
  34997. static UseCustomRequestHeaders: boolean;
  34998. /**
  34999. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  35000. * i.e. when loading files, where the server/service expects an Authorization header
  35001. */
  35002. static CustomRequestHeaders: {
  35003. [key: string]: string;
  35004. };
  35005. /**
  35006. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  35007. */
  35008. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  35009. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  35010. /**
  35011. * Default behaviour for cors in the application.
  35012. * It can be a string if the expected behavior is identical in the entire app.
  35013. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  35014. */
  35015. static CorsBehavior: string | ((url: string | string[]) => string);
  35016. /**
  35017. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  35018. * @ignorenaming
  35019. */
  35020. static get UseFallbackTexture(): boolean;
  35021. static set UseFallbackTexture(value: boolean);
  35022. /**
  35023. * Use this object to register external classes like custom textures or material
  35024. * to allow the laoders to instantiate them
  35025. */
  35026. static get RegisteredExternalClasses(): {
  35027. [key: string]: Object;
  35028. };
  35029. static set RegisteredExternalClasses(classes: {
  35030. [key: string]: Object;
  35031. });
  35032. /**
  35033. * Texture content used if a texture cannot loaded
  35034. * @ignorenaming
  35035. */
  35036. static get fallbackTexture(): string;
  35037. static set fallbackTexture(value: string);
  35038. /**
  35039. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  35040. * @param u defines the coordinate on X axis
  35041. * @param v defines the coordinate on Y axis
  35042. * @param width defines the width of the source data
  35043. * @param height defines the height of the source data
  35044. * @param pixels defines the source byte array
  35045. * @param color defines the output color
  35046. */
  35047. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  35048. /**
  35049. * Interpolates between a and b via alpha
  35050. * @param a The lower value (returned when alpha = 0)
  35051. * @param b The upper value (returned when alpha = 1)
  35052. * @param alpha The interpolation-factor
  35053. * @return The mixed value
  35054. */
  35055. static Mix(a: number, b: number, alpha: number): number;
  35056. /**
  35057. * Tries to instantiate a new object from a given class name
  35058. * @param className defines the class name to instantiate
  35059. * @returns the new object or null if the system was not able to do the instantiation
  35060. */
  35061. static Instantiate(className: string): any;
  35062. /**
  35063. * Provides a slice function that will work even on IE
  35064. * @param data defines the array to slice
  35065. * @param start defines the start of the data (optional)
  35066. * @param end defines the end of the data (optional)
  35067. * @returns the new sliced array
  35068. */
  35069. static Slice<T>(data: T, start?: number, end?: number): T;
  35070. /**
  35071. * Polyfill for setImmediate
  35072. * @param action defines the action to execute after the current execution block
  35073. */
  35074. static SetImmediate(action: () => void): void;
  35075. /**
  35076. * Function indicating if a number is an exponent of 2
  35077. * @param value defines the value to test
  35078. * @returns true if the value is an exponent of 2
  35079. */
  35080. static IsExponentOfTwo(value: number): boolean;
  35081. private static _tmpFloatArray;
  35082. /**
  35083. * Returns the nearest 32-bit single precision float representation of a Number
  35084. * @param value A Number. If the parameter is of a different type, it will get converted
  35085. * to a number or to NaN if it cannot be converted
  35086. * @returns number
  35087. */
  35088. static FloatRound(value: number): number;
  35089. /**
  35090. * Extracts the filename from a path
  35091. * @param path defines the path to use
  35092. * @returns the filename
  35093. */
  35094. static GetFilename(path: string): string;
  35095. /**
  35096. * Extracts the "folder" part of a path (everything before the filename).
  35097. * @param uri The URI to extract the info from
  35098. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  35099. * @returns The "folder" part of the path
  35100. */
  35101. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  35102. /**
  35103. * Extracts text content from a DOM element hierarchy
  35104. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  35105. */
  35106. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  35107. /**
  35108. * Convert an angle in radians to degrees
  35109. * @param angle defines the angle to convert
  35110. * @returns the angle in degrees
  35111. */
  35112. static ToDegrees(angle: number): number;
  35113. /**
  35114. * Convert an angle in degrees to radians
  35115. * @param angle defines the angle to convert
  35116. * @returns the angle in radians
  35117. */
  35118. static ToRadians(angle: number): number;
  35119. /**
  35120. * Returns an array if obj is not an array
  35121. * @param obj defines the object to evaluate as an array
  35122. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  35123. * @returns either obj directly if obj is an array or a new array containing obj
  35124. */
  35125. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  35126. /**
  35127. * Gets the pointer prefix to use
  35128. * @returns "pointer" if touch is enabled. Else returns "mouse"
  35129. */
  35130. static GetPointerPrefix(): string;
  35131. /**
  35132. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  35133. * @param url define the url we are trying
  35134. * @param element define the dom element where to configure the cors policy
  35135. */
  35136. static SetCorsBehavior(url: string | string[], element: {
  35137. crossOrigin: string | null;
  35138. }): void;
  35139. /**
  35140. * Removes unwanted characters from an url
  35141. * @param url defines the url to clean
  35142. * @returns the cleaned url
  35143. */
  35144. static CleanUrl(url: string): string;
  35145. /**
  35146. * Gets or sets a function used to pre-process url before using them to load assets
  35147. */
  35148. static get PreprocessUrl(): (url: string) => string;
  35149. static set PreprocessUrl(processor: (url: string) => string);
  35150. /**
  35151. * Loads an image as an HTMLImageElement.
  35152. * @param input url string, ArrayBuffer, or Blob to load
  35153. * @param onLoad callback called when the image successfully loads
  35154. * @param onError callback called when the image fails to load
  35155. * @param offlineProvider offline provider for caching
  35156. * @param mimeType optional mime type
  35157. * @returns the HTMLImageElement of the loaded image
  35158. */
  35159. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  35160. /**
  35161. * Loads a file from a url
  35162. * @param url url string, ArrayBuffer, or Blob to load
  35163. * @param onSuccess callback called when the file successfully loads
  35164. * @param onProgress callback called while file is loading (if the server supports this mode)
  35165. * @param offlineProvider defines the offline provider for caching
  35166. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35167. * @param onError callback called when the file fails to load
  35168. * @returns a file request object
  35169. */
  35170. 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;
  35171. /**
  35172. * Loads a file from a url
  35173. * @param url the file url to load
  35174. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35175. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  35176. */
  35177. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  35178. /**
  35179. * Load a script (identified by an url). When the url returns, the
  35180. * content of this file is added into a new script element, attached to the DOM (body element)
  35181. * @param scriptUrl defines the url of the script to laod
  35182. * @param onSuccess defines the callback called when the script is loaded
  35183. * @param onError defines the callback to call if an error occurs
  35184. * @param scriptId defines the id of the script element
  35185. */
  35186. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  35187. /**
  35188. * Load an asynchronous script (identified by an url). When the url returns, the
  35189. * content of this file is added into a new script element, attached to the DOM (body element)
  35190. * @param scriptUrl defines the url of the script to laod
  35191. * @param scriptId defines the id of the script element
  35192. * @returns a promise request object
  35193. */
  35194. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  35195. /**
  35196. * Loads a file from a blob
  35197. * @param fileToLoad defines the blob to use
  35198. * @param callback defines the callback to call when data is loaded
  35199. * @param progressCallback defines the callback to call during loading process
  35200. * @returns a file request object
  35201. */
  35202. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  35203. /**
  35204. * Reads a file from a File object
  35205. * @param file defines the file to load
  35206. * @param onSuccess defines the callback to call when data is loaded
  35207. * @param onProgress defines the callback to call during loading process
  35208. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  35209. * @param onError defines the callback to call when an error occurs
  35210. * @returns a file request object
  35211. */
  35212. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  35213. /**
  35214. * Creates a data url from a given string content
  35215. * @param content defines the content to convert
  35216. * @returns the new data url link
  35217. */
  35218. static FileAsURL(content: string): string;
  35219. /**
  35220. * Format the given number to a specific decimal format
  35221. * @param value defines the number to format
  35222. * @param decimals defines the number of decimals to use
  35223. * @returns the formatted string
  35224. */
  35225. static Format(value: number, decimals?: number): string;
  35226. /**
  35227. * Tries to copy an object by duplicating every property
  35228. * @param source defines the source object
  35229. * @param destination defines the target object
  35230. * @param doNotCopyList defines a list of properties to avoid
  35231. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  35232. */
  35233. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  35234. /**
  35235. * Gets a boolean indicating if the given object has no own property
  35236. * @param obj defines the object to test
  35237. * @returns true if object has no own property
  35238. */
  35239. static IsEmpty(obj: any): boolean;
  35240. /**
  35241. * Function used to register events at window level
  35242. * @param windowElement defines the Window object to use
  35243. * @param events defines the events to register
  35244. */
  35245. static RegisterTopRootEvents(windowElement: Window, events: {
  35246. name: string;
  35247. handler: Nullable<(e: FocusEvent) => any>;
  35248. }[]): void;
  35249. /**
  35250. * Function used to unregister events from window level
  35251. * @param windowElement defines the Window object to use
  35252. * @param events defines the events to unregister
  35253. */
  35254. static UnregisterTopRootEvents(windowElement: Window, events: {
  35255. name: string;
  35256. handler: Nullable<(e: FocusEvent) => any>;
  35257. }[]): void;
  35258. /**
  35259. * @ignore
  35260. */
  35261. static _ScreenshotCanvas: HTMLCanvasElement;
  35262. /**
  35263. * Dumps the current bound framebuffer
  35264. * @param width defines the rendering width
  35265. * @param height defines the rendering height
  35266. * @param engine defines the hosting engine
  35267. * @param successCallback defines the callback triggered once the data are available
  35268. * @param mimeType defines the mime type of the result
  35269. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  35270. */
  35271. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35272. /**
  35273. * Converts the canvas data to blob.
  35274. * This acts as a polyfill for browsers not supporting the to blob function.
  35275. * @param canvas Defines the canvas to extract the data from
  35276. * @param successCallback Defines the callback triggered once the data are available
  35277. * @param mimeType Defines the mime type of the result
  35278. */
  35279. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  35280. /**
  35281. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  35282. * @param successCallback defines the callback triggered once the data are available
  35283. * @param mimeType defines the mime type of the result
  35284. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  35285. */
  35286. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35287. /**
  35288. * Downloads a blob in the browser
  35289. * @param blob defines the blob to download
  35290. * @param fileName defines the name of the downloaded file
  35291. */
  35292. static Download(blob: Blob, fileName: string): void;
  35293. /**
  35294. * Captures a screenshot of the current rendering
  35295. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35296. * @param engine defines the rendering engine
  35297. * @param camera defines the source camera
  35298. * @param size This parameter can be set to a single number or to an object with the
  35299. * following (optional) properties: precision, width, height. If a single number is passed,
  35300. * it will be used for both width and height. If an object is passed, the screenshot size
  35301. * will be derived from the parameters. The precision property is a multiplier allowing
  35302. * rendering at a higher or lower resolution
  35303. * @param successCallback defines the callback receives a single parameter which contains the
  35304. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35305. * src parameter of an <img> to display it
  35306. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35307. * Check your browser for supported MIME types
  35308. */
  35309. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  35310. /**
  35311. * Captures a screenshot of the current rendering
  35312. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35313. * @param engine defines the rendering engine
  35314. * @param camera defines the source camera
  35315. * @param size This parameter can be set to a single number or to an object with the
  35316. * following (optional) properties: precision, width, height. If a single number is passed,
  35317. * it will be used for both width and height. If an object is passed, the screenshot size
  35318. * will be derived from the parameters. The precision property is a multiplier allowing
  35319. * rendering at a higher or lower resolution
  35320. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35321. * Check your browser for supported MIME types
  35322. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35323. * to the src parameter of an <img> to display it
  35324. */
  35325. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  35326. /**
  35327. * Generates an image screenshot from the specified camera.
  35328. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35329. * @param engine The engine to use for rendering
  35330. * @param camera The camera to use for rendering
  35331. * @param size This parameter can be set to a single number or to an object with the
  35332. * following (optional) properties: precision, width, height. If a single number is passed,
  35333. * it will be used for both width and height. If an object is passed, the screenshot size
  35334. * will be derived from the parameters. The precision property is a multiplier allowing
  35335. * rendering at a higher or lower resolution
  35336. * @param successCallback The callback receives a single parameter which contains the
  35337. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35338. * src parameter of an <img> to display it
  35339. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35340. * Check your browser for supported MIME types
  35341. * @param samples Texture samples (default: 1)
  35342. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35343. * @param fileName A name for for the downloaded file.
  35344. */
  35345. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  35346. /**
  35347. * Generates an image screenshot from the specified camera.
  35348. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35349. * @param engine The engine to use for rendering
  35350. * @param camera The camera to use for rendering
  35351. * @param size This parameter can be set to a single number or to an object with the
  35352. * following (optional) properties: precision, width, height. If a single number is passed,
  35353. * it will be used for both width and height. If an object is passed, the screenshot size
  35354. * will be derived from the parameters. The precision property is a multiplier allowing
  35355. * rendering at a higher or lower resolution
  35356. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35357. * Check your browser for supported MIME types
  35358. * @param samples Texture samples (default: 1)
  35359. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35360. * @param fileName A name for for the downloaded file.
  35361. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35362. * to the src parameter of an <img> to display it
  35363. */
  35364. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  35365. /**
  35366. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  35367. * Be aware Math.random() could cause collisions, but:
  35368. * "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"
  35369. * @returns a pseudo random id
  35370. */
  35371. static RandomId(): string;
  35372. /**
  35373. * Test if the given uri is a base64 string
  35374. * @param uri The uri to test
  35375. * @return True if the uri is a base64 string or false otherwise
  35376. */
  35377. static IsBase64(uri: string): boolean;
  35378. /**
  35379. * Decode the given base64 uri.
  35380. * @param uri The uri to decode
  35381. * @return The decoded base64 data.
  35382. */
  35383. static DecodeBase64(uri: string): ArrayBuffer;
  35384. /**
  35385. * Gets the absolute url.
  35386. * @param url the input url
  35387. * @return the absolute url
  35388. */
  35389. static GetAbsoluteUrl(url: string): string;
  35390. /**
  35391. * No log
  35392. */
  35393. static readonly NoneLogLevel: number;
  35394. /**
  35395. * Only message logs
  35396. */
  35397. static readonly MessageLogLevel: number;
  35398. /**
  35399. * Only warning logs
  35400. */
  35401. static readonly WarningLogLevel: number;
  35402. /**
  35403. * Only error logs
  35404. */
  35405. static readonly ErrorLogLevel: number;
  35406. /**
  35407. * All logs
  35408. */
  35409. static readonly AllLogLevel: number;
  35410. /**
  35411. * Gets a value indicating the number of loading errors
  35412. * @ignorenaming
  35413. */
  35414. static get errorsCount(): number;
  35415. /**
  35416. * Callback called when a new log is added
  35417. */
  35418. static OnNewCacheEntry: (entry: string) => void;
  35419. /**
  35420. * Log a message to the console
  35421. * @param message defines the message to log
  35422. */
  35423. static Log(message: string): void;
  35424. /**
  35425. * Write a warning message to the console
  35426. * @param message defines the message to log
  35427. */
  35428. static Warn(message: string): void;
  35429. /**
  35430. * Write an error message to the console
  35431. * @param message defines the message to log
  35432. */
  35433. static Error(message: string): void;
  35434. /**
  35435. * Gets current log cache (list of logs)
  35436. */
  35437. static get LogCache(): string;
  35438. /**
  35439. * Clears the log cache
  35440. */
  35441. static ClearLogCache(): void;
  35442. /**
  35443. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  35444. */
  35445. static set LogLevels(level: number);
  35446. /**
  35447. * Checks if the window object exists
  35448. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  35449. */
  35450. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  35451. /**
  35452. * No performance log
  35453. */
  35454. static readonly PerformanceNoneLogLevel: number;
  35455. /**
  35456. * Use user marks to log performance
  35457. */
  35458. static readonly PerformanceUserMarkLogLevel: number;
  35459. /**
  35460. * Log performance to the console
  35461. */
  35462. static readonly PerformanceConsoleLogLevel: number;
  35463. private static _performance;
  35464. /**
  35465. * Sets the current performance log level
  35466. */
  35467. static set PerformanceLogLevel(level: number);
  35468. private static _StartPerformanceCounterDisabled;
  35469. private static _EndPerformanceCounterDisabled;
  35470. private static _StartUserMark;
  35471. private static _EndUserMark;
  35472. private static _StartPerformanceConsole;
  35473. private static _EndPerformanceConsole;
  35474. /**
  35475. * Starts a performance counter
  35476. */
  35477. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35478. /**
  35479. * Ends a specific performance coutner
  35480. */
  35481. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35482. /**
  35483. * Gets either window.performance.now() if supported or Date.now() else
  35484. */
  35485. static get Now(): number;
  35486. /**
  35487. * This method will return the name of the class used to create the instance of the given object.
  35488. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  35489. * @param object the object to get the class name from
  35490. * @param isType defines if the object is actually a type
  35491. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  35492. */
  35493. static GetClassName(object: any, isType?: boolean): string;
  35494. /**
  35495. * Gets the first element of an array satisfying a given predicate
  35496. * @param array defines the array to browse
  35497. * @param predicate defines the predicate to use
  35498. * @returns null if not found or the element
  35499. */
  35500. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  35501. /**
  35502. * This method will return the name of the full name of the class, including its owning module (if any).
  35503. * 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).
  35504. * @param object the object to get the class name from
  35505. * @param isType defines if the object is actually a type
  35506. * @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.
  35507. * @ignorenaming
  35508. */
  35509. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  35510. /**
  35511. * Returns a promise that resolves after the given amount of time.
  35512. * @param delay Number of milliseconds to delay
  35513. * @returns Promise that resolves after the given amount of time
  35514. */
  35515. static DelayAsync(delay: number): Promise<void>;
  35516. /**
  35517. * Utility function to detect if the current user agent is Safari
  35518. * @returns whether or not the current user agent is safari
  35519. */
  35520. static IsSafari(): boolean;
  35521. }
  35522. /**
  35523. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  35524. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  35525. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  35526. * @param name The name of the class, case should be preserved
  35527. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  35528. */
  35529. export function className(name: string, module?: string): (target: Object) => void;
  35530. /**
  35531. * An implementation of a loop for asynchronous functions.
  35532. */
  35533. export class AsyncLoop {
  35534. /**
  35535. * Defines the number of iterations for the loop
  35536. */
  35537. iterations: number;
  35538. /**
  35539. * Defines the current index of the loop.
  35540. */
  35541. index: number;
  35542. private _done;
  35543. private _fn;
  35544. private _successCallback;
  35545. /**
  35546. * Constructor.
  35547. * @param iterations the number of iterations.
  35548. * @param func the function to run each iteration
  35549. * @param successCallback the callback that will be called upon succesful execution
  35550. * @param offset starting offset.
  35551. */
  35552. constructor(
  35553. /**
  35554. * Defines the number of iterations for the loop
  35555. */
  35556. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35557. /**
  35558. * Execute the next iteration. Must be called after the last iteration was finished.
  35559. */
  35560. executeNext(): void;
  35561. /**
  35562. * Break the loop and run the success callback.
  35563. */
  35564. breakLoop(): void;
  35565. /**
  35566. * Create and run an async loop.
  35567. * @param iterations the number of iterations.
  35568. * @param fn the function to run each iteration
  35569. * @param successCallback the callback that will be called upon succesful execution
  35570. * @param offset starting offset.
  35571. * @returns the created async loop object
  35572. */
  35573. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35574. /**
  35575. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35576. * @param iterations total number of iterations
  35577. * @param syncedIterations number of synchronous iterations in each async iteration.
  35578. * @param fn the function to call each iteration.
  35579. * @param callback a success call back that will be called when iterating stops.
  35580. * @param breakFunction a break condition (optional)
  35581. * @param timeout timeout settings for the setTimeout function. default - 0.
  35582. * @returns the created async loop object
  35583. */
  35584. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35585. }
  35586. }
  35587. declare module "babylonjs/Misc/stringDictionary" {
  35588. import { Nullable } from "babylonjs/types";
  35589. /**
  35590. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35591. * The underlying implementation relies on an associative array to ensure the best performances.
  35592. * The value can be anything including 'null' but except 'undefined'
  35593. */
  35594. export class StringDictionary<T> {
  35595. /**
  35596. * This will clear this dictionary and copy the content from the 'source' one.
  35597. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35598. * @param source the dictionary to take the content from and copy to this dictionary
  35599. */
  35600. copyFrom(source: StringDictionary<T>): void;
  35601. /**
  35602. * Get a value based from its key
  35603. * @param key the given key to get the matching value from
  35604. * @return the value if found, otherwise undefined is returned
  35605. */
  35606. get(key: string): T | undefined;
  35607. /**
  35608. * Get a value from its key or add it if it doesn't exist.
  35609. * This method will ensure you that a given key/data will be present in the dictionary.
  35610. * @param key the given key to get the matching value from
  35611. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35612. * The factory will only be invoked if there's no data for the given key.
  35613. * @return the value corresponding to the key.
  35614. */
  35615. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35616. /**
  35617. * Get a value from its key if present in the dictionary otherwise add it
  35618. * @param key the key to get the value from
  35619. * @param val if there's no such key/value pair in the dictionary add it with this value
  35620. * @return the value corresponding to the key
  35621. */
  35622. getOrAdd(key: string, val: T): T;
  35623. /**
  35624. * Check if there's a given key in the dictionary
  35625. * @param key the key to check for
  35626. * @return true if the key is present, false otherwise
  35627. */
  35628. contains(key: string): boolean;
  35629. /**
  35630. * Add a new key and its corresponding value
  35631. * @param key the key to add
  35632. * @param value the value corresponding to the key
  35633. * @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
  35634. */
  35635. add(key: string, value: T): boolean;
  35636. /**
  35637. * Update a specific value associated to a key
  35638. * @param key defines the key to use
  35639. * @param value defines the value to store
  35640. * @returns true if the value was updated (or false if the key was not found)
  35641. */
  35642. set(key: string, value: T): boolean;
  35643. /**
  35644. * Get the element of the given key and remove it from the dictionary
  35645. * @param key defines the key to search
  35646. * @returns the value associated with the key or null if not found
  35647. */
  35648. getAndRemove(key: string): Nullable<T>;
  35649. /**
  35650. * Remove a key/value from the dictionary.
  35651. * @param key the key to remove
  35652. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35653. */
  35654. remove(key: string): boolean;
  35655. /**
  35656. * Clear the whole content of the dictionary
  35657. */
  35658. clear(): void;
  35659. /**
  35660. * Gets the current count
  35661. */
  35662. get count(): number;
  35663. /**
  35664. * Execute a callback on each key/val of the dictionary.
  35665. * Note that you can remove any element in this dictionary in the callback implementation
  35666. * @param callback the callback to execute on a given key/value pair
  35667. */
  35668. forEach(callback: (key: string, val: T) => void): void;
  35669. /**
  35670. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35671. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35672. * Note that you can remove any element in this dictionary in the callback implementation
  35673. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35674. * @returns the first item
  35675. */
  35676. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35677. private _count;
  35678. private _data;
  35679. }
  35680. }
  35681. declare module "babylonjs/Collisions/collisionCoordinator" {
  35682. import { Nullable } from "babylonjs/types";
  35683. import { Scene } from "babylonjs/scene";
  35684. import { Vector3 } from "babylonjs/Maths/math.vector";
  35685. import { Collider } from "babylonjs/Collisions/collider";
  35686. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35687. /** @hidden */
  35688. export interface ICollisionCoordinator {
  35689. createCollider(): Collider;
  35690. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35691. init(scene: Scene): void;
  35692. }
  35693. /** @hidden */
  35694. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35695. private _scene;
  35696. private _scaledPosition;
  35697. private _scaledVelocity;
  35698. private _finalPosition;
  35699. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35700. createCollider(): Collider;
  35701. init(scene: Scene): void;
  35702. private _collideWithWorld;
  35703. }
  35704. }
  35705. declare module "babylonjs/Inputs/scene.inputManager" {
  35706. import { Nullable } from "babylonjs/types";
  35707. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35708. import { Vector2 } from "babylonjs/Maths/math.vector";
  35709. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35710. import { Scene } from "babylonjs/scene";
  35711. /**
  35712. * Class used to manage all inputs for the scene.
  35713. */
  35714. export class InputManager {
  35715. /** The distance in pixel that you have to move to prevent some events */
  35716. static DragMovementThreshold: number;
  35717. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35718. static LongPressDelay: number;
  35719. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35720. static DoubleClickDelay: number;
  35721. /** If you need to check double click without raising a single click at first click, enable this flag */
  35722. static ExclusiveDoubleClickMode: boolean;
  35723. private _wheelEventName;
  35724. private _onPointerMove;
  35725. private _onPointerDown;
  35726. private _onPointerUp;
  35727. private _initClickEvent;
  35728. private _initActionManager;
  35729. private _delayedSimpleClick;
  35730. private _delayedSimpleClickTimeout;
  35731. private _previousDelayedSimpleClickTimeout;
  35732. private _meshPickProceed;
  35733. private _previousButtonPressed;
  35734. private _currentPickResult;
  35735. private _previousPickResult;
  35736. private _totalPointersPressed;
  35737. private _doubleClickOccured;
  35738. private _pointerOverMesh;
  35739. private _pickedDownMesh;
  35740. private _pickedUpMesh;
  35741. private _pointerX;
  35742. private _pointerY;
  35743. private _unTranslatedPointerX;
  35744. private _unTranslatedPointerY;
  35745. private _startingPointerPosition;
  35746. private _previousStartingPointerPosition;
  35747. private _startingPointerTime;
  35748. private _previousStartingPointerTime;
  35749. private _pointerCaptures;
  35750. private _onKeyDown;
  35751. private _onKeyUp;
  35752. private _onCanvasFocusObserver;
  35753. private _onCanvasBlurObserver;
  35754. private _scene;
  35755. /**
  35756. * Creates a new InputManager
  35757. * @param scene defines the hosting scene
  35758. */
  35759. constructor(scene: Scene);
  35760. /**
  35761. * Gets the mesh that is currently under the pointer
  35762. */
  35763. get meshUnderPointer(): Nullable<AbstractMesh>;
  35764. /**
  35765. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35766. */
  35767. get unTranslatedPointer(): Vector2;
  35768. /**
  35769. * Gets or sets the current on-screen X position of the pointer
  35770. */
  35771. get pointerX(): number;
  35772. set pointerX(value: number);
  35773. /**
  35774. * Gets or sets the current on-screen Y position of the pointer
  35775. */
  35776. get pointerY(): number;
  35777. set pointerY(value: number);
  35778. private _updatePointerPosition;
  35779. private _processPointerMove;
  35780. private _setRayOnPointerInfo;
  35781. private _checkPrePointerObservable;
  35782. /**
  35783. * Use this method to simulate a pointer move on a mesh
  35784. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35785. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35786. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35787. */
  35788. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35789. /**
  35790. * Use this method to simulate a pointer down on a mesh
  35791. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35792. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35793. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35794. */
  35795. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35796. private _processPointerDown;
  35797. /** @hidden */
  35798. _isPointerSwiping(): boolean;
  35799. /**
  35800. * Use this method to simulate a pointer up on a mesh
  35801. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35802. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35803. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35804. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35805. */
  35806. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35807. private _processPointerUp;
  35808. /**
  35809. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35810. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35811. * @returns true if the pointer was captured
  35812. */
  35813. isPointerCaptured(pointerId?: number): boolean;
  35814. /**
  35815. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35816. * @param attachUp defines if you want to attach events to pointerup
  35817. * @param attachDown defines if you want to attach events to pointerdown
  35818. * @param attachMove defines if you want to attach events to pointermove
  35819. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  35820. */
  35821. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  35822. /**
  35823. * Detaches all event handlers
  35824. */
  35825. detachControl(): void;
  35826. /**
  35827. * Force the value of meshUnderPointer
  35828. * @param mesh defines the mesh to use
  35829. */
  35830. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35831. /**
  35832. * Gets the mesh under the pointer
  35833. * @returns a Mesh or null if no mesh is under the pointer
  35834. */
  35835. getPointerOverMesh(): Nullable<AbstractMesh>;
  35836. }
  35837. }
  35838. declare module "babylonjs/Misc/uniqueIdGenerator" {
  35839. /**
  35840. * Helper class used to generate session unique ID
  35841. */
  35842. export class UniqueIdGenerator {
  35843. private static _UniqueIdCounter;
  35844. /**
  35845. * Gets an unique (relatively to the current scene) Id
  35846. */
  35847. static get UniqueId(): number;
  35848. }
  35849. }
  35850. declare module "babylonjs/Animations/animationGroup" {
  35851. import { Animatable } from "babylonjs/Animations/animatable";
  35852. import { Animation } from "babylonjs/Animations/animation";
  35853. import { Scene, IDisposable } from "babylonjs/scene";
  35854. import { Observable } from "babylonjs/Misc/observable";
  35855. import { Nullable } from "babylonjs/types";
  35856. import "babylonjs/Animations/animatable";
  35857. /**
  35858. * This class defines the direct association between an animation and a target
  35859. */
  35860. export class TargetedAnimation {
  35861. /**
  35862. * Animation to perform
  35863. */
  35864. animation: Animation;
  35865. /**
  35866. * Target to animate
  35867. */
  35868. target: any;
  35869. /**
  35870. * Serialize the object
  35871. * @returns the JSON object representing the current entity
  35872. */
  35873. serialize(): any;
  35874. }
  35875. /**
  35876. * Use this class to create coordinated animations on multiple targets
  35877. */
  35878. export class AnimationGroup implements IDisposable {
  35879. /** The name of the animation group */
  35880. name: string;
  35881. private _scene;
  35882. private _targetedAnimations;
  35883. private _animatables;
  35884. private _from;
  35885. private _to;
  35886. private _isStarted;
  35887. private _isPaused;
  35888. private _speedRatio;
  35889. private _loopAnimation;
  35890. /**
  35891. * Gets or sets the unique id of the node
  35892. */
  35893. uniqueId: number;
  35894. /**
  35895. * This observable will notify when one animation have ended
  35896. */
  35897. onAnimationEndObservable: Observable<TargetedAnimation>;
  35898. /**
  35899. * Observer raised when one animation loops
  35900. */
  35901. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35902. /**
  35903. * Observer raised when all animations have looped
  35904. */
  35905. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35906. /**
  35907. * This observable will notify when all animations have ended.
  35908. */
  35909. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35910. /**
  35911. * This observable will notify when all animations have paused.
  35912. */
  35913. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35914. /**
  35915. * This observable will notify when all animations are playing.
  35916. */
  35917. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35918. /**
  35919. * Gets the first frame
  35920. */
  35921. get from(): number;
  35922. /**
  35923. * Gets the last frame
  35924. */
  35925. get to(): number;
  35926. /**
  35927. * Define if the animations are started
  35928. */
  35929. get isStarted(): boolean;
  35930. /**
  35931. * Gets a value indicating that the current group is playing
  35932. */
  35933. get isPlaying(): boolean;
  35934. /**
  35935. * Gets or sets the speed ratio to use for all animations
  35936. */
  35937. get speedRatio(): number;
  35938. /**
  35939. * Gets or sets the speed ratio to use for all animations
  35940. */
  35941. set speedRatio(value: number);
  35942. /**
  35943. * Gets or sets if all animations should loop or not
  35944. */
  35945. get loopAnimation(): boolean;
  35946. set loopAnimation(value: boolean);
  35947. /**
  35948. * Gets the targeted animations for this animation group
  35949. */
  35950. get targetedAnimations(): Array<TargetedAnimation>;
  35951. /**
  35952. * returning the list of animatables controlled by this animation group.
  35953. */
  35954. get animatables(): Array<Animatable>;
  35955. /**
  35956. * Instantiates a new Animation Group.
  35957. * This helps managing several animations at once.
  35958. * @see http://doc.babylonjs.com/how_to/group
  35959. * @param name Defines the name of the group
  35960. * @param scene Defines the scene the group belongs to
  35961. */
  35962. constructor(
  35963. /** The name of the animation group */
  35964. name: string, scene?: Nullable<Scene>);
  35965. /**
  35966. * Add an animation (with its target) in the group
  35967. * @param animation defines the animation we want to add
  35968. * @param target defines the target of the animation
  35969. * @returns the TargetedAnimation object
  35970. */
  35971. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35972. /**
  35973. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35974. * It can add constant keys at begin or end
  35975. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35976. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35977. * @returns the animation group
  35978. */
  35979. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35980. private _animationLoopCount;
  35981. private _animationLoopFlags;
  35982. private _processLoop;
  35983. /**
  35984. * Start all animations on given targets
  35985. * @param loop defines if animations must loop
  35986. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35987. * @param from defines the from key (optional)
  35988. * @param to defines the to key (optional)
  35989. * @returns the current animation group
  35990. */
  35991. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  35992. /**
  35993. * Pause all animations
  35994. * @returns the animation group
  35995. */
  35996. pause(): AnimationGroup;
  35997. /**
  35998. * Play all animations to initial state
  35999. * This function will start() the animations if they were not started or will restart() them if they were paused
  36000. * @param loop defines if animations must loop
  36001. * @returns the animation group
  36002. */
  36003. play(loop?: boolean): AnimationGroup;
  36004. /**
  36005. * Reset all animations to initial state
  36006. * @returns the animation group
  36007. */
  36008. reset(): AnimationGroup;
  36009. /**
  36010. * Restart animations from key 0
  36011. * @returns the animation group
  36012. */
  36013. restart(): AnimationGroup;
  36014. /**
  36015. * Stop all animations
  36016. * @returns the animation group
  36017. */
  36018. stop(): AnimationGroup;
  36019. /**
  36020. * Set animation weight for all animatables
  36021. * @param weight defines the weight to use
  36022. * @return the animationGroup
  36023. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36024. */
  36025. setWeightForAllAnimatables(weight: number): AnimationGroup;
  36026. /**
  36027. * Synchronize and normalize all animatables with a source animatable
  36028. * @param root defines the root animatable to synchronize with
  36029. * @return the animationGroup
  36030. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36031. */
  36032. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  36033. /**
  36034. * Goes to a specific frame in this animation group
  36035. * @param frame the frame number to go to
  36036. * @return the animationGroup
  36037. */
  36038. goToFrame(frame: number): AnimationGroup;
  36039. /**
  36040. * Dispose all associated resources
  36041. */
  36042. dispose(): void;
  36043. private _checkAnimationGroupEnded;
  36044. /**
  36045. * Clone the current animation group and returns a copy
  36046. * @param newName defines the name of the new group
  36047. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  36048. * @returns the new aniamtion group
  36049. */
  36050. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  36051. /**
  36052. * Serializes the animationGroup to an object
  36053. * @returns Serialized object
  36054. */
  36055. serialize(): any;
  36056. /**
  36057. * Returns a new AnimationGroup object parsed from the source provided.
  36058. * @param parsedAnimationGroup defines the source
  36059. * @param scene defines the scene that will receive the animationGroup
  36060. * @returns a new AnimationGroup
  36061. */
  36062. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  36063. /**
  36064. * Returns the string "AnimationGroup"
  36065. * @returns "AnimationGroup"
  36066. */
  36067. getClassName(): string;
  36068. /**
  36069. * Creates a detailled string about the object
  36070. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  36071. * @returns a string representing the object
  36072. */
  36073. toString(fullDetails?: boolean): string;
  36074. }
  36075. }
  36076. declare module "babylonjs/scene" {
  36077. import { Nullable } from "babylonjs/types";
  36078. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  36079. import { Observable } from "babylonjs/Misc/observable";
  36080. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  36081. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  36082. import { Geometry } from "babylonjs/Meshes/geometry";
  36083. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36084. import { SubMesh } from "babylonjs/Meshes/subMesh";
  36085. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36086. import { Mesh } from "babylonjs/Meshes/mesh";
  36087. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36088. import { Bone } from "babylonjs/Bones/bone";
  36089. import { Skeleton } from "babylonjs/Bones/skeleton";
  36090. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  36091. import { Camera } from "babylonjs/Cameras/camera";
  36092. import { AbstractScene } from "babylonjs/abstractScene";
  36093. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36094. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  36095. import { Material } from "babylonjs/Materials/material";
  36096. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  36097. import { Effect } from "babylonjs/Materials/effect";
  36098. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36099. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36100. import { Light } from "babylonjs/Lights/light";
  36101. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36102. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  36103. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  36104. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  36105. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  36106. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  36107. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36108. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  36109. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  36110. import { Engine } from "babylonjs/Engines/engine";
  36111. import { Node } from "babylonjs/node";
  36112. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  36113. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36114. import { WebRequest } from "babylonjs/Misc/webRequest";
  36115. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  36116. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  36117. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36118. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  36119. import { Plane } from "babylonjs/Maths/math.plane";
  36120. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  36121. import { Ray } from "babylonjs/Culling/ray";
  36122. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36123. import { Animation } from "babylonjs/Animations/animation";
  36124. import { Animatable } from "babylonjs/Animations/animatable";
  36125. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36126. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  36127. import { Collider } from "babylonjs/Collisions/collider";
  36128. /**
  36129. * Define an interface for all classes that will hold resources
  36130. */
  36131. export interface IDisposable {
  36132. /**
  36133. * Releases all held resources
  36134. */
  36135. dispose(): void;
  36136. }
  36137. /** Interface defining initialization parameters for Scene class */
  36138. export interface SceneOptions {
  36139. /**
  36140. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  36141. * It will improve performance when the number of geometries becomes important.
  36142. */
  36143. useGeometryUniqueIdsMap?: boolean;
  36144. /**
  36145. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  36146. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36147. */
  36148. useMaterialMeshMap?: boolean;
  36149. /**
  36150. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  36151. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36152. */
  36153. useClonedMeshMap?: boolean;
  36154. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  36155. virtual?: boolean;
  36156. }
  36157. /**
  36158. * Represents a scene to be rendered by the engine.
  36159. * @see http://doc.babylonjs.com/features/scene
  36160. */
  36161. export class Scene extends AbstractScene implements IAnimatable {
  36162. /** The fog is deactivated */
  36163. static readonly FOGMODE_NONE: number;
  36164. /** The fog density is following an exponential function */
  36165. static readonly FOGMODE_EXP: number;
  36166. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  36167. static readonly FOGMODE_EXP2: number;
  36168. /** The fog density is following a linear function. */
  36169. static readonly FOGMODE_LINEAR: number;
  36170. /**
  36171. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  36172. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36173. */
  36174. static MinDeltaTime: number;
  36175. /**
  36176. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  36177. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36178. */
  36179. static MaxDeltaTime: number;
  36180. /**
  36181. * Factory used to create the default material.
  36182. * @param name The name of the material to create
  36183. * @param scene The scene to create the material for
  36184. * @returns The default material
  36185. */
  36186. static DefaultMaterialFactory(scene: Scene): Material;
  36187. /**
  36188. * Factory used to create the a collision coordinator.
  36189. * @returns The collision coordinator
  36190. */
  36191. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  36192. /** @hidden */
  36193. _inputManager: InputManager;
  36194. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  36195. cameraToUseForPointers: Nullable<Camera>;
  36196. /** @hidden */
  36197. readonly _isScene: boolean;
  36198. /** @hidden */
  36199. _blockEntityCollection: boolean;
  36200. /**
  36201. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  36202. */
  36203. autoClear: boolean;
  36204. /**
  36205. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  36206. */
  36207. autoClearDepthAndStencil: boolean;
  36208. /**
  36209. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  36210. */
  36211. clearColor: Color4;
  36212. /**
  36213. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  36214. */
  36215. ambientColor: Color3;
  36216. /**
  36217. * This is use to store the default BRDF lookup for PBR materials in your scene.
  36218. * It should only be one of the following (if not the default embedded one):
  36219. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  36220. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  36221. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  36222. * The material properties need to be setup according to the type of texture in use.
  36223. */
  36224. environmentBRDFTexture: BaseTexture;
  36225. /** @hidden */
  36226. protected _environmentTexture: Nullable<BaseTexture>;
  36227. /**
  36228. * Texture used in all pbr material as the reflection texture.
  36229. * As in the majority of the scene they are the same (exception for multi room and so on),
  36230. * this is easier to reference from here than from all the materials.
  36231. */
  36232. get environmentTexture(): Nullable<BaseTexture>;
  36233. /**
  36234. * Texture used in all pbr material as the reflection texture.
  36235. * As in the majority of the scene they are the same (exception for multi room and so on),
  36236. * this is easier to set here than in all the materials.
  36237. */
  36238. set environmentTexture(value: Nullable<BaseTexture>);
  36239. /** @hidden */
  36240. protected _environmentIntensity: number;
  36241. /**
  36242. * Intensity of the environment in all pbr material.
  36243. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36244. * As in the majority of the scene they are the same (exception for multi room and so on),
  36245. * this is easier to reference from here than from all the materials.
  36246. */
  36247. get environmentIntensity(): number;
  36248. /**
  36249. * Intensity of the environment in all pbr material.
  36250. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36251. * As in the majority of the scene they are the same (exception for multi room and so on),
  36252. * this is easier to set here than in all the materials.
  36253. */
  36254. set environmentIntensity(value: number);
  36255. /** @hidden */
  36256. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36257. /**
  36258. * Default image processing configuration used either in the rendering
  36259. * Forward main pass or through the imageProcessingPostProcess if present.
  36260. * As in the majority of the scene they are the same (exception for multi camera),
  36261. * this is easier to reference from here than from all the materials and post process.
  36262. *
  36263. * No setter as we it is a shared configuration, you can set the values instead.
  36264. */
  36265. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  36266. private _forceWireframe;
  36267. /**
  36268. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  36269. */
  36270. set forceWireframe(value: boolean);
  36271. get forceWireframe(): boolean;
  36272. private _skipFrustumClipping;
  36273. /**
  36274. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  36275. */
  36276. set skipFrustumClipping(value: boolean);
  36277. get skipFrustumClipping(): boolean;
  36278. private _forcePointsCloud;
  36279. /**
  36280. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  36281. */
  36282. set forcePointsCloud(value: boolean);
  36283. get forcePointsCloud(): boolean;
  36284. /**
  36285. * Gets or sets the active clipplane 1
  36286. */
  36287. clipPlane: Nullable<Plane>;
  36288. /**
  36289. * Gets or sets the active clipplane 2
  36290. */
  36291. clipPlane2: Nullable<Plane>;
  36292. /**
  36293. * Gets or sets the active clipplane 3
  36294. */
  36295. clipPlane3: Nullable<Plane>;
  36296. /**
  36297. * Gets or sets the active clipplane 4
  36298. */
  36299. clipPlane4: Nullable<Plane>;
  36300. /**
  36301. * Gets or sets the active clipplane 5
  36302. */
  36303. clipPlane5: Nullable<Plane>;
  36304. /**
  36305. * Gets or sets the active clipplane 6
  36306. */
  36307. clipPlane6: Nullable<Plane>;
  36308. /**
  36309. * Gets or sets a boolean indicating if animations are enabled
  36310. */
  36311. animationsEnabled: boolean;
  36312. private _animationPropertiesOverride;
  36313. /**
  36314. * Gets or sets the animation properties override
  36315. */
  36316. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36317. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36318. /**
  36319. * Gets or sets a boolean indicating if a constant deltatime has to be used
  36320. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  36321. */
  36322. useConstantAnimationDeltaTime: boolean;
  36323. /**
  36324. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  36325. * Please note that it requires to run a ray cast through the scene on every frame
  36326. */
  36327. constantlyUpdateMeshUnderPointer: boolean;
  36328. /**
  36329. * Defines the HTML cursor to use when hovering over interactive elements
  36330. */
  36331. hoverCursor: string;
  36332. /**
  36333. * Defines the HTML default cursor to use (empty by default)
  36334. */
  36335. defaultCursor: string;
  36336. /**
  36337. * Defines whether cursors are handled by the scene.
  36338. */
  36339. doNotHandleCursors: boolean;
  36340. /**
  36341. * This is used to call preventDefault() on pointer down
  36342. * in order to block unwanted artifacts like system double clicks
  36343. */
  36344. preventDefaultOnPointerDown: boolean;
  36345. /**
  36346. * This is used to call preventDefault() on pointer up
  36347. * in order to block unwanted artifacts like system double clicks
  36348. */
  36349. preventDefaultOnPointerUp: boolean;
  36350. /**
  36351. * Gets or sets user defined metadata
  36352. */
  36353. metadata: any;
  36354. /**
  36355. * For internal use only. Please do not use.
  36356. */
  36357. reservedDataStore: any;
  36358. /**
  36359. * Gets the name of the plugin used to load this scene (null by default)
  36360. */
  36361. loadingPluginName: string;
  36362. /**
  36363. * Use this array to add regular expressions used to disable offline support for specific urls
  36364. */
  36365. disableOfflineSupportExceptionRules: RegExp[];
  36366. /**
  36367. * An event triggered when the scene is disposed.
  36368. */
  36369. onDisposeObservable: Observable<Scene>;
  36370. private _onDisposeObserver;
  36371. /** Sets a function to be executed when this scene is disposed. */
  36372. set onDispose(callback: () => void);
  36373. /**
  36374. * An event triggered before rendering the scene (right after animations and physics)
  36375. */
  36376. onBeforeRenderObservable: Observable<Scene>;
  36377. private _onBeforeRenderObserver;
  36378. /** Sets a function to be executed before rendering this scene */
  36379. set beforeRender(callback: Nullable<() => void>);
  36380. /**
  36381. * An event triggered after rendering the scene
  36382. */
  36383. onAfterRenderObservable: Observable<Scene>;
  36384. /**
  36385. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  36386. */
  36387. onAfterRenderCameraObservable: Observable<Camera>;
  36388. private _onAfterRenderObserver;
  36389. /** Sets a function to be executed after rendering this scene */
  36390. set afterRender(callback: Nullable<() => void>);
  36391. /**
  36392. * An event triggered before animating the scene
  36393. */
  36394. onBeforeAnimationsObservable: Observable<Scene>;
  36395. /**
  36396. * An event triggered after animations processing
  36397. */
  36398. onAfterAnimationsObservable: Observable<Scene>;
  36399. /**
  36400. * An event triggered before draw calls are ready to be sent
  36401. */
  36402. onBeforeDrawPhaseObservable: Observable<Scene>;
  36403. /**
  36404. * An event triggered after draw calls have been sent
  36405. */
  36406. onAfterDrawPhaseObservable: Observable<Scene>;
  36407. /**
  36408. * An event triggered when the scene is ready
  36409. */
  36410. onReadyObservable: Observable<Scene>;
  36411. /**
  36412. * An event triggered before rendering a camera
  36413. */
  36414. onBeforeCameraRenderObservable: Observable<Camera>;
  36415. private _onBeforeCameraRenderObserver;
  36416. /** Sets a function to be executed before rendering a camera*/
  36417. set beforeCameraRender(callback: () => void);
  36418. /**
  36419. * An event triggered after rendering a camera
  36420. */
  36421. onAfterCameraRenderObservable: Observable<Camera>;
  36422. private _onAfterCameraRenderObserver;
  36423. /** Sets a function to be executed after rendering a camera*/
  36424. set afterCameraRender(callback: () => void);
  36425. /**
  36426. * An event triggered when active meshes evaluation is about to start
  36427. */
  36428. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  36429. /**
  36430. * An event triggered when active meshes evaluation is done
  36431. */
  36432. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  36433. /**
  36434. * An event triggered when particles rendering is about to start
  36435. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36436. */
  36437. onBeforeParticlesRenderingObservable: Observable<Scene>;
  36438. /**
  36439. * An event triggered when particles rendering is done
  36440. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36441. */
  36442. onAfterParticlesRenderingObservable: Observable<Scene>;
  36443. /**
  36444. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  36445. */
  36446. onDataLoadedObservable: Observable<Scene>;
  36447. /**
  36448. * An event triggered when a camera is created
  36449. */
  36450. onNewCameraAddedObservable: Observable<Camera>;
  36451. /**
  36452. * An event triggered when a camera is removed
  36453. */
  36454. onCameraRemovedObservable: Observable<Camera>;
  36455. /**
  36456. * An event triggered when a light is created
  36457. */
  36458. onNewLightAddedObservable: Observable<Light>;
  36459. /**
  36460. * An event triggered when a light is removed
  36461. */
  36462. onLightRemovedObservable: Observable<Light>;
  36463. /**
  36464. * An event triggered when a geometry is created
  36465. */
  36466. onNewGeometryAddedObservable: Observable<Geometry>;
  36467. /**
  36468. * An event triggered when a geometry is removed
  36469. */
  36470. onGeometryRemovedObservable: Observable<Geometry>;
  36471. /**
  36472. * An event triggered when a transform node is created
  36473. */
  36474. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  36475. /**
  36476. * An event triggered when a transform node is removed
  36477. */
  36478. onTransformNodeRemovedObservable: Observable<TransformNode>;
  36479. /**
  36480. * An event triggered when a mesh is created
  36481. */
  36482. onNewMeshAddedObservable: Observable<AbstractMesh>;
  36483. /**
  36484. * An event triggered when a mesh is removed
  36485. */
  36486. onMeshRemovedObservable: Observable<AbstractMesh>;
  36487. /**
  36488. * An event triggered when a skeleton is created
  36489. */
  36490. onNewSkeletonAddedObservable: Observable<Skeleton>;
  36491. /**
  36492. * An event triggered when a skeleton is removed
  36493. */
  36494. onSkeletonRemovedObservable: Observable<Skeleton>;
  36495. /**
  36496. * An event triggered when a material is created
  36497. */
  36498. onNewMaterialAddedObservable: Observable<Material>;
  36499. /**
  36500. * An event triggered when a material is removed
  36501. */
  36502. onMaterialRemovedObservable: Observable<Material>;
  36503. /**
  36504. * An event triggered when a texture is created
  36505. */
  36506. onNewTextureAddedObservable: Observable<BaseTexture>;
  36507. /**
  36508. * An event triggered when a texture is removed
  36509. */
  36510. onTextureRemovedObservable: Observable<BaseTexture>;
  36511. /**
  36512. * An event triggered when render targets are about to be rendered
  36513. * Can happen multiple times per frame.
  36514. */
  36515. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  36516. /**
  36517. * An event triggered when render targets were rendered.
  36518. * Can happen multiple times per frame.
  36519. */
  36520. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  36521. /**
  36522. * An event triggered before calculating deterministic simulation step
  36523. */
  36524. onBeforeStepObservable: Observable<Scene>;
  36525. /**
  36526. * An event triggered after calculating deterministic simulation step
  36527. */
  36528. onAfterStepObservable: Observable<Scene>;
  36529. /**
  36530. * An event triggered when the activeCamera property is updated
  36531. */
  36532. onActiveCameraChanged: Observable<Scene>;
  36533. /**
  36534. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  36535. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36536. * 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)
  36537. */
  36538. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36539. /**
  36540. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  36541. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36542. * 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)
  36543. */
  36544. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36545. /**
  36546. * This Observable will when a mesh has been imported into the scene.
  36547. */
  36548. onMeshImportedObservable: Observable<AbstractMesh>;
  36549. /**
  36550. * This Observable will when an animation file has been imported into the scene.
  36551. */
  36552. onAnimationFileImportedObservable: Observable<Scene>;
  36553. /**
  36554. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  36555. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  36556. */
  36557. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  36558. /** @hidden */
  36559. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  36560. /**
  36561. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  36562. */
  36563. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  36564. /**
  36565. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  36566. */
  36567. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  36568. /**
  36569. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  36570. */
  36571. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  36572. /** Callback called when a pointer move is detected */
  36573. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36574. /** Callback called when a pointer down is detected */
  36575. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36576. /** Callback called when a pointer up is detected */
  36577. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  36578. /** Callback called when a pointer pick is detected */
  36579. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  36580. /**
  36581. * 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).
  36582. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  36583. */
  36584. onPrePointerObservable: Observable<PointerInfoPre>;
  36585. /**
  36586. * Observable event triggered each time an input event is received from the rendering canvas
  36587. */
  36588. onPointerObservable: Observable<PointerInfo>;
  36589. /**
  36590. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  36591. */
  36592. get unTranslatedPointer(): Vector2;
  36593. /**
  36594. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  36595. */
  36596. static get DragMovementThreshold(): number;
  36597. static set DragMovementThreshold(value: number);
  36598. /**
  36599. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  36600. */
  36601. static get LongPressDelay(): number;
  36602. static set LongPressDelay(value: number);
  36603. /**
  36604. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  36605. */
  36606. static get DoubleClickDelay(): number;
  36607. static set DoubleClickDelay(value: number);
  36608. /** If you need to check double click without raising a single click at first click, enable this flag */
  36609. static get ExclusiveDoubleClickMode(): boolean;
  36610. static set ExclusiveDoubleClickMode(value: boolean);
  36611. /** @hidden */
  36612. _mirroredCameraPosition: Nullable<Vector3>;
  36613. /**
  36614. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36615. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36616. */
  36617. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36618. /**
  36619. * Observable event triggered each time an keyboard event is received from the hosting window
  36620. */
  36621. onKeyboardObservable: Observable<KeyboardInfo>;
  36622. private _useRightHandedSystem;
  36623. /**
  36624. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36625. */
  36626. set useRightHandedSystem(value: boolean);
  36627. get useRightHandedSystem(): boolean;
  36628. private _timeAccumulator;
  36629. private _currentStepId;
  36630. private _currentInternalStep;
  36631. /**
  36632. * Sets the step Id used by deterministic lock step
  36633. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36634. * @param newStepId defines the step Id
  36635. */
  36636. setStepId(newStepId: number): void;
  36637. /**
  36638. * Gets the step Id used by deterministic lock step
  36639. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36640. * @returns the step Id
  36641. */
  36642. getStepId(): number;
  36643. /**
  36644. * Gets the internal step used by deterministic lock step
  36645. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36646. * @returns the internal step
  36647. */
  36648. getInternalStep(): number;
  36649. private _fogEnabled;
  36650. /**
  36651. * Gets or sets a boolean indicating if fog is enabled on this scene
  36652. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36653. * (Default is true)
  36654. */
  36655. set fogEnabled(value: boolean);
  36656. get fogEnabled(): boolean;
  36657. private _fogMode;
  36658. /**
  36659. * Gets or sets the fog mode to use
  36660. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36661. * | mode | value |
  36662. * | --- | --- |
  36663. * | FOGMODE_NONE | 0 |
  36664. * | FOGMODE_EXP | 1 |
  36665. * | FOGMODE_EXP2 | 2 |
  36666. * | FOGMODE_LINEAR | 3 |
  36667. */
  36668. set fogMode(value: number);
  36669. get fogMode(): number;
  36670. /**
  36671. * Gets or sets the fog color to use
  36672. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36673. * (Default is Color3(0.2, 0.2, 0.3))
  36674. */
  36675. fogColor: Color3;
  36676. /**
  36677. * Gets or sets the fog density to use
  36678. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36679. * (Default is 0.1)
  36680. */
  36681. fogDensity: number;
  36682. /**
  36683. * Gets or sets the fog start distance to use
  36684. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36685. * (Default is 0)
  36686. */
  36687. fogStart: number;
  36688. /**
  36689. * Gets or sets the fog end distance to use
  36690. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36691. * (Default is 1000)
  36692. */
  36693. fogEnd: number;
  36694. private _shadowsEnabled;
  36695. /**
  36696. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36697. */
  36698. set shadowsEnabled(value: boolean);
  36699. get shadowsEnabled(): boolean;
  36700. private _lightsEnabled;
  36701. /**
  36702. * Gets or sets a boolean indicating if lights are enabled on this scene
  36703. */
  36704. set lightsEnabled(value: boolean);
  36705. get lightsEnabled(): boolean;
  36706. /** All of the active cameras added to this scene. */
  36707. activeCameras: Camera[];
  36708. /** @hidden */
  36709. _activeCamera: Nullable<Camera>;
  36710. /** Gets or sets the current active camera */
  36711. get activeCamera(): Nullable<Camera>;
  36712. set activeCamera(value: Nullable<Camera>);
  36713. private _defaultMaterial;
  36714. /** The default material used on meshes when no material is affected */
  36715. get defaultMaterial(): Material;
  36716. /** The default material used on meshes when no material is affected */
  36717. set defaultMaterial(value: Material);
  36718. private _texturesEnabled;
  36719. /**
  36720. * Gets or sets a boolean indicating if textures are enabled on this scene
  36721. */
  36722. set texturesEnabled(value: boolean);
  36723. get texturesEnabled(): boolean;
  36724. /**
  36725. * Gets or sets a boolean indicating if particles are enabled on this scene
  36726. */
  36727. particlesEnabled: boolean;
  36728. /**
  36729. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36730. */
  36731. spritesEnabled: boolean;
  36732. private _skeletonsEnabled;
  36733. /**
  36734. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36735. */
  36736. set skeletonsEnabled(value: boolean);
  36737. get skeletonsEnabled(): boolean;
  36738. /**
  36739. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36740. */
  36741. lensFlaresEnabled: boolean;
  36742. /**
  36743. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36744. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36745. */
  36746. collisionsEnabled: boolean;
  36747. private _collisionCoordinator;
  36748. /** @hidden */
  36749. get collisionCoordinator(): ICollisionCoordinator;
  36750. /**
  36751. * Defines the gravity applied to this scene (used only for collisions)
  36752. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36753. */
  36754. gravity: Vector3;
  36755. /**
  36756. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36757. */
  36758. postProcessesEnabled: boolean;
  36759. /**
  36760. * The list of postprocesses added to the scene
  36761. */
  36762. postProcesses: PostProcess[];
  36763. /**
  36764. * Gets the current postprocess manager
  36765. */
  36766. postProcessManager: PostProcessManager;
  36767. /**
  36768. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36769. */
  36770. renderTargetsEnabled: boolean;
  36771. /**
  36772. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36773. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36774. */
  36775. dumpNextRenderTargets: boolean;
  36776. /**
  36777. * The list of user defined render targets added to the scene
  36778. */
  36779. customRenderTargets: RenderTargetTexture[];
  36780. /**
  36781. * Defines if texture loading must be delayed
  36782. * If true, textures will only be loaded when they need to be rendered
  36783. */
  36784. useDelayedTextureLoading: boolean;
  36785. /**
  36786. * Gets the list of meshes imported to the scene through SceneLoader
  36787. */
  36788. importedMeshesFiles: String[];
  36789. /**
  36790. * Gets or sets a boolean indicating if probes are enabled on this scene
  36791. */
  36792. probesEnabled: boolean;
  36793. /**
  36794. * Gets or sets the current offline provider to use to store scene data
  36795. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36796. */
  36797. offlineProvider: IOfflineProvider;
  36798. /**
  36799. * Gets or sets the action manager associated with the scene
  36800. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36801. */
  36802. actionManager: AbstractActionManager;
  36803. private _meshesForIntersections;
  36804. /**
  36805. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36806. */
  36807. proceduralTexturesEnabled: boolean;
  36808. private _engine;
  36809. private _totalVertices;
  36810. /** @hidden */
  36811. _activeIndices: PerfCounter;
  36812. /** @hidden */
  36813. _activeParticles: PerfCounter;
  36814. /** @hidden */
  36815. _activeBones: PerfCounter;
  36816. private _animationRatio;
  36817. /** @hidden */
  36818. _animationTimeLast: number;
  36819. /** @hidden */
  36820. _animationTime: number;
  36821. /**
  36822. * Gets or sets a general scale for animation speed
  36823. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36824. */
  36825. animationTimeScale: number;
  36826. /** @hidden */
  36827. _cachedMaterial: Nullable<Material>;
  36828. /** @hidden */
  36829. _cachedEffect: Nullable<Effect>;
  36830. /** @hidden */
  36831. _cachedVisibility: Nullable<number>;
  36832. private _renderId;
  36833. private _frameId;
  36834. private _executeWhenReadyTimeoutId;
  36835. private _intermediateRendering;
  36836. private _viewUpdateFlag;
  36837. private _projectionUpdateFlag;
  36838. /** @hidden */
  36839. _toBeDisposed: Nullable<IDisposable>[];
  36840. private _activeRequests;
  36841. /** @hidden */
  36842. _pendingData: any[];
  36843. private _isDisposed;
  36844. /**
  36845. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36846. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36847. */
  36848. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36849. private _activeMeshes;
  36850. private _processedMaterials;
  36851. private _renderTargets;
  36852. /** @hidden */
  36853. _activeParticleSystems: SmartArray<IParticleSystem>;
  36854. private _activeSkeletons;
  36855. private _softwareSkinnedMeshes;
  36856. private _renderingManager;
  36857. /** @hidden */
  36858. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  36859. private _transformMatrix;
  36860. private _sceneUbo;
  36861. /** @hidden */
  36862. _viewMatrix: Matrix;
  36863. private _projectionMatrix;
  36864. /** @hidden */
  36865. _forcedViewPosition: Nullable<Vector3>;
  36866. /** @hidden */
  36867. _frustumPlanes: Plane[];
  36868. /**
  36869. * Gets the list of frustum planes (built from the active camera)
  36870. */
  36871. get frustumPlanes(): Plane[];
  36872. /**
  36873. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36874. * This is useful if there are more lights that the maximum simulteanous authorized
  36875. */
  36876. requireLightSorting: boolean;
  36877. /** @hidden */
  36878. readonly useMaterialMeshMap: boolean;
  36879. /** @hidden */
  36880. readonly useClonedMeshMap: boolean;
  36881. private _externalData;
  36882. private _uid;
  36883. /**
  36884. * @hidden
  36885. * Backing store of defined scene components.
  36886. */
  36887. _components: ISceneComponent[];
  36888. /**
  36889. * @hidden
  36890. * Backing store of defined scene components.
  36891. */
  36892. _serializableComponents: ISceneSerializableComponent[];
  36893. /**
  36894. * List of components to register on the next registration step.
  36895. */
  36896. private _transientComponents;
  36897. /**
  36898. * Registers the transient components if needed.
  36899. */
  36900. private _registerTransientComponents;
  36901. /**
  36902. * @hidden
  36903. * Add a component to the scene.
  36904. * Note that the ccomponent could be registered on th next frame if this is called after
  36905. * the register component stage.
  36906. * @param component Defines the component to add to the scene
  36907. */
  36908. _addComponent(component: ISceneComponent): void;
  36909. /**
  36910. * @hidden
  36911. * Gets a component from the scene.
  36912. * @param name defines the name of the component to retrieve
  36913. * @returns the component or null if not present
  36914. */
  36915. _getComponent(name: string): Nullable<ISceneComponent>;
  36916. /**
  36917. * @hidden
  36918. * Defines the actions happening before camera updates.
  36919. */
  36920. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36921. /**
  36922. * @hidden
  36923. * Defines the actions happening before clear the canvas.
  36924. */
  36925. _beforeClearStage: Stage<SimpleStageAction>;
  36926. /**
  36927. * @hidden
  36928. * Defines the actions when collecting render targets for the frame.
  36929. */
  36930. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36931. /**
  36932. * @hidden
  36933. * Defines the actions happening for one camera in the frame.
  36934. */
  36935. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36936. /**
  36937. * @hidden
  36938. * Defines the actions happening during the per mesh ready checks.
  36939. */
  36940. _isReadyForMeshStage: Stage<MeshStageAction>;
  36941. /**
  36942. * @hidden
  36943. * Defines the actions happening before evaluate active mesh checks.
  36944. */
  36945. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36946. /**
  36947. * @hidden
  36948. * Defines the actions happening during the evaluate sub mesh checks.
  36949. */
  36950. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36951. /**
  36952. * @hidden
  36953. * Defines the actions happening during the active mesh stage.
  36954. */
  36955. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36956. /**
  36957. * @hidden
  36958. * Defines the actions happening during the per camera render target step.
  36959. */
  36960. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36961. /**
  36962. * @hidden
  36963. * Defines the actions happening just before the active camera is drawing.
  36964. */
  36965. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36966. /**
  36967. * @hidden
  36968. * Defines the actions happening just before a render target is drawing.
  36969. */
  36970. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36971. /**
  36972. * @hidden
  36973. * Defines the actions happening just before a rendering group is drawing.
  36974. */
  36975. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36976. /**
  36977. * @hidden
  36978. * Defines the actions happening just before a mesh is drawing.
  36979. */
  36980. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36981. /**
  36982. * @hidden
  36983. * Defines the actions happening just after a mesh has been drawn.
  36984. */
  36985. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36986. /**
  36987. * @hidden
  36988. * Defines the actions happening just after a rendering group has been drawn.
  36989. */
  36990. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36991. /**
  36992. * @hidden
  36993. * Defines the actions happening just after the active camera has been drawn.
  36994. */
  36995. _afterCameraDrawStage: Stage<CameraStageAction>;
  36996. /**
  36997. * @hidden
  36998. * Defines the actions happening just after a render target has been drawn.
  36999. */
  37000. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  37001. /**
  37002. * @hidden
  37003. * Defines the actions happening just after rendering all cameras and computing intersections.
  37004. */
  37005. _afterRenderStage: Stage<SimpleStageAction>;
  37006. /**
  37007. * @hidden
  37008. * Defines the actions happening when a pointer move event happens.
  37009. */
  37010. _pointerMoveStage: Stage<PointerMoveStageAction>;
  37011. /**
  37012. * @hidden
  37013. * Defines the actions happening when a pointer down event happens.
  37014. */
  37015. _pointerDownStage: Stage<PointerUpDownStageAction>;
  37016. /**
  37017. * @hidden
  37018. * Defines the actions happening when a pointer up event happens.
  37019. */
  37020. _pointerUpStage: Stage<PointerUpDownStageAction>;
  37021. /**
  37022. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  37023. */
  37024. private geometriesByUniqueId;
  37025. /**
  37026. * Creates a new Scene
  37027. * @param engine defines the engine to use to render this scene
  37028. * @param options defines the scene options
  37029. */
  37030. constructor(engine: Engine, options?: SceneOptions);
  37031. /**
  37032. * Gets a string idenfifying the name of the class
  37033. * @returns "Scene" string
  37034. */
  37035. getClassName(): string;
  37036. private _defaultMeshCandidates;
  37037. /**
  37038. * @hidden
  37039. */
  37040. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  37041. private _defaultSubMeshCandidates;
  37042. /**
  37043. * @hidden
  37044. */
  37045. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  37046. /**
  37047. * Sets the default candidate providers for the scene.
  37048. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  37049. * and getCollidingSubMeshCandidates to their default function
  37050. */
  37051. setDefaultCandidateProviders(): void;
  37052. /**
  37053. * Gets the mesh that is currently under the pointer
  37054. */
  37055. get meshUnderPointer(): Nullable<AbstractMesh>;
  37056. /**
  37057. * Gets or sets the current on-screen X position of the pointer
  37058. */
  37059. get pointerX(): number;
  37060. set pointerX(value: number);
  37061. /**
  37062. * Gets or sets the current on-screen Y position of the pointer
  37063. */
  37064. get pointerY(): number;
  37065. set pointerY(value: number);
  37066. /**
  37067. * Gets the cached material (ie. the latest rendered one)
  37068. * @returns the cached material
  37069. */
  37070. getCachedMaterial(): Nullable<Material>;
  37071. /**
  37072. * Gets the cached effect (ie. the latest rendered one)
  37073. * @returns the cached effect
  37074. */
  37075. getCachedEffect(): Nullable<Effect>;
  37076. /**
  37077. * Gets the cached visibility state (ie. the latest rendered one)
  37078. * @returns the cached visibility state
  37079. */
  37080. getCachedVisibility(): Nullable<number>;
  37081. /**
  37082. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  37083. * @param material defines the current material
  37084. * @param effect defines the current effect
  37085. * @param visibility defines the current visibility state
  37086. * @returns true if one parameter is not cached
  37087. */
  37088. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  37089. /**
  37090. * Gets the engine associated with the scene
  37091. * @returns an Engine
  37092. */
  37093. getEngine(): Engine;
  37094. /**
  37095. * Gets the total number of vertices rendered per frame
  37096. * @returns the total number of vertices rendered per frame
  37097. */
  37098. getTotalVertices(): number;
  37099. /**
  37100. * Gets the performance counter for total vertices
  37101. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37102. */
  37103. get totalVerticesPerfCounter(): PerfCounter;
  37104. /**
  37105. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  37106. * @returns the total number of active indices rendered per frame
  37107. */
  37108. getActiveIndices(): number;
  37109. /**
  37110. * Gets the performance counter for active indices
  37111. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37112. */
  37113. get totalActiveIndicesPerfCounter(): PerfCounter;
  37114. /**
  37115. * Gets the total number of active particles rendered per frame
  37116. * @returns the total number of active particles rendered per frame
  37117. */
  37118. getActiveParticles(): number;
  37119. /**
  37120. * Gets the performance counter for active particles
  37121. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37122. */
  37123. get activeParticlesPerfCounter(): PerfCounter;
  37124. /**
  37125. * Gets the total number of active bones rendered per frame
  37126. * @returns the total number of active bones rendered per frame
  37127. */
  37128. getActiveBones(): number;
  37129. /**
  37130. * Gets the performance counter for active bones
  37131. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37132. */
  37133. get activeBonesPerfCounter(): PerfCounter;
  37134. /**
  37135. * Gets the array of active meshes
  37136. * @returns an array of AbstractMesh
  37137. */
  37138. getActiveMeshes(): SmartArray<AbstractMesh>;
  37139. /**
  37140. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  37141. * @returns a number
  37142. */
  37143. getAnimationRatio(): number;
  37144. /**
  37145. * Gets an unique Id for the current render phase
  37146. * @returns a number
  37147. */
  37148. getRenderId(): number;
  37149. /**
  37150. * Gets an unique Id for the current frame
  37151. * @returns a number
  37152. */
  37153. getFrameId(): number;
  37154. /** Call this function if you want to manually increment the render Id*/
  37155. incrementRenderId(): void;
  37156. private _createUbo;
  37157. /**
  37158. * Use this method to simulate a pointer move on a mesh
  37159. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37160. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37161. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37162. * @returns the current scene
  37163. */
  37164. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37165. /**
  37166. * Use this method to simulate a pointer down on a mesh
  37167. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37168. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37169. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37170. * @returns the current scene
  37171. */
  37172. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37173. /**
  37174. * Use this method to simulate a pointer up on a mesh
  37175. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37176. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37177. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37178. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  37179. * @returns the current scene
  37180. */
  37181. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  37182. /**
  37183. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  37184. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  37185. * @returns true if the pointer was captured
  37186. */
  37187. isPointerCaptured(pointerId?: number): boolean;
  37188. /**
  37189. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  37190. * @param attachUp defines if you want to attach events to pointerup
  37191. * @param attachDown defines if you want to attach events to pointerdown
  37192. * @param attachMove defines if you want to attach events to pointermove
  37193. */
  37194. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  37195. /** Detaches all event handlers*/
  37196. detachControl(): void;
  37197. /**
  37198. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  37199. * Delay loaded resources are not taking in account
  37200. * @return true if all required resources are ready
  37201. */
  37202. isReady(): boolean;
  37203. /** Resets all cached information relative to material (including effect and visibility) */
  37204. resetCachedMaterial(): void;
  37205. /**
  37206. * Registers a function to be called before every frame render
  37207. * @param func defines the function to register
  37208. */
  37209. registerBeforeRender(func: () => void): void;
  37210. /**
  37211. * Unregisters a function called before every frame render
  37212. * @param func defines the function to unregister
  37213. */
  37214. unregisterBeforeRender(func: () => void): void;
  37215. /**
  37216. * Registers a function to be called after every frame render
  37217. * @param func defines the function to register
  37218. */
  37219. registerAfterRender(func: () => void): void;
  37220. /**
  37221. * Unregisters a function called after every frame render
  37222. * @param func defines the function to unregister
  37223. */
  37224. unregisterAfterRender(func: () => void): void;
  37225. private _executeOnceBeforeRender;
  37226. /**
  37227. * The provided function will run before render once and will be disposed afterwards.
  37228. * A timeout delay can be provided so that the function will be executed in N ms.
  37229. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  37230. * @param func The function to be executed.
  37231. * @param timeout optional delay in ms
  37232. */
  37233. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  37234. /** @hidden */
  37235. _addPendingData(data: any): void;
  37236. /** @hidden */
  37237. _removePendingData(data: any): void;
  37238. /**
  37239. * Returns the number of items waiting to be loaded
  37240. * @returns the number of items waiting to be loaded
  37241. */
  37242. getWaitingItemsCount(): number;
  37243. /**
  37244. * Returns a boolean indicating if the scene is still loading data
  37245. */
  37246. get isLoading(): boolean;
  37247. /**
  37248. * Registers a function to be executed when the scene is ready
  37249. * @param {Function} func - the function to be executed
  37250. */
  37251. executeWhenReady(func: () => void): void;
  37252. /**
  37253. * Returns a promise that resolves when the scene is ready
  37254. * @returns A promise that resolves when the scene is ready
  37255. */
  37256. whenReadyAsync(): Promise<void>;
  37257. /** @hidden */
  37258. _checkIsReady(): void;
  37259. /**
  37260. * Gets all animatable attached to the scene
  37261. */
  37262. get animatables(): Animatable[];
  37263. /**
  37264. * Resets the last animation time frame.
  37265. * Useful to override when animations start running when loading a scene for the first time.
  37266. */
  37267. resetLastAnimationTimeFrame(): void;
  37268. /**
  37269. * Gets the current view matrix
  37270. * @returns a Matrix
  37271. */
  37272. getViewMatrix(): Matrix;
  37273. /**
  37274. * Gets the current projection matrix
  37275. * @returns a Matrix
  37276. */
  37277. getProjectionMatrix(): Matrix;
  37278. /**
  37279. * Gets the current transform matrix
  37280. * @returns a Matrix made of View * Projection
  37281. */
  37282. getTransformMatrix(): Matrix;
  37283. /**
  37284. * Sets the current transform matrix
  37285. * @param viewL defines the View matrix to use
  37286. * @param projectionL defines the Projection matrix to use
  37287. * @param viewR defines the right View matrix to use (if provided)
  37288. * @param projectionR defines the right Projection matrix to use (if provided)
  37289. */
  37290. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  37291. /**
  37292. * Gets the uniform buffer used to store scene data
  37293. * @returns a UniformBuffer
  37294. */
  37295. getSceneUniformBuffer(): UniformBuffer;
  37296. /**
  37297. * Gets an unique (relatively to the current scene) Id
  37298. * @returns an unique number for the scene
  37299. */
  37300. getUniqueId(): number;
  37301. /**
  37302. * Add a mesh to the list of scene's meshes
  37303. * @param newMesh defines the mesh to add
  37304. * @param recursive if all child meshes should also be added to the scene
  37305. */
  37306. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  37307. /**
  37308. * Remove a mesh for the list of scene's meshes
  37309. * @param toRemove defines the mesh to remove
  37310. * @param recursive if all child meshes should also be removed from the scene
  37311. * @returns the index where the mesh was in the mesh list
  37312. */
  37313. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  37314. /**
  37315. * Add a transform node to the list of scene's transform nodes
  37316. * @param newTransformNode defines the transform node to add
  37317. */
  37318. addTransformNode(newTransformNode: TransformNode): void;
  37319. /**
  37320. * Remove a transform node for the list of scene's transform nodes
  37321. * @param toRemove defines the transform node to remove
  37322. * @returns the index where the transform node was in the transform node list
  37323. */
  37324. removeTransformNode(toRemove: TransformNode): number;
  37325. /**
  37326. * Remove a skeleton for the list of scene's skeletons
  37327. * @param toRemove defines the skeleton to remove
  37328. * @returns the index where the skeleton was in the skeleton list
  37329. */
  37330. removeSkeleton(toRemove: Skeleton): number;
  37331. /**
  37332. * Remove a morph target for the list of scene's morph targets
  37333. * @param toRemove defines the morph target to remove
  37334. * @returns the index where the morph target was in the morph target list
  37335. */
  37336. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  37337. /**
  37338. * Remove a light for the list of scene's lights
  37339. * @param toRemove defines the light to remove
  37340. * @returns the index where the light was in the light list
  37341. */
  37342. removeLight(toRemove: Light): number;
  37343. /**
  37344. * Remove a camera for the list of scene's cameras
  37345. * @param toRemove defines the camera to remove
  37346. * @returns the index where the camera was in the camera list
  37347. */
  37348. removeCamera(toRemove: Camera): number;
  37349. /**
  37350. * Remove a particle system for the list of scene's particle systems
  37351. * @param toRemove defines the particle system to remove
  37352. * @returns the index where the particle system was in the particle system list
  37353. */
  37354. removeParticleSystem(toRemove: IParticleSystem): number;
  37355. /**
  37356. * Remove a animation for the list of scene's animations
  37357. * @param toRemove defines the animation to remove
  37358. * @returns the index where the animation was in the animation list
  37359. */
  37360. removeAnimation(toRemove: Animation): number;
  37361. /**
  37362. * Will stop the animation of the given target
  37363. * @param target - the target
  37364. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  37365. * @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)
  37366. */
  37367. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  37368. /**
  37369. * Removes the given animation group from this scene.
  37370. * @param toRemove The animation group to remove
  37371. * @returns The index of the removed animation group
  37372. */
  37373. removeAnimationGroup(toRemove: AnimationGroup): number;
  37374. /**
  37375. * Removes the given multi-material from this scene.
  37376. * @param toRemove The multi-material to remove
  37377. * @returns The index of the removed multi-material
  37378. */
  37379. removeMultiMaterial(toRemove: MultiMaterial): number;
  37380. /**
  37381. * Removes the given material from this scene.
  37382. * @param toRemove The material to remove
  37383. * @returns The index of the removed material
  37384. */
  37385. removeMaterial(toRemove: Material): number;
  37386. /**
  37387. * Removes the given action manager from this scene.
  37388. * @param toRemove The action manager to remove
  37389. * @returns The index of the removed action manager
  37390. */
  37391. removeActionManager(toRemove: AbstractActionManager): number;
  37392. /**
  37393. * Removes the given texture from this scene.
  37394. * @param toRemove The texture to remove
  37395. * @returns The index of the removed texture
  37396. */
  37397. removeTexture(toRemove: BaseTexture): number;
  37398. /**
  37399. * Adds the given light to this scene
  37400. * @param newLight The light to add
  37401. */
  37402. addLight(newLight: Light): void;
  37403. /**
  37404. * Sorts the list list based on light priorities
  37405. */
  37406. sortLightsByPriority(): void;
  37407. /**
  37408. * Adds the given camera to this scene
  37409. * @param newCamera The camera to add
  37410. */
  37411. addCamera(newCamera: Camera): void;
  37412. /**
  37413. * Adds the given skeleton to this scene
  37414. * @param newSkeleton The skeleton to add
  37415. */
  37416. addSkeleton(newSkeleton: Skeleton): void;
  37417. /**
  37418. * Adds the given particle system to this scene
  37419. * @param newParticleSystem The particle system to add
  37420. */
  37421. addParticleSystem(newParticleSystem: IParticleSystem): void;
  37422. /**
  37423. * Adds the given animation to this scene
  37424. * @param newAnimation The animation to add
  37425. */
  37426. addAnimation(newAnimation: Animation): void;
  37427. /**
  37428. * Adds the given animation group to this scene.
  37429. * @param newAnimationGroup The animation group to add
  37430. */
  37431. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  37432. /**
  37433. * Adds the given multi-material to this scene
  37434. * @param newMultiMaterial The multi-material to add
  37435. */
  37436. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  37437. /**
  37438. * Adds the given material to this scene
  37439. * @param newMaterial The material to add
  37440. */
  37441. addMaterial(newMaterial: Material): void;
  37442. /**
  37443. * Adds the given morph target to this scene
  37444. * @param newMorphTargetManager The morph target to add
  37445. */
  37446. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  37447. /**
  37448. * Adds the given geometry to this scene
  37449. * @param newGeometry The geometry to add
  37450. */
  37451. addGeometry(newGeometry: Geometry): void;
  37452. /**
  37453. * Adds the given action manager to this scene
  37454. * @param newActionManager The action manager to add
  37455. */
  37456. addActionManager(newActionManager: AbstractActionManager): void;
  37457. /**
  37458. * Adds the given texture to this scene.
  37459. * @param newTexture The texture to add
  37460. */
  37461. addTexture(newTexture: BaseTexture): void;
  37462. /**
  37463. * Switch active camera
  37464. * @param newCamera defines the new active camera
  37465. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  37466. */
  37467. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  37468. /**
  37469. * sets the active camera of the scene using its ID
  37470. * @param id defines the camera's ID
  37471. * @return the new active camera or null if none found.
  37472. */
  37473. setActiveCameraByID(id: string): Nullable<Camera>;
  37474. /**
  37475. * sets the active camera of the scene using its name
  37476. * @param name defines the camera's name
  37477. * @returns the new active camera or null if none found.
  37478. */
  37479. setActiveCameraByName(name: string): Nullable<Camera>;
  37480. /**
  37481. * get an animation group using its name
  37482. * @param name defines the material's name
  37483. * @return the animation group or null if none found.
  37484. */
  37485. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  37486. /**
  37487. * Get a material using its unique id
  37488. * @param uniqueId defines the material's unique id
  37489. * @return the material or null if none found.
  37490. */
  37491. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  37492. /**
  37493. * get a material using its id
  37494. * @param id defines the material's ID
  37495. * @return the material or null if none found.
  37496. */
  37497. getMaterialByID(id: string): Nullable<Material>;
  37498. /**
  37499. * Gets a the last added material using a given id
  37500. * @param id defines the material's ID
  37501. * @return the last material with the given id or null if none found.
  37502. */
  37503. getLastMaterialByID(id: string): Nullable<Material>;
  37504. /**
  37505. * Gets a material using its name
  37506. * @param name defines the material's name
  37507. * @return the material or null if none found.
  37508. */
  37509. getMaterialByName(name: string): Nullable<Material>;
  37510. /**
  37511. * Get a texture using its unique id
  37512. * @param uniqueId defines the texture's unique id
  37513. * @return the texture or null if none found.
  37514. */
  37515. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  37516. /**
  37517. * Gets a camera using its id
  37518. * @param id defines the id to look for
  37519. * @returns the camera or null if not found
  37520. */
  37521. getCameraByID(id: string): Nullable<Camera>;
  37522. /**
  37523. * Gets a camera using its unique id
  37524. * @param uniqueId defines the unique id to look for
  37525. * @returns the camera or null if not found
  37526. */
  37527. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  37528. /**
  37529. * Gets a camera using its name
  37530. * @param name defines the camera's name
  37531. * @return the camera or null if none found.
  37532. */
  37533. getCameraByName(name: string): Nullable<Camera>;
  37534. /**
  37535. * Gets a bone using its id
  37536. * @param id defines the bone's id
  37537. * @return the bone or null if not found
  37538. */
  37539. getBoneByID(id: string): Nullable<Bone>;
  37540. /**
  37541. * Gets a bone using its id
  37542. * @param name defines the bone's name
  37543. * @return the bone or null if not found
  37544. */
  37545. getBoneByName(name: string): Nullable<Bone>;
  37546. /**
  37547. * Gets a light node using its name
  37548. * @param name defines the the light's name
  37549. * @return the light or null if none found.
  37550. */
  37551. getLightByName(name: string): Nullable<Light>;
  37552. /**
  37553. * Gets a light node using its id
  37554. * @param id defines the light's id
  37555. * @return the light or null if none found.
  37556. */
  37557. getLightByID(id: string): Nullable<Light>;
  37558. /**
  37559. * Gets a light node using its scene-generated unique ID
  37560. * @param uniqueId defines the light's unique id
  37561. * @return the light or null if none found.
  37562. */
  37563. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  37564. /**
  37565. * Gets a particle system by id
  37566. * @param id defines the particle system id
  37567. * @return the corresponding system or null if none found
  37568. */
  37569. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  37570. /**
  37571. * Gets a geometry using its ID
  37572. * @param id defines the geometry's id
  37573. * @return the geometry or null if none found.
  37574. */
  37575. getGeometryByID(id: string): Nullable<Geometry>;
  37576. private _getGeometryByUniqueID;
  37577. /**
  37578. * Add a new geometry to this scene
  37579. * @param geometry defines the geometry to be added to the scene.
  37580. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  37581. * @return a boolean defining if the geometry was added or not
  37582. */
  37583. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  37584. /**
  37585. * Removes an existing geometry
  37586. * @param geometry defines the geometry to be removed from the scene
  37587. * @return a boolean defining if the geometry was removed or not
  37588. */
  37589. removeGeometry(geometry: Geometry): boolean;
  37590. /**
  37591. * Gets the list of geometries attached to the scene
  37592. * @returns an array of Geometry
  37593. */
  37594. getGeometries(): Geometry[];
  37595. /**
  37596. * Gets the first added mesh found of a given ID
  37597. * @param id defines the id to search for
  37598. * @return the mesh found or null if not found at all
  37599. */
  37600. getMeshByID(id: string): Nullable<AbstractMesh>;
  37601. /**
  37602. * Gets a list of meshes using their id
  37603. * @param id defines the id to search for
  37604. * @returns a list of meshes
  37605. */
  37606. getMeshesByID(id: string): Array<AbstractMesh>;
  37607. /**
  37608. * Gets the first added transform node found of a given ID
  37609. * @param id defines the id to search for
  37610. * @return the found transform node or null if not found at all.
  37611. */
  37612. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37613. /**
  37614. * Gets a transform node with its auto-generated unique id
  37615. * @param uniqueId efines the unique id to search for
  37616. * @return the found transform node or null if not found at all.
  37617. */
  37618. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37619. /**
  37620. * Gets a list of transform nodes using their id
  37621. * @param id defines the id to search for
  37622. * @returns a list of transform nodes
  37623. */
  37624. getTransformNodesByID(id: string): Array<TransformNode>;
  37625. /**
  37626. * Gets a mesh with its auto-generated unique id
  37627. * @param uniqueId defines the unique id to search for
  37628. * @return the found mesh or null if not found at all.
  37629. */
  37630. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37631. /**
  37632. * Gets a the last added mesh using a given id
  37633. * @param id defines the id to search for
  37634. * @return the found mesh or null if not found at all.
  37635. */
  37636. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  37637. /**
  37638. * Gets a the last added node (Mesh, Camera, Light) using a given id
  37639. * @param id defines the id to search for
  37640. * @return the found node or null if not found at all
  37641. */
  37642. getLastEntryByID(id: string): Nullable<Node>;
  37643. /**
  37644. * Gets a node (Mesh, Camera, Light) using a given id
  37645. * @param id defines the id to search for
  37646. * @return the found node or null if not found at all
  37647. */
  37648. getNodeByID(id: string): Nullable<Node>;
  37649. /**
  37650. * Gets a node (Mesh, Camera, Light) using a given name
  37651. * @param name defines the name to search for
  37652. * @return the found node or null if not found at all.
  37653. */
  37654. getNodeByName(name: string): Nullable<Node>;
  37655. /**
  37656. * Gets a mesh using a given name
  37657. * @param name defines the name to search for
  37658. * @return the found mesh or null if not found at all.
  37659. */
  37660. getMeshByName(name: string): Nullable<AbstractMesh>;
  37661. /**
  37662. * Gets a transform node using a given name
  37663. * @param name defines the name to search for
  37664. * @return the found transform node or null if not found at all.
  37665. */
  37666. getTransformNodeByName(name: string): Nullable<TransformNode>;
  37667. /**
  37668. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  37669. * @param id defines the id to search for
  37670. * @return the found skeleton or null if not found at all.
  37671. */
  37672. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  37673. /**
  37674. * Gets a skeleton using a given auto generated unique id
  37675. * @param uniqueId defines the unique id to search for
  37676. * @return the found skeleton or null if not found at all.
  37677. */
  37678. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  37679. /**
  37680. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  37681. * @param id defines the id to search for
  37682. * @return the found skeleton or null if not found at all.
  37683. */
  37684. getSkeletonById(id: string): Nullable<Skeleton>;
  37685. /**
  37686. * Gets a skeleton using a given name
  37687. * @param name defines the name to search for
  37688. * @return the found skeleton or null if not found at all.
  37689. */
  37690. getSkeletonByName(name: string): Nullable<Skeleton>;
  37691. /**
  37692. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37693. * @param id defines the id to search for
  37694. * @return the found morph target manager or null if not found at all.
  37695. */
  37696. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37697. /**
  37698. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37699. * @param id defines the id to search for
  37700. * @return the found morph target or null if not found at all.
  37701. */
  37702. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37703. /**
  37704. * Gets a boolean indicating if the given mesh is active
  37705. * @param mesh defines the mesh to look for
  37706. * @returns true if the mesh is in the active list
  37707. */
  37708. isActiveMesh(mesh: AbstractMesh): boolean;
  37709. /**
  37710. * Return a unique id as a string which can serve as an identifier for the scene
  37711. */
  37712. get uid(): string;
  37713. /**
  37714. * Add an externaly attached data from its key.
  37715. * This method call will fail and return false, if such key already exists.
  37716. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37717. * @param key the unique key that identifies the data
  37718. * @param data the data object to associate to the key for this Engine instance
  37719. * @return true if no such key were already present and the data was added successfully, false otherwise
  37720. */
  37721. addExternalData<T>(key: string, data: T): boolean;
  37722. /**
  37723. * Get an externaly attached data from its key
  37724. * @param key the unique key that identifies the data
  37725. * @return the associated data, if present (can be null), or undefined if not present
  37726. */
  37727. getExternalData<T>(key: string): Nullable<T>;
  37728. /**
  37729. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37730. * @param key the unique key that identifies the data
  37731. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37732. * @return the associated data, can be null if the factory returned null.
  37733. */
  37734. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37735. /**
  37736. * Remove an externaly attached data from the Engine instance
  37737. * @param key the unique key that identifies the data
  37738. * @return true if the data was successfully removed, false if it doesn't exist
  37739. */
  37740. removeExternalData(key: string): boolean;
  37741. private _evaluateSubMesh;
  37742. /**
  37743. * Clear the processed materials smart array preventing retention point in material dispose.
  37744. */
  37745. freeProcessedMaterials(): void;
  37746. private _preventFreeActiveMeshesAndRenderingGroups;
  37747. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37748. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37749. * when disposing several meshes in a row or a hierarchy of meshes.
  37750. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37751. */
  37752. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37753. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37754. /**
  37755. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37756. */
  37757. freeActiveMeshes(): void;
  37758. /**
  37759. * Clear the info related to rendering groups preventing retention points during dispose.
  37760. */
  37761. freeRenderingGroups(): void;
  37762. /** @hidden */
  37763. _isInIntermediateRendering(): boolean;
  37764. /**
  37765. * Lambda returning the list of potentially active meshes.
  37766. */
  37767. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37768. /**
  37769. * Lambda returning the list of potentially active sub meshes.
  37770. */
  37771. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37772. /**
  37773. * Lambda returning the list of potentially intersecting sub meshes.
  37774. */
  37775. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37776. /**
  37777. * Lambda returning the list of potentially colliding sub meshes.
  37778. */
  37779. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37780. private _activeMeshesFrozen;
  37781. private _skipEvaluateActiveMeshesCompletely;
  37782. /**
  37783. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37784. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37785. * @returns the current scene
  37786. */
  37787. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37788. /**
  37789. * Use this function to restart evaluating active meshes on every frame
  37790. * @returns the current scene
  37791. */
  37792. unfreezeActiveMeshes(): Scene;
  37793. private _evaluateActiveMeshes;
  37794. private _activeMesh;
  37795. /**
  37796. * Update the transform matrix to update from the current active camera
  37797. * @param force defines a boolean used to force the update even if cache is up to date
  37798. */
  37799. updateTransformMatrix(force?: boolean): void;
  37800. private _bindFrameBuffer;
  37801. /** @hidden */
  37802. _allowPostProcessClearColor: boolean;
  37803. /** @hidden */
  37804. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37805. private _processSubCameras;
  37806. private _checkIntersections;
  37807. /** @hidden */
  37808. _advancePhysicsEngineStep(step: number): void;
  37809. /**
  37810. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37811. */
  37812. getDeterministicFrameTime: () => number;
  37813. /** @hidden */
  37814. _animate(): void;
  37815. /** Execute all animations (for a frame) */
  37816. animate(): void;
  37817. /**
  37818. * Render the scene
  37819. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37820. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37821. */
  37822. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37823. /**
  37824. * Freeze all materials
  37825. * A frozen material will not be updatable but should be faster to render
  37826. */
  37827. freezeMaterials(): void;
  37828. /**
  37829. * Unfreeze all materials
  37830. * A frozen material will not be updatable but should be faster to render
  37831. */
  37832. unfreezeMaterials(): void;
  37833. /**
  37834. * Releases all held ressources
  37835. */
  37836. dispose(): void;
  37837. /**
  37838. * Gets if the scene is already disposed
  37839. */
  37840. get isDisposed(): boolean;
  37841. /**
  37842. * Call this function to reduce memory footprint of the scene.
  37843. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37844. */
  37845. clearCachedVertexData(): void;
  37846. /**
  37847. * This function will remove the local cached buffer data from texture.
  37848. * It will save memory but will prevent the texture from being rebuilt
  37849. */
  37850. cleanCachedTextureBuffer(): void;
  37851. /**
  37852. * Get the world extend vectors with an optional filter
  37853. *
  37854. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37855. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37856. */
  37857. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37858. min: Vector3;
  37859. max: Vector3;
  37860. };
  37861. /**
  37862. * Creates a ray that can be used to pick in the scene
  37863. * @param x defines the x coordinate of the origin (on-screen)
  37864. * @param y defines the y coordinate of the origin (on-screen)
  37865. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  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 a Ray
  37869. */
  37870. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  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 world defines the world matrix to use if you want to pick in object space (instead of world space)
  37876. * @param result defines the ray where to store the picking ray
  37877. * @param camera defines the camera to use for the picking
  37878. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37879. * @returns the current scene
  37880. */
  37881. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37882. /**
  37883. * Creates a ray that can be used to pick in the scene
  37884. * @param x defines the x coordinate of the origin (on-screen)
  37885. * @param y defines the y coordinate of the origin (on-screen)
  37886. * @param camera defines the camera to use for the picking
  37887. * @returns a Ray
  37888. */
  37889. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37890. /**
  37891. * Creates a ray that can be used to pick in the scene
  37892. * @param x defines the x coordinate of the origin (on-screen)
  37893. * @param y defines the y coordinate of the origin (on-screen)
  37894. * @param result defines the ray where to store the picking ray
  37895. * @param camera defines the camera to use for the picking
  37896. * @returns the current scene
  37897. */
  37898. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37899. /** Launch a ray to try to pick a mesh in the scene
  37900. * @param x position on screen
  37901. * @param y position on screen
  37902. * @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
  37903. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37904. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37905. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37906. * @returns a PickingInfo
  37907. */
  37908. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37909. /** Use the given ray to pick a mesh in the scene
  37910. * @param ray The ray to use to pick meshes
  37911. * @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
  37912. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37913. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37914. * @returns a PickingInfo
  37915. */
  37916. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37917. /**
  37918. * Launch a ray to try to pick a mesh in the scene
  37919. * @param x X position on screen
  37920. * @param y Y position on screen
  37921. * @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
  37922. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37923. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37924. * @returns an array of PickingInfo
  37925. */
  37926. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37927. /**
  37928. * Launch a ray to try to pick a mesh in the scene
  37929. * @param ray Ray to use
  37930. * @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
  37931. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37932. * @returns an array of PickingInfo
  37933. */
  37934. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37935. /**
  37936. * Force the value of meshUnderPointer
  37937. * @param mesh defines the mesh to use
  37938. */
  37939. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37940. /**
  37941. * Gets the mesh under the pointer
  37942. * @returns a Mesh or null if no mesh is under the pointer
  37943. */
  37944. getPointerOverMesh(): Nullable<AbstractMesh>;
  37945. /** @hidden */
  37946. _rebuildGeometries(): void;
  37947. /** @hidden */
  37948. _rebuildTextures(): void;
  37949. private _getByTags;
  37950. /**
  37951. * Get a list of meshes by tags
  37952. * @param tagsQuery defines the tags query to use
  37953. * @param forEach defines a predicate used to filter results
  37954. * @returns an array of Mesh
  37955. */
  37956. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37957. /**
  37958. * Get a list of cameras by tags
  37959. * @param tagsQuery defines the tags query to use
  37960. * @param forEach defines a predicate used to filter results
  37961. * @returns an array of Camera
  37962. */
  37963. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37964. /**
  37965. * Get a list of lights by tags
  37966. * @param tagsQuery defines the tags query to use
  37967. * @param forEach defines a predicate used to filter results
  37968. * @returns an array of Light
  37969. */
  37970. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37971. /**
  37972. * Get a list of materials by tags
  37973. * @param tagsQuery defines the tags query to use
  37974. * @param forEach defines a predicate used to filter results
  37975. * @returns an array of Material
  37976. */
  37977. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37978. /**
  37979. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37980. * This allowed control for front to back rendering or reversly depending of the special needs.
  37981. *
  37982. * @param renderingGroupId The rendering group id corresponding to its index
  37983. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37984. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37985. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37986. */
  37987. 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;
  37988. /**
  37989. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37990. *
  37991. * @param renderingGroupId The rendering group id corresponding to its index
  37992. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37993. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37994. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37995. */
  37996. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37997. /**
  37998. * Gets the current auto clear configuration for one rendering group of the rendering
  37999. * manager.
  38000. * @param index the rendering group index to get the information for
  38001. * @returns The auto clear setup for the requested rendering group
  38002. */
  38003. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  38004. private _blockMaterialDirtyMechanism;
  38005. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  38006. get blockMaterialDirtyMechanism(): boolean;
  38007. set blockMaterialDirtyMechanism(value: boolean);
  38008. /**
  38009. * Will flag all materials as dirty to trigger new shader compilation
  38010. * @param flag defines the flag used to specify which material part must be marked as dirty
  38011. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  38012. */
  38013. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  38014. /** @hidden */
  38015. _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;
  38016. /** @hidden */
  38017. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38018. /** @hidden */
  38019. _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;
  38020. /** @hidden */
  38021. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  38022. /** @hidden */
  38023. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38024. /** @hidden */
  38025. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38026. }
  38027. }
  38028. declare module "babylonjs/assetContainer" {
  38029. import { AbstractScene } from "babylonjs/abstractScene";
  38030. import { Scene } from "babylonjs/scene";
  38031. import { Mesh } from "babylonjs/Meshes/mesh";
  38032. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38033. import { Skeleton } from "babylonjs/Bones/skeleton";
  38034. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38035. import { Animatable } from "babylonjs/Animations/animatable";
  38036. import { Nullable } from "babylonjs/types";
  38037. import { Node } from "babylonjs/node";
  38038. /**
  38039. * Set of assets to keep when moving a scene into an asset container.
  38040. */
  38041. export class KeepAssets extends AbstractScene {
  38042. }
  38043. /**
  38044. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  38045. */
  38046. export class InstantiatedEntries {
  38047. /**
  38048. * List of new root nodes (eg. nodes with no parent)
  38049. */
  38050. rootNodes: TransformNode[];
  38051. /**
  38052. * List of new skeletons
  38053. */
  38054. skeletons: Skeleton[];
  38055. /**
  38056. * List of new animation groups
  38057. */
  38058. animationGroups: AnimationGroup[];
  38059. }
  38060. /**
  38061. * Container with a set of assets that can be added or removed from a scene.
  38062. */
  38063. export class AssetContainer extends AbstractScene {
  38064. private _wasAddedToScene;
  38065. /**
  38066. * The scene the AssetContainer belongs to.
  38067. */
  38068. scene: Scene;
  38069. /**
  38070. * Instantiates an AssetContainer.
  38071. * @param scene The scene the AssetContainer belongs to.
  38072. */
  38073. constructor(scene: Scene);
  38074. /**
  38075. * Instantiate or clone all meshes and add the new ones to the scene.
  38076. * Skeletons and animation groups will all be cloned
  38077. * @param nameFunction defines an optional function used to get new names for clones
  38078. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  38079. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  38080. */
  38081. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  38082. /**
  38083. * Adds all the assets from the container to the scene.
  38084. */
  38085. addAllToScene(): void;
  38086. /**
  38087. * Removes all the assets in the container from the scene
  38088. */
  38089. removeAllFromScene(): void;
  38090. /**
  38091. * Disposes all the assets in the container
  38092. */
  38093. dispose(): void;
  38094. private _moveAssets;
  38095. /**
  38096. * Removes all the assets contained in the scene and adds them to the container.
  38097. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  38098. */
  38099. moveAllFromScene(keepAssets?: KeepAssets): void;
  38100. /**
  38101. * 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.
  38102. * @returns the root mesh
  38103. */
  38104. createRootMesh(): Mesh;
  38105. /**
  38106. * Merge animations from this asset container into a scene
  38107. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  38108. * @param animatables set of animatables to retarget to a node from the scene
  38109. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  38110. */
  38111. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  38112. }
  38113. }
  38114. declare module "babylonjs/abstractScene" {
  38115. import { Scene } from "babylonjs/scene";
  38116. import { Nullable } from "babylonjs/types";
  38117. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38118. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38119. import { Geometry } from "babylonjs/Meshes/geometry";
  38120. import { Skeleton } from "babylonjs/Bones/skeleton";
  38121. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  38122. import { AssetContainer } from "babylonjs/assetContainer";
  38123. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  38124. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38125. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38126. import { Material } from "babylonjs/Materials/material";
  38127. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  38128. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  38129. import { Camera } from "babylonjs/Cameras/camera";
  38130. import { Light } from "babylonjs/Lights/light";
  38131. import { Node } from "babylonjs/node";
  38132. import { Animation } from "babylonjs/Animations/animation";
  38133. /**
  38134. * Defines how the parser contract is defined.
  38135. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  38136. */
  38137. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  38138. /**
  38139. * Defines how the individual parser contract is defined.
  38140. * These parser can parse an individual asset
  38141. */
  38142. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  38143. /**
  38144. * Base class of the scene acting as a container for the different elements composing a scene.
  38145. * This class is dynamically extended by the different components of the scene increasing
  38146. * flexibility and reducing coupling
  38147. */
  38148. export abstract class AbstractScene {
  38149. /**
  38150. * Stores the list of available parsers in the application.
  38151. */
  38152. private static _BabylonFileParsers;
  38153. /**
  38154. * Stores the list of available individual parsers in the application.
  38155. */
  38156. private static _IndividualBabylonFileParsers;
  38157. /**
  38158. * Adds a parser in the list of available ones
  38159. * @param name Defines the name of the parser
  38160. * @param parser Defines the parser to add
  38161. */
  38162. static AddParser(name: string, parser: BabylonFileParser): void;
  38163. /**
  38164. * Gets a general parser from the list of avaialble ones
  38165. * @param name Defines the name of the parser
  38166. * @returns the requested parser or null
  38167. */
  38168. static GetParser(name: string): Nullable<BabylonFileParser>;
  38169. /**
  38170. * Adds n individual parser in the list of available ones
  38171. * @param name Defines the name of the parser
  38172. * @param parser Defines the parser to add
  38173. */
  38174. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  38175. /**
  38176. * Gets an individual parser from the list of avaialble ones
  38177. * @param name Defines the name of the parser
  38178. * @returns the requested parser or null
  38179. */
  38180. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  38181. /**
  38182. * Parser json data and populate both a scene and its associated container object
  38183. * @param jsonData Defines the data to parse
  38184. * @param scene Defines the scene to parse the data for
  38185. * @param container Defines the container attached to the parsing sequence
  38186. * @param rootUrl Defines the root url of the data
  38187. */
  38188. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  38189. /**
  38190. * Gets the list of root nodes (ie. nodes with no parent)
  38191. */
  38192. rootNodes: Node[];
  38193. /** All of the cameras added to this scene
  38194. * @see http://doc.babylonjs.com/babylon101/cameras
  38195. */
  38196. cameras: Camera[];
  38197. /**
  38198. * All of the lights added to this scene
  38199. * @see http://doc.babylonjs.com/babylon101/lights
  38200. */
  38201. lights: Light[];
  38202. /**
  38203. * All of the (abstract) meshes added to this scene
  38204. */
  38205. meshes: AbstractMesh[];
  38206. /**
  38207. * The list of skeletons added to the scene
  38208. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  38209. */
  38210. skeletons: Skeleton[];
  38211. /**
  38212. * All of the particle systems added to this scene
  38213. * @see http://doc.babylonjs.com/babylon101/particles
  38214. */
  38215. particleSystems: IParticleSystem[];
  38216. /**
  38217. * Gets a list of Animations associated with the scene
  38218. */
  38219. animations: Animation[];
  38220. /**
  38221. * All of the animation groups added to this scene
  38222. * @see http://doc.babylonjs.com/how_to/group
  38223. */
  38224. animationGroups: AnimationGroup[];
  38225. /**
  38226. * All of the multi-materials added to this scene
  38227. * @see http://doc.babylonjs.com/how_to/multi_materials
  38228. */
  38229. multiMaterials: MultiMaterial[];
  38230. /**
  38231. * All of the materials added to this scene
  38232. * In the context of a Scene, it is not supposed to be modified manually.
  38233. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  38234. * Note also that the order of the Material within the array is not significant and might change.
  38235. * @see http://doc.babylonjs.com/babylon101/materials
  38236. */
  38237. materials: Material[];
  38238. /**
  38239. * The list of morph target managers added to the scene
  38240. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  38241. */
  38242. morphTargetManagers: MorphTargetManager[];
  38243. /**
  38244. * The list of geometries used in the scene.
  38245. */
  38246. geometries: Geometry[];
  38247. /**
  38248. * All of the tranform nodes added to this scene
  38249. * In the context of a Scene, it is not supposed to be modified manually.
  38250. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  38251. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  38252. * @see http://doc.babylonjs.com/how_to/transformnode
  38253. */
  38254. transformNodes: TransformNode[];
  38255. /**
  38256. * ActionManagers available on the scene.
  38257. */
  38258. actionManagers: AbstractActionManager[];
  38259. /**
  38260. * Textures to keep.
  38261. */
  38262. textures: BaseTexture[];
  38263. /**
  38264. * Environment texture for the scene
  38265. */
  38266. environmentTexture: Nullable<BaseTexture>;
  38267. /**
  38268. * @returns all meshes, lights, cameras, transformNodes and bones
  38269. */
  38270. getNodes(): Array<Node>;
  38271. }
  38272. }
  38273. declare module "babylonjs/Audio/sound" {
  38274. import { Observable } from "babylonjs/Misc/observable";
  38275. import { Vector3 } from "babylonjs/Maths/math.vector";
  38276. import { Nullable } from "babylonjs/types";
  38277. import { Scene } from "babylonjs/scene";
  38278. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38279. /**
  38280. * Interface used to define options for Sound class
  38281. */
  38282. export interface ISoundOptions {
  38283. /**
  38284. * Does the sound autoplay once loaded.
  38285. */
  38286. autoplay?: boolean;
  38287. /**
  38288. * Does the sound loop after it finishes playing once.
  38289. */
  38290. loop?: boolean;
  38291. /**
  38292. * Sound's volume
  38293. */
  38294. volume?: number;
  38295. /**
  38296. * Is it a spatial sound?
  38297. */
  38298. spatialSound?: boolean;
  38299. /**
  38300. * Maximum distance to hear that sound
  38301. */
  38302. maxDistance?: number;
  38303. /**
  38304. * Uses user defined attenuation function
  38305. */
  38306. useCustomAttenuation?: boolean;
  38307. /**
  38308. * Define the roll off factor of spatial sounds.
  38309. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38310. */
  38311. rolloffFactor?: number;
  38312. /**
  38313. * Define the reference distance the sound should be heard perfectly.
  38314. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38315. */
  38316. refDistance?: number;
  38317. /**
  38318. * Define the distance attenuation model the sound will follow.
  38319. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38320. */
  38321. distanceModel?: string;
  38322. /**
  38323. * Defines the playback speed (1 by default)
  38324. */
  38325. playbackRate?: number;
  38326. /**
  38327. * Defines if the sound is from a streaming source
  38328. */
  38329. streaming?: boolean;
  38330. /**
  38331. * Defines an optional length (in seconds) inside the sound file
  38332. */
  38333. length?: number;
  38334. /**
  38335. * Defines an optional offset (in seconds) inside the sound file
  38336. */
  38337. offset?: number;
  38338. /**
  38339. * If true, URLs will not be required to state the audio file codec to use.
  38340. */
  38341. skipCodecCheck?: boolean;
  38342. }
  38343. /**
  38344. * Defines a sound that can be played in the application.
  38345. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  38346. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38347. */
  38348. export class Sound {
  38349. /**
  38350. * The name of the sound in the scene.
  38351. */
  38352. name: string;
  38353. /**
  38354. * Does the sound autoplay once loaded.
  38355. */
  38356. autoplay: boolean;
  38357. /**
  38358. * Does the sound loop after it finishes playing once.
  38359. */
  38360. loop: boolean;
  38361. /**
  38362. * Does the sound use a custom attenuation curve to simulate the falloff
  38363. * happening when the source gets further away from the camera.
  38364. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38365. */
  38366. useCustomAttenuation: boolean;
  38367. /**
  38368. * The sound track id this sound belongs to.
  38369. */
  38370. soundTrackId: number;
  38371. /**
  38372. * Is this sound currently played.
  38373. */
  38374. isPlaying: boolean;
  38375. /**
  38376. * Is this sound currently paused.
  38377. */
  38378. isPaused: boolean;
  38379. /**
  38380. * Does this sound enables spatial sound.
  38381. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38382. */
  38383. spatialSound: boolean;
  38384. /**
  38385. * Define the reference distance the sound should be heard perfectly.
  38386. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38387. */
  38388. refDistance: number;
  38389. /**
  38390. * Define the roll off factor of spatial sounds.
  38391. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38392. */
  38393. rolloffFactor: number;
  38394. /**
  38395. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  38396. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38397. */
  38398. maxDistance: number;
  38399. /**
  38400. * Define the distance attenuation model the sound will follow.
  38401. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38402. */
  38403. distanceModel: string;
  38404. /**
  38405. * @hidden
  38406. * Back Compat
  38407. **/
  38408. onended: () => any;
  38409. /**
  38410. * Observable event when the current playing sound finishes.
  38411. */
  38412. onEndedObservable: Observable<Sound>;
  38413. private _panningModel;
  38414. private _playbackRate;
  38415. private _streaming;
  38416. private _startTime;
  38417. private _startOffset;
  38418. private _position;
  38419. /** @hidden */
  38420. _positionInEmitterSpace: boolean;
  38421. private _localDirection;
  38422. private _volume;
  38423. private _isReadyToPlay;
  38424. private _isDirectional;
  38425. private _readyToPlayCallback;
  38426. private _audioBuffer;
  38427. private _soundSource;
  38428. private _streamingSource;
  38429. private _soundPanner;
  38430. private _soundGain;
  38431. private _inputAudioNode;
  38432. private _outputAudioNode;
  38433. private _coneInnerAngle;
  38434. private _coneOuterAngle;
  38435. private _coneOuterGain;
  38436. private _scene;
  38437. private _connectedTransformNode;
  38438. private _customAttenuationFunction;
  38439. private _registerFunc;
  38440. private _isOutputConnected;
  38441. private _htmlAudioElement;
  38442. private _urlType;
  38443. private _length?;
  38444. private _offset?;
  38445. /** @hidden */
  38446. static _SceneComponentInitialization: (scene: Scene) => void;
  38447. /**
  38448. * Create a sound and attach it to a scene
  38449. * @param name Name of your sound
  38450. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  38451. * @param scene defines the scene the sound belongs to
  38452. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  38453. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  38454. */
  38455. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  38456. /**
  38457. * Release the sound and its associated resources
  38458. */
  38459. dispose(): void;
  38460. /**
  38461. * Gets if the sounds is ready to be played or not.
  38462. * @returns true if ready, otherwise false
  38463. */
  38464. isReady(): boolean;
  38465. private _soundLoaded;
  38466. /**
  38467. * Sets the data of the sound from an audiobuffer
  38468. * @param audioBuffer The audioBuffer containing the data
  38469. */
  38470. setAudioBuffer(audioBuffer: AudioBuffer): void;
  38471. /**
  38472. * Updates the current sounds options such as maxdistance, loop...
  38473. * @param options A JSON object containing values named as the object properties
  38474. */
  38475. updateOptions(options: ISoundOptions): void;
  38476. private _createSpatialParameters;
  38477. private _updateSpatialParameters;
  38478. /**
  38479. * Switch the panning model to HRTF:
  38480. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38481. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38482. */
  38483. switchPanningModelToHRTF(): void;
  38484. /**
  38485. * Switch the panning model to Equal Power:
  38486. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38487. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38488. */
  38489. switchPanningModelToEqualPower(): void;
  38490. private _switchPanningModel;
  38491. /**
  38492. * Connect this sound to a sound track audio node like gain...
  38493. * @param soundTrackAudioNode the sound track audio node to connect to
  38494. */
  38495. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  38496. /**
  38497. * Transform this sound into a directional source
  38498. * @param coneInnerAngle Size of the inner cone in degree
  38499. * @param coneOuterAngle Size of the outer cone in degree
  38500. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  38501. */
  38502. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  38503. /**
  38504. * Gets or sets the inner angle for the directional cone.
  38505. */
  38506. get directionalConeInnerAngle(): number;
  38507. /**
  38508. * Gets or sets the inner angle for the directional cone.
  38509. */
  38510. set directionalConeInnerAngle(value: number);
  38511. /**
  38512. * Gets or sets the outer angle for the directional cone.
  38513. */
  38514. get directionalConeOuterAngle(): number;
  38515. /**
  38516. * Gets or sets the outer angle for the directional cone.
  38517. */
  38518. set directionalConeOuterAngle(value: number);
  38519. /**
  38520. * Sets the position of the emitter if spatial sound is enabled
  38521. * @param newPosition Defines the new posisiton
  38522. */
  38523. setPosition(newPosition: Vector3): void;
  38524. /**
  38525. * Sets the local direction of the emitter if spatial sound is enabled
  38526. * @param newLocalDirection Defines the new local direction
  38527. */
  38528. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  38529. private _updateDirection;
  38530. /** @hidden */
  38531. updateDistanceFromListener(): void;
  38532. /**
  38533. * Sets a new custom attenuation function for the sound.
  38534. * @param callback Defines the function used for the attenuation
  38535. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38536. */
  38537. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  38538. /**
  38539. * Play the sound
  38540. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  38541. * @param offset (optional) Start the sound at a specific time in seconds
  38542. * @param length (optional) Sound duration (in seconds)
  38543. */
  38544. play(time?: number, offset?: number, length?: number): void;
  38545. private _onended;
  38546. /**
  38547. * Stop the sound
  38548. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  38549. */
  38550. stop(time?: number): void;
  38551. /**
  38552. * Put the sound in pause
  38553. */
  38554. pause(): void;
  38555. /**
  38556. * Sets a dedicated volume for this sounds
  38557. * @param newVolume Define the new volume of the sound
  38558. * @param time Define time for gradual change to new volume
  38559. */
  38560. setVolume(newVolume: number, time?: number): void;
  38561. /**
  38562. * Set the sound play back rate
  38563. * @param newPlaybackRate Define the playback rate the sound should be played at
  38564. */
  38565. setPlaybackRate(newPlaybackRate: number): void;
  38566. /**
  38567. * Gets the volume of the sound.
  38568. * @returns the volume of the sound
  38569. */
  38570. getVolume(): number;
  38571. /**
  38572. * Attach the sound to a dedicated mesh
  38573. * @param transformNode The transform node to connect the sound with
  38574. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38575. */
  38576. attachToMesh(transformNode: TransformNode): void;
  38577. /**
  38578. * Detach the sound from the previously attached mesh
  38579. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38580. */
  38581. detachFromMesh(): void;
  38582. private _onRegisterAfterWorldMatrixUpdate;
  38583. /**
  38584. * Clone the current sound in the scene.
  38585. * @returns the new sound clone
  38586. */
  38587. clone(): Nullable<Sound>;
  38588. /**
  38589. * Gets the current underlying audio buffer containing the data
  38590. * @returns the audio buffer
  38591. */
  38592. getAudioBuffer(): Nullable<AudioBuffer>;
  38593. /**
  38594. * Serializes the Sound in a JSON representation
  38595. * @returns the JSON representation of the sound
  38596. */
  38597. serialize(): any;
  38598. /**
  38599. * Parse a JSON representation of a sound to innstantiate in a given scene
  38600. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  38601. * @param scene Define the scene the new parsed sound should be created in
  38602. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  38603. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  38604. * @returns the newly parsed sound
  38605. */
  38606. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  38607. }
  38608. }
  38609. declare module "babylonjs/Actions/directAudioActions" {
  38610. import { Action } from "babylonjs/Actions/action";
  38611. import { Condition } from "babylonjs/Actions/condition";
  38612. import { Sound } from "babylonjs/Audio/sound";
  38613. /**
  38614. * This defines an action helpful to play a defined sound on a triggered action.
  38615. */
  38616. export class PlaySoundAction extends Action {
  38617. private _sound;
  38618. /**
  38619. * Instantiate the action
  38620. * @param triggerOptions defines the trigger options
  38621. * @param sound defines the sound to play
  38622. * @param condition defines the trigger related conditions
  38623. */
  38624. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38625. /** @hidden */
  38626. _prepare(): void;
  38627. /**
  38628. * Execute the action and play the sound.
  38629. */
  38630. execute(): void;
  38631. /**
  38632. * Serializes the actions and its related information.
  38633. * @param parent defines the object to serialize in
  38634. * @returns the serialized object
  38635. */
  38636. serialize(parent: any): any;
  38637. }
  38638. /**
  38639. * This defines an action helpful to stop a defined sound on a triggered action.
  38640. */
  38641. export class StopSoundAction extends Action {
  38642. private _sound;
  38643. /**
  38644. * Instantiate the action
  38645. * @param triggerOptions defines the trigger options
  38646. * @param sound defines the sound to stop
  38647. * @param condition defines the trigger related conditions
  38648. */
  38649. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38650. /** @hidden */
  38651. _prepare(): void;
  38652. /**
  38653. * Execute the action and stop the sound.
  38654. */
  38655. execute(): void;
  38656. /**
  38657. * Serializes the actions and its related information.
  38658. * @param parent defines the object to serialize in
  38659. * @returns the serialized object
  38660. */
  38661. serialize(parent: any): any;
  38662. }
  38663. }
  38664. declare module "babylonjs/Actions/interpolateValueAction" {
  38665. import { Action } from "babylonjs/Actions/action";
  38666. import { Condition } from "babylonjs/Actions/condition";
  38667. import { Observable } from "babylonjs/Misc/observable";
  38668. /**
  38669. * This defines an action responsible to change the value of a property
  38670. * by interpolating between its current value and the newly set one once triggered.
  38671. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38672. */
  38673. export class InterpolateValueAction extends Action {
  38674. /**
  38675. * Defines the path of the property where the value should be interpolated
  38676. */
  38677. propertyPath: string;
  38678. /**
  38679. * Defines the target value at the end of the interpolation.
  38680. */
  38681. value: any;
  38682. /**
  38683. * Defines the time it will take for the property to interpolate to the value.
  38684. */
  38685. duration: number;
  38686. /**
  38687. * Defines if the other scene animations should be stopped when the action has been triggered
  38688. */
  38689. stopOtherAnimations?: boolean;
  38690. /**
  38691. * Defines a callback raised once the interpolation animation has been done.
  38692. */
  38693. onInterpolationDone?: () => void;
  38694. /**
  38695. * Observable triggered once the interpolation animation has been done.
  38696. */
  38697. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  38698. private _target;
  38699. private _effectiveTarget;
  38700. private _property;
  38701. /**
  38702. * Instantiate the action
  38703. * @param triggerOptions defines the trigger options
  38704. * @param target defines the object containing the value to interpolate
  38705. * @param propertyPath defines the path to the property in the target object
  38706. * @param value defines the target value at the end of the interpolation
  38707. * @param duration deines the time it will take for the property to interpolate to the value.
  38708. * @param condition defines the trigger related conditions
  38709. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38710. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38711. */
  38712. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38713. /** @hidden */
  38714. _prepare(): void;
  38715. /**
  38716. * Execute the action starts the value interpolation.
  38717. */
  38718. execute(): void;
  38719. /**
  38720. * Serializes the actions and its related information.
  38721. * @param parent defines the object to serialize in
  38722. * @returns the serialized object
  38723. */
  38724. serialize(parent: any): any;
  38725. }
  38726. }
  38727. declare module "babylonjs/Actions/index" {
  38728. export * from "babylonjs/Actions/abstractActionManager";
  38729. export * from "babylonjs/Actions/action";
  38730. export * from "babylonjs/Actions/actionEvent";
  38731. export * from "babylonjs/Actions/actionManager";
  38732. export * from "babylonjs/Actions/condition";
  38733. export * from "babylonjs/Actions/directActions";
  38734. export * from "babylonjs/Actions/directAudioActions";
  38735. export * from "babylonjs/Actions/interpolateValueAction";
  38736. }
  38737. declare module "babylonjs/Animations/index" {
  38738. export * from "babylonjs/Animations/animatable";
  38739. export * from "babylonjs/Animations/animation";
  38740. export * from "babylonjs/Animations/animationGroup";
  38741. export * from "babylonjs/Animations/animationPropertiesOverride";
  38742. export * from "babylonjs/Animations/easing";
  38743. export * from "babylonjs/Animations/runtimeAnimation";
  38744. export * from "babylonjs/Animations/animationEvent";
  38745. export * from "babylonjs/Animations/animationGroup";
  38746. export * from "babylonjs/Animations/animationKey";
  38747. export * from "babylonjs/Animations/animationRange";
  38748. export * from "babylonjs/Animations/animatable.interface";
  38749. }
  38750. declare module "babylonjs/Audio/soundTrack" {
  38751. import { Sound } from "babylonjs/Audio/sound";
  38752. import { Analyser } from "babylonjs/Audio/analyser";
  38753. import { Scene } from "babylonjs/scene";
  38754. /**
  38755. * Options allowed during the creation of a sound track.
  38756. */
  38757. export interface ISoundTrackOptions {
  38758. /**
  38759. * The volume the sound track should take during creation
  38760. */
  38761. volume?: number;
  38762. /**
  38763. * Define if the sound track is the main sound track of the scene
  38764. */
  38765. mainTrack?: boolean;
  38766. }
  38767. /**
  38768. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38769. * It will be also used in a future release to apply effects on a specific track.
  38770. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38771. */
  38772. export class SoundTrack {
  38773. /**
  38774. * The unique identifier of the sound track in the scene.
  38775. */
  38776. id: number;
  38777. /**
  38778. * The list of sounds included in the sound track.
  38779. */
  38780. soundCollection: Array<Sound>;
  38781. private _outputAudioNode;
  38782. private _scene;
  38783. private _connectedAnalyser;
  38784. private _options;
  38785. private _isInitialized;
  38786. /**
  38787. * Creates a new sound track.
  38788. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38789. * @param scene Define the scene the sound track belongs to
  38790. * @param options
  38791. */
  38792. constructor(scene: Scene, options?: ISoundTrackOptions);
  38793. private _initializeSoundTrackAudioGraph;
  38794. /**
  38795. * Release the sound track and its associated resources
  38796. */
  38797. dispose(): void;
  38798. /**
  38799. * Adds a sound to this sound track
  38800. * @param sound define the cound to add
  38801. * @ignoreNaming
  38802. */
  38803. AddSound(sound: Sound): void;
  38804. /**
  38805. * Removes a sound to this sound track
  38806. * @param sound define the cound to remove
  38807. * @ignoreNaming
  38808. */
  38809. RemoveSound(sound: Sound): void;
  38810. /**
  38811. * Set a global volume for the full sound track.
  38812. * @param newVolume Define the new volume of the sound track
  38813. */
  38814. setVolume(newVolume: number): void;
  38815. /**
  38816. * Switch the panning model to HRTF:
  38817. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38818. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38819. */
  38820. switchPanningModelToHRTF(): void;
  38821. /**
  38822. * Switch the panning model to Equal Power:
  38823. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38824. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38825. */
  38826. switchPanningModelToEqualPower(): void;
  38827. /**
  38828. * Connect the sound track to an audio analyser allowing some amazing
  38829. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38830. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38831. * @param analyser The analyser to connect to the engine
  38832. */
  38833. connectToAnalyser(analyser: Analyser): void;
  38834. }
  38835. }
  38836. declare module "babylonjs/Audio/audioSceneComponent" {
  38837. import { Sound } from "babylonjs/Audio/sound";
  38838. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  38839. import { Nullable } from "babylonjs/types";
  38840. import { Vector3 } from "babylonjs/Maths/math.vector";
  38841. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  38842. import { Scene } from "babylonjs/scene";
  38843. import { AbstractScene } from "babylonjs/abstractScene";
  38844. import "babylonjs/Audio/audioEngine";
  38845. module "babylonjs/abstractScene" {
  38846. interface AbstractScene {
  38847. /**
  38848. * The list of sounds used in the scene.
  38849. */
  38850. sounds: Nullable<Array<Sound>>;
  38851. }
  38852. }
  38853. module "babylonjs/scene" {
  38854. interface Scene {
  38855. /**
  38856. * @hidden
  38857. * Backing field
  38858. */
  38859. _mainSoundTrack: SoundTrack;
  38860. /**
  38861. * The main sound track played by the scene.
  38862. * It cotains your primary collection of sounds.
  38863. */
  38864. mainSoundTrack: SoundTrack;
  38865. /**
  38866. * The list of sound tracks added to the scene
  38867. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38868. */
  38869. soundTracks: Nullable<Array<SoundTrack>>;
  38870. /**
  38871. * Gets a sound using a given name
  38872. * @param name defines the name to search for
  38873. * @return the found sound or null if not found at all.
  38874. */
  38875. getSoundByName(name: string): Nullable<Sound>;
  38876. /**
  38877. * Gets or sets if audio support is enabled
  38878. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38879. */
  38880. audioEnabled: boolean;
  38881. /**
  38882. * Gets or sets if audio will be output to headphones
  38883. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38884. */
  38885. headphone: boolean;
  38886. /**
  38887. * Gets or sets custom audio listener position provider
  38888. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38889. */
  38890. audioListenerPositionProvider: Nullable<() => Vector3>;
  38891. /**
  38892. * Gets or sets a refresh rate when using 3D audio positioning
  38893. */
  38894. audioPositioningRefreshRate: number;
  38895. }
  38896. }
  38897. /**
  38898. * Defines the sound scene component responsible to manage any sounds
  38899. * in a given scene.
  38900. */
  38901. export class AudioSceneComponent implements ISceneSerializableComponent {
  38902. /**
  38903. * The component name helpfull to identify the component in the list of scene components.
  38904. */
  38905. readonly name: string;
  38906. /**
  38907. * The scene the component belongs to.
  38908. */
  38909. scene: Scene;
  38910. private _audioEnabled;
  38911. /**
  38912. * Gets whether audio is enabled or not.
  38913. * Please use related enable/disable method to switch state.
  38914. */
  38915. get audioEnabled(): boolean;
  38916. private _headphone;
  38917. /**
  38918. * Gets whether audio is outputing to headphone or not.
  38919. * Please use the according Switch methods to change output.
  38920. */
  38921. get headphone(): boolean;
  38922. /**
  38923. * Gets or sets a refresh rate when using 3D audio positioning
  38924. */
  38925. audioPositioningRefreshRate: number;
  38926. private _audioListenerPositionProvider;
  38927. /**
  38928. * Gets the current audio listener position provider
  38929. */
  38930. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38931. /**
  38932. * Sets a custom listener position for all sounds in the scene
  38933. * By default, this is the position of the first active camera
  38934. */
  38935. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38936. /**
  38937. * Creates a new instance of the component for the given scene
  38938. * @param scene Defines the scene to register the component in
  38939. */
  38940. constructor(scene: Scene);
  38941. /**
  38942. * Registers the component in a given scene
  38943. */
  38944. register(): void;
  38945. /**
  38946. * Rebuilds the elements related to this component in case of
  38947. * context lost for instance.
  38948. */
  38949. rebuild(): void;
  38950. /**
  38951. * Serializes the component data to the specified json object
  38952. * @param serializationObject The object to serialize to
  38953. */
  38954. serialize(serializationObject: any): void;
  38955. /**
  38956. * Adds all the elements from the container to the scene
  38957. * @param container the container holding the elements
  38958. */
  38959. addFromContainer(container: AbstractScene): void;
  38960. /**
  38961. * Removes all the elements in the container from the scene
  38962. * @param container contains the elements to remove
  38963. * @param dispose if the removed element should be disposed (default: false)
  38964. */
  38965. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38966. /**
  38967. * Disposes the component and the associated ressources.
  38968. */
  38969. dispose(): void;
  38970. /**
  38971. * Disables audio in the associated scene.
  38972. */
  38973. disableAudio(): void;
  38974. /**
  38975. * Enables audio in the associated scene.
  38976. */
  38977. enableAudio(): void;
  38978. /**
  38979. * Switch audio to headphone output.
  38980. */
  38981. switchAudioModeForHeadphones(): void;
  38982. /**
  38983. * Switch audio to normal speakers.
  38984. */
  38985. switchAudioModeForNormalSpeakers(): void;
  38986. private _cachedCameraDirection;
  38987. private _cachedCameraPosition;
  38988. private _lastCheck;
  38989. private _afterRender;
  38990. }
  38991. }
  38992. declare module "babylonjs/Audio/weightedsound" {
  38993. import { Sound } from "babylonjs/Audio/sound";
  38994. /**
  38995. * Wraps one or more Sound objects and selects one with random weight for playback.
  38996. */
  38997. export class WeightedSound {
  38998. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38999. loop: boolean;
  39000. private _coneInnerAngle;
  39001. private _coneOuterAngle;
  39002. private _volume;
  39003. /** A Sound is currently playing. */
  39004. isPlaying: boolean;
  39005. /** A Sound is currently paused. */
  39006. isPaused: boolean;
  39007. private _sounds;
  39008. private _weights;
  39009. private _currentIndex?;
  39010. /**
  39011. * Creates a new WeightedSound from the list of sounds given.
  39012. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  39013. * @param sounds Array of Sounds that will be selected from.
  39014. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  39015. */
  39016. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  39017. /**
  39018. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  39019. */
  39020. get directionalConeInnerAngle(): number;
  39021. /**
  39022. * The size of cone in degress for a directional sound in which there will be no attenuation.
  39023. */
  39024. set directionalConeInnerAngle(value: number);
  39025. /**
  39026. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39027. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39028. */
  39029. get directionalConeOuterAngle(): number;
  39030. /**
  39031. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39032. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39033. */
  39034. set directionalConeOuterAngle(value: number);
  39035. /**
  39036. * Playback volume.
  39037. */
  39038. get volume(): number;
  39039. /**
  39040. * Playback volume.
  39041. */
  39042. set volume(value: number);
  39043. private _onended;
  39044. /**
  39045. * Suspend playback
  39046. */
  39047. pause(): void;
  39048. /**
  39049. * Stop playback
  39050. */
  39051. stop(): void;
  39052. /**
  39053. * Start playback.
  39054. * @param startOffset Position the clip head at a specific time in seconds.
  39055. */
  39056. play(startOffset?: number): void;
  39057. }
  39058. }
  39059. declare module "babylonjs/Audio/index" {
  39060. export * from "babylonjs/Audio/analyser";
  39061. export * from "babylonjs/Audio/audioEngine";
  39062. export * from "babylonjs/Audio/audioSceneComponent";
  39063. export * from "babylonjs/Audio/sound";
  39064. export * from "babylonjs/Audio/soundTrack";
  39065. export * from "babylonjs/Audio/weightedsound";
  39066. }
  39067. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  39068. import { Behavior } from "babylonjs/Behaviors/behavior";
  39069. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39070. import { BackEase } from "babylonjs/Animations/easing";
  39071. /**
  39072. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  39073. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39074. */
  39075. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  39076. /**
  39077. * Gets the name of the behavior.
  39078. */
  39079. get name(): string;
  39080. /**
  39081. * The easing function used by animations
  39082. */
  39083. static EasingFunction: BackEase;
  39084. /**
  39085. * The easing mode used by animations
  39086. */
  39087. static EasingMode: number;
  39088. /**
  39089. * The duration of the animation, in milliseconds
  39090. */
  39091. transitionDuration: number;
  39092. /**
  39093. * Length of the distance animated by the transition when lower radius is reached
  39094. */
  39095. lowerRadiusTransitionRange: number;
  39096. /**
  39097. * Length of the distance animated by the transition when upper radius is reached
  39098. */
  39099. upperRadiusTransitionRange: number;
  39100. private _autoTransitionRange;
  39101. /**
  39102. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39103. */
  39104. get autoTransitionRange(): boolean;
  39105. /**
  39106. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39107. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  39108. */
  39109. set autoTransitionRange(value: boolean);
  39110. private _attachedCamera;
  39111. private _onAfterCheckInputsObserver;
  39112. private _onMeshTargetChangedObserver;
  39113. /**
  39114. * Initializes the behavior.
  39115. */
  39116. init(): void;
  39117. /**
  39118. * Attaches the behavior to its arc rotate camera.
  39119. * @param camera Defines the camera to attach the behavior to
  39120. */
  39121. attach(camera: ArcRotateCamera): void;
  39122. /**
  39123. * Detaches the behavior from its current arc rotate camera.
  39124. */
  39125. detach(): void;
  39126. private _radiusIsAnimating;
  39127. private _radiusBounceTransition;
  39128. private _animatables;
  39129. private _cachedWheelPrecision;
  39130. /**
  39131. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  39132. * @param radiusLimit The limit to check against.
  39133. * @return Bool to indicate if at limit.
  39134. */
  39135. private _isRadiusAtLimit;
  39136. /**
  39137. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  39138. * @param radiusDelta The delta by which to animate to. Can be negative.
  39139. */
  39140. private _applyBoundRadiusAnimation;
  39141. /**
  39142. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  39143. */
  39144. protected _clearAnimationLocks(): void;
  39145. /**
  39146. * Stops and removes all animations that have been applied to the camera
  39147. */
  39148. stopAllAnimations(): void;
  39149. }
  39150. }
  39151. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  39152. import { Behavior } from "babylonjs/Behaviors/behavior";
  39153. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39154. import { ExponentialEase } from "babylonjs/Animations/easing";
  39155. import { Nullable } from "babylonjs/types";
  39156. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39157. import { Vector3 } from "babylonjs/Maths/math.vector";
  39158. /**
  39159. * 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.
  39160. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39161. */
  39162. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  39163. /**
  39164. * Gets the name of the behavior.
  39165. */
  39166. get name(): string;
  39167. private _mode;
  39168. private _radiusScale;
  39169. private _positionScale;
  39170. private _defaultElevation;
  39171. private _elevationReturnTime;
  39172. private _elevationReturnWaitTime;
  39173. private _zoomStopsAnimation;
  39174. private _framingTime;
  39175. /**
  39176. * The easing function used by animations
  39177. */
  39178. static EasingFunction: ExponentialEase;
  39179. /**
  39180. * The easing mode used by animations
  39181. */
  39182. static EasingMode: number;
  39183. /**
  39184. * Sets the current mode used by the behavior
  39185. */
  39186. set mode(mode: number);
  39187. /**
  39188. * Gets current mode used by the behavior.
  39189. */
  39190. get mode(): number;
  39191. /**
  39192. * Sets the scale applied to the radius (1 by default)
  39193. */
  39194. set radiusScale(radius: number);
  39195. /**
  39196. * Gets the scale applied to the radius
  39197. */
  39198. get radiusScale(): number;
  39199. /**
  39200. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39201. */
  39202. set positionScale(scale: number);
  39203. /**
  39204. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39205. */
  39206. get positionScale(): number;
  39207. /**
  39208. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39209. * behaviour is triggered, in radians.
  39210. */
  39211. set defaultElevation(elevation: number);
  39212. /**
  39213. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39214. * behaviour is triggered, in radians.
  39215. */
  39216. get defaultElevation(): number;
  39217. /**
  39218. * Sets the time (in milliseconds) taken to return to the default beta position.
  39219. * Negative value indicates camera should not return to default.
  39220. */
  39221. set elevationReturnTime(speed: number);
  39222. /**
  39223. * Gets the time (in milliseconds) taken to return to the default beta position.
  39224. * Negative value indicates camera should not return to default.
  39225. */
  39226. get elevationReturnTime(): number;
  39227. /**
  39228. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39229. */
  39230. set elevationReturnWaitTime(time: number);
  39231. /**
  39232. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39233. */
  39234. get elevationReturnWaitTime(): number;
  39235. /**
  39236. * Sets the flag that indicates if user zooming should stop animation.
  39237. */
  39238. set zoomStopsAnimation(flag: boolean);
  39239. /**
  39240. * Gets the flag that indicates if user zooming should stop animation.
  39241. */
  39242. get zoomStopsAnimation(): boolean;
  39243. /**
  39244. * Sets the transition time when framing the mesh, in milliseconds
  39245. */
  39246. set framingTime(time: number);
  39247. /**
  39248. * Gets the transition time when framing the mesh, in milliseconds
  39249. */
  39250. get framingTime(): number;
  39251. /**
  39252. * Define if the behavior should automatically change the configured
  39253. * camera limits and sensibilities.
  39254. */
  39255. autoCorrectCameraLimitsAndSensibility: boolean;
  39256. private _onPrePointerObservableObserver;
  39257. private _onAfterCheckInputsObserver;
  39258. private _onMeshTargetChangedObserver;
  39259. private _attachedCamera;
  39260. private _isPointerDown;
  39261. private _lastInteractionTime;
  39262. /**
  39263. * Initializes the behavior.
  39264. */
  39265. init(): void;
  39266. /**
  39267. * Attaches the behavior to its arc rotate camera.
  39268. * @param camera Defines the camera to attach the behavior to
  39269. */
  39270. attach(camera: ArcRotateCamera): void;
  39271. /**
  39272. * Detaches the behavior from its current arc rotate camera.
  39273. */
  39274. detach(): void;
  39275. private _animatables;
  39276. private _betaIsAnimating;
  39277. private _betaTransition;
  39278. private _radiusTransition;
  39279. private _vectorTransition;
  39280. /**
  39281. * Targets the given mesh and updates zoom level accordingly.
  39282. * @param mesh The mesh to target.
  39283. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39284. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39285. */
  39286. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39287. /**
  39288. * Targets the given mesh with its children and updates zoom level accordingly.
  39289. * @param mesh The mesh to target.
  39290. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39291. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39292. */
  39293. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39294. /**
  39295. * Targets the given meshes with their children and updates zoom level accordingly.
  39296. * @param meshes The mesh to target.
  39297. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39298. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39299. */
  39300. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39301. /**
  39302. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  39303. * @param minimumWorld Determines the smaller position of the bounding box extend
  39304. * @param maximumWorld Determines the bigger position of the bounding box extend
  39305. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39306. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39307. */
  39308. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39309. /**
  39310. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  39311. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  39312. * frustum width.
  39313. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  39314. * to fully enclose the mesh in the viewing frustum.
  39315. */
  39316. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  39317. /**
  39318. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  39319. * is automatically returned to its default position (expected to be above ground plane).
  39320. */
  39321. private _maintainCameraAboveGround;
  39322. /**
  39323. * Returns the frustum slope based on the canvas ratio and camera FOV
  39324. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  39325. */
  39326. private _getFrustumSlope;
  39327. /**
  39328. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  39329. */
  39330. private _clearAnimationLocks;
  39331. /**
  39332. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39333. */
  39334. private _applyUserInteraction;
  39335. /**
  39336. * Stops and removes all animations that have been applied to the camera
  39337. */
  39338. stopAllAnimations(): void;
  39339. /**
  39340. * Gets a value indicating if the user is moving the camera
  39341. */
  39342. get isUserIsMoving(): boolean;
  39343. /**
  39344. * The camera can move all the way towards the mesh.
  39345. */
  39346. static IgnoreBoundsSizeMode: number;
  39347. /**
  39348. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  39349. */
  39350. static FitFrustumSidesMode: number;
  39351. }
  39352. }
  39353. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  39354. import { Nullable } from "babylonjs/types";
  39355. import { Camera } from "babylonjs/Cameras/camera";
  39356. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39357. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39358. /**
  39359. * Base class for Camera Pointer Inputs.
  39360. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  39361. * for example usage.
  39362. */
  39363. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  39364. /**
  39365. * Defines the camera the input is attached to.
  39366. */
  39367. abstract camera: Camera;
  39368. /**
  39369. * Whether keyboard modifier keys are pressed at time of last mouse event.
  39370. */
  39371. protected _altKey: boolean;
  39372. protected _ctrlKey: boolean;
  39373. protected _metaKey: boolean;
  39374. protected _shiftKey: boolean;
  39375. /**
  39376. * Which mouse buttons were pressed at time of last mouse event.
  39377. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  39378. */
  39379. protected _buttonsPressed: number;
  39380. /**
  39381. * Defines the buttons associated with the input to handle camera move.
  39382. */
  39383. buttons: number[];
  39384. /**
  39385. * Attach the input controls to a specific dom element to get the input from.
  39386. * @param element Defines the element the controls should be listened from
  39387. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39388. */
  39389. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39390. /**
  39391. * Detach the current controls from the specified dom element.
  39392. * @param element Defines the element to stop listening the inputs from
  39393. */
  39394. detachControl(element: Nullable<HTMLElement>): void;
  39395. /**
  39396. * Gets the class name of the current input.
  39397. * @returns the class name
  39398. */
  39399. getClassName(): string;
  39400. /**
  39401. * Get the friendly name associated with the input class.
  39402. * @returns the input friendly name
  39403. */
  39404. getSimpleName(): string;
  39405. /**
  39406. * Called on pointer POINTERDOUBLETAP event.
  39407. * Override this method to provide functionality on POINTERDOUBLETAP event.
  39408. */
  39409. protected onDoubleTap(type: string): void;
  39410. /**
  39411. * Called on pointer POINTERMOVE event if only a single touch is active.
  39412. * Override this method to provide functionality.
  39413. */
  39414. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39415. /**
  39416. * Called on pointer POINTERMOVE event if multiple touches are active.
  39417. * Override this method to provide functionality.
  39418. */
  39419. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39420. /**
  39421. * Called on JS contextmenu event.
  39422. * Override this method to provide functionality.
  39423. */
  39424. protected onContextMenu(evt: PointerEvent): void;
  39425. /**
  39426. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39427. * press.
  39428. * Override this method to provide functionality.
  39429. */
  39430. protected onButtonDown(evt: PointerEvent): void;
  39431. /**
  39432. * Called each time a new POINTERUP event occurs. Ie, for each button
  39433. * release.
  39434. * Override this method to provide functionality.
  39435. */
  39436. protected onButtonUp(evt: PointerEvent): void;
  39437. /**
  39438. * Called when window becomes inactive.
  39439. * Override this method to provide functionality.
  39440. */
  39441. protected onLostFocus(): void;
  39442. private _pointerInput;
  39443. private _observer;
  39444. private _onLostFocus;
  39445. private pointA;
  39446. private pointB;
  39447. }
  39448. }
  39449. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  39450. import { Nullable } from "babylonjs/types";
  39451. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39452. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39453. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39454. /**
  39455. * Manage the pointers inputs to control an arc rotate camera.
  39456. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39457. */
  39458. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  39459. /**
  39460. * Defines the camera the input is attached to.
  39461. */
  39462. camera: ArcRotateCamera;
  39463. /**
  39464. * Gets the class name of the current input.
  39465. * @returns the class name
  39466. */
  39467. getClassName(): string;
  39468. /**
  39469. * Defines the buttons associated with the input to handle camera move.
  39470. */
  39471. buttons: number[];
  39472. /**
  39473. * Defines the pointer angular sensibility along the X axis or how fast is
  39474. * the camera rotating.
  39475. */
  39476. angularSensibilityX: number;
  39477. /**
  39478. * Defines the pointer angular sensibility along the Y axis or how fast is
  39479. * the camera rotating.
  39480. */
  39481. angularSensibilityY: number;
  39482. /**
  39483. * Defines the pointer pinch precision or how fast is the camera zooming.
  39484. */
  39485. pinchPrecision: number;
  39486. /**
  39487. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39488. * from 0.
  39489. * It defines the percentage of current camera.radius to use as delta when
  39490. * pinch zoom is used.
  39491. */
  39492. pinchDeltaPercentage: number;
  39493. /**
  39494. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39495. * that any object in the plane at the camera's target point will scale
  39496. * perfectly with finger motion.
  39497. * Overrides pinchDeltaPercentage and pinchPrecision.
  39498. */
  39499. useNaturalPinchZoom: boolean;
  39500. /**
  39501. * Defines the pointer panning sensibility or how fast is the camera moving.
  39502. */
  39503. panningSensibility: number;
  39504. /**
  39505. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  39506. */
  39507. multiTouchPanning: boolean;
  39508. /**
  39509. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  39510. * zoom (pinch) through multitouch.
  39511. */
  39512. multiTouchPanAndZoom: boolean;
  39513. /**
  39514. * Revers pinch action direction.
  39515. */
  39516. pinchInwards: boolean;
  39517. private _isPanClick;
  39518. private _twoFingerActivityCount;
  39519. private _isPinching;
  39520. /**
  39521. * Called on pointer POINTERMOVE event if only a single touch is active.
  39522. */
  39523. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39524. /**
  39525. * Called on pointer POINTERDOUBLETAP event.
  39526. */
  39527. protected onDoubleTap(type: string): void;
  39528. /**
  39529. * Called on pointer POINTERMOVE event if multiple touches are active.
  39530. */
  39531. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39532. /**
  39533. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39534. * press.
  39535. */
  39536. protected onButtonDown(evt: PointerEvent): void;
  39537. /**
  39538. * Called each time a new POINTERUP event occurs. Ie, for each button
  39539. * release.
  39540. */
  39541. protected onButtonUp(evt: PointerEvent): void;
  39542. /**
  39543. * Called when window becomes inactive.
  39544. */
  39545. protected onLostFocus(): void;
  39546. }
  39547. }
  39548. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  39549. import { Nullable } from "babylonjs/types";
  39550. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39551. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39552. /**
  39553. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  39554. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39555. */
  39556. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  39557. /**
  39558. * Defines the camera the input is attached to.
  39559. */
  39560. camera: ArcRotateCamera;
  39561. /**
  39562. * Defines the list of key codes associated with the up action (increase alpha)
  39563. */
  39564. keysUp: number[];
  39565. /**
  39566. * Defines the list of key codes associated with the down action (decrease alpha)
  39567. */
  39568. keysDown: number[];
  39569. /**
  39570. * Defines the list of key codes associated with the left action (increase beta)
  39571. */
  39572. keysLeft: number[];
  39573. /**
  39574. * Defines the list of key codes associated with the right action (decrease beta)
  39575. */
  39576. keysRight: number[];
  39577. /**
  39578. * Defines the list of key codes associated with the reset action.
  39579. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  39580. */
  39581. keysReset: number[];
  39582. /**
  39583. * Defines the panning sensibility of the inputs.
  39584. * (How fast is the camera panning)
  39585. */
  39586. panningSensibility: number;
  39587. /**
  39588. * Defines the zooming sensibility of the inputs.
  39589. * (How fast is the camera zooming)
  39590. */
  39591. zoomingSensibility: number;
  39592. /**
  39593. * Defines whether maintaining the alt key down switch the movement mode from
  39594. * orientation to zoom.
  39595. */
  39596. useAltToZoom: boolean;
  39597. /**
  39598. * Rotation speed of the camera
  39599. */
  39600. angularSpeed: number;
  39601. private _keys;
  39602. private _ctrlPressed;
  39603. private _altPressed;
  39604. private _onCanvasBlurObserver;
  39605. private _onKeyboardObserver;
  39606. private _engine;
  39607. private _scene;
  39608. /**
  39609. * Attach the input controls to a specific dom element to get the input from.
  39610. * @param element Defines the element the controls should be listened from
  39611. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39612. */
  39613. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39614. /**
  39615. * Detach the current controls from the specified dom element.
  39616. * @param element Defines the element to stop listening the inputs from
  39617. */
  39618. detachControl(element: Nullable<HTMLElement>): void;
  39619. /**
  39620. * Update the current camera state depending on the inputs that have been used this frame.
  39621. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39622. */
  39623. checkInputs(): void;
  39624. /**
  39625. * Gets the class name of the current intput.
  39626. * @returns the class name
  39627. */
  39628. getClassName(): string;
  39629. /**
  39630. * Get the friendly name associated with the input class.
  39631. * @returns the input friendly name
  39632. */
  39633. getSimpleName(): string;
  39634. }
  39635. }
  39636. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  39637. import { Nullable } from "babylonjs/types";
  39638. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39639. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39640. /**
  39641. * Manage the mouse wheel inputs to control an arc rotate camera.
  39642. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39643. */
  39644. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  39645. /**
  39646. * Defines the camera the input is attached to.
  39647. */
  39648. camera: ArcRotateCamera;
  39649. /**
  39650. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39651. */
  39652. wheelPrecision: number;
  39653. /**
  39654. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39655. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39656. */
  39657. wheelDeltaPercentage: number;
  39658. private _wheel;
  39659. private _observer;
  39660. private computeDeltaFromMouseWheelLegacyEvent;
  39661. /**
  39662. * Attach the input controls to a specific dom element to get the input from.
  39663. * @param element Defines the element the controls should be listened from
  39664. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39665. */
  39666. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39667. /**
  39668. * Detach the current controls from the specified dom element.
  39669. * @param element Defines the element to stop listening the inputs from
  39670. */
  39671. detachControl(element: Nullable<HTMLElement>): void;
  39672. /**
  39673. * Gets the class name of the current intput.
  39674. * @returns the class name
  39675. */
  39676. getClassName(): string;
  39677. /**
  39678. * Get the friendly name associated with the input class.
  39679. * @returns the input friendly name
  39680. */
  39681. getSimpleName(): string;
  39682. }
  39683. }
  39684. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39685. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39686. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39687. /**
  39688. * Default Inputs manager for the ArcRotateCamera.
  39689. * It groups all the default supported inputs for ease of use.
  39690. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39691. */
  39692. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  39693. /**
  39694. * Instantiates a new ArcRotateCameraInputsManager.
  39695. * @param camera Defines the camera the inputs belong to
  39696. */
  39697. constructor(camera: ArcRotateCamera);
  39698. /**
  39699. * Add mouse wheel input support to the input manager.
  39700. * @returns the current input manager
  39701. */
  39702. addMouseWheel(): ArcRotateCameraInputsManager;
  39703. /**
  39704. * Add pointers input support to the input manager.
  39705. * @returns the current input manager
  39706. */
  39707. addPointers(): ArcRotateCameraInputsManager;
  39708. /**
  39709. * Add keyboard input support to the input manager.
  39710. * @returns the current input manager
  39711. */
  39712. addKeyboard(): ArcRotateCameraInputsManager;
  39713. }
  39714. }
  39715. declare module "babylonjs/Cameras/arcRotateCamera" {
  39716. import { Observable } from "babylonjs/Misc/observable";
  39717. import { Nullable } from "babylonjs/types";
  39718. import { Scene } from "babylonjs/scene";
  39719. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  39720. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39721. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39722. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39723. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  39724. import { Camera } from "babylonjs/Cameras/camera";
  39725. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39726. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  39727. import { Collider } from "babylonjs/Collisions/collider";
  39728. /**
  39729. * This represents an orbital type of camera.
  39730. *
  39731. * 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.
  39732. * 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.
  39733. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39734. */
  39735. export class ArcRotateCamera extends TargetCamera {
  39736. /**
  39737. * Defines the rotation angle of the camera along the longitudinal axis.
  39738. */
  39739. alpha: number;
  39740. /**
  39741. * Defines the rotation angle of the camera along the latitudinal axis.
  39742. */
  39743. beta: number;
  39744. /**
  39745. * Defines the radius of the camera from it s target point.
  39746. */
  39747. radius: number;
  39748. protected _target: Vector3;
  39749. protected _targetHost: Nullable<AbstractMesh>;
  39750. /**
  39751. * Defines the target point of the camera.
  39752. * The camera looks towards it form the radius distance.
  39753. */
  39754. get target(): Vector3;
  39755. set target(value: Vector3);
  39756. /**
  39757. * Define the current local position of the camera in the scene
  39758. */
  39759. get position(): Vector3;
  39760. set position(newPosition: Vector3);
  39761. protected _upVector: Vector3;
  39762. protected _upToYMatrix: Matrix;
  39763. protected _YToUpMatrix: Matrix;
  39764. /**
  39765. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39766. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39767. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39768. */
  39769. set upVector(vec: Vector3);
  39770. get upVector(): Vector3;
  39771. /**
  39772. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39773. */
  39774. setMatUp(): void;
  39775. /**
  39776. * Current inertia value on the longitudinal axis.
  39777. * The bigger this number the longer it will take for the camera to stop.
  39778. */
  39779. inertialAlphaOffset: number;
  39780. /**
  39781. * Current inertia value on the latitudinal axis.
  39782. * The bigger this number the longer it will take for the camera to stop.
  39783. */
  39784. inertialBetaOffset: number;
  39785. /**
  39786. * Current inertia value on the radius axis.
  39787. * The bigger this number the longer it will take for the camera to stop.
  39788. */
  39789. inertialRadiusOffset: number;
  39790. /**
  39791. * Minimum allowed angle on the longitudinal axis.
  39792. * This can help limiting how the Camera is able to move in the scene.
  39793. */
  39794. lowerAlphaLimit: Nullable<number>;
  39795. /**
  39796. * Maximum allowed angle on the longitudinal axis.
  39797. * This can help limiting how the Camera is able to move in the scene.
  39798. */
  39799. upperAlphaLimit: Nullable<number>;
  39800. /**
  39801. * Minimum allowed angle on the latitudinal axis.
  39802. * This can help limiting how the Camera is able to move in the scene.
  39803. */
  39804. lowerBetaLimit: number;
  39805. /**
  39806. * Maximum allowed angle on the latitudinal axis.
  39807. * This can help limiting how the Camera is able to move in the scene.
  39808. */
  39809. upperBetaLimit: number;
  39810. /**
  39811. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39812. * This can help limiting how the Camera is able to move in the scene.
  39813. */
  39814. lowerRadiusLimit: Nullable<number>;
  39815. /**
  39816. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39817. * This can help limiting how the Camera is able to move in the scene.
  39818. */
  39819. upperRadiusLimit: Nullable<number>;
  39820. /**
  39821. * Defines the current inertia value used during panning of the camera along the X axis.
  39822. */
  39823. inertialPanningX: number;
  39824. /**
  39825. * Defines the current inertia value used during panning of the camera along the Y axis.
  39826. */
  39827. inertialPanningY: number;
  39828. /**
  39829. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39830. * Basically if your fingers moves away from more than this distance you will be considered
  39831. * in pinch mode.
  39832. */
  39833. pinchToPanMaxDistance: number;
  39834. /**
  39835. * Defines the maximum distance the camera can pan.
  39836. * This could help keeping the cammera always in your scene.
  39837. */
  39838. panningDistanceLimit: Nullable<number>;
  39839. /**
  39840. * Defines the target of the camera before paning.
  39841. */
  39842. panningOriginTarget: Vector3;
  39843. /**
  39844. * Defines the value of the inertia used during panning.
  39845. * 0 would mean stop inertia and one would mean no decelleration at all.
  39846. */
  39847. panningInertia: number;
  39848. /**
  39849. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39850. */
  39851. get angularSensibilityX(): number;
  39852. set angularSensibilityX(value: number);
  39853. /**
  39854. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39855. */
  39856. get angularSensibilityY(): number;
  39857. set angularSensibilityY(value: number);
  39858. /**
  39859. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39860. */
  39861. get pinchPrecision(): number;
  39862. set pinchPrecision(value: number);
  39863. /**
  39864. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39865. * It will be used instead of pinchDeltaPrecision if different from 0.
  39866. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39867. */
  39868. get pinchDeltaPercentage(): number;
  39869. set pinchDeltaPercentage(value: number);
  39870. /**
  39871. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  39872. * and pinch delta percentage.
  39873. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39874. * that any object in the plane at the camera's target point will scale
  39875. * perfectly with finger motion.
  39876. */
  39877. get useNaturalPinchZoom(): boolean;
  39878. set useNaturalPinchZoom(value: boolean);
  39879. /**
  39880. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39881. */
  39882. get panningSensibility(): number;
  39883. set panningSensibility(value: number);
  39884. /**
  39885. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39886. */
  39887. get keysUp(): number[];
  39888. set keysUp(value: number[]);
  39889. /**
  39890. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39891. */
  39892. get keysDown(): number[];
  39893. set keysDown(value: number[]);
  39894. /**
  39895. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39896. */
  39897. get keysLeft(): number[];
  39898. set keysLeft(value: number[]);
  39899. /**
  39900. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39901. */
  39902. get keysRight(): number[];
  39903. set keysRight(value: number[]);
  39904. /**
  39905. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39906. */
  39907. get wheelPrecision(): number;
  39908. set wheelPrecision(value: number);
  39909. /**
  39910. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39911. * It will be used instead of pinchDeltaPrecision if different from 0.
  39912. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39913. */
  39914. get wheelDeltaPercentage(): number;
  39915. set wheelDeltaPercentage(value: number);
  39916. /**
  39917. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39918. */
  39919. zoomOnFactor: number;
  39920. /**
  39921. * Defines a screen offset for the camera position.
  39922. */
  39923. targetScreenOffset: Vector2;
  39924. /**
  39925. * Allows the camera to be completely reversed.
  39926. * If false the camera can not arrive upside down.
  39927. */
  39928. allowUpsideDown: boolean;
  39929. /**
  39930. * Define if double tap/click is used to restore the previously saved state of the camera.
  39931. */
  39932. useInputToRestoreState: boolean;
  39933. /** @hidden */
  39934. _viewMatrix: Matrix;
  39935. /** @hidden */
  39936. _useCtrlForPanning: boolean;
  39937. /** @hidden */
  39938. _panningMouseButton: number;
  39939. /**
  39940. * Defines the input associated to the camera.
  39941. */
  39942. inputs: ArcRotateCameraInputsManager;
  39943. /** @hidden */
  39944. _reset: () => void;
  39945. /**
  39946. * Defines the allowed panning axis.
  39947. */
  39948. panningAxis: Vector3;
  39949. protected _localDirection: Vector3;
  39950. protected _transformedDirection: Vector3;
  39951. private _bouncingBehavior;
  39952. /**
  39953. * Gets the bouncing behavior of the camera if it has been enabled.
  39954. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39955. */
  39956. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39957. /**
  39958. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39959. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39960. */
  39961. get useBouncingBehavior(): boolean;
  39962. set useBouncingBehavior(value: boolean);
  39963. private _framingBehavior;
  39964. /**
  39965. * Gets the framing behavior of the camera if it has been enabled.
  39966. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39967. */
  39968. get framingBehavior(): Nullable<FramingBehavior>;
  39969. /**
  39970. * Defines if the framing behavior of the camera is enabled on the camera.
  39971. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39972. */
  39973. get useFramingBehavior(): boolean;
  39974. set useFramingBehavior(value: boolean);
  39975. private _autoRotationBehavior;
  39976. /**
  39977. * Gets the auto rotation behavior of the camera if it has been enabled.
  39978. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39979. */
  39980. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39981. /**
  39982. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39983. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39984. */
  39985. get useAutoRotationBehavior(): boolean;
  39986. set useAutoRotationBehavior(value: boolean);
  39987. /**
  39988. * Observable triggered when the mesh target has been changed on the camera.
  39989. */
  39990. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39991. /**
  39992. * Event raised when the camera is colliding with a mesh.
  39993. */
  39994. onCollide: (collidedMesh: AbstractMesh) => void;
  39995. /**
  39996. * Defines whether the camera should check collision with the objects oh the scene.
  39997. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39998. */
  39999. checkCollisions: boolean;
  40000. /**
  40001. * Defines the collision radius of the camera.
  40002. * This simulates a sphere around the camera.
  40003. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40004. */
  40005. collisionRadius: Vector3;
  40006. protected _collider: Collider;
  40007. protected _previousPosition: Vector3;
  40008. protected _collisionVelocity: Vector3;
  40009. protected _newPosition: Vector3;
  40010. protected _previousAlpha: number;
  40011. protected _previousBeta: number;
  40012. protected _previousRadius: number;
  40013. protected _collisionTriggered: boolean;
  40014. protected _targetBoundingCenter: Nullable<Vector3>;
  40015. private _computationVector;
  40016. /**
  40017. * Instantiates a new ArcRotateCamera in a given scene
  40018. * @param name Defines the name of the camera
  40019. * @param alpha Defines the camera rotation along the logitudinal axis
  40020. * @param beta Defines the camera rotation along the latitudinal axis
  40021. * @param radius Defines the camera distance from its target
  40022. * @param target Defines the camera target
  40023. * @param scene Defines the scene the camera belongs to
  40024. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  40025. */
  40026. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40027. /** @hidden */
  40028. _initCache(): void;
  40029. /** @hidden */
  40030. _updateCache(ignoreParentClass?: boolean): void;
  40031. protected _getTargetPosition(): Vector3;
  40032. private _storedAlpha;
  40033. private _storedBeta;
  40034. private _storedRadius;
  40035. private _storedTarget;
  40036. private _storedTargetScreenOffset;
  40037. /**
  40038. * Stores the current state of the camera (alpha, beta, radius and target)
  40039. * @returns the camera itself
  40040. */
  40041. storeState(): Camera;
  40042. /**
  40043. * @hidden
  40044. * Restored camera state. You must call storeState() first
  40045. */
  40046. _restoreStateValues(): boolean;
  40047. /** @hidden */
  40048. _isSynchronizedViewMatrix(): boolean;
  40049. /**
  40050. * Attached controls to the current camera.
  40051. * @param element Defines the element the controls should be listened from
  40052. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40053. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  40054. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  40055. */
  40056. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  40057. /**
  40058. * Detach the current controls from the camera.
  40059. * The camera will stop reacting to inputs.
  40060. * @param element Defines the element to stop listening the inputs from
  40061. */
  40062. detachControl(element: HTMLElement): void;
  40063. /** @hidden */
  40064. _checkInputs(): void;
  40065. protected _checkLimits(): void;
  40066. /**
  40067. * Rebuilds angles (alpha, beta) and radius from the give position and target
  40068. */
  40069. rebuildAnglesAndRadius(): void;
  40070. /**
  40071. * Use a position to define the current camera related information like alpha, beta and radius
  40072. * @param position Defines the position to set the camera at
  40073. */
  40074. setPosition(position: Vector3): void;
  40075. /**
  40076. * Defines the target the camera should look at.
  40077. * This will automatically adapt alpha beta and radius to fit within the new target.
  40078. * @param target Defines the new target as a Vector or a mesh
  40079. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  40080. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  40081. */
  40082. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  40083. /** @hidden */
  40084. _getViewMatrix(): Matrix;
  40085. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  40086. /**
  40087. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  40088. * @param meshes Defines the mesh to zoom on
  40089. * @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)
  40090. */
  40091. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  40092. /**
  40093. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  40094. * The target will be changed but the radius
  40095. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  40096. * @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)
  40097. */
  40098. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  40099. min: Vector3;
  40100. max: Vector3;
  40101. distance: number;
  40102. }, doNotUpdateMaxZ?: boolean): void;
  40103. /**
  40104. * @override
  40105. * Override Camera.createRigCamera
  40106. */
  40107. createRigCamera(name: string, cameraIndex: number): Camera;
  40108. /**
  40109. * @hidden
  40110. * @override
  40111. * Override Camera._updateRigCameras
  40112. */
  40113. _updateRigCameras(): void;
  40114. /**
  40115. * Destroy the camera and release the current resources hold by it.
  40116. */
  40117. dispose(): void;
  40118. /**
  40119. * Gets the current object class name.
  40120. * @return the class name
  40121. */
  40122. getClassName(): string;
  40123. }
  40124. }
  40125. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  40126. import { Behavior } from "babylonjs/Behaviors/behavior";
  40127. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40128. /**
  40129. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40130. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40131. */
  40132. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40133. /**
  40134. * Gets the name of the behavior.
  40135. */
  40136. get name(): string;
  40137. private _zoomStopsAnimation;
  40138. private _idleRotationSpeed;
  40139. private _idleRotationWaitTime;
  40140. private _idleRotationSpinupTime;
  40141. /**
  40142. * Sets the flag that indicates if user zooming should stop animation.
  40143. */
  40144. set zoomStopsAnimation(flag: boolean);
  40145. /**
  40146. * Gets the flag that indicates if user zooming should stop animation.
  40147. */
  40148. get zoomStopsAnimation(): boolean;
  40149. /**
  40150. * Sets the default speed at which the camera rotates around the model.
  40151. */
  40152. set idleRotationSpeed(speed: number);
  40153. /**
  40154. * Gets the default speed at which the camera rotates around the model.
  40155. */
  40156. get idleRotationSpeed(): number;
  40157. /**
  40158. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40159. */
  40160. set idleRotationWaitTime(time: number);
  40161. /**
  40162. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40163. */
  40164. get idleRotationWaitTime(): number;
  40165. /**
  40166. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40167. */
  40168. set idleRotationSpinupTime(time: number);
  40169. /**
  40170. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40171. */
  40172. get idleRotationSpinupTime(): number;
  40173. /**
  40174. * Gets a value indicating if the camera is currently rotating because of this behavior
  40175. */
  40176. get rotationInProgress(): boolean;
  40177. private _onPrePointerObservableObserver;
  40178. private _onAfterCheckInputsObserver;
  40179. private _attachedCamera;
  40180. private _isPointerDown;
  40181. private _lastFrameTime;
  40182. private _lastInteractionTime;
  40183. private _cameraRotationSpeed;
  40184. /**
  40185. * Initializes the behavior.
  40186. */
  40187. init(): void;
  40188. /**
  40189. * Attaches the behavior to its arc rotate camera.
  40190. * @param camera Defines the camera to attach the behavior to
  40191. */
  40192. attach(camera: ArcRotateCamera): void;
  40193. /**
  40194. * Detaches the behavior from its current arc rotate camera.
  40195. */
  40196. detach(): void;
  40197. /**
  40198. * Returns true if user is scrolling.
  40199. * @return true if user is scrolling.
  40200. */
  40201. private _userIsZooming;
  40202. private _lastFrameRadius;
  40203. private _shouldAnimationStopForInteraction;
  40204. /**
  40205. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40206. */
  40207. private _applyUserInteraction;
  40208. private _userIsMoving;
  40209. }
  40210. }
  40211. declare module "babylonjs/Behaviors/Cameras/index" {
  40212. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  40213. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  40214. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  40215. }
  40216. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  40217. import { Mesh } from "babylonjs/Meshes/mesh";
  40218. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40219. import { Behavior } from "babylonjs/Behaviors/behavior";
  40220. /**
  40221. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40222. */
  40223. export class AttachToBoxBehavior implements Behavior<Mesh> {
  40224. private ui;
  40225. /**
  40226. * The name of the behavior
  40227. */
  40228. name: string;
  40229. /**
  40230. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40231. */
  40232. distanceAwayFromFace: number;
  40233. /**
  40234. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40235. */
  40236. distanceAwayFromBottomOfFace: number;
  40237. private _faceVectors;
  40238. private _target;
  40239. private _scene;
  40240. private _onRenderObserver;
  40241. private _tmpMatrix;
  40242. private _tmpVector;
  40243. /**
  40244. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40245. * @param ui The transform node that should be attched to the mesh
  40246. */
  40247. constructor(ui: TransformNode);
  40248. /**
  40249. * Initializes the behavior
  40250. */
  40251. init(): void;
  40252. private _closestFace;
  40253. private _zeroVector;
  40254. private _lookAtTmpMatrix;
  40255. private _lookAtToRef;
  40256. /**
  40257. * Attaches the AttachToBoxBehavior to the passed in mesh
  40258. * @param target The mesh that the specified node will be attached to
  40259. */
  40260. attach(target: Mesh): void;
  40261. /**
  40262. * Detaches the behavior from the mesh
  40263. */
  40264. detach(): void;
  40265. }
  40266. }
  40267. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  40268. import { Behavior } from "babylonjs/Behaviors/behavior";
  40269. import { Mesh } from "babylonjs/Meshes/mesh";
  40270. /**
  40271. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40272. */
  40273. export class FadeInOutBehavior implements Behavior<Mesh> {
  40274. /**
  40275. * Time in milliseconds to delay before fading in (Default: 0)
  40276. */
  40277. delay: number;
  40278. /**
  40279. * Time in milliseconds for the mesh to fade in (Default: 300)
  40280. */
  40281. fadeInTime: number;
  40282. private _millisecondsPerFrame;
  40283. private _hovered;
  40284. private _hoverValue;
  40285. private _ownerNode;
  40286. /**
  40287. * Instatiates the FadeInOutBehavior
  40288. */
  40289. constructor();
  40290. /**
  40291. * The name of the behavior
  40292. */
  40293. get name(): string;
  40294. /**
  40295. * Initializes the behavior
  40296. */
  40297. init(): void;
  40298. /**
  40299. * Attaches the fade behavior on the passed in mesh
  40300. * @param ownerNode The mesh that will be faded in/out once attached
  40301. */
  40302. attach(ownerNode: Mesh): void;
  40303. /**
  40304. * Detaches the behavior from the mesh
  40305. */
  40306. detach(): void;
  40307. /**
  40308. * Triggers the mesh to begin fading in or out
  40309. * @param value if the object should fade in or out (true to fade in)
  40310. */
  40311. fadeIn(value: boolean): void;
  40312. private _update;
  40313. private _setAllVisibility;
  40314. }
  40315. }
  40316. declare module "babylonjs/Misc/pivotTools" {
  40317. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40318. /**
  40319. * Class containing a set of static utilities functions for managing Pivots
  40320. * @hidden
  40321. */
  40322. export class PivotTools {
  40323. private static _PivotCached;
  40324. private static _OldPivotPoint;
  40325. private static _PivotTranslation;
  40326. private static _PivotTmpVector;
  40327. /** @hidden */
  40328. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  40329. /** @hidden */
  40330. static _RestorePivotPoint(mesh: AbstractMesh): void;
  40331. }
  40332. }
  40333. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  40334. import { Scene } from "babylonjs/scene";
  40335. import { Vector4 } from "babylonjs/Maths/math.vector";
  40336. import { Mesh } from "babylonjs/Meshes/mesh";
  40337. import { Nullable } from "babylonjs/types";
  40338. import { Plane } from "babylonjs/Maths/math.plane";
  40339. /**
  40340. * Class containing static functions to help procedurally build meshes
  40341. */
  40342. export class PlaneBuilder {
  40343. /**
  40344. * Creates a plane mesh
  40345. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  40346. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  40347. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  40348. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40349. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40350. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40351. * @param name defines the name of the mesh
  40352. * @param options defines the options used to create the mesh
  40353. * @param scene defines the hosting scene
  40354. * @returns the plane mesh
  40355. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  40356. */
  40357. static CreatePlane(name: string, options: {
  40358. size?: number;
  40359. width?: number;
  40360. height?: number;
  40361. sideOrientation?: number;
  40362. frontUVs?: Vector4;
  40363. backUVs?: Vector4;
  40364. updatable?: boolean;
  40365. sourcePlane?: Plane;
  40366. }, scene?: Nullable<Scene>): Mesh;
  40367. }
  40368. }
  40369. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  40370. import { Behavior } from "babylonjs/Behaviors/behavior";
  40371. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40372. import { Observable } from "babylonjs/Misc/observable";
  40373. import { Vector3 } from "babylonjs/Maths/math.vector";
  40374. import { Ray } from "babylonjs/Culling/ray";
  40375. import "babylonjs/Meshes/Builders/planeBuilder";
  40376. /**
  40377. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40378. */
  40379. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  40380. private static _AnyMouseID;
  40381. /**
  40382. * Abstract mesh the behavior is set on
  40383. */
  40384. attachedNode: AbstractMesh;
  40385. private _dragPlane;
  40386. private _scene;
  40387. private _pointerObserver;
  40388. private _beforeRenderObserver;
  40389. private static _planeScene;
  40390. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  40391. /**
  40392. * 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)
  40393. */
  40394. maxDragAngle: number;
  40395. /**
  40396. * @hidden
  40397. */
  40398. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40399. /**
  40400. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40401. */
  40402. currentDraggingPointerID: number;
  40403. /**
  40404. * The last position where the pointer hit the drag plane in world space
  40405. */
  40406. lastDragPosition: Vector3;
  40407. /**
  40408. * If the behavior is currently in a dragging state
  40409. */
  40410. dragging: boolean;
  40411. /**
  40412. * 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)
  40413. */
  40414. dragDeltaRatio: number;
  40415. /**
  40416. * If the drag plane orientation should be updated during the dragging (Default: true)
  40417. */
  40418. updateDragPlane: boolean;
  40419. private _debugMode;
  40420. private _moving;
  40421. /**
  40422. * Fires each time the attached mesh is dragged with the pointer
  40423. * * delta between last drag position and current drag position in world space
  40424. * * dragDistance along the drag axis
  40425. * * dragPlaneNormal normal of the current drag plane used during the drag
  40426. * * dragPlanePoint in world space where the drag intersects the drag plane
  40427. */
  40428. onDragObservable: Observable<{
  40429. delta: Vector3;
  40430. dragPlanePoint: Vector3;
  40431. dragPlaneNormal: Vector3;
  40432. dragDistance: number;
  40433. pointerId: number;
  40434. }>;
  40435. /**
  40436. * Fires each time a drag begins (eg. mouse down on mesh)
  40437. */
  40438. onDragStartObservable: Observable<{
  40439. dragPlanePoint: Vector3;
  40440. pointerId: number;
  40441. }>;
  40442. /**
  40443. * Fires each time a drag ends (eg. mouse release after drag)
  40444. */
  40445. onDragEndObservable: Observable<{
  40446. dragPlanePoint: Vector3;
  40447. pointerId: number;
  40448. }>;
  40449. /**
  40450. * If the attached mesh should be moved when dragged
  40451. */
  40452. moveAttached: boolean;
  40453. /**
  40454. * If the drag behavior will react to drag events (Default: true)
  40455. */
  40456. enabled: boolean;
  40457. /**
  40458. * If pointer events should start and release the drag (Default: true)
  40459. */
  40460. startAndReleaseDragOnPointerEvents: boolean;
  40461. /**
  40462. * If camera controls should be detached during the drag
  40463. */
  40464. detachCameraControls: boolean;
  40465. /**
  40466. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40467. */
  40468. useObjectOrientationForDragging: boolean;
  40469. private _options;
  40470. /**
  40471. * Gets the options used by the behavior
  40472. */
  40473. get options(): {
  40474. dragAxis?: Vector3;
  40475. dragPlaneNormal?: Vector3;
  40476. };
  40477. /**
  40478. * Sets the options used by the behavior
  40479. */
  40480. set options(options: {
  40481. dragAxis?: Vector3;
  40482. dragPlaneNormal?: Vector3;
  40483. });
  40484. /**
  40485. * Creates a pointer drag behavior that can be attached to a mesh
  40486. * @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)
  40487. */
  40488. constructor(options?: {
  40489. dragAxis?: Vector3;
  40490. dragPlaneNormal?: Vector3;
  40491. });
  40492. /**
  40493. * Predicate to determine if it is valid to move the object to a new position when it is moved
  40494. */
  40495. validateDrag: (targetPosition: Vector3) => boolean;
  40496. /**
  40497. * The name of the behavior
  40498. */
  40499. get name(): string;
  40500. /**
  40501. * Initializes the behavior
  40502. */
  40503. init(): void;
  40504. private _tmpVector;
  40505. private _alternatePickedPoint;
  40506. private _worldDragAxis;
  40507. private _targetPosition;
  40508. private _attachedElement;
  40509. /**
  40510. * Attaches the drag behavior the passed in mesh
  40511. * @param ownerNode The mesh that will be dragged around once attached
  40512. * @param predicate Predicate to use for pick filtering
  40513. */
  40514. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  40515. /**
  40516. * Force relase the drag action by code.
  40517. */
  40518. releaseDrag(): void;
  40519. private _startDragRay;
  40520. private _lastPointerRay;
  40521. /**
  40522. * Simulates the start of a pointer drag event on the behavior
  40523. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40524. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40525. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40526. */
  40527. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40528. private _startDrag;
  40529. private _dragDelta;
  40530. private _moveDrag;
  40531. private _pickWithRayOnDragPlane;
  40532. private _pointA;
  40533. private _pointB;
  40534. private _pointC;
  40535. private _lineA;
  40536. private _lineB;
  40537. private _localAxis;
  40538. private _lookAt;
  40539. private _updateDragPlanePosition;
  40540. /**
  40541. * Detaches the behavior from the mesh
  40542. */
  40543. detach(): void;
  40544. }
  40545. }
  40546. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  40547. import { Mesh } from "babylonjs/Meshes/mesh";
  40548. import { Behavior } from "babylonjs/Behaviors/behavior";
  40549. /**
  40550. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40551. */
  40552. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40553. private _dragBehaviorA;
  40554. private _dragBehaviorB;
  40555. private _startDistance;
  40556. private _initialScale;
  40557. private _targetScale;
  40558. private _ownerNode;
  40559. private _sceneRenderObserver;
  40560. /**
  40561. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40562. */
  40563. constructor();
  40564. /**
  40565. * The name of the behavior
  40566. */
  40567. get name(): string;
  40568. /**
  40569. * Initializes the behavior
  40570. */
  40571. init(): void;
  40572. private _getCurrentDistance;
  40573. /**
  40574. * Attaches the scale behavior the passed in mesh
  40575. * @param ownerNode The mesh that will be scaled around once attached
  40576. */
  40577. attach(ownerNode: Mesh): void;
  40578. /**
  40579. * Detaches the behavior from the mesh
  40580. */
  40581. detach(): void;
  40582. }
  40583. }
  40584. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  40585. import { Behavior } from "babylonjs/Behaviors/behavior";
  40586. import { Mesh } from "babylonjs/Meshes/mesh";
  40587. import { Observable } from "babylonjs/Misc/observable";
  40588. /**
  40589. * 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
  40590. */
  40591. export class SixDofDragBehavior implements Behavior<Mesh> {
  40592. private static _virtualScene;
  40593. private _ownerNode;
  40594. private _sceneRenderObserver;
  40595. private _scene;
  40596. private _targetPosition;
  40597. private _virtualOriginMesh;
  40598. private _virtualDragMesh;
  40599. private _pointerObserver;
  40600. private _moving;
  40601. private _startingOrientation;
  40602. /**
  40603. * 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)
  40604. */
  40605. private zDragFactor;
  40606. /**
  40607. * If the object should rotate to face the drag origin
  40608. */
  40609. rotateDraggedObject: boolean;
  40610. /**
  40611. * If the behavior is currently in a dragging state
  40612. */
  40613. dragging: boolean;
  40614. /**
  40615. * 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)
  40616. */
  40617. dragDeltaRatio: number;
  40618. /**
  40619. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40620. */
  40621. currentDraggingPointerID: number;
  40622. /**
  40623. * If camera controls should be detached during the drag
  40624. */
  40625. detachCameraControls: boolean;
  40626. /**
  40627. * Fires each time a drag starts
  40628. */
  40629. onDragStartObservable: Observable<{}>;
  40630. /**
  40631. * Fires each time a drag ends (eg. mouse release after drag)
  40632. */
  40633. onDragEndObservable: Observable<{}>;
  40634. /**
  40635. * 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
  40636. */
  40637. constructor();
  40638. /**
  40639. * The name of the behavior
  40640. */
  40641. get name(): string;
  40642. /**
  40643. * Initializes the behavior
  40644. */
  40645. init(): void;
  40646. /**
  40647. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  40648. */
  40649. private get _pointerCamera();
  40650. /**
  40651. * Attaches the scale behavior the passed in mesh
  40652. * @param ownerNode The mesh that will be scaled around once attached
  40653. */
  40654. attach(ownerNode: Mesh): void;
  40655. /**
  40656. * Detaches the behavior from the mesh
  40657. */
  40658. detach(): void;
  40659. }
  40660. }
  40661. declare module "babylonjs/Behaviors/Meshes/index" {
  40662. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  40663. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  40664. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  40665. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  40666. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  40667. }
  40668. declare module "babylonjs/Behaviors/index" {
  40669. export * from "babylonjs/Behaviors/behavior";
  40670. export * from "babylonjs/Behaviors/Cameras/index";
  40671. export * from "babylonjs/Behaviors/Meshes/index";
  40672. }
  40673. declare module "babylonjs/Bones/boneIKController" {
  40674. import { Bone } from "babylonjs/Bones/bone";
  40675. import { Vector3 } from "babylonjs/Maths/math.vector";
  40676. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40677. import { Nullable } from "babylonjs/types";
  40678. /**
  40679. * Class used to apply inverse kinematics to bones
  40680. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  40681. */
  40682. export class BoneIKController {
  40683. private static _tmpVecs;
  40684. private static _tmpQuat;
  40685. private static _tmpMats;
  40686. /**
  40687. * Gets or sets the target mesh
  40688. */
  40689. targetMesh: AbstractMesh;
  40690. /** Gets or sets the mesh used as pole */
  40691. poleTargetMesh: AbstractMesh;
  40692. /**
  40693. * Gets or sets the bone used as pole
  40694. */
  40695. poleTargetBone: Nullable<Bone>;
  40696. /**
  40697. * Gets or sets the target position
  40698. */
  40699. targetPosition: Vector3;
  40700. /**
  40701. * Gets or sets the pole target position
  40702. */
  40703. poleTargetPosition: Vector3;
  40704. /**
  40705. * Gets or sets the pole target local offset
  40706. */
  40707. poleTargetLocalOffset: Vector3;
  40708. /**
  40709. * Gets or sets the pole angle
  40710. */
  40711. poleAngle: number;
  40712. /**
  40713. * Gets or sets the mesh associated with the controller
  40714. */
  40715. mesh: AbstractMesh;
  40716. /**
  40717. * 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)
  40718. */
  40719. slerpAmount: number;
  40720. private _bone1Quat;
  40721. private _bone1Mat;
  40722. private _bone2Ang;
  40723. private _bone1;
  40724. private _bone2;
  40725. private _bone1Length;
  40726. private _bone2Length;
  40727. private _maxAngle;
  40728. private _maxReach;
  40729. private _rightHandedSystem;
  40730. private _bendAxis;
  40731. private _slerping;
  40732. private _adjustRoll;
  40733. /**
  40734. * Gets or sets maximum allowed angle
  40735. */
  40736. get maxAngle(): number;
  40737. set maxAngle(value: number);
  40738. /**
  40739. * Creates a new BoneIKController
  40740. * @param mesh defines the mesh to control
  40741. * @param bone defines the bone to control
  40742. * @param options defines options to set up the controller
  40743. */
  40744. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  40745. targetMesh?: AbstractMesh;
  40746. poleTargetMesh?: AbstractMesh;
  40747. poleTargetBone?: Bone;
  40748. poleTargetLocalOffset?: Vector3;
  40749. poleAngle?: number;
  40750. bendAxis?: Vector3;
  40751. maxAngle?: number;
  40752. slerpAmount?: number;
  40753. });
  40754. private _setMaxAngle;
  40755. /**
  40756. * Force the controller to update the bones
  40757. */
  40758. update(): void;
  40759. }
  40760. }
  40761. declare module "babylonjs/Bones/boneLookController" {
  40762. import { Vector3 } from "babylonjs/Maths/math.vector";
  40763. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40764. import { Bone } from "babylonjs/Bones/bone";
  40765. import { Space } from "babylonjs/Maths/math.axis";
  40766. /**
  40767. * Class used to make a bone look toward a point in space
  40768. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40769. */
  40770. export class BoneLookController {
  40771. private static _tmpVecs;
  40772. private static _tmpQuat;
  40773. private static _tmpMats;
  40774. /**
  40775. * The target Vector3 that the bone will look at
  40776. */
  40777. target: Vector3;
  40778. /**
  40779. * The mesh that the bone is attached to
  40780. */
  40781. mesh: AbstractMesh;
  40782. /**
  40783. * The bone that will be looking to the target
  40784. */
  40785. bone: Bone;
  40786. /**
  40787. * The up axis of the coordinate system that is used when the bone is rotated
  40788. */
  40789. upAxis: Vector3;
  40790. /**
  40791. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40792. */
  40793. upAxisSpace: Space;
  40794. /**
  40795. * Used to make an adjustment to the yaw of the bone
  40796. */
  40797. adjustYaw: number;
  40798. /**
  40799. * Used to make an adjustment to the pitch of the bone
  40800. */
  40801. adjustPitch: number;
  40802. /**
  40803. * Used to make an adjustment to the roll of the bone
  40804. */
  40805. adjustRoll: number;
  40806. /**
  40807. * 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)
  40808. */
  40809. slerpAmount: number;
  40810. private _minYaw;
  40811. private _maxYaw;
  40812. private _minPitch;
  40813. private _maxPitch;
  40814. private _minYawSin;
  40815. private _minYawCos;
  40816. private _maxYawSin;
  40817. private _maxYawCos;
  40818. private _midYawConstraint;
  40819. private _minPitchTan;
  40820. private _maxPitchTan;
  40821. private _boneQuat;
  40822. private _slerping;
  40823. private _transformYawPitch;
  40824. private _transformYawPitchInv;
  40825. private _firstFrameSkipped;
  40826. private _yawRange;
  40827. private _fowardAxis;
  40828. /**
  40829. * Gets or sets the minimum yaw angle that the bone can look to
  40830. */
  40831. get minYaw(): number;
  40832. set minYaw(value: number);
  40833. /**
  40834. * Gets or sets the maximum yaw angle that the bone can look to
  40835. */
  40836. get maxYaw(): number;
  40837. set maxYaw(value: number);
  40838. /**
  40839. * Gets or sets the minimum pitch angle that the bone can look to
  40840. */
  40841. get minPitch(): number;
  40842. set minPitch(value: number);
  40843. /**
  40844. * Gets or sets the maximum pitch angle that the bone can look to
  40845. */
  40846. get maxPitch(): number;
  40847. set maxPitch(value: number);
  40848. /**
  40849. * Create a BoneLookController
  40850. * @param mesh the mesh that the bone belongs to
  40851. * @param bone the bone that will be looking to the target
  40852. * @param target the target Vector3 to look at
  40853. * @param options optional settings:
  40854. * * maxYaw: the maximum angle the bone will yaw to
  40855. * * minYaw: the minimum angle the bone will yaw to
  40856. * * maxPitch: the maximum angle the bone will pitch to
  40857. * * minPitch: the minimum angle the bone will yaw to
  40858. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40859. * * upAxis: the up axis of the coordinate system
  40860. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40861. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40862. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40863. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40864. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40865. * * adjustRoll: used to make an adjustment to the roll of the bone
  40866. **/
  40867. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40868. maxYaw?: number;
  40869. minYaw?: number;
  40870. maxPitch?: number;
  40871. minPitch?: number;
  40872. slerpAmount?: number;
  40873. upAxis?: Vector3;
  40874. upAxisSpace?: Space;
  40875. yawAxis?: Vector3;
  40876. pitchAxis?: Vector3;
  40877. adjustYaw?: number;
  40878. adjustPitch?: number;
  40879. adjustRoll?: number;
  40880. });
  40881. /**
  40882. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40883. */
  40884. update(): void;
  40885. private _getAngleDiff;
  40886. private _getAngleBetween;
  40887. private _isAngleBetween;
  40888. }
  40889. }
  40890. declare module "babylonjs/Bones/index" {
  40891. export * from "babylonjs/Bones/bone";
  40892. export * from "babylonjs/Bones/boneIKController";
  40893. export * from "babylonjs/Bones/boneLookController";
  40894. export * from "babylonjs/Bones/skeleton";
  40895. }
  40896. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  40897. import { Nullable } from "babylonjs/types";
  40898. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40899. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40900. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40901. /**
  40902. * Manage the gamepad inputs to control an arc rotate camera.
  40903. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40904. */
  40905. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40906. /**
  40907. * Defines the camera the input is attached to.
  40908. */
  40909. camera: ArcRotateCamera;
  40910. /**
  40911. * Defines the gamepad the input is gathering event from.
  40912. */
  40913. gamepad: Nullable<Gamepad>;
  40914. /**
  40915. * Defines the gamepad rotation sensiblity.
  40916. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40917. */
  40918. gamepadRotationSensibility: number;
  40919. /**
  40920. * Defines the gamepad move sensiblity.
  40921. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40922. */
  40923. gamepadMoveSensibility: number;
  40924. private _yAxisScale;
  40925. /**
  40926. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40927. */
  40928. get invertYAxis(): boolean;
  40929. set invertYAxis(value: boolean);
  40930. private _onGamepadConnectedObserver;
  40931. private _onGamepadDisconnectedObserver;
  40932. /**
  40933. * Attach the input controls to a specific dom element to get the input from.
  40934. * @param element Defines the element the controls should be listened from
  40935. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40936. */
  40937. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40938. /**
  40939. * Detach the current controls from the specified dom element.
  40940. * @param element Defines the element to stop listening the inputs from
  40941. */
  40942. detachControl(element: Nullable<HTMLElement>): void;
  40943. /**
  40944. * Update the current camera state depending on the inputs that have been used this frame.
  40945. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40946. */
  40947. checkInputs(): void;
  40948. /**
  40949. * Gets the class name of the current intput.
  40950. * @returns the class name
  40951. */
  40952. getClassName(): string;
  40953. /**
  40954. * Get the friendly name associated with the input class.
  40955. * @returns the input friendly name
  40956. */
  40957. getSimpleName(): string;
  40958. }
  40959. }
  40960. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  40961. import { Nullable } from "babylonjs/types";
  40962. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40963. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40964. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40965. interface ArcRotateCameraInputsManager {
  40966. /**
  40967. * Add orientation input support to the input manager.
  40968. * @returns the current input manager
  40969. */
  40970. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40971. }
  40972. }
  40973. /**
  40974. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40975. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40976. */
  40977. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40978. /**
  40979. * Defines the camera the input is attached to.
  40980. */
  40981. camera: ArcRotateCamera;
  40982. /**
  40983. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40984. */
  40985. alphaCorrection: number;
  40986. /**
  40987. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40988. */
  40989. gammaCorrection: number;
  40990. private _alpha;
  40991. private _gamma;
  40992. private _dirty;
  40993. private _deviceOrientationHandler;
  40994. /**
  40995. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40996. */
  40997. constructor();
  40998. /**
  40999. * Attach the input controls to a specific dom element to get the input from.
  41000. * @param element Defines the element the controls should be listened from
  41001. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41002. */
  41003. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41004. /** @hidden */
  41005. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  41006. /**
  41007. * Update the current camera state depending on the inputs that have been used this frame.
  41008. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41009. */
  41010. checkInputs(): void;
  41011. /**
  41012. * Detach the current controls from the specified dom element.
  41013. * @param element Defines the element to stop listening the inputs from
  41014. */
  41015. detachControl(element: Nullable<HTMLElement>): void;
  41016. /**
  41017. * Gets the class name of the current intput.
  41018. * @returns the class name
  41019. */
  41020. getClassName(): string;
  41021. /**
  41022. * Get the friendly name associated with the input class.
  41023. * @returns the input friendly name
  41024. */
  41025. getSimpleName(): string;
  41026. }
  41027. }
  41028. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  41029. import { Nullable } from "babylonjs/types";
  41030. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41031. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41032. /**
  41033. * Listen to mouse events to control the camera.
  41034. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41035. */
  41036. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  41037. /**
  41038. * Defines the camera the input is attached to.
  41039. */
  41040. camera: FlyCamera;
  41041. /**
  41042. * Defines if touch is enabled. (Default is true.)
  41043. */
  41044. touchEnabled: boolean;
  41045. /**
  41046. * Defines the buttons associated with the input to handle camera rotation.
  41047. */
  41048. buttons: number[];
  41049. /**
  41050. * Assign buttons for Yaw control.
  41051. */
  41052. buttonsYaw: number[];
  41053. /**
  41054. * Assign buttons for Pitch control.
  41055. */
  41056. buttonsPitch: number[];
  41057. /**
  41058. * Assign buttons for Roll control.
  41059. */
  41060. buttonsRoll: number[];
  41061. /**
  41062. * Detect if any button is being pressed while mouse is moved.
  41063. * -1 = Mouse locked.
  41064. * 0 = Left button.
  41065. * 1 = Middle Button.
  41066. * 2 = Right Button.
  41067. */
  41068. activeButton: number;
  41069. /**
  41070. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  41071. * Higher values reduce its sensitivity.
  41072. */
  41073. angularSensibility: number;
  41074. private _mousemoveCallback;
  41075. private _observer;
  41076. private _rollObserver;
  41077. private previousPosition;
  41078. private noPreventDefault;
  41079. private element;
  41080. /**
  41081. * Listen to mouse events to control the camera.
  41082. * @param touchEnabled Define if touch is enabled. (Default is true.)
  41083. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41084. */
  41085. constructor(touchEnabled?: boolean);
  41086. /**
  41087. * Attach the mouse control to the HTML DOM element.
  41088. * @param element Defines the element that listens to the input events.
  41089. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  41090. */
  41091. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41092. /**
  41093. * Detach the current controls from the specified dom element.
  41094. * @param element Defines the element to stop listening the inputs from
  41095. */
  41096. detachControl(element: Nullable<HTMLElement>): void;
  41097. /**
  41098. * Gets the class name of the current input.
  41099. * @returns the class name.
  41100. */
  41101. getClassName(): string;
  41102. /**
  41103. * Get the friendly name associated with the input class.
  41104. * @returns the input's friendly name.
  41105. */
  41106. getSimpleName(): string;
  41107. private _pointerInput;
  41108. private _onMouseMove;
  41109. /**
  41110. * Rotate camera by mouse offset.
  41111. */
  41112. private rotateCamera;
  41113. }
  41114. }
  41115. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  41116. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41117. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41118. /**
  41119. * Default Inputs manager for the FlyCamera.
  41120. * It groups all the default supported inputs for ease of use.
  41121. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41122. */
  41123. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  41124. /**
  41125. * Instantiates a new FlyCameraInputsManager.
  41126. * @param camera Defines the camera the inputs belong to.
  41127. */
  41128. constructor(camera: FlyCamera);
  41129. /**
  41130. * Add keyboard input support to the input manager.
  41131. * @returns the new FlyCameraKeyboardMoveInput().
  41132. */
  41133. addKeyboard(): FlyCameraInputsManager;
  41134. /**
  41135. * Add mouse input support to the input manager.
  41136. * @param touchEnabled Enable touch screen support.
  41137. * @returns the new FlyCameraMouseInput().
  41138. */
  41139. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  41140. }
  41141. }
  41142. declare module "babylonjs/Cameras/flyCamera" {
  41143. import { Scene } from "babylonjs/scene";
  41144. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  41145. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41146. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41147. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  41148. /**
  41149. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41150. * such as in a 3D Space Shooter or a Flight Simulator.
  41151. */
  41152. export class FlyCamera extends TargetCamera {
  41153. /**
  41154. * Define the collision ellipsoid of the camera.
  41155. * This is helpful for simulating a camera body, like a player's body.
  41156. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  41157. */
  41158. ellipsoid: Vector3;
  41159. /**
  41160. * Define an offset for the position of the ellipsoid around the camera.
  41161. * This can be helpful if the camera is attached away from the player's body center,
  41162. * such as at its head.
  41163. */
  41164. ellipsoidOffset: Vector3;
  41165. /**
  41166. * Enable or disable collisions of the camera with the rest of the scene objects.
  41167. */
  41168. checkCollisions: boolean;
  41169. /**
  41170. * Enable or disable gravity on the camera.
  41171. */
  41172. applyGravity: boolean;
  41173. /**
  41174. * Define the current direction the camera is moving to.
  41175. */
  41176. cameraDirection: Vector3;
  41177. /**
  41178. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  41179. * This overrides and empties cameraRotation.
  41180. */
  41181. rotationQuaternion: Quaternion;
  41182. /**
  41183. * Track Roll to maintain the wanted Rolling when looking around.
  41184. */
  41185. _trackRoll: number;
  41186. /**
  41187. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  41188. */
  41189. rollCorrect: number;
  41190. /**
  41191. * Mimic a banked turn, Rolling the camera when Yawing.
  41192. * It's recommended to use rollCorrect = 10 for faster banking correction.
  41193. */
  41194. bankedTurn: boolean;
  41195. /**
  41196. * Limit in radians for how much Roll banking will add. (Default: 90°)
  41197. */
  41198. bankedTurnLimit: number;
  41199. /**
  41200. * Value of 0 disables the banked Roll.
  41201. * Value of 1 is equal to the Yaw angle in radians.
  41202. */
  41203. bankedTurnMultiplier: number;
  41204. /**
  41205. * The inputs manager loads all the input sources, such as keyboard and mouse.
  41206. */
  41207. inputs: FlyCameraInputsManager;
  41208. /**
  41209. * Gets the input sensibility for mouse input.
  41210. * Higher values reduce sensitivity.
  41211. */
  41212. get angularSensibility(): number;
  41213. /**
  41214. * Sets the input sensibility for a mouse input.
  41215. * Higher values reduce sensitivity.
  41216. */
  41217. set angularSensibility(value: number);
  41218. /**
  41219. * Get the keys for camera movement forward.
  41220. */
  41221. get keysForward(): number[];
  41222. /**
  41223. * Set the keys for camera movement forward.
  41224. */
  41225. set keysForward(value: number[]);
  41226. /**
  41227. * Get the keys for camera movement backward.
  41228. */
  41229. get keysBackward(): number[];
  41230. set keysBackward(value: number[]);
  41231. /**
  41232. * Get the keys for camera movement up.
  41233. */
  41234. get keysUp(): number[];
  41235. /**
  41236. * Set the keys for camera movement up.
  41237. */
  41238. set keysUp(value: number[]);
  41239. /**
  41240. * Get the keys for camera movement down.
  41241. */
  41242. get keysDown(): number[];
  41243. /**
  41244. * Set the keys for camera movement down.
  41245. */
  41246. set keysDown(value: number[]);
  41247. /**
  41248. * Get the keys for camera movement left.
  41249. */
  41250. get keysLeft(): number[];
  41251. /**
  41252. * Set the keys for camera movement left.
  41253. */
  41254. set keysLeft(value: number[]);
  41255. /**
  41256. * Set the keys for camera movement right.
  41257. */
  41258. get keysRight(): number[];
  41259. /**
  41260. * Set the keys for camera movement right.
  41261. */
  41262. set keysRight(value: number[]);
  41263. /**
  41264. * Event raised when the camera collides with a mesh in the scene.
  41265. */
  41266. onCollide: (collidedMesh: AbstractMesh) => void;
  41267. private _collider;
  41268. private _needMoveForGravity;
  41269. private _oldPosition;
  41270. private _diffPosition;
  41271. private _newPosition;
  41272. /** @hidden */
  41273. _localDirection: Vector3;
  41274. /** @hidden */
  41275. _transformedDirection: Vector3;
  41276. /**
  41277. * Instantiates a FlyCamera.
  41278. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41279. * such as in a 3D Space Shooter or a Flight Simulator.
  41280. * @param name Define the name of the camera in the scene.
  41281. * @param position Define the starting position of the camera in the scene.
  41282. * @param scene Define the scene the camera belongs to.
  41283. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  41284. */
  41285. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41286. /**
  41287. * Attach a control to the HTML DOM element.
  41288. * @param element Defines the element that listens to the input events.
  41289. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  41290. */
  41291. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41292. /**
  41293. * Detach a control from the HTML DOM element.
  41294. * The camera will stop reacting to that input.
  41295. * @param element Defines the element that listens to the input events.
  41296. */
  41297. detachControl(element: HTMLElement): void;
  41298. private _collisionMask;
  41299. /**
  41300. * Get the mask that the camera ignores in collision events.
  41301. */
  41302. get collisionMask(): number;
  41303. /**
  41304. * Set the mask that the camera ignores in collision events.
  41305. */
  41306. set collisionMask(mask: number);
  41307. /** @hidden */
  41308. _collideWithWorld(displacement: Vector3): void;
  41309. /** @hidden */
  41310. private _onCollisionPositionChange;
  41311. /** @hidden */
  41312. _checkInputs(): void;
  41313. /** @hidden */
  41314. _decideIfNeedsToMove(): boolean;
  41315. /** @hidden */
  41316. _updatePosition(): void;
  41317. /**
  41318. * Restore the Roll to its target value at the rate specified.
  41319. * @param rate - Higher means slower restoring.
  41320. * @hidden
  41321. */
  41322. restoreRoll(rate: number): void;
  41323. /**
  41324. * Destroy the camera and release the current resources held by it.
  41325. */
  41326. dispose(): void;
  41327. /**
  41328. * Get the current object class name.
  41329. * @returns the class name.
  41330. */
  41331. getClassName(): string;
  41332. }
  41333. }
  41334. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  41335. import { Nullable } from "babylonjs/types";
  41336. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41337. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41338. /**
  41339. * Listen to keyboard events to control the camera.
  41340. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41341. */
  41342. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41343. /**
  41344. * Defines the camera the input is attached to.
  41345. */
  41346. camera: FlyCamera;
  41347. /**
  41348. * The list of keyboard keys used to control the forward move of the camera.
  41349. */
  41350. keysForward: number[];
  41351. /**
  41352. * The list of keyboard keys used to control the backward move of the camera.
  41353. */
  41354. keysBackward: number[];
  41355. /**
  41356. * The list of keyboard keys used to control the forward move of the camera.
  41357. */
  41358. keysUp: number[];
  41359. /**
  41360. * The list of keyboard keys used to control the backward move of the camera.
  41361. */
  41362. keysDown: number[];
  41363. /**
  41364. * The list of keyboard keys used to control the right strafe move of the camera.
  41365. */
  41366. keysRight: number[];
  41367. /**
  41368. * The list of keyboard keys used to control the left strafe move of the camera.
  41369. */
  41370. keysLeft: number[];
  41371. private _keys;
  41372. private _onCanvasBlurObserver;
  41373. private _onKeyboardObserver;
  41374. private _engine;
  41375. private _scene;
  41376. /**
  41377. * Attach the input controls to a specific dom element to get the input from.
  41378. * @param element Defines the element the controls should be listened from
  41379. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41380. */
  41381. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41382. /**
  41383. * Detach the current controls from the specified dom element.
  41384. * @param element Defines the element to stop listening the inputs from
  41385. */
  41386. detachControl(element: Nullable<HTMLElement>): void;
  41387. /**
  41388. * Gets the class name of the current intput.
  41389. * @returns the class name
  41390. */
  41391. getClassName(): string;
  41392. /** @hidden */
  41393. _onLostFocus(e: FocusEvent): void;
  41394. /**
  41395. * Get the friendly name associated with the input class.
  41396. * @returns the input friendly name
  41397. */
  41398. getSimpleName(): string;
  41399. /**
  41400. * Update the current camera state depending on the inputs that have been used this frame.
  41401. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41402. */
  41403. checkInputs(): void;
  41404. }
  41405. }
  41406. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  41407. import { Nullable } from "babylonjs/types";
  41408. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41409. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41410. /**
  41411. * Manage the mouse wheel inputs to control a follow camera.
  41412. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41413. */
  41414. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  41415. /**
  41416. * Defines the camera the input is attached to.
  41417. */
  41418. camera: FollowCamera;
  41419. /**
  41420. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  41421. */
  41422. axisControlRadius: boolean;
  41423. /**
  41424. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  41425. */
  41426. axisControlHeight: boolean;
  41427. /**
  41428. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  41429. */
  41430. axisControlRotation: boolean;
  41431. /**
  41432. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  41433. * relation to mouseWheel events.
  41434. */
  41435. wheelPrecision: number;
  41436. /**
  41437. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41438. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41439. */
  41440. wheelDeltaPercentage: number;
  41441. private _wheel;
  41442. private _observer;
  41443. /**
  41444. * Attach the input controls to a specific dom element to get the input from.
  41445. * @param element Defines the element the controls should be listened from
  41446. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41447. */
  41448. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41449. /**
  41450. * Detach the current controls from the specified dom element.
  41451. * @param element Defines the element to stop listening the inputs from
  41452. */
  41453. detachControl(element: Nullable<HTMLElement>): void;
  41454. /**
  41455. * Gets the class name of the current intput.
  41456. * @returns the class name
  41457. */
  41458. getClassName(): string;
  41459. /**
  41460. * Get the friendly name associated with the input class.
  41461. * @returns the input friendly name
  41462. */
  41463. getSimpleName(): string;
  41464. }
  41465. }
  41466. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  41467. import { Nullable } from "babylonjs/types";
  41468. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41469. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  41470. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  41471. /**
  41472. * Manage the pointers inputs to control an follow camera.
  41473. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41474. */
  41475. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  41476. /**
  41477. * Defines the camera the input is attached to.
  41478. */
  41479. camera: FollowCamera;
  41480. /**
  41481. * Gets the class name of the current input.
  41482. * @returns the class name
  41483. */
  41484. getClassName(): string;
  41485. /**
  41486. * Defines the pointer angular sensibility along the X axis or how fast is
  41487. * the camera rotating.
  41488. * A negative number will reverse the axis direction.
  41489. */
  41490. angularSensibilityX: number;
  41491. /**
  41492. * Defines the pointer angular sensibility along the Y axis or how fast is
  41493. * the camera rotating.
  41494. * A negative number will reverse the axis direction.
  41495. */
  41496. angularSensibilityY: number;
  41497. /**
  41498. * Defines the pointer pinch precision or how fast is the camera zooming.
  41499. * A negative number will reverse the axis direction.
  41500. */
  41501. pinchPrecision: number;
  41502. /**
  41503. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41504. * from 0.
  41505. * It defines the percentage of current camera.radius to use as delta when
  41506. * pinch zoom is used.
  41507. */
  41508. pinchDeltaPercentage: number;
  41509. /**
  41510. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  41511. */
  41512. axisXControlRadius: boolean;
  41513. /**
  41514. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  41515. */
  41516. axisXControlHeight: boolean;
  41517. /**
  41518. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  41519. */
  41520. axisXControlRotation: boolean;
  41521. /**
  41522. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  41523. */
  41524. axisYControlRadius: boolean;
  41525. /**
  41526. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  41527. */
  41528. axisYControlHeight: boolean;
  41529. /**
  41530. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  41531. */
  41532. axisYControlRotation: boolean;
  41533. /**
  41534. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  41535. */
  41536. axisPinchControlRadius: boolean;
  41537. /**
  41538. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  41539. */
  41540. axisPinchControlHeight: boolean;
  41541. /**
  41542. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  41543. */
  41544. axisPinchControlRotation: boolean;
  41545. /**
  41546. * Log error messages if basic misconfiguration has occurred.
  41547. */
  41548. warningEnable: boolean;
  41549. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41550. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41551. private _warningCounter;
  41552. private _warning;
  41553. }
  41554. }
  41555. declare module "babylonjs/Cameras/followCameraInputsManager" {
  41556. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41557. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41558. /**
  41559. * Default Inputs manager for the FollowCamera.
  41560. * It groups all the default supported inputs for ease of use.
  41561. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41562. */
  41563. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  41564. /**
  41565. * Instantiates a new FollowCameraInputsManager.
  41566. * @param camera Defines the camera the inputs belong to
  41567. */
  41568. constructor(camera: FollowCamera);
  41569. /**
  41570. * Add keyboard input support to the input manager.
  41571. * @returns the current input manager
  41572. */
  41573. addKeyboard(): FollowCameraInputsManager;
  41574. /**
  41575. * Add mouse wheel input support to the input manager.
  41576. * @returns the current input manager
  41577. */
  41578. addMouseWheel(): FollowCameraInputsManager;
  41579. /**
  41580. * Add pointers input support to the input manager.
  41581. * @returns the current input manager
  41582. */
  41583. addPointers(): FollowCameraInputsManager;
  41584. /**
  41585. * Add orientation input support to the input manager.
  41586. * @returns the current input manager
  41587. */
  41588. addVRDeviceOrientation(): FollowCameraInputsManager;
  41589. }
  41590. }
  41591. declare module "babylonjs/Cameras/followCamera" {
  41592. import { Nullable } from "babylonjs/types";
  41593. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41594. import { Scene } from "babylonjs/scene";
  41595. import { Vector3 } from "babylonjs/Maths/math.vector";
  41596. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41597. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  41598. /**
  41599. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  41600. * an arc rotate version arcFollowCamera are available.
  41601. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41602. */
  41603. export class FollowCamera extends TargetCamera {
  41604. /**
  41605. * Distance the follow camera should follow an object at
  41606. */
  41607. radius: number;
  41608. /**
  41609. * Minimum allowed distance of the camera to the axis of rotation
  41610. * (The camera can not get closer).
  41611. * This can help limiting how the Camera is able to move in the scene.
  41612. */
  41613. lowerRadiusLimit: Nullable<number>;
  41614. /**
  41615. * Maximum allowed distance of the camera to the axis of rotation
  41616. * (The camera can not get further).
  41617. * This can help limiting how the Camera is able to move in the scene.
  41618. */
  41619. upperRadiusLimit: Nullable<number>;
  41620. /**
  41621. * Define a rotation offset between the camera and the object it follows
  41622. */
  41623. rotationOffset: number;
  41624. /**
  41625. * Minimum allowed angle to camera position relative to target object.
  41626. * This can help limiting how the Camera is able to move in the scene.
  41627. */
  41628. lowerRotationOffsetLimit: Nullable<number>;
  41629. /**
  41630. * Maximum allowed angle to camera position relative to target object.
  41631. * This can help limiting how the Camera is able to move in the scene.
  41632. */
  41633. upperRotationOffsetLimit: Nullable<number>;
  41634. /**
  41635. * Define a height offset between the camera and the object it follows.
  41636. * It can help following an object from the top (like a car chaing a plane)
  41637. */
  41638. heightOffset: number;
  41639. /**
  41640. * Minimum allowed height of camera position relative to target object.
  41641. * This can help limiting how the Camera is able to move in the scene.
  41642. */
  41643. lowerHeightOffsetLimit: Nullable<number>;
  41644. /**
  41645. * Maximum allowed height of camera position relative to target object.
  41646. * This can help limiting how the Camera is able to move in the scene.
  41647. */
  41648. upperHeightOffsetLimit: Nullable<number>;
  41649. /**
  41650. * Define how fast the camera can accelerate to follow it s target.
  41651. */
  41652. cameraAcceleration: number;
  41653. /**
  41654. * Define the speed limit of the camera following an object.
  41655. */
  41656. maxCameraSpeed: number;
  41657. /**
  41658. * Define the target of the camera.
  41659. */
  41660. lockedTarget: Nullable<AbstractMesh>;
  41661. /**
  41662. * Defines the input associated with the camera.
  41663. */
  41664. inputs: FollowCameraInputsManager;
  41665. /**
  41666. * Instantiates the follow camera.
  41667. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41668. * @param name Define the name of the camera in the scene
  41669. * @param position Define the position of the camera
  41670. * @param scene Define the scene the camera belong to
  41671. * @param lockedTarget Define the target of the camera
  41672. */
  41673. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  41674. private _follow;
  41675. /**
  41676. * Attached controls to the current camera.
  41677. * @param element Defines the element the controls should be listened from
  41678. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41679. */
  41680. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41681. /**
  41682. * Detach the current controls from the camera.
  41683. * The camera will stop reacting to inputs.
  41684. * @param element Defines the element to stop listening the inputs from
  41685. */
  41686. detachControl(element: HTMLElement): void;
  41687. /** @hidden */
  41688. _checkInputs(): void;
  41689. private _checkLimits;
  41690. /**
  41691. * Gets the camera class name.
  41692. * @returns the class name
  41693. */
  41694. getClassName(): string;
  41695. }
  41696. /**
  41697. * Arc Rotate version of the follow camera.
  41698. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  41699. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41700. */
  41701. export class ArcFollowCamera extends TargetCamera {
  41702. /** The longitudinal angle of the camera */
  41703. alpha: number;
  41704. /** The latitudinal angle of the camera */
  41705. beta: number;
  41706. /** The radius of the camera from its target */
  41707. radius: number;
  41708. /** Define the camera target (the messh it should follow) */
  41709. target: Nullable<AbstractMesh>;
  41710. private _cartesianCoordinates;
  41711. /**
  41712. * Instantiates a new ArcFollowCamera
  41713. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41714. * @param name Define the name of the camera
  41715. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  41716. * @param beta Define the rotation angle of the camera around the elevation axis
  41717. * @param radius Define the radius of the camera from its target point
  41718. * @param target Define the target of the camera
  41719. * @param scene Define the scene the camera belongs to
  41720. */
  41721. constructor(name: string,
  41722. /** The longitudinal angle of the camera */
  41723. alpha: number,
  41724. /** The latitudinal angle of the camera */
  41725. beta: number,
  41726. /** The radius of the camera from its target */
  41727. radius: number,
  41728. /** Define the camera target (the messh it should follow) */
  41729. target: Nullable<AbstractMesh>, scene: Scene);
  41730. private _follow;
  41731. /** @hidden */
  41732. _checkInputs(): void;
  41733. /**
  41734. * Returns the class name of the object.
  41735. * It is mostly used internally for serialization purposes.
  41736. */
  41737. getClassName(): string;
  41738. }
  41739. }
  41740. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  41741. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41742. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41743. import { Nullable } from "babylonjs/types";
  41744. /**
  41745. * Manage the keyboard inputs to control the movement of a follow camera.
  41746. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41747. */
  41748. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  41749. /**
  41750. * Defines the camera the input is attached to.
  41751. */
  41752. camera: FollowCamera;
  41753. /**
  41754. * Defines the list of key codes associated with the up action (increase heightOffset)
  41755. */
  41756. keysHeightOffsetIncr: number[];
  41757. /**
  41758. * Defines the list of key codes associated with the down action (decrease heightOffset)
  41759. */
  41760. keysHeightOffsetDecr: number[];
  41761. /**
  41762. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  41763. */
  41764. keysHeightOffsetModifierAlt: boolean;
  41765. /**
  41766. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  41767. */
  41768. keysHeightOffsetModifierCtrl: boolean;
  41769. /**
  41770. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  41771. */
  41772. keysHeightOffsetModifierShift: boolean;
  41773. /**
  41774. * Defines the list of key codes associated with the left action (increase rotationOffset)
  41775. */
  41776. keysRotationOffsetIncr: number[];
  41777. /**
  41778. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  41779. */
  41780. keysRotationOffsetDecr: number[];
  41781. /**
  41782. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  41783. */
  41784. keysRotationOffsetModifierAlt: boolean;
  41785. /**
  41786. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41787. */
  41788. keysRotationOffsetModifierCtrl: boolean;
  41789. /**
  41790. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41791. */
  41792. keysRotationOffsetModifierShift: boolean;
  41793. /**
  41794. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41795. */
  41796. keysRadiusIncr: number[];
  41797. /**
  41798. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41799. */
  41800. keysRadiusDecr: number[];
  41801. /**
  41802. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41803. */
  41804. keysRadiusModifierAlt: boolean;
  41805. /**
  41806. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41807. */
  41808. keysRadiusModifierCtrl: boolean;
  41809. /**
  41810. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41811. */
  41812. keysRadiusModifierShift: boolean;
  41813. /**
  41814. * Defines the rate of change of heightOffset.
  41815. */
  41816. heightSensibility: number;
  41817. /**
  41818. * Defines the rate of change of rotationOffset.
  41819. */
  41820. rotationSensibility: number;
  41821. /**
  41822. * Defines the rate of change of radius.
  41823. */
  41824. radiusSensibility: number;
  41825. private _keys;
  41826. private _ctrlPressed;
  41827. private _altPressed;
  41828. private _shiftPressed;
  41829. private _onCanvasBlurObserver;
  41830. private _onKeyboardObserver;
  41831. private _engine;
  41832. private _scene;
  41833. /**
  41834. * Attach the input controls to a specific dom element to get the input from.
  41835. * @param element Defines the element the controls should be listened from
  41836. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41837. */
  41838. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41839. /**
  41840. * Detach the current controls from the specified dom element.
  41841. * @param element Defines the element to stop listening the inputs from
  41842. */
  41843. detachControl(element: Nullable<HTMLElement>): void;
  41844. /**
  41845. * Update the current camera state depending on the inputs that have been used this frame.
  41846. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41847. */
  41848. checkInputs(): void;
  41849. /**
  41850. * Gets the class name of the current input.
  41851. * @returns the class name
  41852. */
  41853. getClassName(): string;
  41854. /**
  41855. * Get the friendly name associated with the input class.
  41856. * @returns the input friendly name
  41857. */
  41858. getSimpleName(): string;
  41859. /**
  41860. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41861. * allow modification of the heightOffset value.
  41862. */
  41863. private _modifierHeightOffset;
  41864. /**
  41865. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41866. * allow modification of the rotationOffset value.
  41867. */
  41868. private _modifierRotationOffset;
  41869. /**
  41870. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41871. * allow modification of the radius value.
  41872. */
  41873. private _modifierRadius;
  41874. }
  41875. }
  41876. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  41877. import { Nullable } from "babylonjs/types";
  41878. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41879. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41880. import { Observable } from "babylonjs/Misc/observable";
  41881. module "babylonjs/Cameras/freeCameraInputsManager" {
  41882. interface FreeCameraInputsManager {
  41883. /**
  41884. * @hidden
  41885. */
  41886. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41887. /**
  41888. * Add orientation input support to the input manager.
  41889. * @returns the current input manager
  41890. */
  41891. addDeviceOrientation(): FreeCameraInputsManager;
  41892. }
  41893. }
  41894. /**
  41895. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41896. * Screen rotation is taken into account.
  41897. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41898. */
  41899. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41900. private _camera;
  41901. private _screenOrientationAngle;
  41902. private _constantTranform;
  41903. private _screenQuaternion;
  41904. private _alpha;
  41905. private _beta;
  41906. private _gamma;
  41907. /**
  41908. * Can be used to detect if a device orientation sensor is available on a device
  41909. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41910. * @returns a promise that will resolve on orientation change
  41911. */
  41912. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41913. /**
  41914. * @hidden
  41915. */
  41916. _onDeviceOrientationChangedObservable: Observable<void>;
  41917. /**
  41918. * Instantiates a new input
  41919. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41920. */
  41921. constructor();
  41922. /**
  41923. * Define the camera controlled by the input.
  41924. */
  41925. get camera(): FreeCamera;
  41926. set camera(camera: FreeCamera);
  41927. /**
  41928. * Attach the input controls to a specific dom element to get the input from.
  41929. * @param element Defines the element the controls should be listened from
  41930. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41931. */
  41932. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41933. private _orientationChanged;
  41934. private _deviceOrientation;
  41935. /**
  41936. * Detach the current controls from the specified dom element.
  41937. * @param element Defines the element to stop listening the inputs from
  41938. */
  41939. detachControl(element: Nullable<HTMLElement>): void;
  41940. /**
  41941. * Update the current camera state depending on the inputs that have been used this frame.
  41942. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41943. */
  41944. checkInputs(): void;
  41945. /**
  41946. * Gets the class name of the current intput.
  41947. * @returns the class name
  41948. */
  41949. getClassName(): string;
  41950. /**
  41951. * Get the friendly name associated with the input class.
  41952. * @returns the input friendly name
  41953. */
  41954. getSimpleName(): string;
  41955. }
  41956. }
  41957. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  41958. import { Nullable } from "babylonjs/types";
  41959. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41960. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41961. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41962. /**
  41963. * Manage the gamepad inputs to control a free camera.
  41964. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41965. */
  41966. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41967. /**
  41968. * Define the camera the input is attached to.
  41969. */
  41970. camera: FreeCamera;
  41971. /**
  41972. * Define the Gamepad controlling the input
  41973. */
  41974. gamepad: Nullable<Gamepad>;
  41975. /**
  41976. * Defines the gamepad rotation sensiblity.
  41977. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41978. */
  41979. gamepadAngularSensibility: number;
  41980. /**
  41981. * Defines the gamepad move sensiblity.
  41982. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41983. */
  41984. gamepadMoveSensibility: number;
  41985. private _yAxisScale;
  41986. /**
  41987. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41988. */
  41989. get invertYAxis(): boolean;
  41990. set invertYAxis(value: boolean);
  41991. private _onGamepadConnectedObserver;
  41992. private _onGamepadDisconnectedObserver;
  41993. private _cameraTransform;
  41994. private _deltaTransform;
  41995. private _vector3;
  41996. private _vector2;
  41997. /**
  41998. * Attach the input controls to a specific dom element to get the input from.
  41999. * @param element Defines the element the controls should be listened from
  42000. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42001. */
  42002. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42003. /**
  42004. * Detach the current controls from the specified dom element.
  42005. * @param element Defines the element to stop listening the inputs from
  42006. */
  42007. detachControl(element: Nullable<HTMLElement>): void;
  42008. /**
  42009. * Update the current camera state depending on the inputs that have been used this frame.
  42010. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42011. */
  42012. checkInputs(): void;
  42013. /**
  42014. * Gets the class name of the current intput.
  42015. * @returns the class name
  42016. */
  42017. getClassName(): string;
  42018. /**
  42019. * Get the friendly name associated with the input class.
  42020. * @returns the input friendly name
  42021. */
  42022. getSimpleName(): string;
  42023. }
  42024. }
  42025. declare module "babylonjs/Misc/virtualJoystick" {
  42026. import { Nullable } from "babylonjs/types";
  42027. import { Vector3 } from "babylonjs/Maths/math.vector";
  42028. /**
  42029. * Defines the potential axis of a Joystick
  42030. */
  42031. export enum JoystickAxis {
  42032. /** X axis */
  42033. X = 0,
  42034. /** Y axis */
  42035. Y = 1,
  42036. /** Z axis */
  42037. Z = 2
  42038. }
  42039. /**
  42040. * Class used to define virtual joystick (used in touch mode)
  42041. */
  42042. export class VirtualJoystick {
  42043. /**
  42044. * Gets or sets a boolean indicating that left and right values must be inverted
  42045. */
  42046. reverseLeftRight: boolean;
  42047. /**
  42048. * Gets or sets a boolean indicating that up and down values must be inverted
  42049. */
  42050. reverseUpDown: boolean;
  42051. /**
  42052. * Gets the offset value for the position (ie. the change of the position value)
  42053. */
  42054. deltaPosition: Vector3;
  42055. /**
  42056. * Gets a boolean indicating if the virtual joystick was pressed
  42057. */
  42058. pressed: boolean;
  42059. /**
  42060. * Canvas the virtual joystick will render onto, default z-index of this is 5
  42061. */
  42062. static Canvas: Nullable<HTMLCanvasElement>;
  42063. private static _globalJoystickIndex;
  42064. private static vjCanvasContext;
  42065. private static vjCanvasWidth;
  42066. private static vjCanvasHeight;
  42067. private static halfWidth;
  42068. private _action;
  42069. private _axisTargetedByLeftAndRight;
  42070. private _axisTargetedByUpAndDown;
  42071. private _joystickSensibility;
  42072. private _inversedSensibility;
  42073. private _joystickPointerID;
  42074. private _joystickColor;
  42075. private _joystickPointerPos;
  42076. private _joystickPreviousPointerPos;
  42077. private _joystickPointerStartPos;
  42078. private _deltaJoystickVector;
  42079. private _leftJoystick;
  42080. private _touches;
  42081. private _onPointerDownHandlerRef;
  42082. private _onPointerMoveHandlerRef;
  42083. private _onPointerUpHandlerRef;
  42084. private _onResize;
  42085. /**
  42086. * Creates a new virtual joystick
  42087. * @param leftJoystick defines that the joystick is for left hand (false by default)
  42088. */
  42089. constructor(leftJoystick?: boolean);
  42090. /**
  42091. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  42092. * @param newJoystickSensibility defines the new sensibility
  42093. */
  42094. setJoystickSensibility(newJoystickSensibility: number): void;
  42095. private _onPointerDown;
  42096. private _onPointerMove;
  42097. private _onPointerUp;
  42098. /**
  42099. * Change the color of the virtual joystick
  42100. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  42101. */
  42102. setJoystickColor(newColor: string): void;
  42103. /**
  42104. * Defines a callback to call when the joystick is touched
  42105. * @param action defines the callback
  42106. */
  42107. setActionOnTouch(action: () => any): void;
  42108. /**
  42109. * Defines which axis you'd like to control for left & right
  42110. * @param axis defines the axis to use
  42111. */
  42112. setAxisForLeftRight(axis: JoystickAxis): void;
  42113. /**
  42114. * Defines which axis you'd like to control for up & down
  42115. * @param axis defines the axis to use
  42116. */
  42117. setAxisForUpDown(axis: JoystickAxis): void;
  42118. private _drawVirtualJoystick;
  42119. /**
  42120. * Release internal HTML canvas
  42121. */
  42122. releaseCanvas(): void;
  42123. }
  42124. }
  42125. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  42126. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  42127. import { Nullable } from "babylonjs/types";
  42128. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42129. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42130. module "babylonjs/Cameras/freeCameraInputsManager" {
  42131. interface FreeCameraInputsManager {
  42132. /**
  42133. * Add virtual joystick input support to the input manager.
  42134. * @returns the current input manager
  42135. */
  42136. addVirtualJoystick(): FreeCameraInputsManager;
  42137. }
  42138. }
  42139. /**
  42140. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  42141. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42142. */
  42143. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  42144. /**
  42145. * Defines the camera the input is attached to.
  42146. */
  42147. camera: FreeCamera;
  42148. private _leftjoystick;
  42149. private _rightjoystick;
  42150. /**
  42151. * Gets the left stick of the virtual joystick.
  42152. * @returns The virtual Joystick
  42153. */
  42154. getLeftJoystick(): VirtualJoystick;
  42155. /**
  42156. * Gets the right stick of the virtual joystick.
  42157. * @returns The virtual Joystick
  42158. */
  42159. getRightJoystick(): VirtualJoystick;
  42160. /**
  42161. * Update the current camera state depending on the inputs that have been used this frame.
  42162. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42163. */
  42164. checkInputs(): void;
  42165. /**
  42166. * Attach the input controls to a specific dom element to get the input from.
  42167. * @param element Defines the element the controls should be listened from
  42168. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42169. */
  42170. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42171. /**
  42172. * Detach the current controls from the specified dom element.
  42173. * @param element Defines the element to stop listening the inputs from
  42174. */
  42175. detachControl(element: Nullable<HTMLElement>): void;
  42176. /**
  42177. * Gets the class name of the current intput.
  42178. * @returns the class name
  42179. */
  42180. getClassName(): string;
  42181. /**
  42182. * Get the friendly name associated with the input class.
  42183. * @returns the input friendly name
  42184. */
  42185. getSimpleName(): string;
  42186. }
  42187. }
  42188. declare module "babylonjs/Cameras/Inputs/index" {
  42189. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  42190. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  42191. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  42192. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  42193. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  42194. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  42195. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  42196. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  42197. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  42198. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  42199. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42200. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  42201. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  42202. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  42203. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  42204. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  42205. }
  42206. declare module "babylonjs/Cameras/touchCamera" {
  42207. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42208. import { Scene } from "babylonjs/scene";
  42209. import { Vector3 } from "babylonjs/Maths/math.vector";
  42210. /**
  42211. * This represents a FPS type of camera controlled by touch.
  42212. * This is like a universal camera minus the Gamepad controls.
  42213. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42214. */
  42215. export class TouchCamera extends FreeCamera {
  42216. /**
  42217. * Defines the touch sensibility for rotation.
  42218. * The higher the faster.
  42219. */
  42220. get touchAngularSensibility(): number;
  42221. set touchAngularSensibility(value: number);
  42222. /**
  42223. * Defines the touch sensibility for move.
  42224. * The higher the faster.
  42225. */
  42226. get touchMoveSensibility(): number;
  42227. set touchMoveSensibility(value: number);
  42228. /**
  42229. * Instantiates a new touch camera.
  42230. * This represents a FPS type of camera controlled by touch.
  42231. * This is like a universal camera minus the Gamepad controls.
  42232. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42233. * @param name Define the name of the camera in the scene
  42234. * @param position Define the start position of the camera in the scene
  42235. * @param scene Define the scene the camera belongs to
  42236. */
  42237. constructor(name: string, position: Vector3, scene: Scene);
  42238. /**
  42239. * Gets the current object class name.
  42240. * @return the class name
  42241. */
  42242. getClassName(): string;
  42243. /** @hidden */
  42244. _setupInputs(): void;
  42245. }
  42246. }
  42247. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  42248. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42249. import { Scene } from "babylonjs/scene";
  42250. import { Vector3 } from "babylonjs/Maths/math.vector";
  42251. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42252. import { Axis } from "babylonjs/Maths/math.axis";
  42253. /**
  42254. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  42255. * being tilted forward or back and left or right.
  42256. */
  42257. export class DeviceOrientationCamera extends FreeCamera {
  42258. private _initialQuaternion;
  42259. private _quaternionCache;
  42260. private _tmpDragQuaternion;
  42261. private _disablePointerInputWhenUsingDeviceOrientation;
  42262. /**
  42263. * Creates a new device orientation camera
  42264. * @param name The name of the camera
  42265. * @param position The start position camera
  42266. * @param scene The scene the camera belongs to
  42267. */
  42268. constructor(name: string, position: Vector3, scene: Scene);
  42269. /**
  42270. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  42271. */
  42272. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  42273. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  42274. private _dragFactor;
  42275. /**
  42276. * Enabled turning on the y axis when the orientation sensor is active
  42277. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  42278. */
  42279. enableHorizontalDragging(dragFactor?: number): void;
  42280. /**
  42281. * Gets the current instance class name ("DeviceOrientationCamera").
  42282. * This helps avoiding instanceof at run time.
  42283. * @returns the class name
  42284. */
  42285. getClassName(): string;
  42286. /**
  42287. * @hidden
  42288. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  42289. */
  42290. _checkInputs(): void;
  42291. /**
  42292. * Reset the camera to its default orientation on the specified axis only.
  42293. * @param axis The axis to reset
  42294. */
  42295. resetToCurrentRotation(axis?: Axis): void;
  42296. }
  42297. }
  42298. declare module "babylonjs/Gamepads/xboxGamepad" {
  42299. import { Observable } from "babylonjs/Misc/observable";
  42300. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42301. /**
  42302. * Defines supported buttons for XBox360 compatible gamepads
  42303. */
  42304. export enum Xbox360Button {
  42305. /** A */
  42306. A = 0,
  42307. /** B */
  42308. B = 1,
  42309. /** X */
  42310. X = 2,
  42311. /** Y */
  42312. Y = 3,
  42313. /** Start */
  42314. Start = 4,
  42315. /** Back */
  42316. Back = 5,
  42317. /** Left button */
  42318. LB = 6,
  42319. /** Right button */
  42320. RB = 7,
  42321. /** Left stick */
  42322. LeftStick = 8,
  42323. /** Right stick */
  42324. RightStick = 9
  42325. }
  42326. /** Defines values for XBox360 DPad */
  42327. export enum Xbox360Dpad {
  42328. /** Up */
  42329. Up = 0,
  42330. /** Down */
  42331. Down = 1,
  42332. /** Left */
  42333. Left = 2,
  42334. /** Right */
  42335. Right = 3
  42336. }
  42337. /**
  42338. * Defines a XBox360 gamepad
  42339. */
  42340. export class Xbox360Pad extends Gamepad {
  42341. private _leftTrigger;
  42342. private _rightTrigger;
  42343. private _onlefttriggerchanged;
  42344. private _onrighttriggerchanged;
  42345. private _onbuttondown;
  42346. private _onbuttonup;
  42347. private _ondpaddown;
  42348. private _ondpadup;
  42349. /** Observable raised when a button is pressed */
  42350. onButtonDownObservable: Observable<Xbox360Button>;
  42351. /** Observable raised when a button is released */
  42352. onButtonUpObservable: Observable<Xbox360Button>;
  42353. /** Observable raised when a pad is pressed */
  42354. onPadDownObservable: Observable<Xbox360Dpad>;
  42355. /** Observable raised when a pad is released */
  42356. onPadUpObservable: Observable<Xbox360Dpad>;
  42357. private _buttonA;
  42358. private _buttonB;
  42359. private _buttonX;
  42360. private _buttonY;
  42361. private _buttonBack;
  42362. private _buttonStart;
  42363. private _buttonLB;
  42364. private _buttonRB;
  42365. private _buttonLeftStick;
  42366. private _buttonRightStick;
  42367. private _dPadUp;
  42368. private _dPadDown;
  42369. private _dPadLeft;
  42370. private _dPadRight;
  42371. private _isXboxOnePad;
  42372. /**
  42373. * Creates a new XBox360 gamepad object
  42374. * @param id defines the id of this gamepad
  42375. * @param index defines its index
  42376. * @param gamepad defines the internal HTML gamepad object
  42377. * @param xboxOne defines if it is a XBox One gamepad
  42378. */
  42379. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  42380. /**
  42381. * Defines the callback to call when left trigger is pressed
  42382. * @param callback defines the callback to use
  42383. */
  42384. onlefttriggerchanged(callback: (value: number) => void): void;
  42385. /**
  42386. * Defines the callback to call when right trigger is pressed
  42387. * @param callback defines the callback to use
  42388. */
  42389. onrighttriggerchanged(callback: (value: number) => void): void;
  42390. /**
  42391. * Gets the left trigger value
  42392. */
  42393. get leftTrigger(): number;
  42394. /**
  42395. * Sets the left trigger value
  42396. */
  42397. set leftTrigger(newValue: number);
  42398. /**
  42399. * Gets the right trigger value
  42400. */
  42401. get rightTrigger(): number;
  42402. /**
  42403. * Sets the right trigger value
  42404. */
  42405. set rightTrigger(newValue: number);
  42406. /**
  42407. * Defines the callback to call when a button is pressed
  42408. * @param callback defines the callback to use
  42409. */
  42410. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  42411. /**
  42412. * Defines the callback to call when a button is released
  42413. * @param callback defines the callback to use
  42414. */
  42415. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  42416. /**
  42417. * Defines the callback to call when a pad is pressed
  42418. * @param callback defines the callback to use
  42419. */
  42420. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  42421. /**
  42422. * Defines the callback to call when a pad is released
  42423. * @param callback defines the callback to use
  42424. */
  42425. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  42426. private _setButtonValue;
  42427. private _setDPadValue;
  42428. /**
  42429. * Gets the value of the `A` button
  42430. */
  42431. get buttonA(): number;
  42432. /**
  42433. * Sets the value of the `A` button
  42434. */
  42435. set buttonA(value: number);
  42436. /**
  42437. * Gets the value of the `B` button
  42438. */
  42439. get buttonB(): number;
  42440. /**
  42441. * Sets the value of the `B` button
  42442. */
  42443. set buttonB(value: number);
  42444. /**
  42445. * Gets the value of the `X` button
  42446. */
  42447. get buttonX(): number;
  42448. /**
  42449. * Sets the value of the `X` button
  42450. */
  42451. set buttonX(value: number);
  42452. /**
  42453. * Gets the value of the `Y` button
  42454. */
  42455. get buttonY(): number;
  42456. /**
  42457. * Sets the value of the `Y` button
  42458. */
  42459. set buttonY(value: number);
  42460. /**
  42461. * Gets the value of the `Start` button
  42462. */
  42463. get buttonStart(): number;
  42464. /**
  42465. * Sets the value of the `Start` button
  42466. */
  42467. set buttonStart(value: number);
  42468. /**
  42469. * Gets the value of the `Back` button
  42470. */
  42471. get buttonBack(): number;
  42472. /**
  42473. * Sets the value of the `Back` button
  42474. */
  42475. set buttonBack(value: number);
  42476. /**
  42477. * Gets the value of the `Left` button
  42478. */
  42479. get buttonLB(): number;
  42480. /**
  42481. * Sets the value of the `Left` button
  42482. */
  42483. set buttonLB(value: number);
  42484. /**
  42485. * Gets the value of the `Right` button
  42486. */
  42487. get buttonRB(): number;
  42488. /**
  42489. * Sets the value of the `Right` button
  42490. */
  42491. set buttonRB(value: number);
  42492. /**
  42493. * Gets the value of the Left joystick
  42494. */
  42495. get buttonLeftStick(): number;
  42496. /**
  42497. * Sets the value of the Left joystick
  42498. */
  42499. set buttonLeftStick(value: number);
  42500. /**
  42501. * Gets the value of the Right joystick
  42502. */
  42503. get buttonRightStick(): number;
  42504. /**
  42505. * Sets the value of the Right joystick
  42506. */
  42507. set buttonRightStick(value: number);
  42508. /**
  42509. * Gets the value of D-pad up
  42510. */
  42511. get dPadUp(): number;
  42512. /**
  42513. * Sets the value of D-pad up
  42514. */
  42515. set dPadUp(value: number);
  42516. /**
  42517. * Gets the value of D-pad down
  42518. */
  42519. get dPadDown(): number;
  42520. /**
  42521. * Sets the value of D-pad down
  42522. */
  42523. set dPadDown(value: number);
  42524. /**
  42525. * Gets the value of D-pad left
  42526. */
  42527. get dPadLeft(): number;
  42528. /**
  42529. * Sets the value of D-pad left
  42530. */
  42531. set dPadLeft(value: number);
  42532. /**
  42533. * Gets the value of D-pad right
  42534. */
  42535. get dPadRight(): number;
  42536. /**
  42537. * Sets the value of D-pad right
  42538. */
  42539. set dPadRight(value: number);
  42540. /**
  42541. * Force the gamepad to synchronize with device values
  42542. */
  42543. update(): void;
  42544. /**
  42545. * Disposes the gamepad
  42546. */
  42547. dispose(): void;
  42548. }
  42549. }
  42550. declare module "babylonjs/Gamepads/dualShockGamepad" {
  42551. import { Observable } from "babylonjs/Misc/observable";
  42552. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42553. /**
  42554. * Defines supported buttons for DualShock compatible gamepads
  42555. */
  42556. export enum DualShockButton {
  42557. /** Cross */
  42558. Cross = 0,
  42559. /** Circle */
  42560. Circle = 1,
  42561. /** Square */
  42562. Square = 2,
  42563. /** Triangle */
  42564. Triangle = 3,
  42565. /** Options */
  42566. Options = 4,
  42567. /** Share */
  42568. Share = 5,
  42569. /** L1 */
  42570. L1 = 6,
  42571. /** R1 */
  42572. R1 = 7,
  42573. /** Left stick */
  42574. LeftStick = 8,
  42575. /** Right stick */
  42576. RightStick = 9
  42577. }
  42578. /** Defines values for DualShock DPad */
  42579. export enum DualShockDpad {
  42580. /** Up */
  42581. Up = 0,
  42582. /** Down */
  42583. Down = 1,
  42584. /** Left */
  42585. Left = 2,
  42586. /** Right */
  42587. Right = 3
  42588. }
  42589. /**
  42590. * Defines a DualShock gamepad
  42591. */
  42592. export class DualShockPad extends Gamepad {
  42593. private _leftTrigger;
  42594. private _rightTrigger;
  42595. private _onlefttriggerchanged;
  42596. private _onrighttriggerchanged;
  42597. private _onbuttondown;
  42598. private _onbuttonup;
  42599. private _ondpaddown;
  42600. private _ondpadup;
  42601. /** Observable raised when a button is pressed */
  42602. onButtonDownObservable: Observable<DualShockButton>;
  42603. /** Observable raised when a button is released */
  42604. onButtonUpObservable: Observable<DualShockButton>;
  42605. /** Observable raised when a pad is pressed */
  42606. onPadDownObservable: Observable<DualShockDpad>;
  42607. /** Observable raised when a pad is released */
  42608. onPadUpObservable: Observable<DualShockDpad>;
  42609. private _buttonCross;
  42610. private _buttonCircle;
  42611. private _buttonSquare;
  42612. private _buttonTriangle;
  42613. private _buttonShare;
  42614. private _buttonOptions;
  42615. private _buttonL1;
  42616. private _buttonR1;
  42617. private _buttonLeftStick;
  42618. private _buttonRightStick;
  42619. private _dPadUp;
  42620. private _dPadDown;
  42621. private _dPadLeft;
  42622. private _dPadRight;
  42623. /**
  42624. * Creates a new DualShock gamepad object
  42625. * @param id defines the id of this gamepad
  42626. * @param index defines its index
  42627. * @param gamepad defines the internal HTML gamepad object
  42628. */
  42629. constructor(id: string, index: number, gamepad: any);
  42630. /**
  42631. * Defines the callback to call when left trigger is pressed
  42632. * @param callback defines the callback to use
  42633. */
  42634. onlefttriggerchanged(callback: (value: number) => void): void;
  42635. /**
  42636. * Defines the callback to call when right trigger is pressed
  42637. * @param callback defines the callback to use
  42638. */
  42639. onrighttriggerchanged(callback: (value: number) => void): void;
  42640. /**
  42641. * Gets the left trigger value
  42642. */
  42643. get leftTrigger(): number;
  42644. /**
  42645. * Sets the left trigger value
  42646. */
  42647. set leftTrigger(newValue: number);
  42648. /**
  42649. * Gets the right trigger value
  42650. */
  42651. get rightTrigger(): number;
  42652. /**
  42653. * Sets the right trigger value
  42654. */
  42655. set rightTrigger(newValue: number);
  42656. /**
  42657. * Defines the callback to call when a button is pressed
  42658. * @param callback defines the callback to use
  42659. */
  42660. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  42661. /**
  42662. * Defines the callback to call when a button is released
  42663. * @param callback defines the callback to use
  42664. */
  42665. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  42666. /**
  42667. * Defines the callback to call when a pad is pressed
  42668. * @param callback defines the callback to use
  42669. */
  42670. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  42671. /**
  42672. * Defines the callback to call when a pad is released
  42673. * @param callback defines the callback to use
  42674. */
  42675. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  42676. private _setButtonValue;
  42677. private _setDPadValue;
  42678. /**
  42679. * Gets the value of the `Cross` button
  42680. */
  42681. get buttonCross(): number;
  42682. /**
  42683. * Sets the value of the `Cross` button
  42684. */
  42685. set buttonCross(value: number);
  42686. /**
  42687. * Gets the value of the `Circle` button
  42688. */
  42689. get buttonCircle(): number;
  42690. /**
  42691. * Sets the value of the `Circle` button
  42692. */
  42693. set buttonCircle(value: number);
  42694. /**
  42695. * Gets the value of the `Square` button
  42696. */
  42697. get buttonSquare(): number;
  42698. /**
  42699. * Sets the value of the `Square` button
  42700. */
  42701. set buttonSquare(value: number);
  42702. /**
  42703. * Gets the value of the `Triangle` button
  42704. */
  42705. get buttonTriangle(): number;
  42706. /**
  42707. * Sets the value of the `Triangle` button
  42708. */
  42709. set buttonTriangle(value: number);
  42710. /**
  42711. * Gets the value of the `Options` button
  42712. */
  42713. get buttonOptions(): number;
  42714. /**
  42715. * Sets the value of the `Options` button
  42716. */
  42717. set buttonOptions(value: number);
  42718. /**
  42719. * Gets the value of the `Share` button
  42720. */
  42721. get buttonShare(): number;
  42722. /**
  42723. * Sets the value of the `Share` button
  42724. */
  42725. set buttonShare(value: number);
  42726. /**
  42727. * Gets the value of the `L1` button
  42728. */
  42729. get buttonL1(): number;
  42730. /**
  42731. * Sets the value of the `L1` button
  42732. */
  42733. set buttonL1(value: number);
  42734. /**
  42735. * Gets the value of the `R1` button
  42736. */
  42737. get buttonR1(): number;
  42738. /**
  42739. * Sets the value of the `R1` button
  42740. */
  42741. set buttonR1(value: number);
  42742. /**
  42743. * Gets the value of the Left joystick
  42744. */
  42745. get buttonLeftStick(): number;
  42746. /**
  42747. * Sets the value of the Left joystick
  42748. */
  42749. set buttonLeftStick(value: number);
  42750. /**
  42751. * Gets the value of the Right joystick
  42752. */
  42753. get buttonRightStick(): number;
  42754. /**
  42755. * Sets the value of the Right joystick
  42756. */
  42757. set buttonRightStick(value: number);
  42758. /**
  42759. * Gets the value of D-pad up
  42760. */
  42761. get dPadUp(): number;
  42762. /**
  42763. * Sets the value of D-pad up
  42764. */
  42765. set dPadUp(value: number);
  42766. /**
  42767. * Gets the value of D-pad down
  42768. */
  42769. get dPadDown(): number;
  42770. /**
  42771. * Sets the value of D-pad down
  42772. */
  42773. set dPadDown(value: number);
  42774. /**
  42775. * Gets the value of D-pad left
  42776. */
  42777. get dPadLeft(): number;
  42778. /**
  42779. * Sets the value of D-pad left
  42780. */
  42781. set dPadLeft(value: number);
  42782. /**
  42783. * Gets the value of D-pad right
  42784. */
  42785. get dPadRight(): number;
  42786. /**
  42787. * Sets the value of D-pad right
  42788. */
  42789. set dPadRight(value: number);
  42790. /**
  42791. * Force the gamepad to synchronize with device values
  42792. */
  42793. update(): void;
  42794. /**
  42795. * Disposes the gamepad
  42796. */
  42797. dispose(): void;
  42798. }
  42799. }
  42800. declare module "babylonjs/Gamepads/gamepadManager" {
  42801. import { Observable } from "babylonjs/Misc/observable";
  42802. import { Nullable } from "babylonjs/types";
  42803. import { Scene } from "babylonjs/scene";
  42804. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42805. /**
  42806. * Manager for handling gamepads
  42807. */
  42808. export class GamepadManager {
  42809. private _scene?;
  42810. private _babylonGamepads;
  42811. private _oneGamepadConnected;
  42812. /** @hidden */
  42813. _isMonitoring: boolean;
  42814. private _gamepadEventSupported;
  42815. private _gamepadSupport?;
  42816. /**
  42817. * observable to be triggered when the gamepad controller has been connected
  42818. */
  42819. onGamepadConnectedObservable: Observable<Gamepad>;
  42820. /**
  42821. * observable to be triggered when the gamepad controller has been disconnected
  42822. */
  42823. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42824. private _onGamepadConnectedEvent;
  42825. private _onGamepadDisconnectedEvent;
  42826. /**
  42827. * Initializes the gamepad manager
  42828. * @param _scene BabylonJS scene
  42829. */
  42830. constructor(_scene?: Scene | undefined);
  42831. /**
  42832. * The gamepads in the game pad manager
  42833. */
  42834. get gamepads(): Gamepad[];
  42835. /**
  42836. * Get the gamepad controllers based on type
  42837. * @param type The type of gamepad controller
  42838. * @returns Nullable gamepad
  42839. */
  42840. getGamepadByType(type?: number): Nullable<Gamepad>;
  42841. /**
  42842. * Disposes the gamepad manager
  42843. */
  42844. dispose(): void;
  42845. private _addNewGamepad;
  42846. private _startMonitoringGamepads;
  42847. private _stopMonitoringGamepads;
  42848. /** @hidden */
  42849. _checkGamepadsStatus(): void;
  42850. private _updateGamepadObjects;
  42851. }
  42852. }
  42853. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  42854. import { Nullable } from "babylonjs/types";
  42855. import { Scene } from "babylonjs/scene";
  42856. import { ISceneComponent } from "babylonjs/sceneComponent";
  42857. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  42858. module "babylonjs/scene" {
  42859. interface Scene {
  42860. /** @hidden */
  42861. _gamepadManager: Nullable<GamepadManager>;
  42862. /**
  42863. * Gets the gamepad manager associated with the scene
  42864. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42865. */
  42866. gamepadManager: GamepadManager;
  42867. }
  42868. }
  42869. module "babylonjs/Cameras/freeCameraInputsManager" {
  42870. /**
  42871. * Interface representing a free camera inputs manager
  42872. */
  42873. interface FreeCameraInputsManager {
  42874. /**
  42875. * Adds gamepad input support to the FreeCameraInputsManager.
  42876. * @returns the FreeCameraInputsManager
  42877. */
  42878. addGamepad(): FreeCameraInputsManager;
  42879. }
  42880. }
  42881. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  42882. /**
  42883. * Interface representing an arc rotate camera inputs manager
  42884. */
  42885. interface ArcRotateCameraInputsManager {
  42886. /**
  42887. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42888. * @returns the camera inputs manager
  42889. */
  42890. addGamepad(): ArcRotateCameraInputsManager;
  42891. }
  42892. }
  42893. /**
  42894. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42895. */
  42896. export class GamepadSystemSceneComponent implements ISceneComponent {
  42897. /**
  42898. * The component name helpfull to identify the component in the list of scene components.
  42899. */
  42900. readonly name: string;
  42901. /**
  42902. * The scene the component belongs to.
  42903. */
  42904. scene: Scene;
  42905. /**
  42906. * Creates a new instance of the component for the given scene
  42907. * @param scene Defines the scene to register the component in
  42908. */
  42909. constructor(scene: Scene);
  42910. /**
  42911. * Registers the component in a given scene
  42912. */
  42913. register(): void;
  42914. /**
  42915. * Rebuilds the elements related to this component in case of
  42916. * context lost for instance.
  42917. */
  42918. rebuild(): void;
  42919. /**
  42920. * Disposes the component and the associated ressources
  42921. */
  42922. dispose(): void;
  42923. private _beforeCameraUpdate;
  42924. }
  42925. }
  42926. declare module "babylonjs/Cameras/universalCamera" {
  42927. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  42928. import { Scene } from "babylonjs/scene";
  42929. import { Vector3 } from "babylonjs/Maths/math.vector";
  42930. import "babylonjs/Gamepads/gamepadSceneComponent";
  42931. /**
  42932. * 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,
  42933. * which still works and will still be found in many Playgrounds.
  42934. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42935. */
  42936. export class UniversalCamera extends TouchCamera {
  42937. /**
  42938. * Defines the gamepad rotation sensiblity.
  42939. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42940. */
  42941. get gamepadAngularSensibility(): number;
  42942. set gamepadAngularSensibility(value: number);
  42943. /**
  42944. * Defines the gamepad move sensiblity.
  42945. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42946. */
  42947. get gamepadMoveSensibility(): number;
  42948. set gamepadMoveSensibility(value: number);
  42949. /**
  42950. * 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,
  42951. * which still works and will still be found in many Playgrounds.
  42952. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42953. * @param name Define the name of the camera in the scene
  42954. * @param position Define the start position of the camera in the scene
  42955. * @param scene Define the scene the camera belongs to
  42956. */
  42957. constructor(name: string, position: Vector3, scene: Scene);
  42958. /**
  42959. * Gets the current object class name.
  42960. * @return the class name
  42961. */
  42962. getClassName(): string;
  42963. }
  42964. }
  42965. declare module "babylonjs/Cameras/gamepadCamera" {
  42966. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42967. import { Scene } from "babylonjs/scene";
  42968. import { Vector3 } from "babylonjs/Maths/math.vector";
  42969. /**
  42970. * This represents a FPS type of camera. This is only here for back compat purpose.
  42971. * Please use the UniversalCamera instead as both are identical.
  42972. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42973. */
  42974. export class GamepadCamera extends UniversalCamera {
  42975. /**
  42976. * Instantiates a new Gamepad Camera
  42977. * This represents a FPS type of camera. This is only here for back compat purpose.
  42978. * Please use the UniversalCamera instead as both are identical.
  42979. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42980. * @param name Define the name of the camera in the scene
  42981. * @param position Define the start position of the camera in the scene
  42982. * @param scene Define the scene the camera belongs to
  42983. */
  42984. constructor(name: string, position: Vector3, scene: Scene);
  42985. /**
  42986. * Gets the current object class name.
  42987. * @return the class name
  42988. */
  42989. getClassName(): string;
  42990. }
  42991. }
  42992. declare module "babylonjs/Shaders/pass.fragment" {
  42993. /** @hidden */
  42994. export var passPixelShader: {
  42995. name: string;
  42996. shader: string;
  42997. };
  42998. }
  42999. declare module "babylonjs/Shaders/passCube.fragment" {
  43000. /** @hidden */
  43001. export var passCubePixelShader: {
  43002. name: string;
  43003. shader: string;
  43004. };
  43005. }
  43006. declare module "babylonjs/PostProcesses/passPostProcess" {
  43007. import { Nullable } from "babylonjs/types";
  43008. import { Camera } from "babylonjs/Cameras/camera";
  43009. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43010. import { Engine } from "babylonjs/Engines/engine";
  43011. import "babylonjs/Shaders/pass.fragment";
  43012. import "babylonjs/Shaders/passCube.fragment";
  43013. /**
  43014. * PassPostProcess which produces an output the same as it's input
  43015. */
  43016. export class PassPostProcess extends PostProcess {
  43017. /**
  43018. * Creates the PassPostProcess
  43019. * @param name The name of the effect.
  43020. * @param options The required width/height ratio to downsize to before computing the render pass.
  43021. * @param camera The camera to apply the render pass to.
  43022. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43023. * @param engine The engine which the post process will be applied. (default: current engine)
  43024. * @param reusable If the post process can be reused on the same frame. (default: false)
  43025. * @param textureType The type of texture to be used when performing the post processing.
  43026. * @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)
  43027. */
  43028. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43029. }
  43030. /**
  43031. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  43032. */
  43033. export class PassCubePostProcess extends PostProcess {
  43034. private _face;
  43035. /**
  43036. * Gets or sets the cube face to display.
  43037. * * 0 is +X
  43038. * * 1 is -X
  43039. * * 2 is +Y
  43040. * * 3 is -Y
  43041. * * 4 is +Z
  43042. * * 5 is -Z
  43043. */
  43044. get face(): number;
  43045. set face(value: number);
  43046. /**
  43047. * Creates the PassCubePostProcess
  43048. * @param name The name of the effect.
  43049. * @param options The required width/height ratio to downsize to before computing the render pass.
  43050. * @param camera The camera to apply the render pass to.
  43051. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43052. * @param engine The engine which the post process will be applied. (default: current engine)
  43053. * @param reusable If the post process can be reused on the same frame. (default: false)
  43054. * @param textureType The type of texture to be used when performing the post processing.
  43055. * @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)
  43056. */
  43057. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43058. }
  43059. }
  43060. declare module "babylonjs/Shaders/anaglyph.fragment" {
  43061. /** @hidden */
  43062. export var anaglyphPixelShader: {
  43063. name: string;
  43064. shader: string;
  43065. };
  43066. }
  43067. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  43068. import { Engine } from "babylonjs/Engines/engine";
  43069. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43070. import { Camera } from "babylonjs/Cameras/camera";
  43071. import "babylonjs/Shaders/anaglyph.fragment";
  43072. /**
  43073. * Postprocess used to generate anaglyphic rendering
  43074. */
  43075. export class AnaglyphPostProcess extends PostProcess {
  43076. private _passedProcess;
  43077. /**
  43078. * Creates a new AnaglyphPostProcess
  43079. * @param name defines postprocess name
  43080. * @param options defines creation options or target ratio scale
  43081. * @param rigCameras defines cameras using this postprocess
  43082. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  43083. * @param engine defines hosting engine
  43084. * @param reusable defines if the postprocess will be reused multiple times per frame
  43085. */
  43086. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  43087. }
  43088. }
  43089. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  43090. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  43091. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43092. import { Scene } from "babylonjs/scene";
  43093. import { Vector3 } from "babylonjs/Maths/math.vector";
  43094. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43095. /**
  43096. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  43097. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43098. */
  43099. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  43100. /**
  43101. * Creates a new AnaglyphArcRotateCamera
  43102. * @param name defines camera name
  43103. * @param alpha defines alpha angle (in radians)
  43104. * @param beta defines beta angle (in radians)
  43105. * @param radius defines radius
  43106. * @param target defines camera target
  43107. * @param interaxialDistance defines distance between each color axis
  43108. * @param scene defines the hosting scene
  43109. */
  43110. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  43111. /**
  43112. * Gets camera class name
  43113. * @returns AnaglyphArcRotateCamera
  43114. */
  43115. getClassName(): string;
  43116. }
  43117. }
  43118. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  43119. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43120. import { Scene } from "babylonjs/scene";
  43121. import { Vector3 } from "babylonjs/Maths/math.vector";
  43122. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43123. /**
  43124. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  43125. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43126. */
  43127. export class AnaglyphFreeCamera extends FreeCamera {
  43128. /**
  43129. * Creates a new AnaglyphFreeCamera
  43130. * @param name defines camera name
  43131. * @param position defines initial position
  43132. * @param interaxialDistance defines distance between each color axis
  43133. * @param scene defines the hosting scene
  43134. */
  43135. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43136. /**
  43137. * Gets camera class name
  43138. * @returns AnaglyphFreeCamera
  43139. */
  43140. getClassName(): string;
  43141. }
  43142. }
  43143. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  43144. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43145. import { Scene } from "babylonjs/scene";
  43146. import { Vector3 } from "babylonjs/Maths/math.vector";
  43147. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43148. /**
  43149. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  43150. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43151. */
  43152. export class AnaglyphGamepadCamera extends GamepadCamera {
  43153. /**
  43154. * Creates a new AnaglyphGamepadCamera
  43155. * @param name defines camera name
  43156. * @param position defines initial position
  43157. * @param interaxialDistance defines distance between each color axis
  43158. * @param scene defines the hosting scene
  43159. */
  43160. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43161. /**
  43162. * Gets camera class name
  43163. * @returns AnaglyphGamepadCamera
  43164. */
  43165. getClassName(): string;
  43166. }
  43167. }
  43168. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  43169. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43170. import { Scene } from "babylonjs/scene";
  43171. import { Vector3 } from "babylonjs/Maths/math.vector";
  43172. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43173. /**
  43174. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  43175. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43176. */
  43177. export class AnaglyphUniversalCamera extends UniversalCamera {
  43178. /**
  43179. * Creates a new AnaglyphUniversalCamera
  43180. * @param name defines camera name
  43181. * @param position defines initial position
  43182. * @param interaxialDistance defines distance between each color axis
  43183. * @param scene defines the hosting scene
  43184. */
  43185. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43186. /**
  43187. * Gets camera class name
  43188. * @returns AnaglyphUniversalCamera
  43189. */
  43190. getClassName(): string;
  43191. }
  43192. }
  43193. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  43194. /** @hidden */
  43195. export var stereoscopicInterlacePixelShader: {
  43196. name: string;
  43197. shader: string;
  43198. };
  43199. }
  43200. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  43201. import { Camera } from "babylonjs/Cameras/camera";
  43202. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43203. import { Engine } from "babylonjs/Engines/engine";
  43204. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  43205. /**
  43206. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  43207. */
  43208. export class StereoscopicInterlacePostProcessI extends PostProcess {
  43209. private _stepSize;
  43210. private _passedProcess;
  43211. /**
  43212. * Initializes a StereoscopicInterlacePostProcessI
  43213. * @param name The name of the effect.
  43214. * @param rigCameras The rig cameras to be appled to the post process
  43215. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  43216. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  43217. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43218. * @param engine The engine which the post process will be applied. (default: current engine)
  43219. * @param reusable If the post process can be reused on the same frame. (default: false)
  43220. */
  43221. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43222. }
  43223. /**
  43224. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  43225. */
  43226. export class StereoscopicInterlacePostProcess extends PostProcess {
  43227. private _stepSize;
  43228. private _passedProcess;
  43229. /**
  43230. * Initializes a StereoscopicInterlacePostProcess
  43231. * @param name The name of the effect.
  43232. * @param rigCameras The rig cameras to be appled to the post process
  43233. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  43234. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43235. * @param engine The engine which the post process will be applied. (default: current engine)
  43236. * @param reusable If the post process can be reused on the same frame. (default: false)
  43237. */
  43238. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43239. }
  43240. }
  43241. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  43242. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  43243. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43244. import { Scene } from "babylonjs/scene";
  43245. import { Vector3 } from "babylonjs/Maths/math.vector";
  43246. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43247. /**
  43248. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  43249. * @see http://doc.babylonjs.com/features/cameras
  43250. */
  43251. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  43252. /**
  43253. * Creates a new StereoscopicArcRotateCamera
  43254. * @param name defines camera name
  43255. * @param alpha defines alpha angle (in radians)
  43256. * @param beta defines beta angle (in radians)
  43257. * @param radius defines radius
  43258. * @param target defines camera target
  43259. * @param interaxialDistance defines distance between each color axis
  43260. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43261. * @param scene defines the hosting scene
  43262. */
  43263. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43264. /**
  43265. * Gets camera class name
  43266. * @returns StereoscopicArcRotateCamera
  43267. */
  43268. getClassName(): string;
  43269. }
  43270. }
  43271. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  43272. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43273. import { Scene } from "babylonjs/scene";
  43274. import { Vector3 } from "babylonjs/Maths/math.vector";
  43275. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43276. /**
  43277. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  43278. * @see http://doc.babylonjs.com/features/cameras
  43279. */
  43280. export class StereoscopicFreeCamera extends FreeCamera {
  43281. /**
  43282. * Creates a new StereoscopicFreeCamera
  43283. * @param name defines camera name
  43284. * @param position defines initial position
  43285. * @param interaxialDistance defines distance between each color axis
  43286. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43287. * @param scene defines the hosting scene
  43288. */
  43289. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43290. /**
  43291. * Gets camera class name
  43292. * @returns StereoscopicFreeCamera
  43293. */
  43294. getClassName(): string;
  43295. }
  43296. }
  43297. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  43298. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43299. import { Scene } from "babylonjs/scene";
  43300. import { Vector3 } from "babylonjs/Maths/math.vector";
  43301. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43302. /**
  43303. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  43304. * @see http://doc.babylonjs.com/features/cameras
  43305. */
  43306. export class StereoscopicGamepadCamera extends GamepadCamera {
  43307. /**
  43308. * Creates a new StereoscopicGamepadCamera
  43309. * @param name defines camera name
  43310. * @param position defines initial position
  43311. * @param interaxialDistance defines distance between each color axis
  43312. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43313. * @param scene defines the hosting scene
  43314. */
  43315. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43316. /**
  43317. * Gets camera class name
  43318. * @returns StereoscopicGamepadCamera
  43319. */
  43320. getClassName(): string;
  43321. }
  43322. }
  43323. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  43324. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43325. import { Scene } from "babylonjs/scene";
  43326. import { Vector3 } from "babylonjs/Maths/math.vector";
  43327. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43328. /**
  43329. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  43330. * @see http://doc.babylonjs.com/features/cameras
  43331. */
  43332. export class StereoscopicUniversalCamera extends UniversalCamera {
  43333. /**
  43334. * Creates a new StereoscopicUniversalCamera
  43335. * @param name defines camera name
  43336. * @param position defines initial position
  43337. * @param interaxialDistance defines distance between each color axis
  43338. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43339. * @param scene defines the hosting scene
  43340. */
  43341. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43342. /**
  43343. * Gets camera class name
  43344. * @returns StereoscopicUniversalCamera
  43345. */
  43346. getClassName(): string;
  43347. }
  43348. }
  43349. declare module "babylonjs/Cameras/Stereoscopic/index" {
  43350. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  43351. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  43352. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  43353. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  43354. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  43355. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  43356. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  43357. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  43358. }
  43359. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  43360. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43361. import { Scene } from "babylonjs/scene";
  43362. import { Vector3 } from "babylonjs/Maths/math.vector";
  43363. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  43364. /**
  43365. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  43366. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43367. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43368. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43369. */
  43370. export class VirtualJoysticksCamera extends FreeCamera {
  43371. /**
  43372. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  43373. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43374. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43375. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43376. * @param name Define the name of the camera in the scene
  43377. * @param position Define the start position of the camera in the scene
  43378. * @param scene Define the scene the camera belongs to
  43379. */
  43380. constructor(name: string, position: Vector3, scene: Scene);
  43381. /**
  43382. * Gets the current object class name.
  43383. * @return the class name
  43384. */
  43385. getClassName(): string;
  43386. }
  43387. }
  43388. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  43389. import { Matrix } from "babylonjs/Maths/math.vector";
  43390. /**
  43391. * This represents all the required metrics to create a VR camera.
  43392. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  43393. */
  43394. export class VRCameraMetrics {
  43395. /**
  43396. * Define the horizontal resolution off the screen.
  43397. */
  43398. hResolution: number;
  43399. /**
  43400. * Define the vertical resolution off the screen.
  43401. */
  43402. vResolution: number;
  43403. /**
  43404. * Define the horizontal screen size.
  43405. */
  43406. hScreenSize: number;
  43407. /**
  43408. * Define the vertical screen size.
  43409. */
  43410. vScreenSize: number;
  43411. /**
  43412. * Define the vertical screen center position.
  43413. */
  43414. vScreenCenter: number;
  43415. /**
  43416. * Define the distance of the eyes to the screen.
  43417. */
  43418. eyeToScreenDistance: number;
  43419. /**
  43420. * Define the distance between both lenses
  43421. */
  43422. lensSeparationDistance: number;
  43423. /**
  43424. * Define the distance between both viewer's eyes.
  43425. */
  43426. interpupillaryDistance: number;
  43427. /**
  43428. * Define the distortion factor of the VR postprocess.
  43429. * Please, touch with care.
  43430. */
  43431. distortionK: number[];
  43432. /**
  43433. * Define the chromatic aberration correction factors for the VR post process.
  43434. */
  43435. chromaAbCorrection: number[];
  43436. /**
  43437. * Define the scale factor of the post process.
  43438. * The smaller the better but the slower.
  43439. */
  43440. postProcessScaleFactor: number;
  43441. /**
  43442. * Define an offset for the lens center.
  43443. */
  43444. lensCenterOffset: number;
  43445. /**
  43446. * Define if the current vr camera should compensate the distortion of the lense or not.
  43447. */
  43448. compensateDistortion: boolean;
  43449. /**
  43450. * Defines if multiview should be enabled when rendering (Default: false)
  43451. */
  43452. multiviewEnabled: boolean;
  43453. /**
  43454. * Gets the rendering aspect ratio based on the provided resolutions.
  43455. */
  43456. get aspectRatio(): number;
  43457. /**
  43458. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  43459. */
  43460. get aspectRatioFov(): number;
  43461. /**
  43462. * @hidden
  43463. */
  43464. get leftHMatrix(): Matrix;
  43465. /**
  43466. * @hidden
  43467. */
  43468. get rightHMatrix(): Matrix;
  43469. /**
  43470. * @hidden
  43471. */
  43472. get leftPreViewMatrix(): Matrix;
  43473. /**
  43474. * @hidden
  43475. */
  43476. get rightPreViewMatrix(): Matrix;
  43477. /**
  43478. * Get the default VRMetrics based on the most generic setup.
  43479. * @returns the default vr metrics
  43480. */
  43481. static GetDefault(): VRCameraMetrics;
  43482. }
  43483. }
  43484. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  43485. /** @hidden */
  43486. export var vrDistortionCorrectionPixelShader: {
  43487. name: string;
  43488. shader: string;
  43489. };
  43490. }
  43491. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  43492. import { Camera } from "babylonjs/Cameras/camera";
  43493. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43494. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43495. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  43496. /**
  43497. * VRDistortionCorrectionPostProcess used for mobile VR
  43498. */
  43499. export class VRDistortionCorrectionPostProcess extends PostProcess {
  43500. private _isRightEye;
  43501. private _distortionFactors;
  43502. private _postProcessScaleFactor;
  43503. private _lensCenterOffset;
  43504. private _scaleIn;
  43505. private _scaleFactor;
  43506. private _lensCenter;
  43507. /**
  43508. * Initializes the VRDistortionCorrectionPostProcess
  43509. * @param name The name of the effect.
  43510. * @param camera The camera to apply the render pass to.
  43511. * @param isRightEye If this is for the right eye distortion
  43512. * @param vrMetrics All the required metrics for the VR camera
  43513. */
  43514. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  43515. }
  43516. }
  43517. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  43518. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  43519. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43520. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43521. import { Scene } from "babylonjs/scene";
  43522. import { Vector3 } from "babylonjs/Maths/math.vector";
  43523. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  43524. import "babylonjs/Cameras/RigModes/vrRigMode";
  43525. /**
  43526. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  43527. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43528. */
  43529. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  43530. /**
  43531. * Creates a new VRDeviceOrientationArcRotateCamera
  43532. * @param name defines camera name
  43533. * @param alpha defines the camera rotation along the logitudinal axis
  43534. * @param beta defines the camera rotation along the latitudinal axis
  43535. * @param radius defines the camera distance from its target
  43536. * @param target defines the camera target
  43537. * @param scene defines the scene the camera belongs to
  43538. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43539. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43540. */
  43541. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43542. /**
  43543. * Gets camera class name
  43544. * @returns VRDeviceOrientationArcRotateCamera
  43545. */
  43546. getClassName(): string;
  43547. }
  43548. }
  43549. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  43550. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  43551. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43552. import { Scene } from "babylonjs/scene";
  43553. import { Vector3 } from "babylonjs/Maths/math.vector";
  43554. import "babylonjs/Cameras/RigModes/vrRigMode";
  43555. /**
  43556. * Camera used to simulate VR rendering (based on FreeCamera)
  43557. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43558. */
  43559. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  43560. /**
  43561. * Creates a new VRDeviceOrientationFreeCamera
  43562. * @param name defines camera name
  43563. * @param position defines the start position of the camera
  43564. * @param scene defines the scene the camera belongs to
  43565. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43566. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43567. */
  43568. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43569. /**
  43570. * Gets camera class name
  43571. * @returns VRDeviceOrientationFreeCamera
  43572. */
  43573. getClassName(): string;
  43574. }
  43575. }
  43576. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  43577. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43578. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43579. import { Scene } from "babylonjs/scene";
  43580. import { Vector3 } from "babylonjs/Maths/math.vector";
  43581. import "babylonjs/Gamepads/gamepadSceneComponent";
  43582. /**
  43583. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  43584. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43585. */
  43586. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  43587. /**
  43588. * Creates a new VRDeviceOrientationGamepadCamera
  43589. * @param name defines camera name
  43590. * @param position defines the start position of the camera
  43591. * @param scene defines the scene the camera belongs to
  43592. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43593. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43594. */
  43595. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43596. /**
  43597. * Gets camera class name
  43598. * @returns VRDeviceOrientationGamepadCamera
  43599. */
  43600. getClassName(): string;
  43601. }
  43602. }
  43603. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  43604. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43605. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43606. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43607. /** @hidden */
  43608. export var imageProcessingPixelShader: {
  43609. name: string;
  43610. shader: string;
  43611. };
  43612. }
  43613. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  43614. import { Nullable } from "babylonjs/types";
  43615. import { Color4 } from "babylonjs/Maths/math.color";
  43616. import { Camera } from "babylonjs/Cameras/camera";
  43617. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43618. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43619. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43620. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43621. import { Engine } from "babylonjs/Engines/engine";
  43622. import "babylonjs/Shaders/imageProcessing.fragment";
  43623. import "babylonjs/Shaders/postprocess.vertex";
  43624. /**
  43625. * ImageProcessingPostProcess
  43626. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  43627. */
  43628. export class ImageProcessingPostProcess extends PostProcess {
  43629. /**
  43630. * Default configuration related to image processing available in the PBR Material.
  43631. */
  43632. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43633. /**
  43634. * Gets the image processing configuration used either in this material.
  43635. */
  43636. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  43637. /**
  43638. * Sets the Default image processing configuration used either in the this material.
  43639. *
  43640. * If sets to null, the scene one is in use.
  43641. */
  43642. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  43643. /**
  43644. * Keep track of the image processing observer to allow dispose and replace.
  43645. */
  43646. private _imageProcessingObserver;
  43647. /**
  43648. * Attaches a new image processing configuration to the PBR Material.
  43649. * @param configuration
  43650. */
  43651. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  43652. /**
  43653. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43654. */
  43655. get colorCurves(): Nullable<ColorCurves>;
  43656. /**
  43657. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43658. */
  43659. set colorCurves(value: Nullable<ColorCurves>);
  43660. /**
  43661. * Gets wether the color curves effect is enabled.
  43662. */
  43663. get colorCurvesEnabled(): boolean;
  43664. /**
  43665. * Sets wether the color curves effect is enabled.
  43666. */
  43667. set colorCurvesEnabled(value: boolean);
  43668. /**
  43669. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43670. */
  43671. get colorGradingTexture(): Nullable<BaseTexture>;
  43672. /**
  43673. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43674. */
  43675. set colorGradingTexture(value: Nullable<BaseTexture>);
  43676. /**
  43677. * Gets wether the color grading effect is enabled.
  43678. */
  43679. get colorGradingEnabled(): boolean;
  43680. /**
  43681. * Gets wether the color grading effect is enabled.
  43682. */
  43683. set colorGradingEnabled(value: boolean);
  43684. /**
  43685. * Gets exposure used in the effect.
  43686. */
  43687. get exposure(): number;
  43688. /**
  43689. * Sets exposure used in the effect.
  43690. */
  43691. set exposure(value: number);
  43692. /**
  43693. * Gets wether tonemapping is enabled or not.
  43694. */
  43695. get toneMappingEnabled(): boolean;
  43696. /**
  43697. * Sets wether tonemapping is enabled or not
  43698. */
  43699. set toneMappingEnabled(value: boolean);
  43700. /**
  43701. * Gets the type of tone mapping effect.
  43702. */
  43703. get toneMappingType(): number;
  43704. /**
  43705. * Sets the type of tone mapping effect.
  43706. */
  43707. set toneMappingType(value: number);
  43708. /**
  43709. * Gets contrast used in the effect.
  43710. */
  43711. get contrast(): number;
  43712. /**
  43713. * Sets contrast used in the effect.
  43714. */
  43715. set contrast(value: number);
  43716. /**
  43717. * Gets Vignette stretch size.
  43718. */
  43719. get vignetteStretch(): number;
  43720. /**
  43721. * Sets Vignette stretch size.
  43722. */
  43723. set vignetteStretch(value: number);
  43724. /**
  43725. * Gets Vignette centre X Offset.
  43726. */
  43727. get vignetteCentreX(): number;
  43728. /**
  43729. * Sets Vignette centre X Offset.
  43730. */
  43731. set vignetteCentreX(value: number);
  43732. /**
  43733. * Gets Vignette centre Y Offset.
  43734. */
  43735. get vignetteCentreY(): number;
  43736. /**
  43737. * Sets Vignette centre Y Offset.
  43738. */
  43739. set vignetteCentreY(value: number);
  43740. /**
  43741. * Gets Vignette weight or intensity of the vignette effect.
  43742. */
  43743. get vignetteWeight(): number;
  43744. /**
  43745. * Sets Vignette weight or intensity of the vignette effect.
  43746. */
  43747. set vignetteWeight(value: number);
  43748. /**
  43749. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43750. * if vignetteEnabled is set to true.
  43751. */
  43752. get vignetteColor(): Color4;
  43753. /**
  43754. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43755. * if vignetteEnabled is set to true.
  43756. */
  43757. set vignetteColor(value: Color4);
  43758. /**
  43759. * Gets Camera field of view used by the Vignette effect.
  43760. */
  43761. get vignetteCameraFov(): number;
  43762. /**
  43763. * Sets Camera field of view used by the Vignette effect.
  43764. */
  43765. set vignetteCameraFov(value: number);
  43766. /**
  43767. * Gets the vignette blend mode allowing different kind of effect.
  43768. */
  43769. get vignetteBlendMode(): number;
  43770. /**
  43771. * Sets the vignette blend mode allowing different kind of effect.
  43772. */
  43773. set vignetteBlendMode(value: number);
  43774. /**
  43775. * Gets wether the vignette effect is enabled.
  43776. */
  43777. get vignetteEnabled(): boolean;
  43778. /**
  43779. * Sets wether the vignette effect is enabled.
  43780. */
  43781. set vignetteEnabled(value: boolean);
  43782. private _fromLinearSpace;
  43783. /**
  43784. * Gets wether the input of the processing is in Gamma or Linear Space.
  43785. */
  43786. get fromLinearSpace(): boolean;
  43787. /**
  43788. * Sets wether the input of the processing is in Gamma or Linear Space.
  43789. */
  43790. set fromLinearSpace(value: boolean);
  43791. /**
  43792. * Defines cache preventing GC.
  43793. */
  43794. private _defines;
  43795. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  43796. /**
  43797. * "ImageProcessingPostProcess"
  43798. * @returns "ImageProcessingPostProcess"
  43799. */
  43800. getClassName(): string;
  43801. protected _updateParameters(): void;
  43802. dispose(camera?: Camera): void;
  43803. }
  43804. }
  43805. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  43806. import { Scene } from "babylonjs/scene";
  43807. import { Color3 } from "babylonjs/Maths/math.color";
  43808. import { Mesh } from "babylonjs/Meshes/mesh";
  43809. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  43810. import { Nullable } from "babylonjs/types";
  43811. /**
  43812. * Class containing static functions to help procedurally build meshes
  43813. */
  43814. export class GroundBuilder {
  43815. /**
  43816. * Creates a ground mesh
  43817. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  43818. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  43819. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43820. * @param name defines the name of the mesh
  43821. * @param options defines the options used to create the mesh
  43822. * @param scene defines the hosting scene
  43823. * @returns the ground mesh
  43824. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  43825. */
  43826. static CreateGround(name: string, options: {
  43827. width?: number;
  43828. height?: number;
  43829. subdivisions?: number;
  43830. subdivisionsX?: number;
  43831. subdivisionsY?: number;
  43832. updatable?: boolean;
  43833. }, scene: any): Mesh;
  43834. /**
  43835. * Creates a tiled ground mesh
  43836. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  43837. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  43838. * * 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
  43839. * * 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
  43840. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43841. * @param name defines the name of the mesh
  43842. * @param options defines the options used to create the mesh
  43843. * @param scene defines the hosting scene
  43844. * @returns the tiled ground mesh
  43845. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  43846. */
  43847. static CreateTiledGround(name: string, options: {
  43848. xmin: number;
  43849. zmin: number;
  43850. xmax: number;
  43851. zmax: number;
  43852. subdivisions?: {
  43853. w: number;
  43854. h: number;
  43855. };
  43856. precision?: {
  43857. w: number;
  43858. h: number;
  43859. };
  43860. updatable?: boolean;
  43861. }, scene?: Nullable<Scene>): Mesh;
  43862. /**
  43863. * Creates a ground mesh from a height map
  43864. * * The parameter `url` sets the URL of the height map image resource.
  43865. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  43866. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  43867. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  43868. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  43869. * * 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.
  43870. * * 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).
  43871. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  43872. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43873. * @param name defines the name of the mesh
  43874. * @param url defines the url to the height map
  43875. * @param options defines the options used to create the mesh
  43876. * @param scene defines the hosting scene
  43877. * @returns the ground mesh
  43878. * @see https://doc.babylonjs.com/babylon101/height_map
  43879. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  43880. */
  43881. static CreateGroundFromHeightMap(name: string, url: string, options: {
  43882. width?: number;
  43883. height?: number;
  43884. subdivisions?: number;
  43885. minHeight?: number;
  43886. maxHeight?: number;
  43887. colorFilter?: Color3;
  43888. alphaFilter?: number;
  43889. updatable?: boolean;
  43890. onReady?: (mesh: GroundMesh) => void;
  43891. }, scene?: Nullable<Scene>): GroundMesh;
  43892. }
  43893. }
  43894. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  43895. import { Vector4 } from "babylonjs/Maths/math.vector";
  43896. import { Mesh } from "babylonjs/Meshes/mesh";
  43897. /**
  43898. * Class containing static functions to help procedurally build meshes
  43899. */
  43900. export class TorusBuilder {
  43901. /**
  43902. * Creates a torus mesh
  43903. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  43904. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  43905. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  43906. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43907. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43908. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43909. * @param name defines the name of the mesh
  43910. * @param options defines the options used to create the mesh
  43911. * @param scene defines the hosting scene
  43912. * @returns the torus mesh
  43913. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  43914. */
  43915. static CreateTorus(name: string, options: {
  43916. diameter?: number;
  43917. thickness?: number;
  43918. tessellation?: number;
  43919. updatable?: boolean;
  43920. sideOrientation?: number;
  43921. frontUVs?: Vector4;
  43922. backUVs?: Vector4;
  43923. }, scene: any): Mesh;
  43924. }
  43925. }
  43926. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  43927. import { Vector4 } from "babylonjs/Maths/math.vector";
  43928. import { Color4 } from "babylonjs/Maths/math.color";
  43929. import { Mesh } from "babylonjs/Meshes/mesh";
  43930. /**
  43931. * Class containing static functions to help procedurally build meshes
  43932. */
  43933. export class CylinderBuilder {
  43934. /**
  43935. * Creates a cylinder or a cone mesh
  43936. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  43937. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  43938. * * 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.
  43939. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  43940. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  43941. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  43942. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  43943. * * 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).
  43944. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  43945. * * 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).
  43946. * * 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
  43947. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  43948. * * 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
  43949. * * 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.
  43950. * * If `enclose` is false, a ring surface is one element.
  43951. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  43952. * * 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
  43953. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43954. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43955. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43956. * @param name defines the name of the mesh
  43957. * @param options defines the options used to create the mesh
  43958. * @param scene defines the hosting scene
  43959. * @returns the cylinder mesh
  43960. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  43961. */
  43962. static CreateCylinder(name: string, options: {
  43963. height?: number;
  43964. diameterTop?: number;
  43965. diameterBottom?: number;
  43966. diameter?: number;
  43967. tessellation?: number;
  43968. subdivisions?: number;
  43969. arc?: number;
  43970. faceColors?: Color4[];
  43971. faceUV?: Vector4[];
  43972. updatable?: boolean;
  43973. hasRings?: boolean;
  43974. enclose?: boolean;
  43975. cap?: number;
  43976. sideOrientation?: number;
  43977. frontUVs?: Vector4;
  43978. backUVs?: Vector4;
  43979. }, scene: any): Mesh;
  43980. }
  43981. }
  43982. declare module "babylonjs/XR/webXRTypes" {
  43983. import { Nullable } from "babylonjs/types";
  43984. import { IDisposable } from "babylonjs/scene";
  43985. /**
  43986. * States of the webXR experience
  43987. */
  43988. export enum WebXRState {
  43989. /**
  43990. * Transitioning to being in XR mode
  43991. */
  43992. ENTERING_XR = 0,
  43993. /**
  43994. * Transitioning to non XR mode
  43995. */
  43996. EXITING_XR = 1,
  43997. /**
  43998. * In XR mode and presenting
  43999. */
  44000. IN_XR = 2,
  44001. /**
  44002. * Not entered XR mode
  44003. */
  44004. NOT_IN_XR = 3
  44005. }
  44006. /**
  44007. * Abstraction of the XR render target
  44008. */
  44009. export interface WebXRRenderTarget extends IDisposable {
  44010. /**
  44011. * xrpresent context of the canvas which can be used to display/mirror xr content
  44012. */
  44013. canvasContext: WebGLRenderingContext;
  44014. /**
  44015. * xr layer for the canvas
  44016. */
  44017. xrLayer: Nullable<XRWebGLLayer>;
  44018. /**
  44019. * Initializes the xr layer for the session
  44020. * @param xrSession xr session
  44021. * @returns a promise that will resolve once the XR Layer has been created
  44022. */
  44023. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44024. }
  44025. }
  44026. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  44027. import { Nullable } from "babylonjs/types";
  44028. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44029. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44030. /**
  44031. * COnfiguration object for WebXR output canvas
  44032. */
  44033. export class WebXRManagedOutputCanvasOptions {
  44034. /**
  44035. * Options for this XR Layer output
  44036. */
  44037. canvasOptions?: XRWebGLLayerOptions;
  44038. /**
  44039. * CSS styling for a newly created canvas (if not provided)
  44040. */
  44041. newCanvasCssStyle?: string;
  44042. /**
  44043. * An optional canvas in case you wish to create it yourself and provide it here.
  44044. * If not provided, a new canvas will be created
  44045. */
  44046. canvasElement?: HTMLCanvasElement;
  44047. /**
  44048. * Get the default values of the configuration object
  44049. * @returns default values of this configuration object
  44050. */
  44051. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  44052. }
  44053. /**
  44054. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  44055. */
  44056. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  44057. private _options;
  44058. private _engine;
  44059. private _canvas;
  44060. /**
  44061. * Rendering context of the canvas which can be used to display/mirror xr content
  44062. */
  44063. canvasContext: WebGLRenderingContext;
  44064. /**
  44065. * xr layer for the canvas
  44066. */
  44067. xrLayer: Nullable<XRWebGLLayer>;
  44068. /**
  44069. * Initializes the xr layer for the session
  44070. * @param xrSession xr session
  44071. * @returns a promise that will resolve once the XR Layer has been created
  44072. */
  44073. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44074. /**
  44075. * Initializes the canvas to be added/removed upon entering/exiting xr
  44076. * @param _xrSessionManager The XR Session manager
  44077. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  44078. */
  44079. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  44080. /**
  44081. * Disposes of the object
  44082. */
  44083. dispose(): void;
  44084. private _setManagedOutputCanvas;
  44085. private _addCanvas;
  44086. private _removeCanvas;
  44087. }
  44088. }
  44089. declare module "babylonjs/XR/webXRSessionManager" {
  44090. import { Observable } from "babylonjs/Misc/observable";
  44091. import { Nullable } from "babylonjs/types";
  44092. import { IDisposable, Scene } from "babylonjs/scene";
  44093. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  44094. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44095. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  44096. /**
  44097. * Manages an XRSession to work with Babylon's engine
  44098. * @see https://doc.babylonjs.com/how_to/webxr
  44099. */
  44100. export class WebXRSessionManager implements IDisposable {
  44101. /** The scene which the session should be created for */
  44102. scene: Scene;
  44103. /**
  44104. * Fires every time a new xrFrame arrives which can be used to update the camera
  44105. */
  44106. onXRFrameObservable: Observable<XRFrame>;
  44107. /**
  44108. * Fires when the xr session is ended either by the device or manually done
  44109. */
  44110. onXRSessionEnded: Observable<any>;
  44111. /**
  44112. * Fires when the xr session is ended either by the device or manually done
  44113. */
  44114. onXRSessionInit: Observable<XRSession>;
  44115. /**
  44116. * Fires when the reference space changed
  44117. */
  44118. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  44119. /**
  44120. * Underlying xr session
  44121. */
  44122. session: XRSession;
  44123. /**
  44124. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  44125. * or get the offset the player is currently at.
  44126. */
  44127. viewerReferenceSpace: XRReferenceSpace;
  44128. private _referenceSpace;
  44129. /**
  44130. * The current reference space used in this session. This reference space can constantly change!
  44131. * It is mainly used to offset the camera's position.
  44132. */
  44133. get referenceSpace(): XRReferenceSpace;
  44134. /**
  44135. * Set a new reference space and triggers the observable
  44136. */
  44137. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  44138. /**
  44139. * The base reference space from which the session started. good if you want to reset your
  44140. * reference space
  44141. */
  44142. baseReferenceSpace: XRReferenceSpace;
  44143. /**
  44144. * Used just in case of a failure to initialize an immersive session.
  44145. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  44146. */
  44147. defaultHeightCompensation: number;
  44148. /**
  44149. * Current XR frame
  44150. */
  44151. currentFrame: Nullable<XRFrame>;
  44152. /** WebXR timestamp updated every frame */
  44153. currentTimestamp: number;
  44154. private _xrNavigator;
  44155. private baseLayer;
  44156. private _rttProvider;
  44157. private _sessionEnded;
  44158. /**
  44159. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  44160. * @param scene The scene which the session should be created for
  44161. */
  44162. constructor(
  44163. /** The scene which the session should be created for */
  44164. scene: Scene);
  44165. /**
  44166. * Initializes the manager
  44167. * After initialization enterXR can be called to start an XR session
  44168. * @returns Promise which resolves after it is initialized
  44169. */
  44170. initializeAsync(): Promise<void>;
  44171. /**
  44172. * Initializes an xr session
  44173. * @param xrSessionMode mode to initialize
  44174. * @param xrSessionInit defines optional and required values to pass to the session builder
  44175. * @returns a promise which will resolve once the session has been initialized
  44176. */
  44177. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  44178. /**
  44179. * Sets the reference space on the xr session
  44180. * @param referenceSpaceType space to set
  44181. * @returns a promise that will resolve once the reference space has been set
  44182. */
  44183. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  44184. /**
  44185. * Resets the reference space to the one started the session
  44186. */
  44187. resetReferenceSpace(): void;
  44188. /**
  44189. * Updates the render state of the session
  44190. * @param state state to set
  44191. * @returns a promise that resolves once the render state has been updated
  44192. */
  44193. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  44194. /**
  44195. * Starts rendering to the xr layer
  44196. */
  44197. runXRRenderLoop(): void;
  44198. /**
  44199. * Gets the correct render target texture to be rendered this frame for this eye
  44200. * @param eye the eye for which to get the render target
  44201. * @returns the render target for the specified eye
  44202. */
  44203. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  44204. /**
  44205. * Stops the xrSession and restores the renderloop
  44206. * @returns Promise which resolves after it exits XR
  44207. */
  44208. exitXRAsync(): Promise<void>;
  44209. /**
  44210. * Checks if a session would be supported for the creation options specified
  44211. * @param sessionMode session mode to check if supported eg. immersive-vr
  44212. * @returns A Promise that resolves to true if supported and false if not
  44213. */
  44214. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44215. /**
  44216. * Creates a WebXRRenderTarget object for the XR session
  44217. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  44218. * @param options optional options to provide when creating a new render target
  44219. * @returns a WebXR render target to which the session can render
  44220. */
  44221. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  44222. /**
  44223. * @hidden
  44224. * Converts the render layer of xrSession to a render target
  44225. * @param session session to create render target for
  44226. * @param scene scene the new render target should be created for
  44227. * @param baseLayer the webgl layer to create the render target for
  44228. */
  44229. static _CreateRenderTargetTextureFromSession(_session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  44230. /**
  44231. * Disposes of the session manager
  44232. */
  44233. dispose(): void;
  44234. /**
  44235. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  44236. * @param sessionMode defines the session to test
  44237. * @returns a promise with boolean as final value
  44238. */
  44239. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44240. }
  44241. }
  44242. declare module "babylonjs/XR/webXRCamera" {
  44243. import { Scene } from "babylonjs/scene";
  44244. import { Camera } from "babylonjs/Cameras/camera";
  44245. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  44246. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44247. /**
  44248. * WebXR Camera which holds the views for the xrSession
  44249. * @see https://doc.babylonjs.com/how_to/webxr_camera
  44250. */
  44251. export class WebXRCamera extends FreeCamera {
  44252. private _xrSessionManager;
  44253. private _firstFrame;
  44254. private _referenceQuaternion;
  44255. private _referencedPosition;
  44256. private _xrInvPositionCache;
  44257. private _xrInvQuaternionCache;
  44258. /**
  44259. * Should position compensation execute on first frame.
  44260. * This is used when copying the position from a native (non XR) camera
  44261. */
  44262. compensateOnFirstFrame: boolean;
  44263. /**
  44264. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  44265. * @param name the name of the camera
  44266. * @param scene the scene to add the camera to
  44267. * @param _xrSessionManager a constructed xr session manager
  44268. */
  44269. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  44270. /**
  44271. * Return the user's height, unrelated to the current ground.
  44272. * This will be the y position of this camera, when ground level is 0.
  44273. */
  44274. get realWorldHeight(): number;
  44275. /** @hidden */
  44276. _updateForDualEyeDebugging(): void;
  44277. /**
  44278. * Sets this camera's transformation based on a non-vr camera
  44279. * @param otherCamera the non-vr camera to copy the transformation from
  44280. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  44281. */
  44282. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  44283. private _updateFromXRSession;
  44284. private _updateNumberOfRigCameras;
  44285. private _updateReferenceSpace;
  44286. private _updateReferenceSpaceOffset;
  44287. }
  44288. }
  44289. declare module "babylonjs/XR/webXRFeaturesManager" {
  44290. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44291. import { IDisposable } from "babylonjs/scene";
  44292. /**
  44293. * Defining the interface required for a (webxr) feature
  44294. */
  44295. export interface IWebXRFeature extends IDisposable {
  44296. /**
  44297. * Is this feature attached
  44298. */
  44299. attached: boolean;
  44300. /**
  44301. * Should auto-attach be disabled?
  44302. */
  44303. disableAutoAttach: boolean;
  44304. /**
  44305. * Attach the feature to the session
  44306. * Will usually be called by the features manager
  44307. *
  44308. * @param force should attachment be forced (even when already attached)
  44309. * @returns true if successful.
  44310. */
  44311. attach(force?: boolean): boolean;
  44312. /**
  44313. * Detach the feature from the session
  44314. * Will usually be called by the features manager
  44315. *
  44316. * @returns true if successful.
  44317. */
  44318. detach(): boolean;
  44319. }
  44320. /**
  44321. * A list of the currently available features without referencing them
  44322. */
  44323. export class WebXRFeatureName {
  44324. /**
  44325. * The name of the hit test feature
  44326. */
  44327. static HIT_TEST: string;
  44328. /**
  44329. * The name of the anchor system feature
  44330. */
  44331. static ANCHOR_SYSTEM: string;
  44332. /**
  44333. * The name of the background remover feature
  44334. */
  44335. static BACKGROUND_REMOVER: string;
  44336. /**
  44337. * The name of the pointer selection feature
  44338. */
  44339. static POINTER_SELECTION: string;
  44340. /**
  44341. * The name of the teleportation feature
  44342. */
  44343. static TELEPORTATION: string;
  44344. /**
  44345. * The name of the plane detection feature
  44346. */
  44347. static PLANE_DETECTION: string;
  44348. /**
  44349. * physics impostors for xr controllers feature
  44350. */
  44351. static PHYSICS_CONTROLLERS: string;
  44352. }
  44353. /**
  44354. * Defining the constructor of a feature. Used to register the modules.
  44355. */
  44356. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  44357. /**
  44358. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  44359. * It is mainly used in AR sessions.
  44360. *
  44361. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  44362. */
  44363. export class WebXRFeaturesManager implements IDisposable {
  44364. private _xrSessionManager;
  44365. private static readonly _AvailableFeatures;
  44366. /**
  44367. * Used to register a module. After calling this function a developer can use this feature in the scene.
  44368. * Mainly used internally.
  44369. *
  44370. * @param featureName the name of the feature to register
  44371. * @param constructorFunction the function used to construct the module
  44372. * @param version the (babylon) version of the module
  44373. * @param stable is that a stable version of this module
  44374. */
  44375. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  44376. /**
  44377. * Returns a constructor of a specific feature.
  44378. *
  44379. * @param featureName the name of the feature to construct
  44380. * @param version the version of the feature to load
  44381. * @param xrSessionManager the xrSessionManager. Used to construct the module
  44382. * @param options optional options provided to the module.
  44383. * @returns a function that, when called, will return a new instance of this feature
  44384. */
  44385. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  44386. /**
  44387. * Return the latest unstable version of this feature
  44388. * @param featureName the name of the feature to search
  44389. * @returns the version number. if not found will return -1
  44390. */
  44391. static GetLatestVersionOfFeature(featureName: string): number;
  44392. /**
  44393. * Return the latest stable version of this feature
  44394. * @param featureName the name of the feature to search
  44395. * @returns the version number. if not found will return -1
  44396. */
  44397. static GetStableVersionOfFeature(featureName: string): number;
  44398. /**
  44399. * Can be used to return the list of features currently registered
  44400. *
  44401. * @returns an Array of available features
  44402. */
  44403. static GetAvailableFeatures(): string[];
  44404. /**
  44405. * Gets the versions available for a specific feature
  44406. * @param featureName the name of the feature
  44407. * @returns an array with the available versions
  44408. */
  44409. static GetAvailableVersions(featureName: string): string[];
  44410. private _features;
  44411. /**
  44412. * constructs a new features manages.
  44413. *
  44414. * @param _xrSessionManager an instance of WebXRSessionManager
  44415. */
  44416. constructor(_xrSessionManager: WebXRSessionManager);
  44417. /**
  44418. * 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.
  44419. * 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.
  44420. *
  44421. * @param featureName the name of the feature to load or the class of the feature
  44422. * @param version optional version to load. if not provided the latest version will be enabled
  44423. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  44424. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  44425. * @returns a new constructed feature or throws an error if feature not found.
  44426. */
  44427. enableFeature(featureName: string | {
  44428. Name: string;
  44429. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  44430. /**
  44431. * Used to disable an already-enabled feature
  44432. * The feature will be disposed and will be recreated once enabled.
  44433. * @param featureName the feature to disable
  44434. * @returns true if disable was successful
  44435. */
  44436. disableFeature(featureName: string | {
  44437. Name: string;
  44438. }): boolean;
  44439. /**
  44440. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  44441. * Can be used during a session to start a feature
  44442. * @param featureName the name of feature to attach
  44443. */
  44444. attachFeature(featureName: string): void;
  44445. /**
  44446. * Can be used inside a session or when the session ends to detach a specific feature
  44447. * @param featureName the name of the feature to detach
  44448. */
  44449. detachFeature(featureName: string): void;
  44450. /**
  44451. * Get the list of enabled features
  44452. * @returns an array of enabled features
  44453. */
  44454. getEnabledFeatures(): string[];
  44455. /**
  44456. * get the implementation of an enabled feature.
  44457. * @param featureName the name of the feature to load
  44458. * @returns the feature class, if found
  44459. */
  44460. getEnabledFeature(featureName: string): IWebXRFeature;
  44461. /**
  44462. * dispose this features manager
  44463. */
  44464. dispose(): void;
  44465. }
  44466. }
  44467. declare module "babylonjs/XR/webXRExperienceHelper" {
  44468. import { Observable } from "babylonjs/Misc/observable";
  44469. import { IDisposable, Scene } from "babylonjs/scene";
  44470. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44471. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  44472. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44473. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  44474. /**
  44475. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  44476. * @see https://doc.babylonjs.com/how_to/webxr
  44477. */
  44478. export class WebXRExperienceHelper implements IDisposable {
  44479. private scene;
  44480. /**
  44481. * Camera used to render xr content
  44482. */
  44483. camera: WebXRCamera;
  44484. /**
  44485. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  44486. */
  44487. state: WebXRState;
  44488. private _setState;
  44489. /**
  44490. * Fires when the state of the experience helper has changed
  44491. */
  44492. onStateChangedObservable: Observable<WebXRState>;
  44493. /**
  44494. * Observers registered here will be triggered after the camera's initial transformation is set
  44495. * This can be used to set a different ground level or an extra rotation.
  44496. *
  44497. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  44498. * to the position set after this observable is done executing.
  44499. */
  44500. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  44501. /** Session manager used to keep track of xr session */
  44502. sessionManager: WebXRSessionManager;
  44503. /** A features manager for this xr session */
  44504. featuresManager: WebXRFeaturesManager;
  44505. private _nonVRCamera;
  44506. private _originalSceneAutoClear;
  44507. private _supported;
  44508. /**
  44509. * Creates the experience helper
  44510. * @param scene the scene to attach the experience helper to
  44511. * @returns a promise for the experience helper
  44512. */
  44513. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  44514. /**
  44515. * Creates a WebXRExperienceHelper
  44516. * @param scene The scene the helper should be created in
  44517. */
  44518. private constructor();
  44519. /**
  44520. * Exits XR mode and returns the scene to its original state
  44521. * @returns promise that resolves after xr mode has exited
  44522. */
  44523. exitXRAsync(): Promise<void>;
  44524. /**
  44525. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  44526. * @param sessionMode options for the XR session
  44527. * @param referenceSpaceType frame of reference of the XR session
  44528. * @param renderTarget the output canvas that will be used to enter XR mode
  44529. * @returns promise that resolves after xr mode has entered
  44530. */
  44531. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  44532. /**
  44533. * Disposes of the experience helper
  44534. */
  44535. dispose(): void;
  44536. private _nonXRToXRCamera;
  44537. }
  44538. }
  44539. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  44540. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  44541. import { Observable } from "babylonjs/Misc/observable";
  44542. import { IDisposable } from "babylonjs/scene";
  44543. /**
  44544. * X-Y values for axes in WebXR
  44545. */
  44546. export interface IWebXRMotionControllerAxesValue {
  44547. /**
  44548. * The value of the x axis
  44549. */
  44550. x: number;
  44551. /**
  44552. * The value of the y-axis
  44553. */
  44554. y: number;
  44555. }
  44556. /**
  44557. * changed / previous values for the values of this component
  44558. */
  44559. export interface IWebXRMotionControllerComponentChangesValues<T> {
  44560. /**
  44561. * current (this frame) value
  44562. */
  44563. current: T;
  44564. /**
  44565. * previous (last change) value
  44566. */
  44567. previous: T;
  44568. }
  44569. /**
  44570. * Represents changes in the component between current frame and last values recorded
  44571. */
  44572. export interface IWebXRMotionControllerComponentChanges {
  44573. /**
  44574. * will be populated with previous and current values if touched changed
  44575. */
  44576. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44577. /**
  44578. * will be populated with previous and current values if pressed changed
  44579. */
  44580. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44581. /**
  44582. * will be populated with previous and current values if value changed
  44583. */
  44584. value?: IWebXRMotionControllerComponentChangesValues<number>;
  44585. /**
  44586. * will be populated with previous and current values if axes changed
  44587. */
  44588. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  44589. }
  44590. /**
  44591. * This class represents a single component (for example button or thumbstick) of a motion controller
  44592. */
  44593. export class WebXRControllerComponent implements IDisposable {
  44594. /**
  44595. * the id of this component
  44596. */
  44597. id: string;
  44598. /**
  44599. * the type of the component
  44600. */
  44601. type: MotionControllerComponentType;
  44602. private _buttonIndex;
  44603. private _axesIndices;
  44604. /**
  44605. * Thumbstick component type
  44606. */
  44607. static THUMBSTICK_TYPE: MotionControllerComponentType;
  44608. /**
  44609. * Touchpad component type
  44610. */
  44611. static TOUCHPAD_TYPE: MotionControllerComponentType;
  44612. /**
  44613. * trigger component type
  44614. */
  44615. static TRIGGER_TYPE: MotionControllerComponentType;
  44616. /**
  44617. * squeeze component type
  44618. */
  44619. static SQUEEZE_TYPE: MotionControllerComponentType;
  44620. /**
  44621. * button component type
  44622. */
  44623. static BUTTON_TYPE: MotionControllerComponentType;
  44624. /**
  44625. * Observers registered here will be triggered when the state of a button changes
  44626. * State change is either pressed / touched / value
  44627. */
  44628. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  44629. /**
  44630. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  44631. * the axes data changes
  44632. */
  44633. onAxisValueChangedObservable: Observable<{
  44634. x: number;
  44635. y: number;
  44636. }>;
  44637. private _currentValue;
  44638. private _touched;
  44639. private _pressed;
  44640. private _axes;
  44641. private _changes;
  44642. private _hasChanges;
  44643. /**
  44644. * Return whether or not the component changed the last frame
  44645. */
  44646. get hasChanges(): boolean;
  44647. /**
  44648. * Creates a new component for a motion controller.
  44649. * It is created by the motion controller itself
  44650. *
  44651. * @param id the id of this component
  44652. * @param type the type of the component
  44653. * @param _buttonIndex index in the buttons array of the gamepad
  44654. * @param _axesIndices indices of the values in the axes array of the gamepad
  44655. */
  44656. constructor(
  44657. /**
  44658. * the id of this component
  44659. */
  44660. id: string,
  44661. /**
  44662. * the type of the component
  44663. */
  44664. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  44665. /**
  44666. * Get the current value of this component
  44667. */
  44668. get value(): number;
  44669. /**
  44670. * is the button currently pressed
  44671. */
  44672. get pressed(): boolean;
  44673. /**
  44674. * is the button currently touched
  44675. */
  44676. get touched(): boolean;
  44677. /**
  44678. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  44679. */
  44680. get axes(): IWebXRMotionControllerAxesValue;
  44681. /**
  44682. * Get the changes. Elements will be populated only if they changed with their previous and current value
  44683. */
  44684. get changes(): IWebXRMotionControllerComponentChanges;
  44685. /**
  44686. * Is this component a button (hence - pressable)
  44687. * @returns true if can be pressed
  44688. */
  44689. isButton(): boolean;
  44690. /**
  44691. * Are there axes correlating to this component
  44692. * @return true is axes data is available
  44693. */
  44694. isAxes(): boolean;
  44695. /**
  44696. * update this component using the gamepad object it is in. Called on every frame
  44697. * @param nativeController the native gamepad controller object
  44698. */
  44699. update(nativeController: IMinimalMotionControllerObject): void;
  44700. /**
  44701. * Dispose this component
  44702. */
  44703. dispose(): void;
  44704. }
  44705. }
  44706. declare module "babylonjs/Loading/sceneLoader" {
  44707. import { Observable } from "babylonjs/Misc/observable";
  44708. import { Nullable } from "babylonjs/types";
  44709. import { Scene } from "babylonjs/scene";
  44710. import { Engine } from "babylonjs/Engines/engine";
  44711. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44712. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44713. import { AssetContainer } from "babylonjs/assetContainer";
  44714. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44715. import { Skeleton } from "babylonjs/Bones/skeleton";
  44716. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  44717. import { WebRequest } from "babylonjs/Misc/webRequest";
  44718. /**
  44719. * Class used to represent data loading progression
  44720. */
  44721. export class SceneLoaderProgressEvent {
  44722. /** defines if data length to load can be evaluated */
  44723. readonly lengthComputable: boolean;
  44724. /** defines the loaded data length */
  44725. readonly loaded: number;
  44726. /** defines the data length to load */
  44727. readonly total: number;
  44728. /**
  44729. * Create a new progress event
  44730. * @param lengthComputable defines if data length to load can be evaluated
  44731. * @param loaded defines the loaded data length
  44732. * @param total defines the data length to load
  44733. */
  44734. constructor(
  44735. /** defines if data length to load can be evaluated */
  44736. lengthComputable: boolean,
  44737. /** defines the loaded data length */
  44738. loaded: number,
  44739. /** defines the data length to load */
  44740. total: number);
  44741. /**
  44742. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  44743. * @param event defines the source event
  44744. * @returns a new SceneLoaderProgressEvent
  44745. */
  44746. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  44747. }
  44748. /**
  44749. * Interface used by SceneLoader plugins to define supported file extensions
  44750. */
  44751. export interface ISceneLoaderPluginExtensions {
  44752. /**
  44753. * Defines the list of supported extensions
  44754. */
  44755. [extension: string]: {
  44756. isBinary: boolean;
  44757. };
  44758. }
  44759. /**
  44760. * Interface used by SceneLoader plugin factory
  44761. */
  44762. export interface ISceneLoaderPluginFactory {
  44763. /**
  44764. * Defines the name of the factory
  44765. */
  44766. name: string;
  44767. /**
  44768. * Function called to create a new plugin
  44769. * @return the new plugin
  44770. */
  44771. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  44772. /**
  44773. * The callback that returns true if the data can be directly loaded.
  44774. * @param data string containing the file data
  44775. * @returns if the data can be loaded directly
  44776. */
  44777. canDirectLoad?(data: string): boolean;
  44778. }
  44779. /**
  44780. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  44781. */
  44782. export interface ISceneLoaderPluginBase {
  44783. /**
  44784. * The friendly name of this plugin.
  44785. */
  44786. name: string;
  44787. /**
  44788. * The file extensions supported by this plugin.
  44789. */
  44790. extensions: string | ISceneLoaderPluginExtensions;
  44791. /**
  44792. * The callback called when loading from a url.
  44793. * @param scene scene loading this url
  44794. * @param url url to load
  44795. * @param onSuccess callback called when the file successfully loads
  44796. * @param onProgress callback called while file is loading (if the server supports this mode)
  44797. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  44798. * @param onError callback called when the file fails to load
  44799. * @returns a file request object
  44800. */
  44801. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44802. /**
  44803. * The callback called when loading from a file object.
  44804. * @param scene scene loading this file
  44805. * @param file defines the file to load
  44806. * @param onSuccess defines the callback to call when data is loaded
  44807. * @param onProgress defines the callback to call during loading process
  44808. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  44809. * @param onError defines the callback to call when an error occurs
  44810. * @returns a file request object
  44811. */
  44812. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44813. /**
  44814. * The callback that returns true if the data can be directly loaded.
  44815. * @param data string containing the file data
  44816. * @returns if the data can be loaded directly
  44817. */
  44818. canDirectLoad?(data: string): boolean;
  44819. /**
  44820. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  44821. * @param scene scene loading this data
  44822. * @param data string containing the data
  44823. * @returns data to pass to the plugin
  44824. */
  44825. directLoad?(scene: Scene, data: string): any;
  44826. /**
  44827. * The callback that allows custom handling of the root url based on the response url.
  44828. * @param rootUrl the original root url
  44829. * @param responseURL the response url if available
  44830. * @returns the new root url
  44831. */
  44832. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  44833. }
  44834. /**
  44835. * Interface used to define a SceneLoader plugin
  44836. */
  44837. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  44838. /**
  44839. * Import meshes into a scene.
  44840. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44841. * @param scene The scene to import into
  44842. * @param data The data to import
  44843. * @param rootUrl The root url for scene and resources
  44844. * @param meshes The meshes array to import into
  44845. * @param particleSystems The particle systems array to import into
  44846. * @param skeletons The skeletons array to import into
  44847. * @param onError The callback when import fails
  44848. * @returns True if successful or false otherwise
  44849. */
  44850. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  44851. /**
  44852. * Load into a scene.
  44853. * @param scene The scene to load into
  44854. * @param data The data to import
  44855. * @param rootUrl The root url for scene and resources
  44856. * @param onError The callback when import fails
  44857. * @returns True if successful or false otherwise
  44858. */
  44859. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  44860. /**
  44861. * Load into an asset container.
  44862. * @param scene The scene to load into
  44863. * @param data The data to import
  44864. * @param rootUrl The root url for scene and resources
  44865. * @param onError The callback when import fails
  44866. * @returns The loaded asset container
  44867. */
  44868. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  44869. }
  44870. /**
  44871. * Interface used to define an async SceneLoader plugin
  44872. */
  44873. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  44874. /**
  44875. * Import meshes into a scene.
  44876. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44877. * @param scene The scene to import into
  44878. * @param data The data to import
  44879. * @param rootUrl The root url for scene and resources
  44880. * @param onProgress The callback when the load progresses
  44881. * @param fileName Defines the name of the file to load
  44882. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  44883. */
  44884. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  44885. meshes: AbstractMesh[];
  44886. particleSystems: IParticleSystem[];
  44887. skeletons: Skeleton[];
  44888. animationGroups: AnimationGroup[];
  44889. }>;
  44890. /**
  44891. * Load into a scene.
  44892. * @param scene The scene to load into
  44893. * @param data The data to import
  44894. * @param rootUrl The root url for scene and resources
  44895. * @param onProgress The callback when the load progresses
  44896. * @param fileName Defines the name of the file to load
  44897. * @returns Nothing
  44898. */
  44899. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44900. /**
  44901. * Load into an asset container.
  44902. * @param scene The scene to load into
  44903. * @param data The data to import
  44904. * @param rootUrl The root url for scene and resources
  44905. * @param onProgress The callback when the load progresses
  44906. * @param fileName Defines the name of the file to load
  44907. * @returns The loaded asset container
  44908. */
  44909. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44910. }
  44911. /**
  44912. * Mode that determines how to handle old animation groups before loading new ones.
  44913. */
  44914. export enum SceneLoaderAnimationGroupLoadingMode {
  44915. /**
  44916. * Reset all old animations to initial state then dispose them.
  44917. */
  44918. Clean = 0,
  44919. /**
  44920. * Stop all old animations.
  44921. */
  44922. Stop = 1,
  44923. /**
  44924. * Restart old animations from first frame.
  44925. */
  44926. Sync = 2,
  44927. /**
  44928. * Old animations remains untouched.
  44929. */
  44930. NoSync = 3
  44931. }
  44932. /**
  44933. * Class used to load scene from various file formats using registered plugins
  44934. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44935. */
  44936. export class SceneLoader {
  44937. /**
  44938. * No logging while loading
  44939. */
  44940. static readonly NO_LOGGING: number;
  44941. /**
  44942. * Minimal logging while loading
  44943. */
  44944. static readonly MINIMAL_LOGGING: number;
  44945. /**
  44946. * Summary logging while loading
  44947. */
  44948. static readonly SUMMARY_LOGGING: number;
  44949. /**
  44950. * Detailled logging while loading
  44951. */
  44952. static readonly DETAILED_LOGGING: number;
  44953. /**
  44954. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44955. */
  44956. static get ForceFullSceneLoadingForIncremental(): boolean;
  44957. static set ForceFullSceneLoadingForIncremental(value: boolean);
  44958. /**
  44959. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44960. */
  44961. static get ShowLoadingScreen(): boolean;
  44962. static set ShowLoadingScreen(value: boolean);
  44963. /**
  44964. * Defines the current logging level (while loading the scene)
  44965. * @ignorenaming
  44966. */
  44967. static get loggingLevel(): number;
  44968. static set loggingLevel(value: number);
  44969. /**
  44970. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44971. */
  44972. static get CleanBoneMatrixWeights(): boolean;
  44973. static set CleanBoneMatrixWeights(value: boolean);
  44974. /**
  44975. * Event raised when a plugin is used to load a scene
  44976. */
  44977. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44978. private static _registeredPlugins;
  44979. private static _getDefaultPlugin;
  44980. private static _getPluginForExtension;
  44981. private static _getPluginForDirectLoad;
  44982. private static _getPluginForFilename;
  44983. private static _getDirectLoad;
  44984. private static _loadData;
  44985. private static _getFileInfo;
  44986. /**
  44987. * Gets a plugin that can load the given extension
  44988. * @param extension defines the extension to load
  44989. * @returns a plugin or null if none works
  44990. */
  44991. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44992. /**
  44993. * Gets a boolean indicating that the given extension can be loaded
  44994. * @param extension defines the extension to load
  44995. * @returns true if the extension is supported
  44996. */
  44997. static IsPluginForExtensionAvailable(extension: string): boolean;
  44998. /**
  44999. * Adds a new plugin to the list of registered plugins
  45000. * @param plugin defines the plugin to add
  45001. */
  45002. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  45003. /**
  45004. * Import meshes into a scene
  45005. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45006. * @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)
  45007. * @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)
  45008. * @param scene the instance of BABYLON.Scene to append to
  45009. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  45010. * @param onProgress a callback with a progress event for each file being loaded
  45011. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45012. * @param pluginExtension the extension used to determine the plugin
  45013. * @returns The loaded plugin
  45014. */
  45015. 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>;
  45016. /**
  45017. * Import meshes into a scene
  45018. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45019. * @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)
  45020. * @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)
  45021. * @param scene the instance of BABYLON.Scene to append to
  45022. * @param onProgress a callback with a progress event for each file being loaded
  45023. * @param pluginExtension the extension used to determine the plugin
  45024. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  45025. */
  45026. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  45027. meshes: AbstractMesh[];
  45028. particleSystems: IParticleSystem[];
  45029. skeletons: Skeleton[];
  45030. animationGroups: AnimationGroup[];
  45031. }>;
  45032. /**
  45033. * Load a scene
  45034. * @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)
  45035. * @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)
  45036. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45037. * @param onSuccess a callback with the scene when import succeeds
  45038. * @param onProgress a callback with a progress event for each file being loaded
  45039. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45040. * @param pluginExtension the extension used to determine the plugin
  45041. * @returns The loaded plugin
  45042. */
  45043. 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>;
  45044. /**
  45045. * Load a scene
  45046. * @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)
  45047. * @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)
  45048. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45049. * @param onProgress a callback with a progress event for each file being loaded
  45050. * @param pluginExtension the extension used to determine the plugin
  45051. * @returns The loaded scene
  45052. */
  45053. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45054. /**
  45055. * Append a scene
  45056. * @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)
  45057. * @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)
  45058. * @param scene is the instance of BABYLON.Scene to append to
  45059. * @param onSuccess a callback with the scene when import succeeds
  45060. * @param onProgress a callback with a progress event for each file being loaded
  45061. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45062. * @param pluginExtension the extension used to determine the plugin
  45063. * @returns The loaded plugin
  45064. */
  45065. 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>;
  45066. /**
  45067. * Append a scene
  45068. * @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)
  45069. * @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)
  45070. * @param scene is the instance of BABYLON.Scene to append to
  45071. * @param onProgress a callback with a progress event for each file being loaded
  45072. * @param pluginExtension the extension used to determine the plugin
  45073. * @returns The given scene
  45074. */
  45075. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45076. /**
  45077. * Load a scene into an asset container
  45078. * @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)
  45079. * @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)
  45080. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45081. * @param onSuccess a callback with the scene when import succeeds
  45082. * @param onProgress a callback with a progress event for each file being loaded
  45083. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45084. * @param pluginExtension the extension used to determine the plugin
  45085. * @returns The loaded plugin
  45086. */
  45087. 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>;
  45088. /**
  45089. * Load a scene into an asset container
  45090. * @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)
  45091. * @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)
  45092. * @param scene is the instance of Scene to append to
  45093. * @param onProgress a callback with a progress event for each file being loaded
  45094. * @param pluginExtension the extension used to determine the plugin
  45095. * @returns The loaded asset container
  45096. */
  45097. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  45098. /**
  45099. * Import animations from a file into a scene
  45100. * @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)
  45101. * @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)
  45102. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45103. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45104. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45105. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45106. * @param onSuccess a callback with the scene when import succeeds
  45107. * @param onProgress a callback with a progress event for each file being loaded
  45108. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45109. */
  45110. 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;
  45111. /**
  45112. * Import animations from a file into a scene
  45113. * @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)
  45114. * @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)
  45115. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45116. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45117. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45118. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45119. * @param onSuccess a callback with the scene when import succeeds
  45120. * @param onProgress a callback with a progress event for each file being loaded
  45121. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45122. * @returns the updated scene with imported animations
  45123. */
  45124. 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>;
  45125. }
  45126. }
  45127. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  45128. import { IDisposable, Scene } from "babylonjs/scene";
  45129. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  45130. import { Observable } from "babylonjs/Misc/observable";
  45131. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45132. import { Nullable } from "babylonjs/types";
  45133. /**
  45134. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  45135. */
  45136. export type MotionControllerHandness = "none" | "left" | "right";
  45137. /**
  45138. * The type of components available in motion controllers.
  45139. * This is not the name of the component.
  45140. */
  45141. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  45142. /**
  45143. * The state of a controller component
  45144. */
  45145. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  45146. /**
  45147. * The schema of motion controller layout.
  45148. * No object will be initialized using this interface
  45149. * This is used just to define the profile.
  45150. */
  45151. export interface IMotionControllerLayout {
  45152. /**
  45153. * Defines the main button component id
  45154. */
  45155. selectComponentId: string;
  45156. /**
  45157. * Available components (unsorted)
  45158. */
  45159. components: {
  45160. /**
  45161. * A map of component Ids
  45162. */
  45163. [componentId: string]: {
  45164. /**
  45165. * The type of input the component outputs
  45166. */
  45167. type: MotionControllerComponentType;
  45168. /**
  45169. * The indices of this component in the gamepad object
  45170. */
  45171. gamepadIndices: {
  45172. /**
  45173. * Index of button
  45174. */
  45175. button?: number;
  45176. /**
  45177. * If available, index of x-axis
  45178. */
  45179. xAxis?: number;
  45180. /**
  45181. * If available, index of y-axis
  45182. */
  45183. yAxis?: number;
  45184. };
  45185. /**
  45186. * The mesh's root node name
  45187. */
  45188. rootNodeName: string;
  45189. /**
  45190. * Animation definitions for this model
  45191. */
  45192. visualResponses: {
  45193. [stateKey: string]: {
  45194. /**
  45195. * What property will be animated
  45196. */
  45197. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  45198. /**
  45199. * What states influence this visual reponse
  45200. */
  45201. states: MotionControllerComponentStateType[];
  45202. /**
  45203. * Type of animation - movement or visibility
  45204. */
  45205. valueNodeProperty: "transform" | "visibility";
  45206. /**
  45207. * Base node name to move. Its position will be calculated according to the min and max nodes
  45208. */
  45209. valueNodeName?: string;
  45210. /**
  45211. * Minimum movement node
  45212. */
  45213. minNodeName?: string;
  45214. /**
  45215. * Max movement node
  45216. */
  45217. maxNodeName?: string;
  45218. };
  45219. };
  45220. /**
  45221. * If touch enabled, what is the name of node to display user feedback
  45222. */
  45223. touchPointNodeName?: string;
  45224. };
  45225. };
  45226. /**
  45227. * Is it xr standard mapping or not
  45228. */
  45229. gamepadMapping: "" | "xr-standard";
  45230. /**
  45231. * Base root node of this entire model
  45232. */
  45233. rootNodeName: string;
  45234. /**
  45235. * Path to load the assets. Usually relative to the base path
  45236. */
  45237. assetPath: string;
  45238. }
  45239. /**
  45240. * A definition for the layout map in the input profile
  45241. */
  45242. export interface IMotionControllerLayoutMap {
  45243. /**
  45244. * Layouts with handness type as a key
  45245. */
  45246. [handness: string]: IMotionControllerLayout;
  45247. }
  45248. /**
  45249. * The XR Input profile schema
  45250. * Profiles can be found here:
  45251. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  45252. */
  45253. export interface IMotionControllerProfile {
  45254. /**
  45255. * The id of this profile
  45256. * correlates to the profile(s) in the xrInput.profiles array
  45257. */
  45258. profileId: string;
  45259. /**
  45260. * fallback profiles for this profileId
  45261. */
  45262. fallbackProfileIds: string[];
  45263. /**
  45264. * The layout map, with handness as key
  45265. */
  45266. layouts: IMotionControllerLayoutMap;
  45267. }
  45268. /**
  45269. * A helper-interface for the 3 meshes needed for controller button animation
  45270. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  45271. */
  45272. export interface IMotionControllerButtonMeshMap {
  45273. /**
  45274. * The mesh that will be changed when value changes
  45275. */
  45276. valueMesh: AbstractMesh;
  45277. /**
  45278. * the mesh that defines the pressed value mesh position.
  45279. * This is used to find the max-position of this button
  45280. */
  45281. pressedMesh: AbstractMesh;
  45282. /**
  45283. * the mesh that defines the unpressed value mesh position.
  45284. * This is used to find the min (or initial) position of this button
  45285. */
  45286. unpressedMesh: AbstractMesh;
  45287. }
  45288. /**
  45289. * A helper-interface for the 3 meshes needed for controller axis animation.
  45290. * This will be expanded when touchpad animations are fully supported
  45291. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  45292. */
  45293. export interface IMotionControllerMeshMap {
  45294. /**
  45295. * The mesh that will be changed when axis value changes
  45296. */
  45297. valueMesh: AbstractMesh;
  45298. /**
  45299. * the mesh that defines the minimum value mesh position.
  45300. */
  45301. minMesh?: AbstractMesh;
  45302. /**
  45303. * the mesh that defines the maximum value mesh position.
  45304. */
  45305. maxMesh?: AbstractMesh;
  45306. }
  45307. /**
  45308. * The elements needed for change-detection of the gamepad objects in motion controllers
  45309. */
  45310. export interface IMinimalMotionControllerObject {
  45311. /**
  45312. * An array of available buttons
  45313. */
  45314. buttons: Array<{
  45315. /**
  45316. * Value of the button/trigger
  45317. */
  45318. value: number;
  45319. /**
  45320. * If the button/trigger is currently touched
  45321. */
  45322. touched: boolean;
  45323. /**
  45324. * If the button/trigger is currently pressed
  45325. */
  45326. pressed: boolean;
  45327. }>;
  45328. /**
  45329. * Available axes of this controller
  45330. */
  45331. axes: number[];
  45332. }
  45333. /**
  45334. * An Abstract Motion controller
  45335. * This class receives an xrInput and a profile layout and uses those to initialize the components
  45336. * Each component has an observable to check for changes in value and state
  45337. */
  45338. export abstract class WebXRAbstractMotionController implements IDisposable {
  45339. protected scene: Scene;
  45340. protected layout: IMotionControllerLayout;
  45341. /**
  45342. * The gamepad object correlating to this controller
  45343. */
  45344. gamepadObject: IMinimalMotionControllerObject;
  45345. /**
  45346. * handness (left/right/none) of this controller
  45347. */
  45348. handness: MotionControllerHandness;
  45349. /**
  45350. * The profile id of this motion controller
  45351. */
  45352. abstract profileId: string;
  45353. /**
  45354. * A map of components (WebXRControllerComponent) in this motion controller
  45355. * Components have a ComponentType and can also have both button and axis definitions
  45356. */
  45357. readonly components: {
  45358. [id: string]: WebXRControllerComponent;
  45359. };
  45360. /**
  45361. * Observers registered here will be triggered when the model of this controller is done loading
  45362. */
  45363. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  45364. /**
  45365. * The root mesh of the model. It is null if the model was not yet initialized
  45366. */
  45367. rootMesh: Nullable<AbstractMesh>;
  45368. /**
  45369. * Disable the model's animation. Can be set at any time.
  45370. */
  45371. disableAnimation: boolean;
  45372. private _modelReady;
  45373. /**
  45374. * constructs a new abstract motion controller
  45375. * @param scene the scene to which the model of the controller will be added
  45376. * @param layout The profile layout to load
  45377. * @param gamepadObject The gamepad object correlating to this controller
  45378. * @param handness handness (left/right/none) of this controller
  45379. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  45380. */
  45381. constructor(scene: Scene, layout: IMotionControllerLayout,
  45382. /**
  45383. * The gamepad object correlating to this controller
  45384. */
  45385. gamepadObject: IMinimalMotionControllerObject,
  45386. /**
  45387. * handness (left/right/none) of this controller
  45388. */
  45389. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  45390. private _initComponent;
  45391. /**
  45392. * Update this model using the current XRFrame
  45393. * @param xrFrame the current xr frame to use and update the model
  45394. */
  45395. updateFromXRFrame(xrFrame: XRFrame): void;
  45396. /**
  45397. * Get the list of components available in this motion controller
  45398. * @returns an array of strings correlating to available components
  45399. */
  45400. getComponentIds(): string[];
  45401. /**
  45402. * Get the main (Select) component of this controller as defined in the layout
  45403. * @returns the main component of this controller
  45404. */
  45405. getMainComponent(): WebXRControllerComponent;
  45406. /**
  45407. * get a component based an its component id as defined in layout.components
  45408. * @param id the id of the component
  45409. * @returns the component correlates to the id or undefined if not found
  45410. */
  45411. getComponent(id: string): WebXRControllerComponent;
  45412. /**
  45413. * Get the first component of specific type
  45414. * @param type type of component to find
  45415. * @return a controller component or null if not found
  45416. */
  45417. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  45418. /**
  45419. * Returns all components of specific type
  45420. * @param type the type to search for
  45421. * @return an array of components with this type
  45422. */
  45423. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  45424. /**
  45425. * Loads the model correlating to this controller
  45426. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  45427. * @returns A promise fulfilled with the result of the model loading
  45428. */
  45429. loadModel(): Promise<boolean>;
  45430. /**
  45431. * Update the model itself with the current frame data
  45432. * @param xrFrame the frame to use for updating the model mesh
  45433. */
  45434. protected updateModel(xrFrame: XRFrame): void;
  45435. /**
  45436. * Moves the axis on the controller mesh based on its current state
  45437. * @param axis the index of the axis
  45438. * @param axisValue the value of the axis which determines the meshes new position
  45439. * @hidden
  45440. */
  45441. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  45442. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45443. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45444. private _getGenericFilenameAndPath;
  45445. private _getGenericParentMesh;
  45446. /**
  45447. * Get the filename and path for this controller's model
  45448. * @returns a map of filename and path
  45449. */
  45450. protected abstract _getFilenameAndPath(): {
  45451. filename: string;
  45452. path: string;
  45453. };
  45454. /**
  45455. * This function will be called after the model was successfully loaded and can be used
  45456. * for mesh transformations before it is available for the user
  45457. * @param meshes the loaded meshes
  45458. */
  45459. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  45460. /**
  45461. * Set the root mesh for this controller. Important for the WebXR controller class
  45462. * @param meshes the loaded meshes
  45463. */
  45464. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  45465. /**
  45466. * A function executed each frame that updates the mesh (if needed)
  45467. * @param xrFrame the current xrFrame
  45468. */
  45469. protected abstract _updateModel(xrFrame: XRFrame): void;
  45470. /**
  45471. * This function is called before the mesh is loaded. It checks for loading constraints.
  45472. * For example, this function can check if the GLB loader is available
  45473. * If this function returns false, the generic controller will be loaded instead
  45474. * @returns Is the client ready to load the mesh
  45475. */
  45476. protected abstract _getModelLoadingConstraints(): boolean;
  45477. /**
  45478. * Dispose this controller, the model mesh and all its components
  45479. */
  45480. dispose(): void;
  45481. }
  45482. }
  45483. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  45484. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45485. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45486. import { Scene } from "babylonjs/scene";
  45487. /**
  45488. * A generic trigger-only motion controller for WebXR
  45489. */
  45490. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  45491. /**
  45492. * Static version of the profile id of this controller
  45493. */
  45494. static ProfileId: string;
  45495. profileId: string;
  45496. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  45497. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  45498. protected _updateModel(): void;
  45499. protected _getFilenameAndPath(): {
  45500. filename: string;
  45501. path: string;
  45502. };
  45503. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45504. protected _getModelLoadingConstraints(): boolean;
  45505. }
  45506. }
  45507. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  45508. import { Vector4 } from "babylonjs/Maths/math.vector";
  45509. import { Mesh } from "babylonjs/Meshes/mesh";
  45510. import { Scene } from "babylonjs/scene";
  45511. import { Nullable } from "babylonjs/types";
  45512. /**
  45513. * Class containing static functions to help procedurally build meshes
  45514. */
  45515. export class SphereBuilder {
  45516. /**
  45517. * Creates a sphere mesh
  45518. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45519. * * 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`)
  45520. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45521. * * 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
  45522. * * 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)
  45523. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45524. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45525. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45526. * @param name defines the name of the mesh
  45527. * @param options defines the options used to create the mesh
  45528. * @param scene defines the hosting scene
  45529. * @returns the sphere mesh
  45530. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45531. */
  45532. static CreateSphere(name: string, options: {
  45533. segments?: number;
  45534. diameter?: number;
  45535. diameterX?: number;
  45536. diameterY?: number;
  45537. diameterZ?: number;
  45538. arc?: number;
  45539. slice?: number;
  45540. sideOrientation?: number;
  45541. frontUVs?: Vector4;
  45542. backUVs?: Vector4;
  45543. updatable?: boolean;
  45544. }, scene?: Nullable<Scene>): Mesh;
  45545. }
  45546. }
  45547. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  45548. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45549. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45550. import { Scene } from "babylonjs/scene";
  45551. /**
  45552. * A profiled motion controller has its profile loaded from an online repository.
  45553. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  45554. */
  45555. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  45556. private _repositoryUrl;
  45557. /**
  45558. * The profile ID of this controller. Will be populated when the controller initializes.
  45559. */
  45560. profileId: string;
  45561. private _buttonMeshMapping;
  45562. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  45563. protected _getFilenameAndPath(): {
  45564. filename: string;
  45565. path: string;
  45566. };
  45567. private _touchDots;
  45568. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  45569. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45570. protected _updateModel(_xrFrame: XRFrame): void;
  45571. protected _getModelLoadingConstraints(): boolean;
  45572. dispose(): void;
  45573. }
  45574. }
  45575. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  45576. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45577. import { Scene } from "babylonjs/scene";
  45578. /**
  45579. * A construction function type to create a new controller based on an xrInput object
  45580. */
  45581. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  45582. /**
  45583. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  45584. *
  45585. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  45586. * it should be replaced with auto-loaded controllers.
  45587. *
  45588. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  45589. */
  45590. export class WebXRMotionControllerManager {
  45591. /**
  45592. * The base URL of the online controller repository. Can be changed at any time.
  45593. */
  45594. static BaseRepositoryUrl: string;
  45595. /**
  45596. * Use the online repository, or use only locally-defined controllers
  45597. */
  45598. static UseOnlineRepository: boolean;
  45599. /**
  45600. * Which repository gets priority - local or online
  45601. */
  45602. static PrioritizeOnlineRepository: boolean;
  45603. private static _AvailableControllers;
  45604. private static _Fallbacks;
  45605. /**
  45606. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  45607. *
  45608. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  45609. *
  45610. * @param type the profile type to register
  45611. * @param constructFunction the function to be called when loading this profile
  45612. */
  45613. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  45614. /**
  45615. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  45616. * The order of search:
  45617. *
  45618. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  45619. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  45620. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  45621. * 4) return the generic trigger controller if none were found
  45622. *
  45623. * @param xrInput the xrInput to which a new controller is initialized
  45624. * @param scene the scene to which the model will be added
  45625. * @param forceProfile force a certain profile for this controller
  45626. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  45627. */
  45628. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  45629. private static _LoadProfilesFromAvailableControllers;
  45630. private static _ProfilesList;
  45631. private static _ProfileLoadingPromises;
  45632. private static _LoadProfileFromRepository;
  45633. /**
  45634. * Clear the cache used for profile loading and reload when requested again
  45635. */
  45636. static ClearProfilesCache(): void;
  45637. /**
  45638. * Will update the list of profiles available in the repository
  45639. * @return a promise that resolves to a map of profiles available online
  45640. */
  45641. static UpdateProfilesList(): Promise<{
  45642. [profile: string]: string;
  45643. }>;
  45644. /**
  45645. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  45646. * @param profileId the profile to which a fallback needs to be found
  45647. * @return an array with corresponding fallback profiles
  45648. */
  45649. static FindFallbackWithProfileId(profileId: string): string[];
  45650. /**
  45651. * Register a fallback to a specific profile.
  45652. * @param profileId the profileId that will receive the fallbacks
  45653. * @param fallbacks A list of fallback profiles
  45654. */
  45655. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  45656. /**
  45657. * Register the default fallbacks.
  45658. * This function is called automatically when this file is imported.
  45659. */
  45660. static DefaultFallbacks(): void;
  45661. }
  45662. }
  45663. declare module "babylonjs/XR/webXRInputSource" {
  45664. import { Observable } from "babylonjs/Misc/observable";
  45665. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45666. import { Ray } from "babylonjs/Culling/ray";
  45667. import { Scene } from "babylonjs/scene";
  45668. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45669. /**
  45670. * Configuration options for the WebXR controller creation
  45671. */
  45672. export interface IWebXRControllerOptions {
  45673. /**
  45674. * Force a specific controller type for this controller.
  45675. * This can be used when creating your own profile or when testing different controllers
  45676. */
  45677. forceControllerProfile?: string;
  45678. /**
  45679. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  45680. */
  45681. doNotLoadControllerMesh?: boolean;
  45682. /**
  45683. * Should the controller mesh be animated when a user interacts with it
  45684. * The pressed buttons / thumbstick and touchpad animations will be disabled
  45685. */
  45686. disableMotionControllerAnimation?: boolean;
  45687. }
  45688. /**
  45689. * Represents an XR controller
  45690. */
  45691. export class WebXRInputSource {
  45692. private _scene;
  45693. /** The underlying input source for the controller */
  45694. inputSource: XRInputSource;
  45695. private _options;
  45696. /**
  45697. * 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
  45698. */
  45699. grip?: AbstractMesh;
  45700. /**
  45701. * Pointer which can be used to select objects or attach a visible laser to
  45702. */
  45703. pointer: AbstractMesh;
  45704. /**
  45705. * If available, this is the gamepad object related to this controller.
  45706. * Using this object it is possible to get click events and trackpad changes of the
  45707. * webxr controller that is currently being used.
  45708. */
  45709. motionController?: WebXRAbstractMotionController;
  45710. /**
  45711. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  45712. */
  45713. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  45714. /**
  45715. * Will be triggered when the mesh associated with the motion controller is done loading.
  45716. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  45717. * A shortened version of controller -> motion controller -> on mesh loaded.
  45718. */
  45719. onMeshLoadedObservable: Observable<AbstractMesh>;
  45720. /**
  45721. * Event that fires when the controller is removed/disposed.
  45722. * The object provided as event data is this controller, after associated assets were disposed.
  45723. * uniqueId is still available.
  45724. */
  45725. onDisposeObservable: Observable<WebXRInputSource>;
  45726. private _tmpQuaternion;
  45727. private _tmpVector;
  45728. private _uniqueId;
  45729. /**
  45730. * Creates the controller
  45731. * @see https://doc.babylonjs.com/how_to/webxr
  45732. * @param _scene the scene which the controller should be associated to
  45733. * @param inputSource the underlying input source for the controller
  45734. * @param _options options for this controller creation
  45735. */
  45736. constructor(_scene: Scene,
  45737. /** The underlying input source for the controller */
  45738. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  45739. /**
  45740. * Get this controllers unique id
  45741. */
  45742. get uniqueId(): string;
  45743. /**
  45744. * Updates the controller pose based on the given XRFrame
  45745. * @param xrFrame xr frame to update the pose with
  45746. * @param referenceSpace reference space to use
  45747. */
  45748. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  45749. /**
  45750. * Gets a world space ray coming from the pointer or grip
  45751. * @param result the resulting ray
  45752. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  45753. */
  45754. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  45755. /**
  45756. * Disposes of the object
  45757. */
  45758. dispose(): void;
  45759. }
  45760. }
  45761. declare module "babylonjs/XR/webXRInput" {
  45762. import { Observable } from "babylonjs/Misc/observable";
  45763. import { IDisposable } from "babylonjs/scene";
  45764. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  45765. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45766. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  45767. /**
  45768. * The schema for initialization options of the XR Input class
  45769. */
  45770. export interface IWebXRInputOptions {
  45771. /**
  45772. * If set to true no model will be automatically loaded
  45773. */
  45774. doNotLoadControllerMeshes?: boolean;
  45775. /**
  45776. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  45777. * If not found, the xr input profile data will be used.
  45778. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  45779. */
  45780. forceInputProfile?: string;
  45781. /**
  45782. * Do not send a request to the controlle repository to load the profile.
  45783. *
  45784. * Instead, use the controllers available in babylon itself.
  45785. */
  45786. disableOnlineControllerRepository?: boolean;
  45787. /**
  45788. * A custom URL for the controllers repository
  45789. */
  45790. customControllersRepositoryURL?: string;
  45791. /**
  45792. * Should the controller model's components not move according to the user input
  45793. */
  45794. disableControllerAnimation?: boolean;
  45795. }
  45796. /**
  45797. * XR input used to track XR inputs such as controllers/rays
  45798. */
  45799. export class WebXRInput implements IDisposable {
  45800. /**
  45801. * the xr session manager for this session
  45802. */
  45803. xrSessionManager: WebXRSessionManager;
  45804. /**
  45805. * the WebXR camera for this session. Mainly used for teleportation
  45806. */
  45807. xrCamera: WebXRCamera;
  45808. private readonly options;
  45809. /**
  45810. * XR controllers being tracked
  45811. */
  45812. controllers: Array<WebXRInputSource>;
  45813. private _frameObserver;
  45814. private _sessionEndedObserver;
  45815. private _sessionInitObserver;
  45816. /**
  45817. * Event when a controller has been connected/added
  45818. */
  45819. onControllerAddedObservable: Observable<WebXRInputSource>;
  45820. /**
  45821. * Event when a controller has been removed/disconnected
  45822. */
  45823. onControllerRemovedObservable: Observable<WebXRInputSource>;
  45824. /**
  45825. * Initializes the WebXRInput
  45826. * @param xrSessionManager the xr session manager for this session
  45827. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  45828. * @param options = initialization options for this xr input
  45829. */
  45830. constructor(
  45831. /**
  45832. * the xr session manager for this session
  45833. */
  45834. xrSessionManager: WebXRSessionManager,
  45835. /**
  45836. * the WebXR camera for this session. Mainly used for teleportation
  45837. */
  45838. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  45839. private _onInputSourcesChange;
  45840. private _addAndRemoveControllers;
  45841. /**
  45842. * Disposes of the object
  45843. */
  45844. dispose(): void;
  45845. }
  45846. }
  45847. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  45848. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  45849. import { Observable, EventState } from "babylonjs/Misc/observable";
  45850. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45851. /**
  45852. * This is the base class for all WebXR features.
  45853. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  45854. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  45855. */
  45856. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  45857. protected _xrSessionManager: WebXRSessionManager;
  45858. /**
  45859. * Construct a new (abstract) webxr feature
  45860. * @param _xrSessionManager the xr session manager for this feature
  45861. */
  45862. constructor(_xrSessionManager: WebXRSessionManager);
  45863. private _attached;
  45864. private _removeOnDetach;
  45865. /**
  45866. * Is this feature attached
  45867. */
  45868. get attached(): boolean;
  45869. /**
  45870. * Should auto-attach be disabled?
  45871. */
  45872. disableAutoAttach: boolean;
  45873. /**
  45874. * attach this feature
  45875. *
  45876. * @param force should attachment be forced (even when already attached)
  45877. * @returns true if successful, false is failed or already attached
  45878. */
  45879. attach(force?: boolean): boolean;
  45880. /**
  45881. * detach this feature.
  45882. *
  45883. * @returns true if successful, false if failed or already detached
  45884. */
  45885. detach(): boolean;
  45886. /**
  45887. * Dispose this feature and all of the resources attached
  45888. */
  45889. dispose(): void;
  45890. /**
  45891. * Code in this function will be executed on each xrFrame received from the browser.
  45892. * This function will not execute after the feature is detached.
  45893. * @param _xrFrame the current frame
  45894. */
  45895. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  45896. /**
  45897. * This is used to register callbacks that will automatically be removed when detach is called.
  45898. * @param observable the observable to which the observer will be attached
  45899. * @param callback the callback to register
  45900. */
  45901. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  45902. }
  45903. }
  45904. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  45905. import { IDisposable, Scene } from "babylonjs/scene";
  45906. import { Nullable } from "babylonjs/types";
  45907. import { Observable } from "babylonjs/Misc/observable";
  45908. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45909. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  45910. import { Camera } from "babylonjs/Cameras/camera";
  45911. /**
  45912. * Renders a layer on top of an existing scene
  45913. */
  45914. export class UtilityLayerRenderer implements IDisposable {
  45915. /** the original scene that will be rendered on top of */
  45916. originalScene: Scene;
  45917. private _pointerCaptures;
  45918. private _lastPointerEvents;
  45919. private static _DefaultUtilityLayer;
  45920. private static _DefaultKeepDepthUtilityLayer;
  45921. private _sharedGizmoLight;
  45922. private _renderCamera;
  45923. /**
  45924. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  45925. * @returns the camera that is used when rendering the utility layer
  45926. */
  45927. getRenderCamera(): Camera;
  45928. /**
  45929. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  45930. * @param cam the camera that should be used when rendering the utility layer
  45931. */
  45932. setRenderCamera(cam: Nullable<Camera>): void;
  45933. /**
  45934. * @hidden
  45935. * Light which used by gizmos to get light shading
  45936. */
  45937. _getSharedGizmoLight(): HemisphericLight;
  45938. /**
  45939. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  45940. */
  45941. pickUtilitySceneFirst: boolean;
  45942. /**
  45943. * 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)
  45944. */
  45945. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  45946. /**
  45947. * 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)
  45948. */
  45949. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  45950. /**
  45951. * The scene that is rendered on top of the original scene
  45952. */
  45953. utilityLayerScene: Scene;
  45954. /**
  45955. * If the utility layer should automatically be rendered on top of existing scene
  45956. */
  45957. shouldRender: boolean;
  45958. /**
  45959. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  45960. */
  45961. onlyCheckPointerDownEvents: boolean;
  45962. /**
  45963. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  45964. */
  45965. processAllEvents: boolean;
  45966. /**
  45967. * Observable raised when the pointer move from the utility layer scene to the main scene
  45968. */
  45969. onPointerOutObservable: Observable<number>;
  45970. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  45971. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  45972. private _afterRenderObserver;
  45973. private _sceneDisposeObserver;
  45974. private _originalPointerObserver;
  45975. /**
  45976. * Instantiates a UtilityLayerRenderer
  45977. * @param originalScene the original scene that will be rendered on top of
  45978. * @param handleEvents boolean indicating if the utility layer should handle events
  45979. */
  45980. constructor(
  45981. /** the original scene that will be rendered on top of */
  45982. originalScene: Scene, handleEvents?: boolean);
  45983. private _notifyObservers;
  45984. /**
  45985. * Renders the utility layers scene on top of the original scene
  45986. */
  45987. render(): void;
  45988. /**
  45989. * Disposes of the renderer
  45990. */
  45991. dispose(): void;
  45992. private _updateCamera;
  45993. }
  45994. }
  45995. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  45996. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45997. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45998. import { WebXRInput } from "babylonjs/XR/webXRInput";
  45999. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  46000. import { Scene } from "babylonjs/scene";
  46001. import { Nullable } from "babylonjs/types";
  46002. import { Color3 } from "babylonjs/Maths/math.color";
  46003. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46004. /**
  46005. * Options interface for the pointer selection module
  46006. */
  46007. export interface IWebXRControllerPointerSelectionOptions {
  46008. /**
  46009. * the xr input to use with this pointer selection
  46010. */
  46011. xrInput: WebXRInput;
  46012. /**
  46013. * Different button type to use instead of the main component
  46014. */
  46015. overrideButtonId?: string;
  46016. /**
  46017. * The amount of time in miliseconds it takes between pick found something to a pointer down event.
  46018. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  46019. * 3000 means 3 seconds between pointing at something and selecting it
  46020. */
  46021. timeToSelect?: number;
  46022. /**
  46023. * 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)
  46024. * If not disabled, the last picked point will be used to execute a pointer up event
  46025. * If disabled, pointer up event will be triggered right after the pointer down event.
  46026. * Used in screen and gaze target ray mode only
  46027. */
  46028. disablePointerUpOnTouchOut: boolean;
  46029. /**
  46030. * For gaze mode (time to select instead of press)
  46031. */
  46032. forceGazeMode: boolean;
  46033. /**
  46034. * 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
  46035. * to start a new countdown to the pointer down event.
  46036. * Defaults to 1.
  46037. */
  46038. gazeModePointerMovedFactor?: number;
  46039. /**
  46040. * Should meshes created here be added to a utility layer or the main scene
  46041. */
  46042. useUtilityLayer?: boolean;
  46043. /**
  46044. * if provided, this scene will be used to render meshes.
  46045. */
  46046. customUtilityLayerScene?: Scene;
  46047. /**
  46048. * use this rendering group id for the meshes (optional)
  46049. */
  46050. renderingGroupId?: number;
  46051. }
  46052. /**
  46053. * A module that will enable pointer selection for motion controllers of XR Input Sources
  46054. */
  46055. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  46056. private readonly _options;
  46057. /**
  46058. * The module's name
  46059. */
  46060. static readonly Name: string;
  46061. /**
  46062. * The (Babylon) version of this module.
  46063. * This is an integer representing the implementation version.
  46064. * This number does not correspond to the webxr specs version
  46065. */
  46066. static readonly Version: number;
  46067. /**
  46068. * This color will be set to the laser pointer when selection is triggered
  46069. */
  46070. laserPointerPickedColor: Color3;
  46071. /**
  46072. * This color will be applied to the selection ring when selection is triggered
  46073. */
  46074. selectionMeshPickedColor: Color3;
  46075. /**
  46076. * default color of the selection ring
  46077. */
  46078. selectionMeshDefaultColor: Color3;
  46079. /**
  46080. * Default color of the laser pointer
  46081. */
  46082. lasterPointerDefaultColor: Color3;
  46083. /**
  46084. * Should the laser pointer be displayed
  46085. */
  46086. displayLaserPointer: boolean;
  46087. /**
  46088. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  46089. */
  46090. displaySelectionMesh: boolean;
  46091. /**
  46092. * Disable lighting on the laser pointer (so it will always be visible)
  46093. */
  46094. disablePointerLighting: boolean;
  46095. /**
  46096. * Disable lighting on the selection mesh (so it will always be visible)
  46097. */
  46098. disableSelectionMeshLighting: boolean;
  46099. private static _idCounter;
  46100. private _controllers;
  46101. private _scene;
  46102. /**
  46103. * constructs a new background remover module
  46104. * @param _xrSessionManager the session manager for this module
  46105. * @param _options read-only options to be used in this module
  46106. */
  46107. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  46108. /**
  46109. * attach this feature
  46110. * Will usually be called by the features manager
  46111. *
  46112. * @returns true if successful.
  46113. */
  46114. attach(): boolean;
  46115. /**
  46116. * detach this feature.
  46117. * Will usually be called by the features manager
  46118. *
  46119. * @returns true if successful.
  46120. */
  46121. detach(): boolean;
  46122. /**
  46123. * Get the xr controller that correlates to the pointer id in the pointer event
  46124. *
  46125. * @param id the pointer id to search for
  46126. * @returns the controller that correlates to this id or null if not found
  46127. */
  46128. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  46129. /**
  46130. * Will get the mesh under a specific pointer.
  46131. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  46132. * @param controllerId the controllerId to check
  46133. * @returns The mesh under pointer or null if no mesh is under the pointer
  46134. */
  46135. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  46136. protected _onXRFrame(_xrFrame: XRFrame): void;
  46137. private _attachController;
  46138. private _attachScreenRayMode;
  46139. private _attachGazeMode;
  46140. private _tmpVectorForPickCompare;
  46141. private _pickingMoved;
  46142. private _attachTrackedPointerRayMode;
  46143. private _detachController;
  46144. private _generateNewMeshPair;
  46145. private _convertNormalToDirectionOfRay;
  46146. private _updatePointerDistance;
  46147. }
  46148. }
  46149. declare module "babylonjs/XR/webXREnterExitUI" {
  46150. import { Nullable } from "babylonjs/types";
  46151. import { Observable } from "babylonjs/Misc/observable";
  46152. import { IDisposable, Scene } from "babylonjs/scene";
  46153. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46154. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46155. /**
  46156. * Button which can be used to enter a different mode of XR
  46157. */
  46158. export class WebXREnterExitUIButton {
  46159. /** button element */
  46160. element: HTMLElement;
  46161. /** XR initialization options for the button */
  46162. sessionMode: XRSessionMode;
  46163. /** Reference space type */
  46164. referenceSpaceType: XRReferenceSpaceType;
  46165. /**
  46166. * Creates a WebXREnterExitUIButton
  46167. * @param element button element
  46168. * @param sessionMode XR initialization session mode
  46169. * @param referenceSpaceType the type of reference space to be used
  46170. */
  46171. constructor(
  46172. /** button element */
  46173. element: HTMLElement,
  46174. /** XR initialization options for the button */
  46175. sessionMode: XRSessionMode,
  46176. /** Reference space type */
  46177. referenceSpaceType: XRReferenceSpaceType);
  46178. /**
  46179. * Overwritable function which can be used to update the button's visuals when the state changes
  46180. * @param activeButton the current active button in the UI
  46181. */
  46182. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  46183. }
  46184. /**
  46185. * Options to create the webXR UI
  46186. */
  46187. export class WebXREnterExitUIOptions {
  46188. /**
  46189. * Context to enter xr with
  46190. */
  46191. renderTarget?: Nullable<WebXRRenderTarget>;
  46192. /**
  46193. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  46194. */
  46195. customButtons?: Array<WebXREnterExitUIButton>;
  46196. /**
  46197. * A session mode to use when creating the default button.
  46198. * Default is immersive-vr
  46199. */
  46200. sessionMode?: XRSessionMode;
  46201. /**
  46202. * A reference space type to use when creating the default button.
  46203. * Default is local-floor
  46204. */
  46205. referenceSpaceType?: XRReferenceSpaceType;
  46206. }
  46207. /**
  46208. * UI to allow the user to enter/exit XR mode
  46209. */
  46210. export class WebXREnterExitUI implements IDisposable {
  46211. private scene;
  46212. /** version of the options passed to this UI */
  46213. options: WebXREnterExitUIOptions;
  46214. private _overlay;
  46215. private _buttons;
  46216. private _activeButton;
  46217. /**
  46218. * Fired every time the active button is changed.
  46219. *
  46220. * When xr is entered via a button that launches xr that button will be the callback parameter
  46221. *
  46222. * When exiting xr the callback parameter will be null)
  46223. */
  46224. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  46225. /**
  46226. * Creates UI to allow the user to enter/exit XR mode
  46227. * @param scene the scene to add the ui to
  46228. * @param helper the xr experience helper to enter/exit xr with
  46229. * @param options options to configure the UI
  46230. * @returns the created ui
  46231. */
  46232. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  46233. /**
  46234. *
  46235. * @param scene babylon scene object to use
  46236. * @param options (read-only) version of the options passed to this UI
  46237. */
  46238. private constructor();
  46239. private _updateButtons;
  46240. /**
  46241. * Disposes of the object
  46242. */
  46243. dispose(): void;
  46244. }
  46245. }
  46246. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  46247. import { Vector3 } from "babylonjs/Maths/math.vector";
  46248. import { Color4 } from "babylonjs/Maths/math.color";
  46249. import { Nullable } from "babylonjs/types";
  46250. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46251. import { Scene } from "babylonjs/scene";
  46252. /**
  46253. * Class containing static functions to help procedurally build meshes
  46254. */
  46255. export class LinesBuilder {
  46256. /**
  46257. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  46258. * * 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
  46259. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  46260. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  46261. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  46262. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  46263. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46264. * * 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
  46265. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  46266. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46267. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  46268. * @param name defines the name of the new line system
  46269. * @param options defines the options used to create the line system
  46270. * @param scene defines the hosting scene
  46271. * @returns a new line system mesh
  46272. */
  46273. static CreateLineSystem(name: string, options: {
  46274. lines: Vector3[][];
  46275. updatable?: boolean;
  46276. instance?: Nullable<LinesMesh>;
  46277. colors?: Nullable<Color4[][]>;
  46278. useVertexAlpha?: boolean;
  46279. }, scene: Nullable<Scene>): LinesMesh;
  46280. /**
  46281. * Creates a line mesh
  46282. * 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
  46283. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46284. * * The parameter `points` is an array successive Vector3
  46285. * * 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
  46286. * * The optional parameter `colors` is an array of successive Color4, one per line point
  46287. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  46288. * * When updating an instance, remember that only point positions can change, not the number of points
  46289. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46290. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  46291. * @param name defines the name of the new line system
  46292. * @param options defines the options used to create the line system
  46293. * @param scene defines the hosting scene
  46294. * @returns a new line mesh
  46295. */
  46296. static CreateLines(name: string, options: {
  46297. points: Vector3[];
  46298. updatable?: boolean;
  46299. instance?: Nullable<LinesMesh>;
  46300. colors?: Color4[];
  46301. useVertexAlpha?: boolean;
  46302. }, scene?: Nullable<Scene>): LinesMesh;
  46303. /**
  46304. * Creates a dashed line mesh
  46305. * * 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
  46306. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46307. * * The parameter `points` is an array successive Vector3
  46308. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  46309. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  46310. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  46311. * * 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
  46312. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46313. * * When updating an instance, remember that only point positions can change, not the number of points
  46314. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46315. * @param name defines the name of the mesh
  46316. * @param options defines the options used to create the mesh
  46317. * @param scene defines the hosting scene
  46318. * @returns the dashed line mesh
  46319. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  46320. */
  46321. static CreateDashedLines(name: string, options: {
  46322. points: Vector3[];
  46323. dashSize?: number;
  46324. gapSize?: number;
  46325. dashNb?: number;
  46326. updatable?: boolean;
  46327. instance?: LinesMesh;
  46328. useVertexAlpha?: boolean;
  46329. }, scene?: Nullable<Scene>): LinesMesh;
  46330. }
  46331. }
  46332. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  46333. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  46334. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46335. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46336. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46337. import { Vector3 } from "babylonjs/Maths/math.vector";
  46338. import { Material } from "babylonjs/Materials/material";
  46339. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46340. import { Scene } from "babylonjs/scene";
  46341. /**
  46342. * The options container for the teleportation module
  46343. */
  46344. export interface IWebXRTeleportationOptions {
  46345. /**
  46346. * Babylon XR Input class for controller
  46347. */
  46348. xrInput: WebXRInput;
  46349. /**
  46350. * A list of meshes to use as floor meshes.
  46351. * Meshes can be added and removed after initializing the feature using the
  46352. * addFloorMesh and removeFloorMesh functions
  46353. * If empty, rotation will still work
  46354. */
  46355. floorMeshes?: AbstractMesh[];
  46356. /**
  46357. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  46358. * If you want to support rotation, make sure your mesh has a direction indicator.
  46359. *
  46360. * When left untouched, the default mesh will be initialized.
  46361. */
  46362. teleportationTargetMesh?: AbstractMesh;
  46363. /**
  46364. * An array of points to which the teleportation will snap to.
  46365. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  46366. */
  46367. snapPositions?: Vector3[];
  46368. /**
  46369. * How close should the teleportation ray be in order to snap to position.
  46370. * Default to 0.8 units (meters)
  46371. */
  46372. snapToPositionRadius?: number;
  46373. /**
  46374. * Should teleportation move only to snap points
  46375. */
  46376. snapPointsOnly?: boolean;
  46377. /**
  46378. * Values to configure the default target mesh
  46379. */
  46380. defaultTargetMeshOptions?: {
  46381. /**
  46382. * Fill color of the teleportation area
  46383. */
  46384. teleportationFillColor?: string;
  46385. /**
  46386. * Border color for the teleportation area
  46387. */
  46388. teleportationBorderColor?: string;
  46389. /**
  46390. * Disable the mesh's animation sequence
  46391. */
  46392. disableAnimation?: boolean;
  46393. /**
  46394. * Disable lighting on the material or the ring and arrow
  46395. */
  46396. disableLighting?: boolean;
  46397. /**
  46398. * Override the default material of the torus and arrow
  46399. */
  46400. torusArrowMaterial?: Material;
  46401. };
  46402. /**
  46403. * Disable using the thumbstick and use the main component (usuallly trigger) on long press.
  46404. * This will be automatically true if the controller doesnt have a thumbstick or touchpad.
  46405. */
  46406. useMainComponentOnly?: boolean;
  46407. /**
  46408. * If main component is used (no thumbstick), how long should the "long press" take before teleporting
  46409. */
  46410. timeToTeleport?: number;
  46411. /**
  46412. * Should meshes created here be added to a utility layer or the main scene
  46413. */
  46414. useUtilityLayer?: boolean;
  46415. /**
  46416. * if provided, this scene will be used to render meshes.
  46417. */
  46418. customUtilityLayerScene?: Scene;
  46419. /**
  46420. * use this rendering group id for the meshes (optional)
  46421. */
  46422. renderingGroupId?: number;
  46423. }
  46424. /**
  46425. * This is a teleportation feature to be used with webxr-enabled motion controllers.
  46426. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  46427. * the input of the attached controllers.
  46428. */
  46429. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  46430. private _options;
  46431. /**
  46432. * The module's name
  46433. */
  46434. static readonly Name: string;
  46435. /**
  46436. * The (Babylon) version of this module.
  46437. * This is an integer representing the implementation version.
  46438. * This number does not correspond to the webxr specs version
  46439. */
  46440. static readonly Version: number;
  46441. /**
  46442. * Is rotation enabled when moving forward?
  46443. * Disabling this feature will prevent the user from deciding the direction when teleporting
  46444. */
  46445. rotationEnabled: boolean;
  46446. /**
  46447. * Should the module support parabolic ray on top of direct ray
  46448. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  46449. * Very helpful when moving between floors / different heights
  46450. */
  46451. parabolicRayEnabled: boolean;
  46452. /**
  46453. * The distance from the user to the inspection point in the direction of the controller
  46454. * A higher number will allow the user to move further
  46455. * defaults to 5 (meters, in xr units)
  46456. */
  46457. parabolicCheckRadius: number;
  46458. /**
  46459. * How much rotation should be applied when rotating right and left
  46460. */
  46461. rotationAngle: number;
  46462. /**
  46463. * Is movement backwards enabled
  46464. */
  46465. backwardsMovementEnabled: boolean;
  46466. /**
  46467. * Distance to travel when moving backwards
  46468. */
  46469. backwardsTeleportationDistance: number;
  46470. /**
  46471. * Add a new mesh to the floor meshes array
  46472. * @param mesh the mesh to use as floor mesh
  46473. */
  46474. addFloorMesh(mesh: AbstractMesh): void;
  46475. /**
  46476. * Remove a mesh from the floor meshes array
  46477. * @param mesh the mesh to remove
  46478. */
  46479. removeFloorMesh(mesh: AbstractMesh): void;
  46480. /**
  46481. * Remove a mesh from the floor meshes array using its name
  46482. * @param name the mesh name to remove
  46483. */
  46484. removeFloorMeshByName(name: string): void;
  46485. private _tmpRay;
  46486. private _tmpVector;
  46487. private _floorMeshes;
  46488. private _snapToPositions;
  46489. private _controllers;
  46490. /**
  46491. * constructs a new anchor system
  46492. * @param _xrSessionManager an instance of WebXRSessionManager
  46493. * @param _options configuration object for this feature
  46494. */
  46495. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  46496. private _selectionFeature;
  46497. private _snappedToPoint;
  46498. private _teleportationRingMaterial?;
  46499. /**
  46500. * Get the snapPointsOnly flag
  46501. */
  46502. get snapPointsOnly(): boolean;
  46503. /**
  46504. * Sets the snapPointsOnly flag
  46505. * @param snapToPoints should teleportation be exclusively to snap points
  46506. */
  46507. set snapPointsOnly(snapToPoints: boolean);
  46508. /**
  46509. * Add a new snap-to point to fix teleportation to this position
  46510. * @param newSnapPoint The new Snap-To point
  46511. */
  46512. addSnapPoint(newSnapPoint: Vector3): void;
  46513. /**
  46514. * 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
  46515. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  46516. * @returns was the point found and removed or not
  46517. */
  46518. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  46519. /**
  46520. * This function sets a selection feature that will be disabled when
  46521. * the forward ray is shown and will be reattached when hidden.
  46522. * This is used to remove the selection rays when moving.
  46523. * @param selectionFeature the feature to disable when forward movement is enabled
  46524. */
  46525. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  46526. attach(): boolean;
  46527. detach(): boolean;
  46528. dispose(): void;
  46529. protected _onXRFrame(_xrFrame: XRFrame): void;
  46530. private _currentTeleportationControllerId;
  46531. private _attachController;
  46532. private _teleportForward;
  46533. private _detachController;
  46534. private _createDefaultTargetMesh;
  46535. private _setTargetMeshVisibility;
  46536. private _setTargetMeshPosition;
  46537. private _quadraticBezierCurve;
  46538. private _showParabolicPath;
  46539. private _findClosestSnapPointWithRadius;
  46540. }
  46541. }
  46542. declare module "babylonjs/XR/webXRDefaultExperience" {
  46543. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46544. import { Scene } from "babylonjs/scene";
  46545. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  46546. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  46547. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46548. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  46549. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46550. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  46551. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  46552. /**
  46553. * Options for the default xr helper
  46554. */
  46555. export class WebXRDefaultExperienceOptions {
  46556. /**
  46557. * Floor meshes that will be used for teleporting
  46558. */
  46559. floorMeshes?: Array<AbstractMesh>;
  46560. /**
  46561. * Enable or disable default UI to enter XR
  46562. */
  46563. disableDefaultUI?: boolean;
  46564. /**
  46565. * optional configuration for the output canvas
  46566. */
  46567. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  46568. /**
  46569. * optional UI options. This can be used among other to change session mode and reference space type
  46570. */
  46571. uiOptions?: WebXREnterExitUIOptions;
  46572. /**
  46573. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  46574. */
  46575. inputOptions?: IWebXRInputOptions;
  46576. /**
  46577. * Should teleportation not initialize. defaults to false.
  46578. */
  46579. disableTeleportation?: boolean;
  46580. /**
  46581. * If set to true, the first frame will not be used to reset position
  46582. * The first frame is mainly used when copying transformation from the old camera
  46583. * Mainly used in AR
  46584. */
  46585. ignoreNativeCameraTransformation?: boolean;
  46586. /**
  46587. * When loading teleportation and pointer select, use stable versions instead of latest.
  46588. */
  46589. useStablePlugins?: boolean;
  46590. }
  46591. /**
  46592. * Default experience which provides a similar setup to the previous webVRExperience
  46593. */
  46594. export class WebXRDefaultExperience {
  46595. /**
  46596. * Base experience
  46597. */
  46598. baseExperience: WebXRExperienceHelper;
  46599. /**
  46600. * Input experience extension
  46601. */
  46602. input: WebXRInput;
  46603. /**
  46604. * Enables laser pointer and selection
  46605. */
  46606. pointerSelection: WebXRControllerPointerSelection;
  46607. /**
  46608. * Enables teleportation
  46609. */
  46610. teleportation: WebXRMotionControllerTeleportation;
  46611. /**
  46612. * Enables ui for entering/exiting xr
  46613. */
  46614. enterExitUI: WebXREnterExitUI;
  46615. /**
  46616. * Default target xr should render to
  46617. */
  46618. renderTarget: WebXRRenderTarget;
  46619. /**
  46620. * Creates the default xr experience
  46621. * @param scene scene
  46622. * @param options options for basic configuration
  46623. * @returns resulting WebXRDefaultExperience
  46624. */
  46625. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  46626. private constructor();
  46627. /**
  46628. * DIsposes of the experience helper
  46629. */
  46630. dispose(): void;
  46631. }
  46632. }
  46633. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  46634. import { Observable } from "babylonjs/Misc/observable";
  46635. import { Nullable } from "babylonjs/types";
  46636. import { Camera } from "babylonjs/Cameras/camera";
  46637. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  46638. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  46639. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  46640. import { Scene } from "babylonjs/scene";
  46641. import { Vector3 } from "babylonjs/Maths/math.vector";
  46642. import { Color3 } from "babylonjs/Maths/math.color";
  46643. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46644. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46645. import { Mesh } from "babylonjs/Meshes/mesh";
  46646. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  46647. import { EasingFunction } from "babylonjs/Animations/easing";
  46648. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46649. import "babylonjs/Meshes/Builders/groundBuilder";
  46650. import "babylonjs/Meshes/Builders/torusBuilder";
  46651. import "babylonjs/Meshes/Builders/cylinderBuilder";
  46652. import "babylonjs/Gamepads/gamepadSceneComponent";
  46653. import "babylonjs/Animations/animatable";
  46654. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  46655. /**
  46656. * Options to modify the vr teleportation behavior.
  46657. */
  46658. export interface VRTeleportationOptions {
  46659. /**
  46660. * The name of the mesh which should be used as the teleportation floor. (default: null)
  46661. */
  46662. floorMeshName?: string;
  46663. /**
  46664. * A list of meshes to be used as the teleportation floor. (default: empty)
  46665. */
  46666. floorMeshes?: Mesh[];
  46667. /**
  46668. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  46669. */
  46670. teleportationMode?: number;
  46671. /**
  46672. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  46673. */
  46674. teleportationTime?: number;
  46675. /**
  46676. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  46677. */
  46678. teleportationSpeed?: number;
  46679. /**
  46680. * The easing function used in the animation or null for Linear. (default CircleEase)
  46681. */
  46682. easingFunction?: EasingFunction;
  46683. }
  46684. /**
  46685. * Options to modify the vr experience helper's behavior.
  46686. */
  46687. export interface VRExperienceHelperOptions extends WebVROptions {
  46688. /**
  46689. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  46690. */
  46691. createDeviceOrientationCamera?: boolean;
  46692. /**
  46693. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  46694. */
  46695. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  46696. /**
  46697. * Uses the main button on the controller to toggle the laser casted. (default: true)
  46698. */
  46699. laserToggle?: boolean;
  46700. /**
  46701. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  46702. */
  46703. floorMeshes?: Mesh[];
  46704. /**
  46705. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  46706. */
  46707. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  46708. /**
  46709. * Defines if WebXR should be used instead of WebVR (if available)
  46710. */
  46711. useXR?: boolean;
  46712. }
  46713. /**
  46714. * Event containing information after VR has been entered
  46715. */
  46716. export class OnAfterEnteringVRObservableEvent {
  46717. /**
  46718. * If entering vr was successful
  46719. */
  46720. success: boolean;
  46721. }
  46722. /**
  46723. * Helps to quickly add VR support to an existing scene.
  46724. * See http://doc.babylonjs.com/how_to/webvr_helper
  46725. */
  46726. export class VRExperienceHelper {
  46727. /** Options to modify the vr experience helper's behavior. */
  46728. webVROptions: VRExperienceHelperOptions;
  46729. private _scene;
  46730. private _position;
  46731. private _btnVR;
  46732. private _btnVRDisplayed;
  46733. private _webVRsupported;
  46734. private _webVRready;
  46735. private _webVRrequesting;
  46736. private _webVRpresenting;
  46737. private _hasEnteredVR;
  46738. private _fullscreenVRpresenting;
  46739. private _inputElement;
  46740. private _webVRCamera;
  46741. private _vrDeviceOrientationCamera;
  46742. private _deviceOrientationCamera;
  46743. private _existingCamera;
  46744. private _onKeyDown;
  46745. private _onVrDisplayPresentChange;
  46746. private _onVRDisplayChanged;
  46747. private _onVRRequestPresentStart;
  46748. private _onVRRequestPresentComplete;
  46749. /**
  46750. * 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)
  46751. */
  46752. enableGazeEvenWhenNoPointerLock: boolean;
  46753. /**
  46754. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  46755. */
  46756. exitVROnDoubleTap: boolean;
  46757. /**
  46758. * Observable raised right before entering VR.
  46759. */
  46760. onEnteringVRObservable: Observable<VRExperienceHelper>;
  46761. /**
  46762. * Observable raised when entering VR has completed.
  46763. */
  46764. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  46765. /**
  46766. * Observable raised when exiting VR.
  46767. */
  46768. onExitingVRObservable: Observable<VRExperienceHelper>;
  46769. /**
  46770. * Observable raised when controller mesh is loaded.
  46771. */
  46772. onControllerMeshLoadedObservable: Observable<WebVRController>;
  46773. /** Return this.onEnteringVRObservable
  46774. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  46775. */
  46776. get onEnteringVR(): Observable<VRExperienceHelper>;
  46777. /** Return this.onExitingVRObservable
  46778. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  46779. */
  46780. get onExitingVR(): Observable<VRExperienceHelper>;
  46781. /** Return this.onControllerMeshLoadedObservable
  46782. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  46783. */
  46784. get onControllerMeshLoaded(): Observable<WebVRController>;
  46785. private _rayLength;
  46786. private _useCustomVRButton;
  46787. private _teleportationRequested;
  46788. private _teleportActive;
  46789. private _floorMeshName;
  46790. private _floorMeshesCollection;
  46791. private _teleportationMode;
  46792. private _teleportationTime;
  46793. private _teleportationSpeed;
  46794. private _teleportationEasing;
  46795. private _rotationAllowed;
  46796. private _teleportBackwardsVector;
  46797. private _teleportationTarget;
  46798. private _isDefaultTeleportationTarget;
  46799. private _postProcessMove;
  46800. private _teleportationFillColor;
  46801. private _teleportationBorderColor;
  46802. private _rotationAngle;
  46803. private _haloCenter;
  46804. private _cameraGazer;
  46805. private _padSensibilityUp;
  46806. private _padSensibilityDown;
  46807. private _leftController;
  46808. private _rightController;
  46809. private _gazeColor;
  46810. private _laserColor;
  46811. private _pickedLaserColor;
  46812. private _pickedGazeColor;
  46813. /**
  46814. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  46815. */
  46816. onNewMeshSelected: Observable<AbstractMesh>;
  46817. /**
  46818. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  46819. * This observable will provide the mesh and the controller used to select the mesh
  46820. */
  46821. onMeshSelectedWithController: Observable<{
  46822. mesh: AbstractMesh;
  46823. controller: WebVRController;
  46824. }>;
  46825. /**
  46826. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  46827. */
  46828. onNewMeshPicked: Observable<PickingInfo>;
  46829. private _circleEase;
  46830. /**
  46831. * Observable raised before camera teleportation
  46832. */
  46833. onBeforeCameraTeleport: Observable<Vector3>;
  46834. /**
  46835. * Observable raised after camera teleportation
  46836. */
  46837. onAfterCameraTeleport: Observable<Vector3>;
  46838. /**
  46839. * Observable raised when current selected mesh gets unselected
  46840. */
  46841. onSelectedMeshUnselected: Observable<AbstractMesh>;
  46842. private _raySelectionPredicate;
  46843. /**
  46844. * To be optionaly changed by user to define custom ray selection
  46845. */
  46846. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  46847. /**
  46848. * To be optionaly changed by user to define custom selection logic (after ray selection)
  46849. */
  46850. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46851. /**
  46852. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  46853. */
  46854. teleportationEnabled: boolean;
  46855. private _defaultHeight;
  46856. private _teleportationInitialized;
  46857. private _interactionsEnabled;
  46858. private _interactionsRequested;
  46859. private _displayGaze;
  46860. private _displayLaserPointer;
  46861. /**
  46862. * The mesh used to display where the user is going to teleport.
  46863. */
  46864. get teleportationTarget(): Mesh;
  46865. /**
  46866. * Sets the mesh to be used to display where the user is going to teleport.
  46867. */
  46868. set teleportationTarget(value: Mesh);
  46869. /**
  46870. * 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
  46871. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  46872. * See http://doc.babylonjs.com/resources/baking_transformations
  46873. */
  46874. get gazeTrackerMesh(): Mesh;
  46875. set gazeTrackerMesh(value: Mesh);
  46876. /**
  46877. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  46878. */
  46879. updateGazeTrackerScale: boolean;
  46880. /**
  46881. * If the gaze trackers color should be updated when selecting meshes
  46882. */
  46883. updateGazeTrackerColor: boolean;
  46884. /**
  46885. * If the controller laser color should be updated when selecting meshes
  46886. */
  46887. updateControllerLaserColor: boolean;
  46888. /**
  46889. * The gaze tracking mesh corresponding to the left controller
  46890. */
  46891. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  46892. /**
  46893. * The gaze tracking mesh corresponding to the right controller
  46894. */
  46895. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  46896. /**
  46897. * If the ray of the gaze should be displayed.
  46898. */
  46899. get displayGaze(): boolean;
  46900. /**
  46901. * Sets if the ray of the gaze should be displayed.
  46902. */
  46903. set displayGaze(value: boolean);
  46904. /**
  46905. * If the ray of the LaserPointer should be displayed.
  46906. */
  46907. get displayLaserPointer(): boolean;
  46908. /**
  46909. * Sets if the ray of the LaserPointer should be displayed.
  46910. */
  46911. set displayLaserPointer(value: boolean);
  46912. /**
  46913. * The deviceOrientationCamera used as the camera when not in VR.
  46914. */
  46915. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  46916. /**
  46917. * Based on the current WebVR support, returns the current VR camera used.
  46918. */
  46919. get currentVRCamera(): Nullable<Camera>;
  46920. /**
  46921. * The webVRCamera which is used when in VR.
  46922. */
  46923. get webVRCamera(): WebVRFreeCamera;
  46924. /**
  46925. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  46926. */
  46927. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  46928. /**
  46929. * The html button that is used to trigger entering into VR.
  46930. */
  46931. get vrButton(): Nullable<HTMLButtonElement>;
  46932. private get _teleportationRequestInitiated();
  46933. /**
  46934. * Defines whether or not Pointer lock should be requested when switching to
  46935. * full screen.
  46936. */
  46937. requestPointerLockOnFullScreen: boolean;
  46938. /**
  46939. * If asking to force XR, this will be populated with the default xr experience
  46940. */
  46941. xr: WebXRDefaultExperience;
  46942. /**
  46943. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  46944. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  46945. */
  46946. xrTestDone: boolean;
  46947. /**
  46948. * Instantiates a VRExperienceHelper.
  46949. * Helps to quickly add VR support to an existing scene.
  46950. * @param scene The scene the VRExperienceHelper belongs to.
  46951. * @param webVROptions Options to modify the vr experience helper's behavior.
  46952. */
  46953. constructor(scene: Scene,
  46954. /** Options to modify the vr experience helper's behavior. */
  46955. webVROptions?: VRExperienceHelperOptions);
  46956. private completeVRInit;
  46957. private _onDefaultMeshLoaded;
  46958. private _onResize;
  46959. private _onFullscreenChange;
  46960. /**
  46961. * Gets a value indicating if we are currently in VR mode.
  46962. */
  46963. get isInVRMode(): boolean;
  46964. private onVrDisplayPresentChange;
  46965. private onVRDisplayChanged;
  46966. private moveButtonToBottomRight;
  46967. private displayVRButton;
  46968. private updateButtonVisibility;
  46969. private _cachedAngularSensibility;
  46970. /**
  46971. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  46972. * Otherwise, will use the fullscreen API.
  46973. */
  46974. enterVR(): void;
  46975. /**
  46976. * Attempt to exit VR, or fullscreen.
  46977. */
  46978. exitVR(): void;
  46979. /**
  46980. * The position of the vr experience helper.
  46981. */
  46982. get position(): Vector3;
  46983. /**
  46984. * Sets the position of the vr experience helper.
  46985. */
  46986. set position(value: Vector3);
  46987. /**
  46988. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  46989. */
  46990. enableInteractions(): void;
  46991. private get _noControllerIsActive();
  46992. private beforeRender;
  46993. private _isTeleportationFloor;
  46994. /**
  46995. * Adds a floor mesh to be used for teleportation.
  46996. * @param floorMesh the mesh to be used for teleportation.
  46997. */
  46998. addFloorMesh(floorMesh: Mesh): void;
  46999. /**
  47000. * Removes a floor mesh from being used for teleportation.
  47001. * @param floorMesh the mesh to be removed.
  47002. */
  47003. removeFloorMesh(floorMesh: Mesh): void;
  47004. /**
  47005. * Enables interactions and teleportation using the VR controllers and gaze.
  47006. * @param vrTeleportationOptions options to modify teleportation behavior.
  47007. */
  47008. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  47009. private _onNewGamepadConnected;
  47010. private _tryEnableInteractionOnController;
  47011. private _onNewGamepadDisconnected;
  47012. private _enableInteractionOnController;
  47013. private _checkTeleportWithRay;
  47014. private _checkRotate;
  47015. private _checkTeleportBackwards;
  47016. private _enableTeleportationOnController;
  47017. private _createTeleportationCircles;
  47018. private _displayTeleportationTarget;
  47019. private _hideTeleportationTarget;
  47020. private _rotateCamera;
  47021. private _moveTeleportationSelectorTo;
  47022. private _workingVector;
  47023. private _workingQuaternion;
  47024. private _workingMatrix;
  47025. /**
  47026. * Time Constant Teleportation Mode
  47027. */
  47028. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  47029. /**
  47030. * Speed Constant Teleportation Mode
  47031. */
  47032. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  47033. /**
  47034. * Teleports the users feet to the desired location
  47035. * @param location The location where the user's feet should be placed
  47036. */
  47037. teleportCamera(location: Vector3): void;
  47038. private _convertNormalToDirectionOfRay;
  47039. private _castRayAndSelectObject;
  47040. private _notifySelectedMeshUnselected;
  47041. /**
  47042. * Permanently set new colors for the laser pointer
  47043. * @param color the new laser color
  47044. * @param pickedColor the new laser color when picked mesh detected
  47045. */
  47046. setLaserColor(color: Color3, pickedColor?: Color3): void;
  47047. /**
  47048. * Set lighting enabled / disabled on the laser pointer of both controllers
  47049. * @param enabled should the lighting be enabled on the laser pointer
  47050. */
  47051. setLaserLightingState(enabled?: boolean): void;
  47052. /**
  47053. * Permanently set new colors for the gaze pointer
  47054. * @param color the new gaze color
  47055. * @param pickedColor the new gaze color when picked mesh detected
  47056. */
  47057. setGazeColor(color: Color3, pickedColor?: Color3): void;
  47058. /**
  47059. * Sets the color of the laser ray from the vr controllers.
  47060. * @param color new color for the ray.
  47061. */
  47062. changeLaserColor(color: Color3): void;
  47063. /**
  47064. * Sets the color of the ray from the vr headsets gaze.
  47065. * @param color new color for the ray.
  47066. */
  47067. changeGazeColor(color: Color3): void;
  47068. /**
  47069. * Exits VR and disposes of the vr experience helper
  47070. */
  47071. dispose(): void;
  47072. /**
  47073. * Gets the name of the VRExperienceHelper class
  47074. * @returns "VRExperienceHelper"
  47075. */
  47076. getClassName(): string;
  47077. }
  47078. }
  47079. declare module "babylonjs/Cameras/VR/index" {
  47080. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  47081. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  47082. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47083. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  47084. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  47085. export * from "babylonjs/Cameras/VR/webVRCamera";
  47086. }
  47087. declare module "babylonjs/Cameras/RigModes/index" {
  47088. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47089. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47090. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  47091. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  47092. }
  47093. declare module "babylonjs/Cameras/index" {
  47094. export * from "babylonjs/Cameras/Inputs/index";
  47095. export * from "babylonjs/Cameras/cameraInputsManager";
  47096. export * from "babylonjs/Cameras/camera";
  47097. export * from "babylonjs/Cameras/targetCamera";
  47098. export * from "babylonjs/Cameras/freeCamera";
  47099. export * from "babylonjs/Cameras/freeCameraInputsManager";
  47100. export * from "babylonjs/Cameras/touchCamera";
  47101. export * from "babylonjs/Cameras/arcRotateCamera";
  47102. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  47103. export * from "babylonjs/Cameras/deviceOrientationCamera";
  47104. export * from "babylonjs/Cameras/flyCamera";
  47105. export * from "babylonjs/Cameras/flyCameraInputsManager";
  47106. export * from "babylonjs/Cameras/followCamera";
  47107. export * from "babylonjs/Cameras/followCameraInputsManager";
  47108. export * from "babylonjs/Cameras/gamepadCamera";
  47109. export * from "babylonjs/Cameras/Stereoscopic/index";
  47110. export * from "babylonjs/Cameras/universalCamera";
  47111. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  47112. export * from "babylonjs/Cameras/VR/index";
  47113. export * from "babylonjs/Cameras/RigModes/index";
  47114. }
  47115. declare module "babylonjs/Collisions/index" {
  47116. export * from "babylonjs/Collisions/collider";
  47117. export * from "babylonjs/Collisions/collisionCoordinator";
  47118. export * from "babylonjs/Collisions/pickingInfo";
  47119. export * from "babylonjs/Collisions/intersectionInfo";
  47120. export * from "babylonjs/Collisions/meshCollisionData";
  47121. }
  47122. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  47123. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  47124. import { Vector3 } from "babylonjs/Maths/math.vector";
  47125. import { Ray } from "babylonjs/Culling/ray";
  47126. import { Plane } from "babylonjs/Maths/math.plane";
  47127. /**
  47128. * Contains an array of blocks representing the octree
  47129. */
  47130. export interface IOctreeContainer<T> {
  47131. /**
  47132. * Blocks within the octree
  47133. */
  47134. blocks: Array<OctreeBlock<T>>;
  47135. }
  47136. /**
  47137. * Class used to store a cell in an octree
  47138. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47139. */
  47140. export class OctreeBlock<T> {
  47141. /**
  47142. * Gets the content of the current block
  47143. */
  47144. entries: T[];
  47145. /**
  47146. * Gets the list of block children
  47147. */
  47148. blocks: Array<OctreeBlock<T>>;
  47149. private _depth;
  47150. private _maxDepth;
  47151. private _capacity;
  47152. private _minPoint;
  47153. private _maxPoint;
  47154. private _boundingVectors;
  47155. private _creationFunc;
  47156. /**
  47157. * Creates a new block
  47158. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  47159. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  47160. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47161. * @param depth defines the current depth of this block in the octree
  47162. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  47163. * @param creationFunc defines a callback to call when an element is added to the block
  47164. */
  47165. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  47166. /**
  47167. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47168. */
  47169. get capacity(): number;
  47170. /**
  47171. * Gets the minimum vector (in world space) of the block's bounding box
  47172. */
  47173. get minPoint(): Vector3;
  47174. /**
  47175. * Gets the maximum vector (in world space) of the block's bounding box
  47176. */
  47177. get maxPoint(): Vector3;
  47178. /**
  47179. * Add a new element to this block
  47180. * @param entry defines the element to add
  47181. */
  47182. addEntry(entry: T): void;
  47183. /**
  47184. * Remove an element from this block
  47185. * @param entry defines the element to remove
  47186. */
  47187. removeEntry(entry: T): void;
  47188. /**
  47189. * Add an array of elements to this block
  47190. * @param entries defines the array of elements to add
  47191. */
  47192. addEntries(entries: T[]): void;
  47193. /**
  47194. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  47195. * @param frustumPlanes defines the frustum planes to test
  47196. * @param selection defines the array to store current content if selection is positive
  47197. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47198. */
  47199. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47200. /**
  47201. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  47202. * @param sphereCenter defines the bounding sphere center
  47203. * @param sphereRadius defines the bounding sphere radius
  47204. * @param selection defines the array to store current content if selection is positive
  47205. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47206. */
  47207. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47208. /**
  47209. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  47210. * @param ray defines the ray to test with
  47211. * @param selection defines the array to store current content if selection is positive
  47212. */
  47213. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  47214. /**
  47215. * Subdivide the content into child blocks (this block will then be empty)
  47216. */
  47217. createInnerBlocks(): void;
  47218. /**
  47219. * @hidden
  47220. */
  47221. 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;
  47222. }
  47223. }
  47224. declare module "babylonjs/Culling/Octrees/octree" {
  47225. import { SmartArray } from "babylonjs/Misc/smartArray";
  47226. import { Vector3 } from "babylonjs/Maths/math.vector";
  47227. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47228. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47229. import { Ray } from "babylonjs/Culling/ray";
  47230. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  47231. import { Plane } from "babylonjs/Maths/math.plane";
  47232. /**
  47233. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  47234. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47235. */
  47236. export class Octree<T> {
  47237. /** 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.) */
  47238. maxDepth: number;
  47239. /**
  47240. * Blocks within the octree containing objects
  47241. */
  47242. blocks: Array<OctreeBlock<T>>;
  47243. /**
  47244. * Content stored in the octree
  47245. */
  47246. dynamicContent: T[];
  47247. private _maxBlockCapacity;
  47248. private _selectionContent;
  47249. private _creationFunc;
  47250. /**
  47251. * Creates a octree
  47252. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47253. * @param creationFunc function to be used to instatiate the octree
  47254. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  47255. * @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.)
  47256. */
  47257. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  47258. /** 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.) */
  47259. maxDepth?: number);
  47260. /**
  47261. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  47262. * @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);
  47263. * @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);
  47264. * @param entries meshes to be added to the octree blocks
  47265. */
  47266. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  47267. /**
  47268. * Adds a mesh to the octree
  47269. * @param entry Mesh to add to the octree
  47270. */
  47271. addMesh(entry: T): void;
  47272. /**
  47273. * Remove an element from the octree
  47274. * @param entry defines the element to remove
  47275. */
  47276. removeMesh(entry: T): void;
  47277. /**
  47278. * Selects an array of meshes within the frustum
  47279. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  47280. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  47281. * @returns array of meshes within the frustum
  47282. */
  47283. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  47284. /**
  47285. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  47286. * @param sphereCenter defines the bounding sphere center
  47287. * @param sphereRadius defines the bounding sphere radius
  47288. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47289. * @returns an array of objects that intersect the sphere
  47290. */
  47291. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  47292. /**
  47293. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  47294. * @param ray defines the ray to test with
  47295. * @returns array of intersected objects
  47296. */
  47297. intersectsRay(ray: Ray): SmartArray<T>;
  47298. /**
  47299. * Adds a mesh into the octree block if it intersects the block
  47300. */
  47301. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  47302. /**
  47303. * Adds a submesh into the octree block if it intersects the block
  47304. */
  47305. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  47306. }
  47307. }
  47308. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  47309. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  47310. import { Scene } from "babylonjs/scene";
  47311. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47312. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47313. import { Ray } from "babylonjs/Culling/ray";
  47314. import { Octree } from "babylonjs/Culling/Octrees/octree";
  47315. import { Collider } from "babylonjs/Collisions/collider";
  47316. module "babylonjs/scene" {
  47317. interface Scene {
  47318. /**
  47319. * @hidden
  47320. * Backing Filed
  47321. */
  47322. _selectionOctree: Octree<AbstractMesh>;
  47323. /**
  47324. * Gets the octree used to boost mesh selection (picking)
  47325. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47326. */
  47327. selectionOctree: Octree<AbstractMesh>;
  47328. /**
  47329. * Creates or updates the octree used to boost selection (picking)
  47330. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47331. * @param maxCapacity defines the maximum capacity per leaf
  47332. * @param maxDepth defines the maximum depth of the octree
  47333. * @returns an octree of AbstractMesh
  47334. */
  47335. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  47336. }
  47337. }
  47338. module "babylonjs/Meshes/abstractMesh" {
  47339. interface AbstractMesh {
  47340. /**
  47341. * @hidden
  47342. * Backing Field
  47343. */
  47344. _submeshesOctree: Octree<SubMesh>;
  47345. /**
  47346. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  47347. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  47348. * @param maxCapacity defines the maximum size of each block (64 by default)
  47349. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  47350. * @returns the new octree
  47351. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  47352. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47353. */
  47354. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  47355. }
  47356. }
  47357. /**
  47358. * Defines the octree scene component responsible to manage any octrees
  47359. * in a given scene.
  47360. */
  47361. export class OctreeSceneComponent {
  47362. /**
  47363. * The component name help to identify the component in the list of scene components.
  47364. */
  47365. readonly name: string;
  47366. /**
  47367. * The scene the component belongs to.
  47368. */
  47369. scene: Scene;
  47370. /**
  47371. * Indicates if the meshes have been checked to make sure they are isEnabled()
  47372. */
  47373. readonly checksIsEnabled: boolean;
  47374. /**
  47375. * Creates a new instance of the component for the given scene
  47376. * @param scene Defines the scene to register the component in
  47377. */
  47378. constructor(scene: Scene);
  47379. /**
  47380. * Registers the component in a given scene
  47381. */
  47382. register(): void;
  47383. /**
  47384. * Return the list of active meshes
  47385. * @returns the list of active meshes
  47386. */
  47387. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  47388. /**
  47389. * Return the list of active sub meshes
  47390. * @param mesh The mesh to get the candidates sub meshes from
  47391. * @returns the list of active sub meshes
  47392. */
  47393. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  47394. private _tempRay;
  47395. /**
  47396. * Return the list of sub meshes intersecting with a given local ray
  47397. * @param mesh defines the mesh to find the submesh for
  47398. * @param localRay defines the ray in local space
  47399. * @returns the list of intersecting sub meshes
  47400. */
  47401. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  47402. /**
  47403. * Return the list of sub meshes colliding with a collider
  47404. * @param mesh defines the mesh to find the submesh for
  47405. * @param collider defines the collider to evaluate the collision against
  47406. * @returns the list of colliding sub meshes
  47407. */
  47408. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  47409. /**
  47410. * Rebuilds the elements related to this component in case of
  47411. * context lost for instance.
  47412. */
  47413. rebuild(): void;
  47414. /**
  47415. * Disposes the component and the associated ressources.
  47416. */
  47417. dispose(): void;
  47418. }
  47419. }
  47420. declare module "babylonjs/Culling/Octrees/index" {
  47421. export * from "babylonjs/Culling/Octrees/octree";
  47422. export * from "babylonjs/Culling/Octrees/octreeBlock";
  47423. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  47424. }
  47425. declare module "babylonjs/Culling/index" {
  47426. export * from "babylonjs/Culling/boundingBox";
  47427. export * from "babylonjs/Culling/boundingInfo";
  47428. export * from "babylonjs/Culling/boundingSphere";
  47429. export * from "babylonjs/Culling/Octrees/index";
  47430. export * from "babylonjs/Culling/ray";
  47431. }
  47432. declare module "babylonjs/Gizmos/gizmo" {
  47433. import { Nullable } from "babylonjs/types";
  47434. import { IDisposable } from "babylonjs/scene";
  47435. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47436. import { Mesh } from "babylonjs/Meshes/mesh";
  47437. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47438. /**
  47439. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  47440. */
  47441. export class Gizmo implements IDisposable {
  47442. /** The utility layer the gizmo will be added to */
  47443. gizmoLayer: UtilityLayerRenderer;
  47444. /**
  47445. * The root mesh of the gizmo
  47446. */
  47447. _rootMesh: Mesh;
  47448. private _attachedMesh;
  47449. /**
  47450. * Ratio for the scale of the gizmo (Default: 1)
  47451. */
  47452. scaleRatio: number;
  47453. /**
  47454. * If a custom mesh has been set (Default: false)
  47455. */
  47456. protected _customMeshSet: boolean;
  47457. /**
  47458. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  47459. * * When set, interactions will be enabled
  47460. */
  47461. get attachedMesh(): Nullable<AbstractMesh>;
  47462. set attachedMesh(value: Nullable<AbstractMesh>);
  47463. /**
  47464. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47465. * @param mesh The mesh to replace the default mesh of the gizmo
  47466. */
  47467. setCustomMesh(mesh: Mesh): void;
  47468. /**
  47469. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  47470. */
  47471. updateGizmoRotationToMatchAttachedMesh: boolean;
  47472. /**
  47473. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  47474. */
  47475. updateGizmoPositionToMatchAttachedMesh: boolean;
  47476. /**
  47477. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  47478. */
  47479. updateScale: boolean;
  47480. protected _interactionsEnabled: boolean;
  47481. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47482. private _beforeRenderObserver;
  47483. private _tempVector;
  47484. /**
  47485. * Creates a gizmo
  47486. * @param gizmoLayer The utility layer the gizmo will be added to
  47487. */
  47488. constructor(
  47489. /** The utility layer the gizmo will be added to */
  47490. gizmoLayer?: UtilityLayerRenderer);
  47491. /**
  47492. * Updates the gizmo to match the attached mesh's position/rotation
  47493. */
  47494. protected _update(): void;
  47495. /**
  47496. * Disposes of the gizmo
  47497. */
  47498. dispose(): void;
  47499. }
  47500. }
  47501. declare module "babylonjs/Gizmos/planeDragGizmo" {
  47502. import { Observable } from "babylonjs/Misc/observable";
  47503. import { Nullable } from "babylonjs/types";
  47504. import { Vector3 } from "babylonjs/Maths/math.vector";
  47505. import { Color3 } from "babylonjs/Maths/math.color";
  47506. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47507. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47508. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47509. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47510. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47511. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47512. import { Scene } from "babylonjs/scene";
  47513. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47514. /**
  47515. * Single plane drag gizmo
  47516. */
  47517. export class PlaneDragGizmo extends Gizmo {
  47518. /**
  47519. * Drag behavior responsible for the gizmos dragging interactions
  47520. */
  47521. dragBehavior: PointerDragBehavior;
  47522. private _pointerObserver;
  47523. /**
  47524. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47525. */
  47526. snapDistance: number;
  47527. /**
  47528. * Event that fires each time the gizmo snaps to a new location.
  47529. * * snapDistance is the the change in distance
  47530. */
  47531. onSnapObservable: Observable<{
  47532. snapDistance: number;
  47533. }>;
  47534. private _plane;
  47535. private _coloredMaterial;
  47536. private _hoverMaterial;
  47537. private _isEnabled;
  47538. private _parent;
  47539. /** @hidden */
  47540. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  47541. /** @hidden */
  47542. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47543. /**
  47544. * Creates a PlaneDragGizmo
  47545. * @param gizmoLayer The utility layer the gizmo will be added to
  47546. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  47547. * @param color The color of the gizmo
  47548. */
  47549. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47550. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47551. /**
  47552. * If the gizmo is enabled
  47553. */
  47554. set isEnabled(value: boolean);
  47555. get isEnabled(): boolean;
  47556. /**
  47557. * Disposes of the gizmo
  47558. */
  47559. dispose(): void;
  47560. }
  47561. }
  47562. declare module "babylonjs/Gizmos/positionGizmo" {
  47563. import { Observable } from "babylonjs/Misc/observable";
  47564. import { Nullable } from "babylonjs/types";
  47565. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47566. import { Mesh } from "babylonjs/Meshes/mesh";
  47567. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47568. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  47569. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  47570. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47571. /**
  47572. * Gizmo that enables dragging a mesh along 3 axis
  47573. */
  47574. export class PositionGizmo extends Gizmo {
  47575. /**
  47576. * Internal gizmo used for interactions on the x axis
  47577. */
  47578. xGizmo: AxisDragGizmo;
  47579. /**
  47580. * Internal gizmo used for interactions on the y axis
  47581. */
  47582. yGizmo: AxisDragGizmo;
  47583. /**
  47584. * Internal gizmo used for interactions on the z axis
  47585. */
  47586. zGizmo: AxisDragGizmo;
  47587. /**
  47588. * Internal gizmo used for interactions on the yz plane
  47589. */
  47590. xPlaneGizmo: PlaneDragGizmo;
  47591. /**
  47592. * Internal gizmo used for interactions on the xz plane
  47593. */
  47594. yPlaneGizmo: PlaneDragGizmo;
  47595. /**
  47596. * Internal gizmo used for interactions on the xy plane
  47597. */
  47598. zPlaneGizmo: PlaneDragGizmo;
  47599. /**
  47600. * private variables
  47601. */
  47602. private _meshAttached;
  47603. private _updateGizmoRotationToMatchAttachedMesh;
  47604. private _snapDistance;
  47605. private _scaleRatio;
  47606. /** Fires an event when any of it's sub gizmos are dragged */
  47607. onDragStartObservable: Observable<unknown>;
  47608. /** Fires an event when any of it's sub gizmos are released from dragging */
  47609. onDragEndObservable: Observable<unknown>;
  47610. /**
  47611. * If set to true, planar drag is enabled
  47612. */
  47613. private _planarGizmoEnabled;
  47614. get attachedMesh(): Nullable<AbstractMesh>;
  47615. set attachedMesh(mesh: Nullable<AbstractMesh>);
  47616. /**
  47617. * Creates a PositionGizmo
  47618. * @param gizmoLayer The utility layer the gizmo will be added to
  47619. */
  47620. constructor(gizmoLayer?: UtilityLayerRenderer);
  47621. /**
  47622. * If the planar drag gizmo is enabled
  47623. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  47624. */
  47625. set planarGizmoEnabled(value: boolean);
  47626. get planarGizmoEnabled(): boolean;
  47627. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  47628. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  47629. /**
  47630. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47631. */
  47632. set snapDistance(value: number);
  47633. get snapDistance(): number;
  47634. /**
  47635. * Ratio for the scale of the gizmo (Default: 1)
  47636. */
  47637. set scaleRatio(value: number);
  47638. get scaleRatio(): number;
  47639. /**
  47640. * Disposes of the gizmo
  47641. */
  47642. dispose(): void;
  47643. /**
  47644. * CustomMeshes are not supported by this gizmo
  47645. * @param mesh The mesh to replace the default mesh of the gizmo
  47646. */
  47647. setCustomMesh(mesh: Mesh): void;
  47648. }
  47649. }
  47650. declare module "babylonjs/Gizmos/axisDragGizmo" {
  47651. import { Observable } from "babylonjs/Misc/observable";
  47652. import { Nullable } from "babylonjs/types";
  47653. import { Vector3 } from "babylonjs/Maths/math.vector";
  47654. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47655. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47656. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47657. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47658. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47659. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47660. import { Scene } from "babylonjs/scene";
  47661. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47662. import { Color3 } from "babylonjs/Maths/math.color";
  47663. /**
  47664. * Single axis drag gizmo
  47665. */
  47666. export class AxisDragGizmo extends Gizmo {
  47667. /**
  47668. * Drag behavior responsible for the gizmos dragging interactions
  47669. */
  47670. dragBehavior: PointerDragBehavior;
  47671. private _pointerObserver;
  47672. /**
  47673. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47674. */
  47675. snapDistance: number;
  47676. /**
  47677. * Event that fires each time the gizmo snaps to a new location.
  47678. * * snapDistance is the the change in distance
  47679. */
  47680. onSnapObservable: Observable<{
  47681. snapDistance: number;
  47682. }>;
  47683. private _isEnabled;
  47684. private _parent;
  47685. private _arrow;
  47686. private _coloredMaterial;
  47687. private _hoverMaterial;
  47688. /** @hidden */
  47689. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  47690. /** @hidden */
  47691. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47692. /**
  47693. * Creates an AxisDragGizmo
  47694. * @param gizmoLayer The utility layer the gizmo will be added to
  47695. * @param dragAxis The axis which the gizmo will be able to drag on
  47696. * @param color The color of the gizmo
  47697. */
  47698. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47699. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47700. /**
  47701. * If the gizmo is enabled
  47702. */
  47703. set isEnabled(value: boolean);
  47704. get isEnabled(): boolean;
  47705. /**
  47706. * Disposes of the gizmo
  47707. */
  47708. dispose(): void;
  47709. }
  47710. }
  47711. declare module "babylonjs/Debug/axesViewer" {
  47712. import { Vector3 } from "babylonjs/Maths/math.vector";
  47713. import { Nullable } from "babylonjs/types";
  47714. import { Scene } from "babylonjs/scene";
  47715. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47716. /**
  47717. * The Axes viewer will show 3 axes in a specific point in space
  47718. */
  47719. export class AxesViewer {
  47720. private _xAxis;
  47721. private _yAxis;
  47722. private _zAxis;
  47723. private _scaleLinesFactor;
  47724. private _instanced;
  47725. /**
  47726. * Gets the hosting scene
  47727. */
  47728. scene: Scene;
  47729. /**
  47730. * Gets or sets a number used to scale line length
  47731. */
  47732. scaleLines: number;
  47733. /** Gets the node hierarchy used to render x-axis */
  47734. get xAxis(): TransformNode;
  47735. /** Gets the node hierarchy used to render y-axis */
  47736. get yAxis(): TransformNode;
  47737. /** Gets the node hierarchy used to render z-axis */
  47738. get zAxis(): TransformNode;
  47739. /**
  47740. * Creates a new AxesViewer
  47741. * @param scene defines the hosting scene
  47742. * @param scaleLines defines a number used to scale line length (1 by default)
  47743. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  47744. * @param xAxis defines the node hierarchy used to render the x-axis
  47745. * @param yAxis defines the node hierarchy used to render the y-axis
  47746. * @param zAxis defines the node hierarchy used to render the z-axis
  47747. */
  47748. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  47749. /**
  47750. * Force the viewer to update
  47751. * @param position defines the position of the viewer
  47752. * @param xaxis defines the x axis of the viewer
  47753. * @param yaxis defines the y axis of the viewer
  47754. * @param zaxis defines the z axis of the viewer
  47755. */
  47756. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  47757. /**
  47758. * Creates an instance of this axes viewer.
  47759. * @returns a new axes viewer with instanced meshes
  47760. */
  47761. createInstance(): AxesViewer;
  47762. /** Releases resources */
  47763. dispose(): void;
  47764. private static _SetRenderingGroupId;
  47765. }
  47766. }
  47767. declare module "babylonjs/Debug/boneAxesViewer" {
  47768. import { Nullable } from "babylonjs/types";
  47769. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  47770. import { Vector3 } from "babylonjs/Maths/math.vector";
  47771. import { Mesh } from "babylonjs/Meshes/mesh";
  47772. import { Bone } from "babylonjs/Bones/bone";
  47773. import { Scene } from "babylonjs/scene";
  47774. /**
  47775. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  47776. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  47777. */
  47778. export class BoneAxesViewer extends AxesViewer {
  47779. /**
  47780. * Gets or sets the target mesh where to display the axes viewer
  47781. */
  47782. mesh: Nullable<Mesh>;
  47783. /**
  47784. * Gets or sets the target bone where to display the axes viewer
  47785. */
  47786. bone: Nullable<Bone>;
  47787. /** Gets current position */
  47788. pos: Vector3;
  47789. /** Gets direction of X axis */
  47790. xaxis: Vector3;
  47791. /** Gets direction of Y axis */
  47792. yaxis: Vector3;
  47793. /** Gets direction of Z axis */
  47794. zaxis: Vector3;
  47795. /**
  47796. * Creates a new BoneAxesViewer
  47797. * @param scene defines the hosting scene
  47798. * @param bone defines the target bone
  47799. * @param mesh defines the target mesh
  47800. * @param scaleLines defines a scaling factor for line length (1 by default)
  47801. */
  47802. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  47803. /**
  47804. * Force the viewer to update
  47805. */
  47806. update(): void;
  47807. /** Releases resources */
  47808. dispose(): void;
  47809. }
  47810. }
  47811. declare module "babylonjs/Debug/debugLayer" {
  47812. import { Scene } from "babylonjs/scene";
  47813. /**
  47814. * Interface used to define scene explorer extensibility option
  47815. */
  47816. export interface IExplorerExtensibilityOption {
  47817. /**
  47818. * Define the option label
  47819. */
  47820. label: string;
  47821. /**
  47822. * Defines the action to execute on click
  47823. */
  47824. action: (entity: any) => void;
  47825. }
  47826. /**
  47827. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  47828. */
  47829. export interface IExplorerExtensibilityGroup {
  47830. /**
  47831. * Defines a predicate to test if a given type mut be extended
  47832. */
  47833. predicate: (entity: any) => boolean;
  47834. /**
  47835. * Gets the list of options added to a type
  47836. */
  47837. entries: IExplorerExtensibilityOption[];
  47838. }
  47839. /**
  47840. * Interface used to define the options to use to create the Inspector
  47841. */
  47842. export interface IInspectorOptions {
  47843. /**
  47844. * Display in overlay mode (default: false)
  47845. */
  47846. overlay?: boolean;
  47847. /**
  47848. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  47849. */
  47850. globalRoot?: HTMLElement;
  47851. /**
  47852. * Display the Scene explorer
  47853. */
  47854. showExplorer?: boolean;
  47855. /**
  47856. * Display the property inspector
  47857. */
  47858. showInspector?: boolean;
  47859. /**
  47860. * Display in embed mode (both panes on the right)
  47861. */
  47862. embedMode?: boolean;
  47863. /**
  47864. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  47865. */
  47866. handleResize?: boolean;
  47867. /**
  47868. * Allow the panes to popup (default: true)
  47869. */
  47870. enablePopup?: boolean;
  47871. /**
  47872. * Allow the panes to be closed by users (default: true)
  47873. */
  47874. enableClose?: boolean;
  47875. /**
  47876. * Optional list of extensibility entries
  47877. */
  47878. explorerExtensibility?: IExplorerExtensibilityGroup[];
  47879. /**
  47880. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  47881. */
  47882. inspectorURL?: string;
  47883. /**
  47884. * Optional initial tab (default to DebugLayerTab.Properties)
  47885. */
  47886. initialTab?: DebugLayerTab;
  47887. }
  47888. module "babylonjs/scene" {
  47889. interface Scene {
  47890. /**
  47891. * @hidden
  47892. * Backing field
  47893. */
  47894. _debugLayer: DebugLayer;
  47895. /**
  47896. * Gets the debug layer (aka Inspector) associated with the scene
  47897. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47898. */
  47899. debugLayer: DebugLayer;
  47900. }
  47901. }
  47902. /**
  47903. * Enum of inspector action tab
  47904. */
  47905. export enum DebugLayerTab {
  47906. /**
  47907. * Properties tag (default)
  47908. */
  47909. Properties = 0,
  47910. /**
  47911. * Debug tab
  47912. */
  47913. Debug = 1,
  47914. /**
  47915. * Statistics tab
  47916. */
  47917. Statistics = 2,
  47918. /**
  47919. * Tools tab
  47920. */
  47921. Tools = 3,
  47922. /**
  47923. * Settings tab
  47924. */
  47925. Settings = 4
  47926. }
  47927. /**
  47928. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47929. * what is happening in your scene
  47930. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47931. */
  47932. export class DebugLayer {
  47933. /**
  47934. * Define the url to get the inspector script from.
  47935. * By default it uses the babylonjs CDN.
  47936. * @ignoreNaming
  47937. */
  47938. static InspectorURL: string;
  47939. private _scene;
  47940. private BJSINSPECTOR;
  47941. private _onPropertyChangedObservable?;
  47942. /**
  47943. * Observable triggered when a property is changed through the inspector.
  47944. */
  47945. get onPropertyChangedObservable(): any;
  47946. /**
  47947. * Instantiates a new debug layer.
  47948. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47949. * what is happening in your scene
  47950. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47951. * @param scene Defines the scene to inspect
  47952. */
  47953. constructor(scene: Scene);
  47954. /** Creates the inspector window. */
  47955. private _createInspector;
  47956. /**
  47957. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  47958. * @param entity defines the entity to select
  47959. * @param lineContainerTitle defines the specific block to highlight
  47960. */
  47961. select(entity: any, lineContainerTitle?: string): void;
  47962. /** Get the inspector from bundle or global */
  47963. private _getGlobalInspector;
  47964. /**
  47965. * Get if the inspector is visible or not.
  47966. * @returns true if visible otherwise, false
  47967. */
  47968. isVisible(): boolean;
  47969. /**
  47970. * Hide the inspector and close its window.
  47971. */
  47972. hide(): void;
  47973. /**
  47974. * Launch the debugLayer.
  47975. * @param config Define the configuration of the inspector
  47976. * @return a promise fulfilled when the debug layer is visible
  47977. */
  47978. show(config?: IInspectorOptions): Promise<DebugLayer>;
  47979. }
  47980. }
  47981. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  47982. import { Nullable } from "babylonjs/types";
  47983. import { Scene } from "babylonjs/scene";
  47984. import { Vector4 } from "babylonjs/Maths/math.vector";
  47985. import { Color4 } from "babylonjs/Maths/math.color";
  47986. import { Mesh } from "babylonjs/Meshes/mesh";
  47987. /**
  47988. * Class containing static functions to help procedurally build meshes
  47989. */
  47990. export class BoxBuilder {
  47991. /**
  47992. * Creates a box mesh
  47993. * * The parameter `size` sets the size (float) of each box side (default 1)
  47994. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  47995. * * 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)
  47996. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  47997. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47998. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47999. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48000. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  48001. * @param name defines the name of the mesh
  48002. * @param options defines the options used to create the mesh
  48003. * @param scene defines the hosting scene
  48004. * @returns the box mesh
  48005. */
  48006. static CreateBox(name: string, options: {
  48007. size?: number;
  48008. width?: number;
  48009. height?: number;
  48010. depth?: number;
  48011. faceUV?: Vector4[];
  48012. faceColors?: Color4[];
  48013. sideOrientation?: number;
  48014. frontUVs?: Vector4;
  48015. backUVs?: Vector4;
  48016. wrap?: boolean;
  48017. topBaseAt?: number;
  48018. bottomBaseAt?: number;
  48019. updatable?: boolean;
  48020. }, scene?: Nullable<Scene>): Mesh;
  48021. }
  48022. }
  48023. declare module "babylonjs/Debug/physicsViewer" {
  48024. import { Nullable } from "babylonjs/types";
  48025. import { Scene } from "babylonjs/scene";
  48026. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48027. import { Mesh } from "babylonjs/Meshes/mesh";
  48028. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  48029. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48030. /**
  48031. * Used to show the physics impostor around the specific mesh
  48032. */
  48033. export class PhysicsViewer {
  48034. /** @hidden */
  48035. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  48036. /** @hidden */
  48037. protected _meshes: Array<Nullable<AbstractMesh>>;
  48038. /** @hidden */
  48039. protected _scene: Nullable<Scene>;
  48040. /** @hidden */
  48041. protected _numMeshes: number;
  48042. /** @hidden */
  48043. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  48044. private _renderFunction;
  48045. private _utilityLayer;
  48046. private _debugBoxMesh;
  48047. private _debugSphereMesh;
  48048. private _debugCylinderMesh;
  48049. private _debugMaterial;
  48050. private _debugMeshMeshes;
  48051. /**
  48052. * Creates a new PhysicsViewer
  48053. * @param scene defines the hosting scene
  48054. */
  48055. constructor(scene: Scene);
  48056. /** @hidden */
  48057. protected _updateDebugMeshes(): void;
  48058. /**
  48059. * Renders a specified physic impostor
  48060. * @param impostor defines the impostor to render
  48061. * @param targetMesh defines the mesh represented by the impostor
  48062. * @returns the new debug mesh used to render the impostor
  48063. */
  48064. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  48065. /**
  48066. * Hides a specified physic impostor
  48067. * @param impostor defines the impostor to hide
  48068. */
  48069. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  48070. private _getDebugMaterial;
  48071. private _getDebugBoxMesh;
  48072. private _getDebugSphereMesh;
  48073. private _getDebugCylinderMesh;
  48074. private _getDebugMeshMesh;
  48075. private _getDebugMesh;
  48076. /** Releases all resources */
  48077. dispose(): void;
  48078. }
  48079. }
  48080. declare module "babylonjs/Debug/rayHelper" {
  48081. import { Nullable } from "babylonjs/types";
  48082. import { Ray } from "babylonjs/Culling/ray";
  48083. import { Vector3 } from "babylonjs/Maths/math.vector";
  48084. import { Color3 } from "babylonjs/Maths/math.color";
  48085. import { Scene } from "babylonjs/scene";
  48086. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48087. import "babylonjs/Meshes/Builders/linesBuilder";
  48088. /**
  48089. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48090. * in order to better appreciate the issue one might have.
  48091. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48092. */
  48093. export class RayHelper {
  48094. /**
  48095. * Defines the ray we are currently tryin to visualize.
  48096. */
  48097. ray: Nullable<Ray>;
  48098. private _renderPoints;
  48099. private _renderLine;
  48100. private _renderFunction;
  48101. private _scene;
  48102. private _updateToMeshFunction;
  48103. private _attachedToMesh;
  48104. private _meshSpaceDirection;
  48105. private _meshSpaceOrigin;
  48106. /**
  48107. * Helper function to create a colored helper in a scene in one line.
  48108. * @param ray Defines the ray we are currently tryin to visualize
  48109. * @param scene Defines the scene the ray is used in
  48110. * @param color Defines the color we want to see the ray in
  48111. * @returns The newly created ray helper.
  48112. */
  48113. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  48114. /**
  48115. * Instantiate a new ray helper.
  48116. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48117. * in order to better appreciate the issue one might have.
  48118. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48119. * @param ray Defines the ray we are currently tryin to visualize
  48120. */
  48121. constructor(ray: Ray);
  48122. /**
  48123. * Shows the ray we are willing to debug.
  48124. * @param scene Defines the scene the ray needs to be rendered in
  48125. * @param color Defines the color the ray needs to be rendered in
  48126. */
  48127. show(scene: Scene, color?: Color3): void;
  48128. /**
  48129. * Hides the ray we are debugging.
  48130. */
  48131. hide(): void;
  48132. private _render;
  48133. /**
  48134. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  48135. * @param mesh Defines the mesh we want the helper attached to
  48136. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  48137. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  48138. * @param length Defines the length of the ray
  48139. */
  48140. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  48141. /**
  48142. * Detach the ray helper from the mesh it has previously been attached to.
  48143. */
  48144. detachFromMesh(): void;
  48145. private _updateToMesh;
  48146. /**
  48147. * Dispose the helper and release its associated resources.
  48148. */
  48149. dispose(): void;
  48150. }
  48151. }
  48152. declare module "babylonjs/Debug/skeletonViewer" {
  48153. import { Color3 } from "babylonjs/Maths/math.color";
  48154. import { Scene } from "babylonjs/scene";
  48155. import { Nullable } from "babylonjs/types";
  48156. import { Skeleton } from "babylonjs/Bones/skeleton";
  48157. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48158. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  48159. /**
  48160. * Class used to render a debug view of a given skeleton
  48161. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  48162. */
  48163. export class SkeletonViewer {
  48164. /** defines the skeleton to render */
  48165. skeleton: Skeleton;
  48166. /** defines the mesh attached to the skeleton */
  48167. mesh: AbstractMesh;
  48168. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48169. autoUpdateBonesMatrices: boolean;
  48170. /** defines the rendering group id to use with the viewer */
  48171. renderingGroupId: number;
  48172. /** Gets or sets the color used to render the skeleton */
  48173. color: Color3;
  48174. private _scene;
  48175. private _debugLines;
  48176. private _debugMesh;
  48177. private _isEnabled;
  48178. private _renderFunction;
  48179. private _utilityLayer;
  48180. /**
  48181. * Returns the mesh used to render the bones
  48182. */
  48183. get debugMesh(): Nullable<LinesMesh>;
  48184. /**
  48185. * Creates a new SkeletonViewer
  48186. * @param skeleton defines the skeleton to render
  48187. * @param mesh defines the mesh attached to the skeleton
  48188. * @param scene defines the hosting scene
  48189. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  48190. * @param renderingGroupId defines the rendering group id to use with the viewer
  48191. */
  48192. constructor(
  48193. /** defines the skeleton to render */
  48194. skeleton: Skeleton,
  48195. /** defines the mesh attached to the skeleton */
  48196. mesh: AbstractMesh, scene: Scene,
  48197. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48198. autoUpdateBonesMatrices?: boolean,
  48199. /** defines the rendering group id to use with the viewer */
  48200. renderingGroupId?: number);
  48201. /** Gets or sets a boolean indicating if the viewer is enabled */
  48202. set isEnabled(value: boolean);
  48203. get isEnabled(): boolean;
  48204. private _getBonePosition;
  48205. private _getLinesForBonesWithLength;
  48206. private _getLinesForBonesNoLength;
  48207. /** Update the viewer to sync with current skeleton state */
  48208. update(): void;
  48209. /** Release associated resources */
  48210. dispose(): void;
  48211. }
  48212. }
  48213. declare module "babylonjs/Debug/index" {
  48214. export * from "babylonjs/Debug/axesViewer";
  48215. export * from "babylonjs/Debug/boneAxesViewer";
  48216. export * from "babylonjs/Debug/debugLayer";
  48217. export * from "babylonjs/Debug/physicsViewer";
  48218. export * from "babylonjs/Debug/rayHelper";
  48219. export * from "babylonjs/Debug/skeletonViewer";
  48220. }
  48221. declare module "babylonjs/Engines/nullEngine" {
  48222. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  48223. import { Scene } from "babylonjs/scene";
  48224. import { Engine } from "babylonjs/Engines/engine";
  48225. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  48226. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  48227. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48228. import { Effect } from "babylonjs/Materials/effect";
  48229. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  48230. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48231. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  48232. /**
  48233. * Options to create the null engine
  48234. */
  48235. export class NullEngineOptions {
  48236. /**
  48237. * Render width (Default: 512)
  48238. */
  48239. renderWidth: number;
  48240. /**
  48241. * Render height (Default: 256)
  48242. */
  48243. renderHeight: number;
  48244. /**
  48245. * Texture size (Default: 512)
  48246. */
  48247. textureSize: number;
  48248. /**
  48249. * If delta time between frames should be constant
  48250. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48251. */
  48252. deterministicLockstep: boolean;
  48253. /**
  48254. * Maximum about of steps between frames (Default: 4)
  48255. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48256. */
  48257. lockstepMaxSteps: number;
  48258. }
  48259. /**
  48260. * The null engine class provides support for headless version of babylon.js.
  48261. * This can be used in server side scenario or for testing purposes
  48262. */
  48263. export class NullEngine extends Engine {
  48264. private _options;
  48265. /**
  48266. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  48267. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48268. * @returns true if engine is in deterministic lock step mode
  48269. */
  48270. isDeterministicLockStep(): boolean;
  48271. /**
  48272. * Gets the max steps when engine is running in deterministic lock step
  48273. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48274. * @returns the max steps
  48275. */
  48276. getLockstepMaxSteps(): number;
  48277. /**
  48278. * Gets the current hardware scaling level.
  48279. * By default the hardware scaling level is computed from the window device ratio.
  48280. * 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.
  48281. * @returns a number indicating the current hardware scaling level
  48282. */
  48283. getHardwareScalingLevel(): number;
  48284. constructor(options?: NullEngineOptions);
  48285. /**
  48286. * Creates a vertex buffer
  48287. * @param vertices the data for the vertex buffer
  48288. * @returns the new WebGL static buffer
  48289. */
  48290. createVertexBuffer(vertices: FloatArray): DataBuffer;
  48291. /**
  48292. * Creates a new index buffer
  48293. * @param indices defines the content of the index buffer
  48294. * @param updatable defines if the index buffer must be updatable
  48295. * @returns a new webGL buffer
  48296. */
  48297. createIndexBuffer(indices: IndicesArray): DataBuffer;
  48298. /**
  48299. * Clear the current render buffer or the current render target (if any is set up)
  48300. * @param color defines the color to use
  48301. * @param backBuffer defines if the back buffer must be cleared
  48302. * @param depth defines if the depth buffer must be cleared
  48303. * @param stencil defines if the stencil buffer must be cleared
  48304. */
  48305. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48306. /**
  48307. * Gets the current render width
  48308. * @param useScreen defines if screen size must be used (or the current render target if any)
  48309. * @returns a number defining the current render width
  48310. */
  48311. getRenderWidth(useScreen?: boolean): number;
  48312. /**
  48313. * Gets the current render height
  48314. * @param useScreen defines if screen size must be used (or the current render target if any)
  48315. * @returns a number defining the current render height
  48316. */
  48317. getRenderHeight(useScreen?: boolean): number;
  48318. /**
  48319. * Set the WebGL's viewport
  48320. * @param viewport defines the viewport element to be used
  48321. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  48322. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  48323. */
  48324. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  48325. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  48326. /**
  48327. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  48328. * @param pipelineContext defines the pipeline context to use
  48329. * @param uniformsNames defines the list of uniform names
  48330. * @returns an array of webGL uniform locations
  48331. */
  48332. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  48333. /**
  48334. * Gets the lsit of active attributes for a given webGL program
  48335. * @param pipelineContext defines the pipeline context to use
  48336. * @param attributesNames defines the list of attribute names to get
  48337. * @returns an array of indices indicating the offset of each attribute
  48338. */
  48339. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48340. /**
  48341. * Binds an effect to the webGL context
  48342. * @param effect defines the effect to bind
  48343. */
  48344. bindSamplers(effect: Effect): void;
  48345. /**
  48346. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  48347. * @param effect defines the effect to activate
  48348. */
  48349. enableEffect(effect: Effect): void;
  48350. /**
  48351. * Set various states to the webGL context
  48352. * @param culling defines backface culling state
  48353. * @param zOffset defines the value to apply to zOffset (0 by default)
  48354. * @param force defines if states must be applied even if cache is up to date
  48355. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  48356. */
  48357. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48358. /**
  48359. * Set the value of an uniform to an array of int32
  48360. * @param uniform defines the webGL uniform location where to store the value
  48361. * @param array defines the array of int32 to store
  48362. */
  48363. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48364. /**
  48365. * Set the value of an uniform to an array of int32 (stored as vec2)
  48366. * @param uniform defines the webGL uniform location where to store the value
  48367. * @param array defines the array of int32 to store
  48368. */
  48369. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48370. /**
  48371. * Set the value of an uniform to an array of int32 (stored as vec3)
  48372. * @param uniform defines the webGL uniform location where to store the value
  48373. * @param array defines the array of int32 to store
  48374. */
  48375. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48376. /**
  48377. * Set the value of an uniform to an array of int32 (stored as vec4)
  48378. * @param uniform defines the webGL uniform location where to store the value
  48379. * @param array defines the array of int32 to store
  48380. */
  48381. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48382. /**
  48383. * Set the value of an uniform to an array of float32
  48384. * @param uniform defines the webGL uniform location where to store the value
  48385. * @param array defines the array of float32 to store
  48386. */
  48387. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48388. /**
  48389. * Set the value of an uniform to an array of float32 (stored as vec2)
  48390. * @param uniform defines the webGL uniform location where to store the value
  48391. * @param array defines the array of float32 to store
  48392. */
  48393. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48394. /**
  48395. * Set the value of an uniform to an array of float32 (stored as vec3)
  48396. * @param uniform defines the webGL uniform location where to store the value
  48397. * @param array defines the array of float32 to store
  48398. */
  48399. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48400. /**
  48401. * Set the value of an uniform to an array of float32 (stored as vec4)
  48402. * @param uniform defines the webGL uniform location where to store the value
  48403. * @param array defines the array of float32 to store
  48404. */
  48405. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48406. /**
  48407. * Set the value of an uniform to an array of number
  48408. * @param uniform defines the webGL uniform location where to store the value
  48409. * @param array defines the array of number to store
  48410. */
  48411. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48412. /**
  48413. * Set the value of an uniform to an array of number (stored as vec2)
  48414. * @param uniform defines the webGL uniform location where to store the value
  48415. * @param array defines the array of number to store
  48416. */
  48417. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48418. /**
  48419. * Set the value of an uniform to an array of number (stored as vec3)
  48420. * @param uniform defines the webGL uniform location where to store the value
  48421. * @param array defines the array of number to store
  48422. */
  48423. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48424. /**
  48425. * Set the value of an uniform to an array of number (stored as vec4)
  48426. * @param uniform defines the webGL uniform location where to store the value
  48427. * @param array defines the array of number to store
  48428. */
  48429. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48430. /**
  48431. * Set the value of an uniform to an array of float32 (stored as matrices)
  48432. * @param uniform defines the webGL uniform location where to store the value
  48433. * @param matrices defines the array of float32 to store
  48434. */
  48435. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48436. /**
  48437. * Set the value of an uniform to a matrix (3x3)
  48438. * @param uniform defines the webGL uniform location where to store the value
  48439. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  48440. */
  48441. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48442. /**
  48443. * Set the value of an uniform to a matrix (2x2)
  48444. * @param uniform defines the webGL uniform location where to store the value
  48445. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  48446. */
  48447. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48448. /**
  48449. * Set the value of an uniform to a number (float)
  48450. * @param uniform defines the webGL uniform location where to store the value
  48451. * @param value defines the float number to store
  48452. */
  48453. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48454. /**
  48455. * Set the value of an uniform to a vec2
  48456. * @param uniform defines the webGL uniform location where to store the value
  48457. * @param x defines the 1st component of the value
  48458. * @param y defines the 2nd component of the value
  48459. */
  48460. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48461. /**
  48462. * Set the value of an uniform to a vec3
  48463. * @param uniform defines the webGL uniform location where to store the value
  48464. * @param x defines the 1st component of the value
  48465. * @param y defines the 2nd component of the value
  48466. * @param z defines the 3rd component of the value
  48467. */
  48468. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48469. /**
  48470. * Set the value of an uniform to a boolean
  48471. * @param uniform defines the webGL uniform location where to store the value
  48472. * @param bool defines the boolean to store
  48473. */
  48474. setBool(uniform: WebGLUniformLocation, bool: number): void;
  48475. /**
  48476. * Set the value of an uniform to a vec4
  48477. * @param uniform defines the webGL uniform location where to store the value
  48478. * @param x defines the 1st component of the value
  48479. * @param y defines the 2nd component of the value
  48480. * @param z defines the 3rd component of the value
  48481. * @param w defines the 4th component of the value
  48482. */
  48483. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48484. /**
  48485. * Sets the current alpha mode
  48486. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  48487. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48488. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48489. */
  48490. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48491. /**
  48492. * Bind webGl buffers directly to the webGL context
  48493. * @param vertexBuffers defines the vertex buffer to bind
  48494. * @param indexBuffer defines the index buffer to bind
  48495. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  48496. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  48497. * @param effect defines the effect associated with the vertex buffer
  48498. */
  48499. bindBuffers(vertexBuffers: {
  48500. [key: string]: VertexBuffer;
  48501. }, indexBuffer: DataBuffer, effect: Effect): void;
  48502. /**
  48503. * Force the entire cache to be cleared
  48504. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  48505. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  48506. */
  48507. wipeCaches(bruteForce?: boolean): void;
  48508. /**
  48509. * Send a draw order
  48510. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  48511. * @param indexStart defines the starting index
  48512. * @param indexCount defines the number of index to draw
  48513. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48514. */
  48515. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  48516. /**
  48517. * Draw a list of indexed primitives
  48518. * @param fillMode defines the primitive to use
  48519. * @param indexStart defines the starting index
  48520. * @param indexCount defines the number of index to draw
  48521. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48522. */
  48523. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48524. /**
  48525. * Draw a list of unindexed primitives
  48526. * @param fillMode defines the primitive to use
  48527. * @param verticesStart defines the index of first vertex to draw
  48528. * @param verticesCount defines the count of vertices to draw
  48529. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48530. */
  48531. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48532. /** @hidden */
  48533. _createTexture(): WebGLTexture;
  48534. /** @hidden */
  48535. _releaseTexture(texture: InternalTexture): void;
  48536. /**
  48537. * Usually called from Texture.ts.
  48538. * Passed information to create a WebGLTexture
  48539. * @param urlArg defines a value which contains one of the following:
  48540. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48541. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48542. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48543. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48544. * @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)
  48545. * @param scene needed for loading to the correct scene
  48546. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48547. * @param onLoad optional callback to be called upon successful completion
  48548. * @param onError optional callback to be called upon failure
  48549. * @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
  48550. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48551. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48552. * @param forcedExtension defines the extension to use to pick the right loader
  48553. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  48554. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48555. */
  48556. 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;
  48557. /**
  48558. * Creates a new render target texture
  48559. * @param size defines the size of the texture
  48560. * @param options defines the options used to create the texture
  48561. * @returns a new render target texture stored in an InternalTexture
  48562. */
  48563. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  48564. /**
  48565. * Update the sampling mode of a given texture
  48566. * @param samplingMode defines the required sampling mode
  48567. * @param texture defines the texture to update
  48568. */
  48569. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48570. /**
  48571. * Binds the frame buffer to the specified texture.
  48572. * @param texture The texture to render to or null for the default canvas
  48573. * @param faceIndex The face of the texture to render to in case of cube texture
  48574. * @param requiredWidth The width of the target to render to
  48575. * @param requiredHeight The height of the target to render to
  48576. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  48577. * @param lodLevel defines le lod level to bind to the frame buffer
  48578. */
  48579. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48580. /**
  48581. * Unbind the current render target texture from the webGL context
  48582. * @param texture defines the render target texture to unbind
  48583. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48584. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48585. */
  48586. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48587. /**
  48588. * Creates a dynamic vertex buffer
  48589. * @param vertices the data for the dynamic vertex buffer
  48590. * @returns the new WebGL dynamic buffer
  48591. */
  48592. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  48593. /**
  48594. * Update the content of a dynamic texture
  48595. * @param texture defines the texture to update
  48596. * @param canvas defines the canvas containing the source
  48597. * @param invertY defines if data must be stored with Y axis inverted
  48598. * @param premulAlpha defines if alpha is stored as premultiplied
  48599. * @param format defines the format of the data
  48600. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  48601. */
  48602. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  48603. /**
  48604. * Gets a boolean indicating if all created effects are ready
  48605. * @returns true if all effects are ready
  48606. */
  48607. areAllEffectsReady(): boolean;
  48608. /**
  48609. * @hidden
  48610. * Get the current error code of the webGL context
  48611. * @returns the error code
  48612. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  48613. */
  48614. getError(): number;
  48615. /** @hidden */
  48616. _getUnpackAlignement(): number;
  48617. /** @hidden */
  48618. _unpackFlipY(value: boolean): void;
  48619. /**
  48620. * Update a dynamic index buffer
  48621. * @param indexBuffer defines the target index buffer
  48622. * @param indices defines the data to update
  48623. * @param offset defines the offset in the target index buffer where update should start
  48624. */
  48625. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  48626. /**
  48627. * Updates a dynamic vertex buffer.
  48628. * @param vertexBuffer the vertex buffer to update
  48629. * @param vertices the data used to update the vertex buffer
  48630. * @param byteOffset the byte offset of the data (optional)
  48631. * @param byteLength the byte length of the data (optional)
  48632. */
  48633. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  48634. /** @hidden */
  48635. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  48636. /** @hidden */
  48637. _bindTexture(channel: number, texture: InternalTexture): void;
  48638. protected _deleteBuffer(buffer: WebGLBuffer): void;
  48639. /**
  48640. * 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
  48641. */
  48642. releaseEffects(): void;
  48643. displayLoadingUI(): void;
  48644. hideLoadingUI(): void;
  48645. /** @hidden */
  48646. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48647. /** @hidden */
  48648. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48649. /** @hidden */
  48650. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48651. /** @hidden */
  48652. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48653. }
  48654. }
  48655. declare module "babylonjs/Instrumentation/timeToken" {
  48656. import { Nullable } from "babylonjs/types";
  48657. /**
  48658. * @hidden
  48659. **/
  48660. export class _TimeToken {
  48661. _startTimeQuery: Nullable<WebGLQuery>;
  48662. _endTimeQuery: Nullable<WebGLQuery>;
  48663. _timeElapsedQuery: Nullable<WebGLQuery>;
  48664. _timeElapsedQueryEnded: boolean;
  48665. }
  48666. }
  48667. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  48668. import { Nullable, int } from "babylonjs/types";
  48669. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  48670. /** @hidden */
  48671. export class _OcclusionDataStorage {
  48672. /** @hidden */
  48673. occlusionInternalRetryCounter: number;
  48674. /** @hidden */
  48675. isOcclusionQueryInProgress: boolean;
  48676. /** @hidden */
  48677. isOccluded: boolean;
  48678. /** @hidden */
  48679. occlusionRetryCount: number;
  48680. /** @hidden */
  48681. occlusionType: number;
  48682. /** @hidden */
  48683. occlusionQueryAlgorithmType: number;
  48684. }
  48685. module "babylonjs/Engines/engine" {
  48686. interface Engine {
  48687. /**
  48688. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  48689. * @return the new query
  48690. */
  48691. createQuery(): WebGLQuery;
  48692. /**
  48693. * Delete and release a webGL query
  48694. * @param query defines the query to delete
  48695. * @return the current engine
  48696. */
  48697. deleteQuery(query: WebGLQuery): Engine;
  48698. /**
  48699. * Check if a given query has resolved and got its value
  48700. * @param query defines the query to check
  48701. * @returns true if the query got its value
  48702. */
  48703. isQueryResultAvailable(query: WebGLQuery): boolean;
  48704. /**
  48705. * Gets the value of a given query
  48706. * @param query defines the query to check
  48707. * @returns the value of the query
  48708. */
  48709. getQueryResult(query: WebGLQuery): number;
  48710. /**
  48711. * Initiates an occlusion query
  48712. * @param algorithmType defines the algorithm to use
  48713. * @param query defines the query to use
  48714. * @returns the current engine
  48715. * @see http://doc.babylonjs.com/features/occlusionquery
  48716. */
  48717. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  48718. /**
  48719. * Ends an occlusion query
  48720. * @see http://doc.babylonjs.com/features/occlusionquery
  48721. * @param algorithmType defines the algorithm to use
  48722. * @returns the current engine
  48723. */
  48724. endOcclusionQuery(algorithmType: number): Engine;
  48725. /**
  48726. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  48727. * Please note that only one query can be issued at a time
  48728. * @returns a time token used to track the time span
  48729. */
  48730. startTimeQuery(): Nullable<_TimeToken>;
  48731. /**
  48732. * Ends a time query
  48733. * @param token defines the token used to measure the time span
  48734. * @returns the time spent (in ns)
  48735. */
  48736. endTimeQuery(token: _TimeToken): int;
  48737. /** @hidden */
  48738. _currentNonTimestampToken: Nullable<_TimeToken>;
  48739. /** @hidden */
  48740. _createTimeQuery(): WebGLQuery;
  48741. /** @hidden */
  48742. _deleteTimeQuery(query: WebGLQuery): void;
  48743. /** @hidden */
  48744. _getGlAlgorithmType(algorithmType: number): number;
  48745. /** @hidden */
  48746. _getTimeQueryResult(query: WebGLQuery): any;
  48747. /** @hidden */
  48748. _getTimeQueryAvailability(query: WebGLQuery): any;
  48749. }
  48750. }
  48751. module "babylonjs/Meshes/abstractMesh" {
  48752. interface AbstractMesh {
  48753. /**
  48754. * Backing filed
  48755. * @hidden
  48756. */
  48757. __occlusionDataStorage: _OcclusionDataStorage;
  48758. /**
  48759. * Access property
  48760. * @hidden
  48761. */
  48762. _occlusionDataStorage: _OcclusionDataStorage;
  48763. /**
  48764. * 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.
  48765. * The default value is -1 which means don't break the query and wait till the result
  48766. * @see http://doc.babylonjs.com/features/occlusionquery
  48767. */
  48768. occlusionRetryCount: number;
  48769. /**
  48770. * 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:
  48771. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  48772. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  48773. * * 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.
  48774. * @see http://doc.babylonjs.com/features/occlusionquery
  48775. */
  48776. occlusionType: number;
  48777. /**
  48778. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  48779. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  48780. * * 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.
  48781. * @see http://doc.babylonjs.com/features/occlusionquery
  48782. */
  48783. occlusionQueryAlgorithmType: number;
  48784. /**
  48785. * 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
  48786. * @see http://doc.babylonjs.com/features/occlusionquery
  48787. */
  48788. isOccluded: boolean;
  48789. /**
  48790. * Flag to check the progress status of the query
  48791. * @see http://doc.babylonjs.com/features/occlusionquery
  48792. */
  48793. isOcclusionQueryInProgress: boolean;
  48794. }
  48795. }
  48796. }
  48797. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  48798. import { Nullable } from "babylonjs/types";
  48799. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48800. /** @hidden */
  48801. export var _forceTransformFeedbackToBundle: boolean;
  48802. module "babylonjs/Engines/engine" {
  48803. interface Engine {
  48804. /**
  48805. * Creates a webGL transform feedback object
  48806. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  48807. * @returns the webGL transform feedback object
  48808. */
  48809. createTransformFeedback(): WebGLTransformFeedback;
  48810. /**
  48811. * Delete a webGL transform feedback object
  48812. * @param value defines the webGL transform feedback object to delete
  48813. */
  48814. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  48815. /**
  48816. * Bind a webGL transform feedback object to the webgl context
  48817. * @param value defines the webGL transform feedback object to bind
  48818. */
  48819. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  48820. /**
  48821. * Begins a transform feedback operation
  48822. * @param usePoints defines if points or triangles must be used
  48823. */
  48824. beginTransformFeedback(usePoints: boolean): void;
  48825. /**
  48826. * Ends a transform feedback operation
  48827. */
  48828. endTransformFeedback(): void;
  48829. /**
  48830. * Specify the varyings to use with transform feedback
  48831. * @param program defines the associated webGL program
  48832. * @param value defines the list of strings representing the varying names
  48833. */
  48834. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  48835. /**
  48836. * Bind a webGL buffer for a transform feedback operation
  48837. * @param value defines the webGL buffer to bind
  48838. */
  48839. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  48840. }
  48841. }
  48842. }
  48843. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  48844. import { Scene } from "babylonjs/scene";
  48845. import { Engine } from "babylonjs/Engines/engine";
  48846. import { Texture } from "babylonjs/Materials/Textures/texture";
  48847. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48848. import "babylonjs/Engines/Extensions/engine.multiRender";
  48849. /**
  48850. * Creation options of the multi render target texture.
  48851. */
  48852. export interface IMultiRenderTargetOptions {
  48853. /**
  48854. * Define if the texture needs to create mip maps after render.
  48855. */
  48856. generateMipMaps?: boolean;
  48857. /**
  48858. * Define the types of all the draw buffers we want to create
  48859. */
  48860. types?: number[];
  48861. /**
  48862. * Define the sampling modes of all the draw buffers we want to create
  48863. */
  48864. samplingModes?: number[];
  48865. /**
  48866. * Define if a depth buffer is required
  48867. */
  48868. generateDepthBuffer?: boolean;
  48869. /**
  48870. * Define if a stencil buffer is required
  48871. */
  48872. generateStencilBuffer?: boolean;
  48873. /**
  48874. * Define if a depth texture is required instead of a depth buffer
  48875. */
  48876. generateDepthTexture?: boolean;
  48877. /**
  48878. * Define the number of desired draw buffers
  48879. */
  48880. textureCount?: number;
  48881. /**
  48882. * Define if aspect ratio should be adapted to the texture or stay the scene one
  48883. */
  48884. doNotChangeAspectRatio?: boolean;
  48885. /**
  48886. * Define the default type of the buffers we are creating
  48887. */
  48888. defaultType?: number;
  48889. }
  48890. /**
  48891. * A multi render target, like a render target provides the ability to render to a texture.
  48892. * Unlike the render target, it can render to several draw buffers in one draw.
  48893. * This is specially interesting in deferred rendering or for any effects requiring more than
  48894. * just one color from a single pass.
  48895. */
  48896. export class MultiRenderTarget extends RenderTargetTexture {
  48897. private _internalTextures;
  48898. private _textures;
  48899. private _multiRenderTargetOptions;
  48900. /**
  48901. * Get if draw buffers are currently supported by the used hardware and browser.
  48902. */
  48903. get isSupported(): boolean;
  48904. /**
  48905. * Get the list of textures generated by the multi render target.
  48906. */
  48907. get textures(): Texture[];
  48908. /**
  48909. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  48910. */
  48911. get depthTexture(): Texture;
  48912. /**
  48913. * Set the wrapping mode on U of all the textures we are rendering to.
  48914. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48915. */
  48916. set wrapU(wrap: number);
  48917. /**
  48918. * Set the wrapping mode on V of all the textures we are rendering to.
  48919. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48920. */
  48921. set wrapV(wrap: number);
  48922. /**
  48923. * Instantiate a new multi render target texture.
  48924. * A multi render target, like a render target provides the ability to render to a texture.
  48925. * Unlike the render target, it can render to several draw buffers in one draw.
  48926. * This is specially interesting in deferred rendering or for any effects requiring more than
  48927. * just one color from a single pass.
  48928. * @param name Define the name of the texture
  48929. * @param size Define the size of the buffers to render to
  48930. * @param count Define the number of target we are rendering into
  48931. * @param scene Define the scene the texture belongs to
  48932. * @param options Define the options used to create the multi render target
  48933. */
  48934. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  48935. /** @hidden */
  48936. _rebuild(): void;
  48937. private _createInternalTextures;
  48938. private _createTextures;
  48939. /**
  48940. * Define the number of samples used if MSAA is enabled.
  48941. */
  48942. get samples(): number;
  48943. set samples(value: number);
  48944. /**
  48945. * Resize all the textures in the multi render target.
  48946. * Be carrefull as it will recreate all the data in the new texture.
  48947. * @param size Define the new size
  48948. */
  48949. resize(size: any): void;
  48950. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  48951. /**
  48952. * Dispose the render targets and their associated resources
  48953. */
  48954. dispose(): void;
  48955. /**
  48956. * Release all the underlying texture used as draw buffers.
  48957. */
  48958. releaseInternalTextures(): void;
  48959. }
  48960. }
  48961. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  48962. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48963. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  48964. import { Nullable } from "babylonjs/types";
  48965. module "babylonjs/Engines/thinEngine" {
  48966. interface ThinEngine {
  48967. /**
  48968. * Unbind a list of render target textures from the webGL context
  48969. * This is used only when drawBuffer extension or webGL2 are active
  48970. * @param textures defines the render target textures to unbind
  48971. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48972. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48973. */
  48974. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  48975. /**
  48976. * Create a multi render target texture
  48977. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  48978. * @param size defines the size of the texture
  48979. * @param options defines the creation options
  48980. * @returns the cube texture as an InternalTexture
  48981. */
  48982. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  48983. /**
  48984. * Update the sample count for a given multiple render target texture
  48985. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  48986. * @param textures defines the textures to update
  48987. * @param samples defines the sample count to set
  48988. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  48989. */
  48990. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  48991. }
  48992. }
  48993. }
  48994. declare module "babylonjs/Engines/Extensions/engine.views" {
  48995. import { Camera } from "babylonjs/Cameras/camera";
  48996. import { Nullable } from "babylonjs/types";
  48997. /**
  48998. * Class used to define an additional view for the engine
  48999. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49000. */
  49001. export class EngineView {
  49002. /** Defines the canvas where to render the view */
  49003. target: HTMLCanvasElement;
  49004. /** Defines an optional camera used to render the view (will use active camera else) */
  49005. camera?: Camera;
  49006. }
  49007. module "babylonjs/Engines/engine" {
  49008. interface Engine {
  49009. /**
  49010. * Gets or sets the HTML element to use for attaching events
  49011. */
  49012. inputElement: Nullable<HTMLElement>;
  49013. /**
  49014. * Gets the current engine view
  49015. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49016. */
  49017. activeView: Nullable<EngineView>;
  49018. /** Gets or sets the list of views */
  49019. views: EngineView[];
  49020. /**
  49021. * Register a new child canvas
  49022. * @param canvas defines the canvas to register
  49023. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  49024. * @returns the associated view
  49025. */
  49026. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  49027. /**
  49028. * Remove a registered child canvas
  49029. * @param canvas defines the canvas to remove
  49030. * @returns the current engine
  49031. */
  49032. unRegisterView(canvas: HTMLCanvasElement): Engine;
  49033. }
  49034. }
  49035. }
  49036. declare module "babylonjs/Engines/Extensions/index" {
  49037. export * from "babylonjs/Engines/Extensions/engine.alpha";
  49038. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  49039. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  49040. export * from "babylonjs/Engines/Extensions/engine.multiview";
  49041. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  49042. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  49043. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  49044. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  49045. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  49046. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  49047. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49048. export * from "babylonjs/Engines/Extensions/engine.webVR";
  49049. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  49050. export * from "babylonjs/Engines/Extensions/engine.views";
  49051. }
  49052. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  49053. import { Nullable } from "babylonjs/types";
  49054. /**
  49055. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  49056. */
  49057. export interface CubeMapInfo {
  49058. /**
  49059. * The pixel array for the front face.
  49060. * This is stored in format, left to right, up to down format.
  49061. */
  49062. front: Nullable<ArrayBufferView>;
  49063. /**
  49064. * The pixel array for the back face.
  49065. * This is stored in format, left to right, up to down format.
  49066. */
  49067. back: Nullable<ArrayBufferView>;
  49068. /**
  49069. * The pixel array for the left face.
  49070. * This is stored in format, left to right, up to down format.
  49071. */
  49072. left: Nullable<ArrayBufferView>;
  49073. /**
  49074. * The pixel array for the right face.
  49075. * This is stored in format, left to right, up to down format.
  49076. */
  49077. right: Nullable<ArrayBufferView>;
  49078. /**
  49079. * The pixel array for the up face.
  49080. * This is stored in format, left to right, up to down format.
  49081. */
  49082. up: Nullable<ArrayBufferView>;
  49083. /**
  49084. * The pixel array for the down face.
  49085. * This is stored in format, left to right, up to down format.
  49086. */
  49087. down: Nullable<ArrayBufferView>;
  49088. /**
  49089. * The size of the cubemap stored.
  49090. *
  49091. * Each faces will be size * size pixels.
  49092. */
  49093. size: number;
  49094. /**
  49095. * The format of the texture.
  49096. *
  49097. * RGBA, RGB.
  49098. */
  49099. format: number;
  49100. /**
  49101. * The type of the texture data.
  49102. *
  49103. * UNSIGNED_INT, FLOAT.
  49104. */
  49105. type: number;
  49106. /**
  49107. * Specifies whether the texture is in gamma space.
  49108. */
  49109. gammaSpace: boolean;
  49110. }
  49111. /**
  49112. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  49113. */
  49114. export class PanoramaToCubeMapTools {
  49115. private static FACE_FRONT;
  49116. private static FACE_BACK;
  49117. private static FACE_RIGHT;
  49118. private static FACE_LEFT;
  49119. private static FACE_DOWN;
  49120. private static FACE_UP;
  49121. /**
  49122. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  49123. *
  49124. * @param float32Array The source data.
  49125. * @param inputWidth The width of the input panorama.
  49126. * @param inputHeight The height of the input panorama.
  49127. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  49128. * @return The cubemap data
  49129. */
  49130. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  49131. private static CreateCubemapTexture;
  49132. private static CalcProjectionSpherical;
  49133. }
  49134. }
  49135. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  49136. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49137. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49138. import { Nullable } from "babylonjs/types";
  49139. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  49140. /**
  49141. * Helper class dealing with the extraction of spherical polynomial dataArray
  49142. * from a cube map.
  49143. */
  49144. export class CubeMapToSphericalPolynomialTools {
  49145. private static FileFaces;
  49146. /**
  49147. * Converts a texture to the according Spherical Polynomial data.
  49148. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49149. *
  49150. * @param texture The texture to extract the information from.
  49151. * @return The Spherical Polynomial data.
  49152. */
  49153. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49154. /**
  49155. * Converts a cubemap to the according Spherical Polynomial data.
  49156. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49157. *
  49158. * @param cubeInfo The Cube map to extract the information from.
  49159. * @return The Spherical Polynomial data.
  49160. */
  49161. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49162. }
  49163. }
  49164. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  49165. import { Nullable } from "babylonjs/types";
  49166. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49167. module "babylonjs/Materials/Textures/baseTexture" {
  49168. interface BaseTexture {
  49169. /**
  49170. * Get the polynomial representation of the texture data.
  49171. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  49172. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  49173. */
  49174. sphericalPolynomial: Nullable<SphericalPolynomial>;
  49175. }
  49176. }
  49177. }
  49178. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  49179. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49180. /** @hidden */
  49181. export var rgbdEncodePixelShader: {
  49182. name: string;
  49183. shader: string;
  49184. };
  49185. }
  49186. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  49187. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49188. /** @hidden */
  49189. export var rgbdDecodePixelShader: {
  49190. name: string;
  49191. shader: string;
  49192. };
  49193. }
  49194. declare module "babylonjs/Misc/environmentTextureTools" {
  49195. import { Nullable } from "babylonjs/types";
  49196. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49197. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49198. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49199. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49200. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  49201. import "babylonjs/Shaders/rgbdEncode.fragment";
  49202. import "babylonjs/Shaders/rgbdDecode.fragment";
  49203. /**
  49204. * Raw texture data and descriptor sufficient for WebGL texture upload
  49205. */
  49206. export interface EnvironmentTextureInfo {
  49207. /**
  49208. * Version of the environment map
  49209. */
  49210. version: number;
  49211. /**
  49212. * Width of image
  49213. */
  49214. width: number;
  49215. /**
  49216. * Irradiance information stored in the file.
  49217. */
  49218. irradiance: any;
  49219. /**
  49220. * Specular information stored in the file.
  49221. */
  49222. specular: any;
  49223. }
  49224. /**
  49225. * Defines One Image in the file. It requires only the position in the file
  49226. * as well as the length.
  49227. */
  49228. interface BufferImageData {
  49229. /**
  49230. * Length of the image data.
  49231. */
  49232. length: number;
  49233. /**
  49234. * Position of the data from the null terminator delimiting the end of the JSON.
  49235. */
  49236. position: number;
  49237. }
  49238. /**
  49239. * Defines the specular data enclosed in the file.
  49240. * This corresponds to the version 1 of the data.
  49241. */
  49242. export interface EnvironmentTextureSpecularInfoV1 {
  49243. /**
  49244. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  49245. */
  49246. specularDataPosition?: number;
  49247. /**
  49248. * This contains all the images data needed to reconstruct the cubemap.
  49249. */
  49250. mipmaps: Array<BufferImageData>;
  49251. /**
  49252. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  49253. */
  49254. lodGenerationScale: number;
  49255. }
  49256. /**
  49257. * Sets of helpers addressing the serialization and deserialization of environment texture
  49258. * stored in a BabylonJS env file.
  49259. * Those files are usually stored as .env files.
  49260. */
  49261. export class EnvironmentTextureTools {
  49262. /**
  49263. * Magic number identifying the env file.
  49264. */
  49265. private static _MagicBytes;
  49266. /**
  49267. * Gets the environment info from an env file.
  49268. * @param data The array buffer containing the .env bytes.
  49269. * @returns the environment file info (the json header) if successfully parsed.
  49270. */
  49271. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  49272. /**
  49273. * Creates an environment texture from a loaded cube texture.
  49274. * @param texture defines the cube texture to convert in env file
  49275. * @return a promise containing the environment data if succesfull.
  49276. */
  49277. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  49278. /**
  49279. * Creates a JSON representation of the spherical data.
  49280. * @param texture defines the texture containing the polynomials
  49281. * @return the JSON representation of the spherical info
  49282. */
  49283. private static _CreateEnvTextureIrradiance;
  49284. /**
  49285. * Creates the ArrayBufferViews used for initializing environment texture image data.
  49286. * @param data the image data
  49287. * @param info parameters that determine what views will be created for accessing the underlying buffer
  49288. * @return the views described by info providing access to the underlying buffer
  49289. */
  49290. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  49291. /**
  49292. * Uploads the texture info contained in the env file to the GPU.
  49293. * @param texture defines the internal texture to upload to
  49294. * @param data defines the data to load
  49295. * @param info defines the texture info retrieved through the GetEnvInfo method
  49296. * @returns a promise
  49297. */
  49298. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  49299. private static _OnImageReadyAsync;
  49300. /**
  49301. * Uploads the levels of image data to the GPU.
  49302. * @param texture defines the internal texture to upload to
  49303. * @param imageData defines the array buffer views of image data [mipmap][face]
  49304. * @returns a promise
  49305. */
  49306. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  49307. /**
  49308. * Uploads spherical polynomials information to the texture.
  49309. * @param texture defines the texture we are trying to upload the information to
  49310. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  49311. */
  49312. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  49313. /** @hidden */
  49314. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49315. }
  49316. }
  49317. declare module "babylonjs/Maths/math.vertexFormat" {
  49318. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  49319. /**
  49320. * Contains position and normal vectors for a vertex
  49321. */
  49322. export class PositionNormalVertex {
  49323. /** the position of the vertex (defaut: 0,0,0) */
  49324. position: Vector3;
  49325. /** the normal of the vertex (defaut: 0,1,0) */
  49326. normal: Vector3;
  49327. /**
  49328. * Creates a PositionNormalVertex
  49329. * @param position the position of the vertex (defaut: 0,0,0)
  49330. * @param normal the normal of the vertex (defaut: 0,1,0)
  49331. */
  49332. constructor(
  49333. /** the position of the vertex (defaut: 0,0,0) */
  49334. position?: Vector3,
  49335. /** the normal of the vertex (defaut: 0,1,0) */
  49336. normal?: Vector3);
  49337. /**
  49338. * Clones the PositionNormalVertex
  49339. * @returns the cloned PositionNormalVertex
  49340. */
  49341. clone(): PositionNormalVertex;
  49342. }
  49343. /**
  49344. * Contains position, normal and uv vectors for a vertex
  49345. */
  49346. export class PositionNormalTextureVertex {
  49347. /** the position of the vertex (defaut: 0,0,0) */
  49348. position: Vector3;
  49349. /** the normal of the vertex (defaut: 0,1,0) */
  49350. normal: Vector3;
  49351. /** the uv of the vertex (default: 0,0) */
  49352. uv: Vector2;
  49353. /**
  49354. * Creates a PositionNormalTextureVertex
  49355. * @param position the position of the vertex (defaut: 0,0,0)
  49356. * @param normal the normal of the vertex (defaut: 0,1,0)
  49357. * @param uv the uv of the vertex (default: 0,0)
  49358. */
  49359. constructor(
  49360. /** the position of the vertex (defaut: 0,0,0) */
  49361. position?: Vector3,
  49362. /** the normal of the vertex (defaut: 0,1,0) */
  49363. normal?: Vector3,
  49364. /** the uv of the vertex (default: 0,0) */
  49365. uv?: Vector2);
  49366. /**
  49367. * Clones the PositionNormalTextureVertex
  49368. * @returns the cloned PositionNormalTextureVertex
  49369. */
  49370. clone(): PositionNormalTextureVertex;
  49371. }
  49372. }
  49373. declare module "babylonjs/Maths/math" {
  49374. export * from "babylonjs/Maths/math.axis";
  49375. export * from "babylonjs/Maths/math.color";
  49376. export * from "babylonjs/Maths/math.constants";
  49377. export * from "babylonjs/Maths/math.frustum";
  49378. export * from "babylonjs/Maths/math.path";
  49379. export * from "babylonjs/Maths/math.plane";
  49380. export * from "babylonjs/Maths/math.size";
  49381. export * from "babylonjs/Maths/math.vector";
  49382. export * from "babylonjs/Maths/math.vertexFormat";
  49383. export * from "babylonjs/Maths/math.viewport";
  49384. }
  49385. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  49386. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49387. /** @hidden */
  49388. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  49389. private _genericAttributeLocation;
  49390. private _varyingLocationCount;
  49391. private _varyingLocationMap;
  49392. private _replacements;
  49393. private _textureCount;
  49394. private _uniforms;
  49395. lineProcessor(line: string): string;
  49396. attributeProcessor(attribute: string): string;
  49397. varyingProcessor(varying: string, isFragment: boolean): string;
  49398. uniformProcessor(uniform: string): string;
  49399. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  49400. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  49401. }
  49402. }
  49403. declare module "babylonjs/Engines/nativeEngine" {
  49404. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  49405. import { Engine } from "babylonjs/Engines/engine";
  49406. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  49407. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49408. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49409. import { Effect } from "babylonjs/Materials/effect";
  49410. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  49411. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  49412. import { IColor4Like } from "babylonjs/Maths/math.like";
  49413. import { Scene } from "babylonjs/scene";
  49414. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  49415. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  49416. /**
  49417. * Container for accessors for natively-stored mesh data buffers.
  49418. */
  49419. class NativeDataBuffer extends DataBuffer {
  49420. /**
  49421. * Accessor value used to identify/retrieve a natively-stored index buffer.
  49422. */
  49423. nativeIndexBuffer?: any;
  49424. /**
  49425. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  49426. */
  49427. nativeVertexBuffer?: any;
  49428. }
  49429. /** @hidden */
  49430. class NativeTexture extends InternalTexture {
  49431. getInternalTexture(): InternalTexture;
  49432. getViewCount(): number;
  49433. }
  49434. /** @hidden */
  49435. export class NativeEngine extends Engine {
  49436. private readonly _native;
  49437. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  49438. private readonly INVALID_HANDLE;
  49439. getHardwareScalingLevel(): number;
  49440. constructor();
  49441. /**
  49442. * Can be used to override the current requestAnimationFrame requester.
  49443. * @hidden
  49444. */
  49445. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  49446. /**
  49447. * Override default engine behavior.
  49448. * @param color
  49449. * @param backBuffer
  49450. * @param depth
  49451. * @param stencil
  49452. */
  49453. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  49454. /**
  49455. * Gets host document
  49456. * @returns the host document object
  49457. */
  49458. getHostDocument(): Nullable<Document>;
  49459. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  49460. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  49461. createVertexBuffer(data: DataArray): NativeDataBuffer;
  49462. recordVertexArrayObject(vertexBuffers: {
  49463. [key: string]: VertexBuffer;
  49464. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  49465. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49466. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49467. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  49468. /**
  49469. * Draw a list of indexed primitives
  49470. * @param fillMode defines the primitive to use
  49471. * @param indexStart defines the starting index
  49472. * @param indexCount defines the number of index to draw
  49473. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49474. */
  49475. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  49476. /**
  49477. * Draw a list of unindexed primitives
  49478. * @param fillMode defines the primitive to use
  49479. * @param verticesStart defines the index of first vertex to draw
  49480. * @param verticesCount defines the count of vertices to draw
  49481. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49482. */
  49483. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  49484. createPipelineContext(): IPipelineContext;
  49485. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  49486. /** @hidden */
  49487. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  49488. /** @hidden */
  49489. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  49490. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49491. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49492. protected _setProgram(program: WebGLProgram): void;
  49493. _releaseEffect(effect: Effect): void;
  49494. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  49495. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  49496. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  49497. bindSamplers(effect: Effect): void;
  49498. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  49499. getRenderWidth(useScreen?: boolean): number;
  49500. getRenderHeight(useScreen?: boolean): number;
  49501. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  49502. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  49503. /**
  49504. * Set the z offset to apply to current rendering
  49505. * @param value defines the offset to apply
  49506. */
  49507. setZOffset(value: number): void;
  49508. /**
  49509. * Gets the current value of the zOffset
  49510. * @returns the current zOffset state
  49511. */
  49512. getZOffset(): number;
  49513. /**
  49514. * Enable or disable depth buffering
  49515. * @param enable defines the state to set
  49516. */
  49517. setDepthBuffer(enable: boolean): void;
  49518. /**
  49519. * Gets a boolean indicating if depth writing is enabled
  49520. * @returns the current depth writing state
  49521. */
  49522. getDepthWrite(): boolean;
  49523. /**
  49524. * Enable or disable depth writing
  49525. * @param enable defines the state to set
  49526. */
  49527. setDepthWrite(enable: boolean): void;
  49528. /**
  49529. * Enable or disable color writing
  49530. * @param enable defines the state to set
  49531. */
  49532. setColorWrite(enable: boolean): void;
  49533. /**
  49534. * Gets a boolean indicating if color writing is enabled
  49535. * @returns the current color writing state
  49536. */
  49537. getColorWrite(): boolean;
  49538. /**
  49539. * Sets alpha constants used by some alpha blending modes
  49540. * @param r defines the red component
  49541. * @param g defines the green component
  49542. * @param b defines the blue component
  49543. * @param a defines the alpha component
  49544. */
  49545. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  49546. /**
  49547. * Sets the current alpha mode
  49548. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  49549. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  49550. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49551. */
  49552. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  49553. /**
  49554. * Gets the current alpha mode
  49555. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49556. * @returns the current alpha mode
  49557. */
  49558. getAlphaMode(): number;
  49559. setInt(uniform: WebGLUniformLocation, int: number): void;
  49560. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  49561. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  49562. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  49563. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  49564. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  49565. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  49566. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  49567. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  49568. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  49569. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  49570. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  49571. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  49572. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  49573. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49574. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49575. setFloat(uniform: WebGLUniformLocation, value: number): void;
  49576. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  49577. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  49578. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  49579. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  49580. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  49581. wipeCaches(bruteForce?: boolean): void;
  49582. _createTexture(): WebGLTexture;
  49583. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  49584. /**
  49585. * Usually called from BABYLON.Texture.ts.
  49586. * Passed information to create a WebGLTexture
  49587. * @param urlArg defines a value which contains one of the following:
  49588. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  49589. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  49590. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  49591. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  49592. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  49593. * @param scene needed for loading to the correct scene
  49594. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  49595. * @param onLoad optional callback to be called upon successful completion
  49596. * @param onError optional callback to be called upon failure
  49597. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  49598. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  49599. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  49600. * @param forcedExtension defines the extension to use to pick the right loader
  49601. * @returns a InternalTexture for assignment back into BABYLON.Texture
  49602. */
  49603. 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;
  49604. /**
  49605. * Creates a cube texture
  49606. * @param rootUrl defines the url where the files to load is located
  49607. * @param scene defines the current scene
  49608. * @param files defines the list of files to load (1 per face)
  49609. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  49610. * @param onLoad defines an optional callback raised when the texture is loaded
  49611. * @param onError defines an optional callback raised if there is an issue to load the texture
  49612. * @param format defines the format of the data
  49613. * @param forcedExtension defines the extension to use to pick the right loader
  49614. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  49615. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49616. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49617. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  49618. * @returns the cube texture as an InternalTexture
  49619. */
  49620. 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;
  49621. private _getSamplingFilter;
  49622. private static _GetNativeTextureFormat;
  49623. createRenderTargetTexture(size: number | {
  49624. width: number;
  49625. height: number;
  49626. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  49627. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  49628. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  49629. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  49630. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  49631. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  49632. /**
  49633. * Updates a dynamic vertex buffer.
  49634. * @param vertexBuffer the vertex buffer to update
  49635. * @param data the data used to update the vertex buffer
  49636. * @param byteOffset the byte offset of the data (optional)
  49637. * @param byteLength the byte length of the data (optional)
  49638. */
  49639. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  49640. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  49641. private _updateAnisotropicLevel;
  49642. private _getAddressMode;
  49643. /** @hidden */
  49644. _bindTexture(channel: number, texture: InternalTexture): void;
  49645. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  49646. releaseEffects(): void;
  49647. /** @hidden */
  49648. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49649. /** @hidden */
  49650. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49651. /** @hidden */
  49652. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49653. /** @hidden */
  49654. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  49655. }
  49656. }
  49657. declare module "babylonjs/Engines/index" {
  49658. export * from "babylonjs/Engines/constants";
  49659. export * from "babylonjs/Engines/engineCapabilities";
  49660. export * from "babylonjs/Engines/instancingAttributeInfo";
  49661. export * from "babylonjs/Engines/thinEngine";
  49662. export * from "babylonjs/Engines/engine";
  49663. export * from "babylonjs/Engines/engineStore";
  49664. export * from "babylonjs/Engines/nullEngine";
  49665. export * from "babylonjs/Engines/Extensions/index";
  49666. export * from "babylonjs/Engines/IPipelineContext";
  49667. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  49668. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49669. export * from "babylonjs/Engines/nativeEngine";
  49670. }
  49671. declare module "babylonjs/Events/clipboardEvents" {
  49672. /**
  49673. * Gather the list of clipboard event types as constants.
  49674. */
  49675. export class ClipboardEventTypes {
  49676. /**
  49677. * The clipboard event is fired when a copy command is active (pressed).
  49678. */
  49679. static readonly COPY: number;
  49680. /**
  49681. * The clipboard event is fired when a cut command is active (pressed).
  49682. */
  49683. static readonly CUT: number;
  49684. /**
  49685. * The clipboard event is fired when a paste command is active (pressed).
  49686. */
  49687. static readonly PASTE: number;
  49688. }
  49689. /**
  49690. * This class is used to store clipboard related info for the onClipboardObservable event.
  49691. */
  49692. export class ClipboardInfo {
  49693. /**
  49694. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49695. */
  49696. type: number;
  49697. /**
  49698. * Defines the related dom event
  49699. */
  49700. event: ClipboardEvent;
  49701. /**
  49702. *Creates an instance of ClipboardInfo.
  49703. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  49704. * @param event Defines the related dom event
  49705. */
  49706. constructor(
  49707. /**
  49708. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49709. */
  49710. type: number,
  49711. /**
  49712. * Defines the related dom event
  49713. */
  49714. event: ClipboardEvent);
  49715. /**
  49716. * Get the clipboard event's type from the keycode.
  49717. * @param keyCode Defines the keyCode for the current keyboard event.
  49718. * @return {number}
  49719. */
  49720. static GetTypeFromCharacter(keyCode: number): number;
  49721. }
  49722. }
  49723. declare module "babylonjs/Events/index" {
  49724. export * from "babylonjs/Events/keyboardEvents";
  49725. export * from "babylonjs/Events/pointerEvents";
  49726. export * from "babylonjs/Events/clipboardEvents";
  49727. }
  49728. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  49729. import { Scene } from "babylonjs/scene";
  49730. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49731. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49732. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49733. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49734. /**
  49735. * Google Daydream controller
  49736. */
  49737. export class DaydreamController extends WebVRController {
  49738. /**
  49739. * Base Url for the controller model.
  49740. */
  49741. static MODEL_BASE_URL: string;
  49742. /**
  49743. * File name for the controller model.
  49744. */
  49745. static MODEL_FILENAME: string;
  49746. /**
  49747. * Gamepad Id prefix used to identify Daydream Controller.
  49748. */
  49749. static readonly GAMEPAD_ID_PREFIX: string;
  49750. /**
  49751. * Creates a new DaydreamController from a gamepad
  49752. * @param vrGamepad the gamepad that the controller should be created from
  49753. */
  49754. constructor(vrGamepad: any);
  49755. /**
  49756. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49757. * @param scene scene in which to add meshes
  49758. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49759. */
  49760. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49761. /**
  49762. * Called once for each button that changed state since the last frame
  49763. * @param buttonIdx Which button index changed
  49764. * @param state New state of the button
  49765. * @param changes Which properties on the state changed since last frame
  49766. */
  49767. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49768. }
  49769. }
  49770. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  49771. import { Scene } from "babylonjs/scene";
  49772. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49773. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49774. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49775. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49776. /**
  49777. * Gear VR Controller
  49778. */
  49779. export class GearVRController extends WebVRController {
  49780. /**
  49781. * Base Url for the controller model.
  49782. */
  49783. static MODEL_BASE_URL: string;
  49784. /**
  49785. * File name for the controller model.
  49786. */
  49787. static MODEL_FILENAME: string;
  49788. /**
  49789. * Gamepad Id prefix used to identify this controller.
  49790. */
  49791. static readonly GAMEPAD_ID_PREFIX: string;
  49792. private readonly _buttonIndexToObservableNameMap;
  49793. /**
  49794. * Creates a new GearVRController from a gamepad
  49795. * @param vrGamepad the gamepad that the controller should be created from
  49796. */
  49797. constructor(vrGamepad: any);
  49798. /**
  49799. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49800. * @param scene scene in which to add meshes
  49801. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49802. */
  49803. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49804. /**
  49805. * Called once for each button that changed state since the last frame
  49806. * @param buttonIdx Which button index changed
  49807. * @param state New state of the button
  49808. * @param changes Which properties on the state changed since last frame
  49809. */
  49810. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49811. }
  49812. }
  49813. declare module "babylonjs/Gamepads/Controllers/genericController" {
  49814. import { Scene } from "babylonjs/scene";
  49815. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49816. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49817. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49818. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49819. /**
  49820. * Generic Controller
  49821. */
  49822. export class GenericController extends WebVRController {
  49823. /**
  49824. * Base Url for the controller model.
  49825. */
  49826. static readonly MODEL_BASE_URL: string;
  49827. /**
  49828. * File name for the controller model.
  49829. */
  49830. static readonly MODEL_FILENAME: string;
  49831. /**
  49832. * Creates a new GenericController from a gamepad
  49833. * @param vrGamepad the gamepad that the controller should be created from
  49834. */
  49835. constructor(vrGamepad: any);
  49836. /**
  49837. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49838. * @param scene scene in which to add meshes
  49839. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49840. */
  49841. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49842. /**
  49843. * Called once for each button that changed state since the last frame
  49844. * @param buttonIdx Which button index changed
  49845. * @param state New state of the button
  49846. * @param changes Which properties on the state changed since last frame
  49847. */
  49848. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49849. }
  49850. }
  49851. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  49852. import { Observable } from "babylonjs/Misc/observable";
  49853. import { Scene } from "babylonjs/scene";
  49854. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49855. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49856. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49857. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49858. /**
  49859. * Oculus Touch Controller
  49860. */
  49861. export class OculusTouchController extends WebVRController {
  49862. /**
  49863. * Base Url for the controller model.
  49864. */
  49865. static MODEL_BASE_URL: string;
  49866. /**
  49867. * File name for the left controller model.
  49868. */
  49869. static MODEL_LEFT_FILENAME: string;
  49870. /**
  49871. * File name for the right controller model.
  49872. */
  49873. static MODEL_RIGHT_FILENAME: string;
  49874. /**
  49875. * Base Url for the Quest controller model.
  49876. */
  49877. static QUEST_MODEL_BASE_URL: string;
  49878. /**
  49879. * @hidden
  49880. * If the controllers are running on a device that needs the updated Quest controller models
  49881. */
  49882. static _IsQuest: boolean;
  49883. /**
  49884. * Fired when the secondary trigger on this controller is modified
  49885. */
  49886. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  49887. /**
  49888. * Fired when the thumb rest on this controller is modified
  49889. */
  49890. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  49891. /**
  49892. * Creates a new OculusTouchController from a gamepad
  49893. * @param vrGamepad the gamepad that the controller should be created from
  49894. */
  49895. constructor(vrGamepad: any);
  49896. /**
  49897. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49898. * @param scene scene in which to add meshes
  49899. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49900. */
  49901. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49902. /**
  49903. * Fired when the A button on this controller is modified
  49904. */
  49905. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49906. /**
  49907. * Fired when the B button on this controller is modified
  49908. */
  49909. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49910. /**
  49911. * Fired when the X button on this controller is modified
  49912. */
  49913. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49914. /**
  49915. * Fired when the Y button on this controller is modified
  49916. */
  49917. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49918. /**
  49919. * Called once for each button that changed state since the last frame
  49920. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  49921. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  49922. * 2) secondary trigger (same)
  49923. * 3) A (right) X (left), touch, pressed = value
  49924. * 4) B / Y
  49925. * 5) thumb rest
  49926. * @param buttonIdx Which button index changed
  49927. * @param state New state of the button
  49928. * @param changes Which properties on the state changed since last frame
  49929. */
  49930. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49931. }
  49932. }
  49933. declare module "babylonjs/Gamepads/Controllers/viveController" {
  49934. import { Scene } from "babylonjs/scene";
  49935. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49936. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49937. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49938. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49939. import { Observable } from "babylonjs/Misc/observable";
  49940. /**
  49941. * Vive Controller
  49942. */
  49943. export class ViveController extends WebVRController {
  49944. /**
  49945. * Base Url for the controller model.
  49946. */
  49947. static MODEL_BASE_URL: string;
  49948. /**
  49949. * File name for the controller model.
  49950. */
  49951. static MODEL_FILENAME: string;
  49952. /**
  49953. * Creates a new ViveController from a gamepad
  49954. * @param vrGamepad the gamepad that the controller should be created from
  49955. */
  49956. constructor(vrGamepad: any);
  49957. /**
  49958. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49959. * @param scene scene in which to add meshes
  49960. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49961. */
  49962. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49963. /**
  49964. * Fired when the left button on this controller is modified
  49965. */
  49966. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49967. /**
  49968. * Fired when the right button on this controller is modified
  49969. */
  49970. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49971. /**
  49972. * Fired when the menu button on this controller is modified
  49973. */
  49974. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49975. /**
  49976. * Called once for each button that changed state since the last frame
  49977. * Vive mapping:
  49978. * 0: touchpad
  49979. * 1: trigger
  49980. * 2: left AND right buttons
  49981. * 3: menu button
  49982. * @param buttonIdx Which button index changed
  49983. * @param state New state of the button
  49984. * @param changes Which properties on the state changed since last frame
  49985. */
  49986. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49987. }
  49988. }
  49989. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  49990. import { Observable } from "babylonjs/Misc/observable";
  49991. import { Scene } from "babylonjs/scene";
  49992. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49993. import { Ray } from "babylonjs/Culling/ray";
  49994. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49995. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49996. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49997. /**
  49998. * Defines the WindowsMotionController object that the state of the windows motion controller
  49999. */
  50000. export class WindowsMotionController extends WebVRController {
  50001. /**
  50002. * The base url used to load the left and right controller models
  50003. */
  50004. static MODEL_BASE_URL: string;
  50005. /**
  50006. * The name of the left controller model file
  50007. */
  50008. static MODEL_LEFT_FILENAME: string;
  50009. /**
  50010. * The name of the right controller model file
  50011. */
  50012. static MODEL_RIGHT_FILENAME: string;
  50013. /**
  50014. * The controller name prefix for this controller type
  50015. */
  50016. static readonly GAMEPAD_ID_PREFIX: string;
  50017. /**
  50018. * The controller id pattern for this controller type
  50019. */
  50020. private static readonly GAMEPAD_ID_PATTERN;
  50021. private _loadedMeshInfo;
  50022. protected readonly _mapping: {
  50023. buttons: string[];
  50024. buttonMeshNames: {
  50025. 'trigger': string;
  50026. 'menu': string;
  50027. 'grip': string;
  50028. 'thumbstick': string;
  50029. 'trackpad': string;
  50030. };
  50031. buttonObservableNames: {
  50032. 'trigger': string;
  50033. 'menu': string;
  50034. 'grip': string;
  50035. 'thumbstick': string;
  50036. 'trackpad': string;
  50037. };
  50038. axisMeshNames: string[];
  50039. pointingPoseMeshName: string;
  50040. };
  50041. /**
  50042. * Fired when the trackpad on this controller is clicked
  50043. */
  50044. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50045. /**
  50046. * Fired when the trackpad on this controller is modified
  50047. */
  50048. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50049. /**
  50050. * The current x and y values of this controller's trackpad
  50051. */
  50052. trackpad: StickValues;
  50053. /**
  50054. * Creates a new WindowsMotionController from a gamepad
  50055. * @param vrGamepad the gamepad that the controller should be created from
  50056. */
  50057. constructor(vrGamepad: any);
  50058. /**
  50059. * Fired when the trigger on this controller is modified
  50060. */
  50061. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50062. /**
  50063. * Fired when the menu button on this controller is modified
  50064. */
  50065. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50066. /**
  50067. * Fired when the grip button on this controller is modified
  50068. */
  50069. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50070. /**
  50071. * Fired when the thumbstick button on this controller is modified
  50072. */
  50073. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50074. /**
  50075. * Fired when the touchpad button on this controller is modified
  50076. */
  50077. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50078. /**
  50079. * Fired when the touchpad values on this controller are modified
  50080. */
  50081. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  50082. protected _updateTrackpad(): void;
  50083. /**
  50084. * Called once per frame by the engine.
  50085. */
  50086. update(): void;
  50087. /**
  50088. * Called once for each button that changed state since the last frame
  50089. * @param buttonIdx Which button index changed
  50090. * @param state New state of the button
  50091. * @param changes Which properties on the state changed since last frame
  50092. */
  50093. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50094. /**
  50095. * Moves the buttons on the controller mesh based on their current state
  50096. * @param buttonName the name of the button to move
  50097. * @param buttonValue the value of the button which determines the buttons new position
  50098. */
  50099. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  50100. /**
  50101. * Moves the axis on the controller mesh based on its current state
  50102. * @param axis the index of the axis
  50103. * @param axisValue the value of the axis which determines the meshes new position
  50104. * @hidden
  50105. */
  50106. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  50107. /**
  50108. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50109. * @param scene scene in which to add meshes
  50110. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50111. */
  50112. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  50113. /**
  50114. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  50115. * can be transformed by button presses and axes values, based on this._mapping.
  50116. *
  50117. * @param scene scene in which the meshes exist
  50118. * @param meshes list of meshes that make up the controller model to process
  50119. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  50120. */
  50121. private processModel;
  50122. private createMeshInfo;
  50123. /**
  50124. * Gets the ray of the controller in the direction the controller is pointing
  50125. * @param length the length the resulting ray should be
  50126. * @returns a ray in the direction the controller is pointing
  50127. */
  50128. getForwardRay(length?: number): Ray;
  50129. /**
  50130. * Disposes of the controller
  50131. */
  50132. dispose(): void;
  50133. }
  50134. /**
  50135. * This class represents a new windows motion controller in XR.
  50136. */
  50137. export class XRWindowsMotionController extends WindowsMotionController {
  50138. /**
  50139. * Changing the original WIndowsMotionController mapping to fir the new mapping
  50140. */
  50141. protected readonly _mapping: {
  50142. buttons: string[];
  50143. buttonMeshNames: {
  50144. 'trigger': string;
  50145. 'menu': string;
  50146. 'grip': string;
  50147. 'thumbstick': string;
  50148. 'trackpad': string;
  50149. };
  50150. buttonObservableNames: {
  50151. 'trigger': string;
  50152. 'menu': string;
  50153. 'grip': string;
  50154. 'thumbstick': string;
  50155. 'trackpad': string;
  50156. };
  50157. axisMeshNames: string[];
  50158. pointingPoseMeshName: string;
  50159. };
  50160. /**
  50161. * Construct a new XR-Based windows motion controller
  50162. *
  50163. * @param gamepadInfo the gamepad object from the browser
  50164. */
  50165. constructor(gamepadInfo: any);
  50166. /**
  50167. * holds the thumbstick values (X,Y)
  50168. */
  50169. thumbstickValues: StickValues;
  50170. /**
  50171. * Fired when the thumbstick on this controller is clicked
  50172. */
  50173. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  50174. /**
  50175. * Fired when the thumbstick on this controller is modified
  50176. */
  50177. onThumbstickValuesChangedObservable: Observable<StickValues>;
  50178. /**
  50179. * Fired when the touchpad button on this controller is modified
  50180. */
  50181. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50182. /**
  50183. * Fired when the touchpad values on this controller are modified
  50184. */
  50185. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50186. /**
  50187. * Fired when the thumbstick button on this controller is modified
  50188. * here to prevent breaking changes
  50189. */
  50190. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50191. /**
  50192. * updating the thumbstick(!) and not the trackpad.
  50193. * This is named this way due to the difference between WebVR and XR and to avoid
  50194. * changing the parent class.
  50195. */
  50196. protected _updateTrackpad(): void;
  50197. /**
  50198. * Disposes the class with joy
  50199. */
  50200. dispose(): void;
  50201. }
  50202. }
  50203. declare module "babylonjs/Gamepads/Controllers/index" {
  50204. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  50205. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  50206. export * from "babylonjs/Gamepads/Controllers/genericController";
  50207. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  50208. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50209. export * from "babylonjs/Gamepads/Controllers/viveController";
  50210. export * from "babylonjs/Gamepads/Controllers/webVRController";
  50211. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  50212. }
  50213. declare module "babylonjs/Gamepads/index" {
  50214. export * from "babylonjs/Gamepads/Controllers/index";
  50215. export * from "babylonjs/Gamepads/gamepad";
  50216. export * from "babylonjs/Gamepads/gamepadManager";
  50217. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  50218. export * from "babylonjs/Gamepads/xboxGamepad";
  50219. export * from "babylonjs/Gamepads/dualShockGamepad";
  50220. }
  50221. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  50222. import { Scene } from "babylonjs/scene";
  50223. import { Vector4 } from "babylonjs/Maths/math.vector";
  50224. import { Color4 } from "babylonjs/Maths/math.color";
  50225. import { Mesh } from "babylonjs/Meshes/mesh";
  50226. import { Nullable } from "babylonjs/types";
  50227. /**
  50228. * Class containing static functions to help procedurally build meshes
  50229. */
  50230. export class PolyhedronBuilder {
  50231. /**
  50232. * Creates a polyhedron mesh
  50233. * * 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
  50234. * * The parameter `size` (positive float, default 1) sets the polygon size
  50235. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50236. * * 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`
  50237. * * 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
  50238. * * 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)`)
  50239. * * 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
  50240. * * 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
  50241. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50242. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50243. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50244. * @param name defines the name of the mesh
  50245. * @param options defines the options used to create the mesh
  50246. * @param scene defines the hosting scene
  50247. * @returns the polyhedron mesh
  50248. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50249. */
  50250. static CreatePolyhedron(name: string, options: {
  50251. type?: number;
  50252. size?: number;
  50253. sizeX?: number;
  50254. sizeY?: number;
  50255. sizeZ?: number;
  50256. custom?: any;
  50257. faceUV?: Vector4[];
  50258. faceColors?: Color4[];
  50259. flat?: boolean;
  50260. updatable?: boolean;
  50261. sideOrientation?: number;
  50262. frontUVs?: Vector4;
  50263. backUVs?: Vector4;
  50264. }, scene?: Nullable<Scene>): Mesh;
  50265. }
  50266. }
  50267. declare module "babylonjs/Gizmos/scaleGizmo" {
  50268. import { Observable } from "babylonjs/Misc/observable";
  50269. import { Nullable } from "babylonjs/types";
  50270. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50271. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50272. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  50273. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50274. /**
  50275. * Gizmo that enables scaling a mesh along 3 axis
  50276. */
  50277. export class ScaleGizmo extends Gizmo {
  50278. /**
  50279. * Internal gizmo used for interactions on the x axis
  50280. */
  50281. xGizmo: AxisScaleGizmo;
  50282. /**
  50283. * Internal gizmo used for interactions on the y axis
  50284. */
  50285. yGizmo: AxisScaleGizmo;
  50286. /**
  50287. * Internal gizmo used for interactions on the z axis
  50288. */
  50289. zGizmo: AxisScaleGizmo;
  50290. /**
  50291. * Internal gizmo used to scale all axis equally
  50292. */
  50293. uniformScaleGizmo: AxisScaleGizmo;
  50294. private _meshAttached;
  50295. private _updateGizmoRotationToMatchAttachedMesh;
  50296. private _snapDistance;
  50297. private _scaleRatio;
  50298. private _uniformScalingMesh;
  50299. private _octahedron;
  50300. private _sensitivity;
  50301. /** Fires an event when any of it's sub gizmos are dragged */
  50302. onDragStartObservable: Observable<unknown>;
  50303. /** Fires an event when any of it's sub gizmos are released from dragging */
  50304. onDragEndObservable: Observable<unknown>;
  50305. get attachedMesh(): Nullable<AbstractMesh>;
  50306. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50307. /**
  50308. * Creates a ScaleGizmo
  50309. * @param gizmoLayer The utility layer the gizmo will be added to
  50310. */
  50311. constructor(gizmoLayer?: UtilityLayerRenderer);
  50312. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50313. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50314. /**
  50315. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50316. */
  50317. set snapDistance(value: number);
  50318. get snapDistance(): number;
  50319. /**
  50320. * Ratio for the scale of the gizmo (Default: 1)
  50321. */
  50322. set scaleRatio(value: number);
  50323. get scaleRatio(): number;
  50324. /**
  50325. * Sensitivity factor for dragging (Default: 1)
  50326. */
  50327. set sensitivity(value: number);
  50328. get sensitivity(): number;
  50329. /**
  50330. * Disposes of the gizmo
  50331. */
  50332. dispose(): void;
  50333. }
  50334. }
  50335. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  50336. import { Observable } from "babylonjs/Misc/observable";
  50337. import { Nullable } from "babylonjs/types";
  50338. import { Vector3 } from "babylonjs/Maths/math.vector";
  50339. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50340. import { Mesh } from "babylonjs/Meshes/mesh";
  50341. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50342. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50343. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50344. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50345. import { Color3 } from "babylonjs/Maths/math.color";
  50346. /**
  50347. * Single axis scale gizmo
  50348. */
  50349. export class AxisScaleGizmo extends Gizmo {
  50350. /**
  50351. * Drag behavior responsible for the gizmos dragging interactions
  50352. */
  50353. dragBehavior: PointerDragBehavior;
  50354. private _pointerObserver;
  50355. /**
  50356. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50357. */
  50358. snapDistance: number;
  50359. /**
  50360. * Event that fires each time the gizmo snaps to a new location.
  50361. * * snapDistance is the the change in distance
  50362. */
  50363. onSnapObservable: Observable<{
  50364. snapDistance: number;
  50365. }>;
  50366. /**
  50367. * If the scaling operation should be done on all axis (default: false)
  50368. */
  50369. uniformScaling: boolean;
  50370. /**
  50371. * Custom sensitivity value for the drag strength
  50372. */
  50373. sensitivity: number;
  50374. private _isEnabled;
  50375. private _parent;
  50376. private _arrow;
  50377. private _coloredMaterial;
  50378. private _hoverMaterial;
  50379. /**
  50380. * Creates an AxisScaleGizmo
  50381. * @param gizmoLayer The utility layer the gizmo will be added to
  50382. * @param dragAxis The axis which the gizmo will be able to scale on
  50383. * @param color The color of the gizmo
  50384. */
  50385. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  50386. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50387. /**
  50388. * If the gizmo is enabled
  50389. */
  50390. set isEnabled(value: boolean);
  50391. get isEnabled(): boolean;
  50392. /**
  50393. * Disposes of the gizmo
  50394. */
  50395. dispose(): void;
  50396. /**
  50397. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50398. * @param mesh The mesh to replace the default mesh of the gizmo
  50399. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  50400. */
  50401. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  50402. }
  50403. }
  50404. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  50405. import { Observable } from "babylonjs/Misc/observable";
  50406. import { Nullable } from "babylonjs/types";
  50407. import { Vector3 } from "babylonjs/Maths/math.vector";
  50408. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50409. import { Mesh } from "babylonjs/Meshes/mesh";
  50410. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50411. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50412. import { Color3 } from "babylonjs/Maths/math.color";
  50413. import "babylonjs/Meshes/Builders/boxBuilder";
  50414. /**
  50415. * Bounding box gizmo
  50416. */
  50417. export class BoundingBoxGizmo extends Gizmo {
  50418. private _lineBoundingBox;
  50419. private _rotateSpheresParent;
  50420. private _scaleBoxesParent;
  50421. private _boundingDimensions;
  50422. private _renderObserver;
  50423. private _pointerObserver;
  50424. private _scaleDragSpeed;
  50425. private _tmpQuaternion;
  50426. private _tmpVector;
  50427. private _tmpRotationMatrix;
  50428. /**
  50429. * 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)
  50430. */
  50431. ignoreChildren: boolean;
  50432. /**
  50433. * 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)
  50434. */
  50435. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  50436. /**
  50437. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  50438. */
  50439. rotationSphereSize: number;
  50440. /**
  50441. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  50442. */
  50443. scaleBoxSize: number;
  50444. /**
  50445. * 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)
  50446. */
  50447. fixedDragMeshScreenSize: boolean;
  50448. /**
  50449. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  50450. */
  50451. fixedDragMeshScreenSizeDistanceFactor: number;
  50452. /**
  50453. * Fired when a rotation sphere or scale box is dragged
  50454. */
  50455. onDragStartObservable: Observable<{}>;
  50456. /**
  50457. * Fired when a scale box is dragged
  50458. */
  50459. onScaleBoxDragObservable: Observable<{}>;
  50460. /**
  50461. * Fired when a scale box drag is ended
  50462. */
  50463. onScaleBoxDragEndObservable: Observable<{}>;
  50464. /**
  50465. * Fired when a rotation sphere is dragged
  50466. */
  50467. onRotationSphereDragObservable: Observable<{}>;
  50468. /**
  50469. * Fired when a rotation sphere drag is ended
  50470. */
  50471. onRotationSphereDragEndObservable: Observable<{}>;
  50472. /**
  50473. * 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)
  50474. */
  50475. scalePivot: Nullable<Vector3>;
  50476. /**
  50477. * Mesh used as a pivot to rotate the attached mesh
  50478. */
  50479. private _anchorMesh;
  50480. private _existingMeshScale;
  50481. private _dragMesh;
  50482. private pointerDragBehavior;
  50483. private coloredMaterial;
  50484. private hoverColoredMaterial;
  50485. /**
  50486. * Sets the color of the bounding box gizmo
  50487. * @param color the color to set
  50488. */
  50489. setColor(color: Color3): void;
  50490. /**
  50491. * Creates an BoundingBoxGizmo
  50492. * @param gizmoLayer The utility layer the gizmo will be added to
  50493. * @param color The color of the gizmo
  50494. */
  50495. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  50496. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50497. private _selectNode;
  50498. /**
  50499. * Updates the bounding box information for the Gizmo
  50500. */
  50501. updateBoundingBox(): void;
  50502. private _updateRotationSpheres;
  50503. private _updateScaleBoxes;
  50504. /**
  50505. * Enables rotation on the specified axis and disables rotation on the others
  50506. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  50507. */
  50508. setEnabledRotationAxis(axis: string): void;
  50509. /**
  50510. * Enables/disables scaling
  50511. * @param enable if scaling should be enabled
  50512. */
  50513. setEnabledScaling(enable: boolean): void;
  50514. private _updateDummy;
  50515. /**
  50516. * Enables a pointer drag behavior on the bounding box of the gizmo
  50517. */
  50518. enableDragBehavior(): void;
  50519. /**
  50520. * Disposes of the gizmo
  50521. */
  50522. dispose(): void;
  50523. /**
  50524. * 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)
  50525. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  50526. * @returns the bounding box mesh with the passed in mesh as a child
  50527. */
  50528. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  50529. /**
  50530. * CustomMeshes are not supported by this gizmo
  50531. * @param mesh The mesh to replace the default mesh of the gizmo
  50532. */
  50533. setCustomMesh(mesh: Mesh): void;
  50534. }
  50535. }
  50536. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  50537. import { Observable } from "babylonjs/Misc/observable";
  50538. import { Nullable } from "babylonjs/types";
  50539. import { Vector3 } from "babylonjs/Maths/math.vector";
  50540. import { Color3 } from "babylonjs/Maths/math.color";
  50541. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50542. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50543. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50544. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50545. import "babylonjs/Meshes/Builders/linesBuilder";
  50546. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50547. /**
  50548. * Single plane rotation gizmo
  50549. */
  50550. export class PlaneRotationGizmo extends Gizmo {
  50551. /**
  50552. * Drag behavior responsible for the gizmos dragging interactions
  50553. */
  50554. dragBehavior: PointerDragBehavior;
  50555. private _pointerObserver;
  50556. /**
  50557. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  50558. */
  50559. snapDistance: number;
  50560. /**
  50561. * Event that fires each time the gizmo snaps to a new location.
  50562. * * snapDistance is the the change in distance
  50563. */
  50564. onSnapObservable: Observable<{
  50565. snapDistance: number;
  50566. }>;
  50567. private _isEnabled;
  50568. private _parent;
  50569. /**
  50570. * Creates a PlaneRotationGizmo
  50571. * @param gizmoLayer The utility layer the gizmo will be added to
  50572. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  50573. * @param color The color of the gizmo
  50574. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50575. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50576. */
  50577. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  50578. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50579. /**
  50580. * If the gizmo is enabled
  50581. */
  50582. set isEnabled(value: boolean);
  50583. get isEnabled(): boolean;
  50584. /**
  50585. * Disposes of the gizmo
  50586. */
  50587. dispose(): void;
  50588. }
  50589. }
  50590. declare module "babylonjs/Gizmos/rotationGizmo" {
  50591. import { Observable } from "babylonjs/Misc/observable";
  50592. import { Nullable } from "babylonjs/types";
  50593. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50594. import { Mesh } from "babylonjs/Meshes/mesh";
  50595. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50596. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  50597. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50598. /**
  50599. * Gizmo that enables rotating a mesh along 3 axis
  50600. */
  50601. export class RotationGizmo extends Gizmo {
  50602. /**
  50603. * Internal gizmo used for interactions on the x axis
  50604. */
  50605. xGizmo: PlaneRotationGizmo;
  50606. /**
  50607. * Internal gizmo used for interactions on the y axis
  50608. */
  50609. yGizmo: PlaneRotationGizmo;
  50610. /**
  50611. * Internal gizmo used for interactions on the z axis
  50612. */
  50613. zGizmo: PlaneRotationGizmo;
  50614. /** Fires an event when any of it's sub gizmos are dragged */
  50615. onDragStartObservable: Observable<unknown>;
  50616. /** Fires an event when any of it's sub gizmos are released from dragging */
  50617. onDragEndObservable: Observable<unknown>;
  50618. private _meshAttached;
  50619. get attachedMesh(): Nullable<AbstractMesh>;
  50620. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50621. /**
  50622. * Creates a RotationGizmo
  50623. * @param gizmoLayer The utility layer the gizmo will be added to
  50624. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50625. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50626. */
  50627. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  50628. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50629. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50630. /**
  50631. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50632. */
  50633. set snapDistance(value: number);
  50634. get snapDistance(): number;
  50635. /**
  50636. * Ratio for the scale of the gizmo (Default: 1)
  50637. */
  50638. set scaleRatio(value: number);
  50639. get scaleRatio(): number;
  50640. /**
  50641. * Disposes of the gizmo
  50642. */
  50643. dispose(): void;
  50644. /**
  50645. * CustomMeshes are not supported by this gizmo
  50646. * @param mesh The mesh to replace the default mesh of the gizmo
  50647. */
  50648. setCustomMesh(mesh: Mesh): void;
  50649. }
  50650. }
  50651. declare module "babylonjs/Gizmos/gizmoManager" {
  50652. import { Observable } from "babylonjs/Misc/observable";
  50653. import { Nullable } from "babylonjs/types";
  50654. import { Scene, IDisposable } from "babylonjs/scene";
  50655. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50656. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50657. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  50658. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50659. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  50660. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50661. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  50662. /**
  50663. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  50664. */
  50665. export class GizmoManager implements IDisposable {
  50666. private scene;
  50667. /**
  50668. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  50669. */
  50670. gizmos: {
  50671. positionGizmo: Nullable<PositionGizmo>;
  50672. rotationGizmo: Nullable<RotationGizmo>;
  50673. scaleGizmo: Nullable<ScaleGizmo>;
  50674. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  50675. };
  50676. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  50677. clearGizmoOnEmptyPointerEvent: boolean;
  50678. /** Fires an event when the manager is attached to a mesh */
  50679. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  50680. private _gizmosEnabled;
  50681. private _pointerObserver;
  50682. private _attachedMesh;
  50683. private _boundingBoxColor;
  50684. private _defaultUtilityLayer;
  50685. private _defaultKeepDepthUtilityLayer;
  50686. /**
  50687. * When bounding box gizmo is enabled, this can be used to track drag/end events
  50688. */
  50689. boundingBoxDragBehavior: SixDofDragBehavior;
  50690. /**
  50691. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  50692. */
  50693. attachableMeshes: Nullable<Array<AbstractMesh>>;
  50694. /**
  50695. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  50696. */
  50697. usePointerToAttachGizmos: boolean;
  50698. /**
  50699. * Utility layer that the bounding box gizmo belongs to
  50700. */
  50701. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  50702. /**
  50703. * Utility layer that all gizmos besides bounding box belong to
  50704. */
  50705. get utilityLayer(): UtilityLayerRenderer;
  50706. /**
  50707. * Instatiates a gizmo manager
  50708. * @param scene the scene to overlay the gizmos on top of
  50709. */
  50710. constructor(scene: Scene);
  50711. /**
  50712. * Attaches a set of gizmos to the specified mesh
  50713. * @param mesh The mesh the gizmo's should be attached to
  50714. */
  50715. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50716. /**
  50717. * If the position gizmo is enabled
  50718. */
  50719. set positionGizmoEnabled(value: boolean);
  50720. get positionGizmoEnabled(): boolean;
  50721. /**
  50722. * If the rotation gizmo is enabled
  50723. */
  50724. set rotationGizmoEnabled(value: boolean);
  50725. get rotationGizmoEnabled(): boolean;
  50726. /**
  50727. * If the scale gizmo is enabled
  50728. */
  50729. set scaleGizmoEnabled(value: boolean);
  50730. get scaleGizmoEnabled(): boolean;
  50731. /**
  50732. * If the boundingBox gizmo is enabled
  50733. */
  50734. set boundingBoxGizmoEnabled(value: boolean);
  50735. get boundingBoxGizmoEnabled(): boolean;
  50736. /**
  50737. * Disposes of the gizmo manager
  50738. */
  50739. dispose(): void;
  50740. }
  50741. }
  50742. declare module "babylonjs/Lights/directionalLight" {
  50743. import { Camera } from "babylonjs/Cameras/camera";
  50744. import { Scene } from "babylonjs/scene";
  50745. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50746. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50747. import { Light } from "babylonjs/Lights/light";
  50748. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50749. import { Effect } from "babylonjs/Materials/effect";
  50750. /**
  50751. * A directional light is defined by a direction (what a surprise!).
  50752. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  50753. * 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.
  50754. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50755. */
  50756. export class DirectionalLight extends ShadowLight {
  50757. private _shadowFrustumSize;
  50758. /**
  50759. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  50760. */
  50761. get shadowFrustumSize(): number;
  50762. /**
  50763. * Specifies a fix frustum size for the shadow generation.
  50764. */
  50765. set shadowFrustumSize(value: number);
  50766. private _shadowOrthoScale;
  50767. /**
  50768. * Gets the shadow projection scale against the optimal computed one.
  50769. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50770. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50771. */
  50772. get shadowOrthoScale(): number;
  50773. /**
  50774. * Sets the shadow projection scale against the optimal computed one.
  50775. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50776. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50777. */
  50778. set shadowOrthoScale(value: number);
  50779. /**
  50780. * Automatically compute the projection matrix to best fit (including all the casters)
  50781. * on each frame.
  50782. */
  50783. autoUpdateExtends: boolean;
  50784. /**
  50785. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  50786. * on each frame. autoUpdateExtends must be set to true for this to work
  50787. */
  50788. autoCalcShadowZBounds: boolean;
  50789. private _orthoLeft;
  50790. private _orthoRight;
  50791. private _orthoTop;
  50792. private _orthoBottom;
  50793. /**
  50794. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  50795. * The directional light is emitted from everywhere in the given direction.
  50796. * It can cast shadows.
  50797. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50798. * @param name The friendly name of the light
  50799. * @param direction The direction of the light
  50800. * @param scene The scene the light belongs to
  50801. */
  50802. constructor(name: string, direction: Vector3, scene: Scene);
  50803. /**
  50804. * Returns the string "DirectionalLight".
  50805. * @return The class name
  50806. */
  50807. getClassName(): string;
  50808. /**
  50809. * Returns the integer 1.
  50810. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50811. */
  50812. getTypeID(): number;
  50813. /**
  50814. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  50815. * Returns the DirectionalLight Shadow projection matrix.
  50816. */
  50817. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50818. /**
  50819. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  50820. * Returns the DirectionalLight Shadow projection matrix.
  50821. */
  50822. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  50823. /**
  50824. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  50825. * Returns the DirectionalLight Shadow projection matrix.
  50826. */
  50827. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50828. protected _buildUniformLayout(): void;
  50829. /**
  50830. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  50831. * @param effect The effect to update
  50832. * @param lightIndex The index of the light in the effect to update
  50833. * @returns The directional light
  50834. */
  50835. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  50836. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  50837. /**
  50838. * Gets the minZ used for shadow according to both the scene and the light.
  50839. *
  50840. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  50841. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  50842. * @param activeCamera The camera we are returning the min for
  50843. * @returns the depth min z
  50844. */
  50845. getDepthMinZ(activeCamera: Camera): number;
  50846. /**
  50847. * Gets the maxZ used for shadow according to both the scene and the light.
  50848. *
  50849. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  50850. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  50851. * @param activeCamera The camera we are returning the max for
  50852. * @returns the depth max z
  50853. */
  50854. getDepthMaxZ(activeCamera: Camera): number;
  50855. /**
  50856. * Prepares the list of defines specific to the light type.
  50857. * @param defines the list of defines
  50858. * @param lightIndex defines the index of the light for the effect
  50859. */
  50860. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50861. }
  50862. }
  50863. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  50864. import { Mesh } from "babylonjs/Meshes/mesh";
  50865. /**
  50866. * Class containing static functions to help procedurally build meshes
  50867. */
  50868. export class HemisphereBuilder {
  50869. /**
  50870. * Creates a hemisphere mesh
  50871. * @param name defines the name of the mesh
  50872. * @param options defines the options used to create the mesh
  50873. * @param scene defines the hosting scene
  50874. * @returns the hemisphere mesh
  50875. */
  50876. static CreateHemisphere(name: string, options: {
  50877. segments?: number;
  50878. diameter?: number;
  50879. sideOrientation?: number;
  50880. }, scene: any): Mesh;
  50881. }
  50882. }
  50883. declare module "babylonjs/Lights/spotLight" {
  50884. import { Nullable } from "babylonjs/types";
  50885. import { Scene } from "babylonjs/scene";
  50886. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50887. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50888. import { Effect } from "babylonjs/Materials/effect";
  50889. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50890. import { Light } from "babylonjs/Lights/light";
  50891. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50892. /**
  50893. * A spot light is defined by a position, a direction, an angle, and an exponent.
  50894. * These values define a cone of light starting from the position, emitting toward the direction.
  50895. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  50896. * and the exponent defines the speed of the decay of the light with distance (reach).
  50897. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50898. */
  50899. export class SpotLight extends ShadowLight {
  50900. private _angle;
  50901. private _innerAngle;
  50902. private _cosHalfAngle;
  50903. private _lightAngleScale;
  50904. private _lightAngleOffset;
  50905. /**
  50906. * Gets the cone angle of the spot light in Radians.
  50907. */
  50908. get angle(): number;
  50909. /**
  50910. * Sets the cone angle of the spot light in Radians.
  50911. */
  50912. set angle(value: number);
  50913. /**
  50914. * Only used in gltf falloff mode, this defines the angle where
  50915. * the directional falloff will start before cutting at angle which could be seen
  50916. * as outer angle.
  50917. */
  50918. get innerAngle(): number;
  50919. /**
  50920. * Only used in gltf falloff mode, this defines the angle where
  50921. * the directional falloff will start before cutting at angle which could be seen
  50922. * as outer angle.
  50923. */
  50924. set innerAngle(value: number);
  50925. private _shadowAngleScale;
  50926. /**
  50927. * Allows scaling the angle of the light for shadow generation only.
  50928. */
  50929. get shadowAngleScale(): number;
  50930. /**
  50931. * Allows scaling the angle of the light for shadow generation only.
  50932. */
  50933. set shadowAngleScale(value: number);
  50934. /**
  50935. * The light decay speed with the distance from the emission spot.
  50936. */
  50937. exponent: number;
  50938. private _projectionTextureMatrix;
  50939. /**
  50940. * Allows reading the projecton texture
  50941. */
  50942. get projectionTextureMatrix(): Matrix;
  50943. protected _projectionTextureLightNear: number;
  50944. /**
  50945. * Gets the near clip of the Spotlight for texture projection.
  50946. */
  50947. get projectionTextureLightNear(): number;
  50948. /**
  50949. * Sets the near clip of the Spotlight for texture projection.
  50950. */
  50951. set projectionTextureLightNear(value: number);
  50952. protected _projectionTextureLightFar: number;
  50953. /**
  50954. * Gets the far clip of the Spotlight for texture projection.
  50955. */
  50956. get projectionTextureLightFar(): number;
  50957. /**
  50958. * Sets the far clip of the Spotlight for texture projection.
  50959. */
  50960. set projectionTextureLightFar(value: number);
  50961. protected _projectionTextureUpDirection: Vector3;
  50962. /**
  50963. * Gets the Up vector of the Spotlight for texture projection.
  50964. */
  50965. get projectionTextureUpDirection(): Vector3;
  50966. /**
  50967. * Sets the Up vector of the Spotlight for texture projection.
  50968. */
  50969. set projectionTextureUpDirection(value: Vector3);
  50970. private _projectionTexture;
  50971. /**
  50972. * Gets the projection texture of the light.
  50973. */
  50974. get projectionTexture(): Nullable<BaseTexture>;
  50975. /**
  50976. * Sets the projection texture of the light.
  50977. */
  50978. set projectionTexture(value: Nullable<BaseTexture>);
  50979. private _projectionTextureViewLightDirty;
  50980. private _projectionTextureProjectionLightDirty;
  50981. private _projectionTextureDirty;
  50982. private _projectionTextureViewTargetVector;
  50983. private _projectionTextureViewLightMatrix;
  50984. private _projectionTextureProjectionLightMatrix;
  50985. private _projectionTextureScalingMatrix;
  50986. /**
  50987. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  50988. * It can cast shadows.
  50989. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50990. * @param name The light friendly name
  50991. * @param position The position of the spot light in the scene
  50992. * @param direction The direction of the light in the scene
  50993. * @param angle The cone angle of the light in Radians
  50994. * @param exponent The light decay speed with the distance from the emission spot
  50995. * @param scene The scene the lights belongs to
  50996. */
  50997. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  50998. /**
  50999. * Returns the string "SpotLight".
  51000. * @returns the class name
  51001. */
  51002. getClassName(): string;
  51003. /**
  51004. * Returns the integer 2.
  51005. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51006. */
  51007. getTypeID(): number;
  51008. /**
  51009. * Overrides the direction setter to recompute the projection texture view light Matrix.
  51010. */
  51011. protected _setDirection(value: Vector3): void;
  51012. /**
  51013. * Overrides the position setter to recompute the projection texture view light Matrix.
  51014. */
  51015. protected _setPosition(value: Vector3): void;
  51016. /**
  51017. * 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.
  51018. * Returns the SpotLight.
  51019. */
  51020. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51021. protected _computeProjectionTextureViewLightMatrix(): void;
  51022. protected _computeProjectionTextureProjectionLightMatrix(): void;
  51023. /**
  51024. * Main function for light texture projection matrix computing.
  51025. */
  51026. protected _computeProjectionTextureMatrix(): void;
  51027. protected _buildUniformLayout(): void;
  51028. private _computeAngleValues;
  51029. /**
  51030. * Sets the passed Effect "effect" with the Light textures.
  51031. * @param effect The effect to update
  51032. * @param lightIndex The index of the light in the effect to update
  51033. * @returns The light
  51034. */
  51035. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  51036. /**
  51037. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  51038. * @param effect The effect to update
  51039. * @param lightIndex The index of the light in the effect to update
  51040. * @returns The spot light
  51041. */
  51042. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  51043. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  51044. /**
  51045. * Disposes the light and the associated resources.
  51046. */
  51047. dispose(): void;
  51048. /**
  51049. * Prepares the list of defines specific to the light type.
  51050. * @param defines the list of defines
  51051. * @param lightIndex defines the index of the light for the effect
  51052. */
  51053. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51054. }
  51055. }
  51056. declare module "babylonjs/Gizmos/lightGizmo" {
  51057. import { Nullable } from "babylonjs/types";
  51058. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51059. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51060. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51061. import { Light } from "babylonjs/Lights/light";
  51062. /**
  51063. * Gizmo that enables viewing a light
  51064. */
  51065. export class LightGizmo extends Gizmo {
  51066. private _lightMesh;
  51067. private _material;
  51068. private _cachedPosition;
  51069. private _cachedForward;
  51070. private _attachedMeshParent;
  51071. /**
  51072. * Creates a LightGizmo
  51073. * @param gizmoLayer The utility layer the gizmo will be added to
  51074. */
  51075. constructor(gizmoLayer?: UtilityLayerRenderer);
  51076. private _light;
  51077. /**
  51078. * The light that the gizmo is attached to
  51079. */
  51080. set light(light: Nullable<Light>);
  51081. get light(): Nullable<Light>;
  51082. /**
  51083. * Gets the material used to render the light gizmo
  51084. */
  51085. get material(): StandardMaterial;
  51086. /**
  51087. * @hidden
  51088. * Updates the gizmo to match the attached mesh's position/rotation
  51089. */
  51090. protected _update(): void;
  51091. private static _Scale;
  51092. /**
  51093. * Creates the lines for a light mesh
  51094. */
  51095. private static _CreateLightLines;
  51096. /**
  51097. * Disposes of the light gizmo
  51098. */
  51099. dispose(): void;
  51100. private static _CreateHemisphericLightMesh;
  51101. private static _CreatePointLightMesh;
  51102. private static _CreateSpotLightMesh;
  51103. private static _CreateDirectionalLightMesh;
  51104. }
  51105. }
  51106. declare module "babylonjs/Gizmos/index" {
  51107. export * from "babylonjs/Gizmos/axisDragGizmo";
  51108. export * from "babylonjs/Gizmos/axisScaleGizmo";
  51109. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  51110. export * from "babylonjs/Gizmos/gizmo";
  51111. export * from "babylonjs/Gizmos/gizmoManager";
  51112. export * from "babylonjs/Gizmos/planeRotationGizmo";
  51113. export * from "babylonjs/Gizmos/positionGizmo";
  51114. export * from "babylonjs/Gizmos/rotationGizmo";
  51115. export * from "babylonjs/Gizmos/scaleGizmo";
  51116. export * from "babylonjs/Gizmos/lightGizmo";
  51117. export * from "babylonjs/Gizmos/planeDragGizmo";
  51118. }
  51119. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  51120. /** @hidden */
  51121. export var backgroundFragmentDeclaration: {
  51122. name: string;
  51123. shader: string;
  51124. };
  51125. }
  51126. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  51127. /** @hidden */
  51128. export var backgroundUboDeclaration: {
  51129. name: string;
  51130. shader: string;
  51131. };
  51132. }
  51133. declare module "babylonjs/Shaders/background.fragment" {
  51134. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  51135. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51136. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  51137. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51138. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51139. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51140. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51141. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  51142. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  51143. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51144. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  51145. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  51146. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51147. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  51148. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  51149. /** @hidden */
  51150. export var backgroundPixelShader: {
  51151. name: string;
  51152. shader: string;
  51153. };
  51154. }
  51155. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  51156. /** @hidden */
  51157. export var backgroundVertexDeclaration: {
  51158. name: string;
  51159. shader: string;
  51160. };
  51161. }
  51162. declare module "babylonjs/Shaders/background.vertex" {
  51163. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  51164. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51165. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51166. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51167. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51168. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  51169. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  51170. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51171. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51172. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51173. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51174. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51175. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  51176. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  51177. /** @hidden */
  51178. export var backgroundVertexShader: {
  51179. name: string;
  51180. shader: string;
  51181. };
  51182. }
  51183. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  51184. import { Nullable, int, float } from "babylonjs/types";
  51185. import { Scene } from "babylonjs/scene";
  51186. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51187. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51188. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51189. import { Mesh } from "babylonjs/Meshes/mesh";
  51190. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  51191. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  51192. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  51193. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51194. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  51195. import { Color3 } from "babylonjs/Maths/math.color";
  51196. import "babylonjs/Shaders/background.fragment";
  51197. import "babylonjs/Shaders/background.vertex";
  51198. /**
  51199. * Background material used to create an efficient environement around your scene.
  51200. */
  51201. export class BackgroundMaterial extends PushMaterial {
  51202. /**
  51203. * Standard reflectance value at parallel view angle.
  51204. */
  51205. static StandardReflectance0: number;
  51206. /**
  51207. * Standard reflectance value at grazing angle.
  51208. */
  51209. static StandardReflectance90: number;
  51210. protected _primaryColor: Color3;
  51211. /**
  51212. * Key light Color (multiply against the environement texture)
  51213. */
  51214. primaryColor: Color3;
  51215. protected __perceptualColor: Nullable<Color3>;
  51216. /**
  51217. * Experimental Internal Use Only.
  51218. *
  51219. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  51220. * This acts as a helper to set the primary color to a more "human friendly" value.
  51221. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  51222. * output color as close as possible from the chosen value.
  51223. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  51224. * part of lighting setup.)
  51225. */
  51226. get _perceptualColor(): Nullable<Color3>;
  51227. set _perceptualColor(value: Nullable<Color3>);
  51228. protected _primaryColorShadowLevel: float;
  51229. /**
  51230. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  51231. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  51232. */
  51233. get primaryColorShadowLevel(): float;
  51234. set primaryColorShadowLevel(value: float);
  51235. protected _primaryColorHighlightLevel: float;
  51236. /**
  51237. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  51238. * The primary color is used at the level chosen to define what the white area would look.
  51239. */
  51240. get primaryColorHighlightLevel(): float;
  51241. set primaryColorHighlightLevel(value: float);
  51242. protected _reflectionTexture: Nullable<BaseTexture>;
  51243. /**
  51244. * Reflection Texture used in the material.
  51245. * Should be author in a specific way for the best result (refer to the documentation).
  51246. */
  51247. reflectionTexture: Nullable<BaseTexture>;
  51248. protected _reflectionBlur: float;
  51249. /**
  51250. * Reflection Texture level of blur.
  51251. *
  51252. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  51253. * texture twice.
  51254. */
  51255. reflectionBlur: float;
  51256. protected _diffuseTexture: Nullable<BaseTexture>;
  51257. /**
  51258. * Diffuse Texture used in the material.
  51259. * Should be author in a specific way for the best result (refer to the documentation).
  51260. */
  51261. diffuseTexture: Nullable<BaseTexture>;
  51262. protected _shadowLights: Nullable<IShadowLight[]>;
  51263. /**
  51264. * Specify the list of lights casting shadow on the material.
  51265. * All scene shadow lights will be included if null.
  51266. */
  51267. shadowLights: Nullable<IShadowLight[]>;
  51268. protected _shadowLevel: float;
  51269. /**
  51270. * Helps adjusting the shadow to a softer level if required.
  51271. * 0 means black shadows and 1 means no shadows.
  51272. */
  51273. shadowLevel: float;
  51274. protected _sceneCenter: Vector3;
  51275. /**
  51276. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  51277. * It is usually zero but might be interesting to modify according to your setup.
  51278. */
  51279. sceneCenter: Vector3;
  51280. protected _opacityFresnel: boolean;
  51281. /**
  51282. * This helps specifying that the material is falling off to the sky box at grazing angle.
  51283. * This helps ensuring a nice transition when the camera goes under the ground.
  51284. */
  51285. opacityFresnel: boolean;
  51286. protected _reflectionFresnel: boolean;
  51287. /**
  51288. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  51289. * This helps adding a mirror texture on the ground.
  51290. */
  51291. reflectionFresnel: boolean;
  51292. protected _reflectionFalloffDistance: number;
  51293. /**
  51294. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  51295. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  51296. */
  51297. reflectionFalloffDistance: number;
  51298. protected _reflectionAmount: number;
  51299. /**
  51300. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  51301. */
  51302. reflectionAmount: number;
  51303. protected _reflectionReflectance0: number;
  51304. /**
  51305. * This specifies the weight of the reflection at grazing angle.
  51306. */
  51307. reflectionReflectance0: number;
  51308. protected _reflectionReflectance90: number;
  51309. /**
  51310. * This specifies the weight of the reflection at a perpendicular point of view.
  51311. */
  51312. reflectionReflectance90: number;
  51313. /**
  51314. * Sets the reflection reflectance fresnel values according to the default standard
  51315. * empirically know to work well :-)
  51316. */
  51317. set reflectionStandardFresnelWeight(value: number);
  51318. protected _useRGBColor: boolean;
  51319. /**
  51320. * Helps to directly use the maps channels instead of their level.
  51321. */
  51322. useRGBColor: boolean;
  51323. protected _enableNoise: boolean;
  51324. /**
  51325. * This helps reducing the banding effect that could occur on the background.
  51326. */
  51327. enableNoise: boolean;
  51328. /**
  51329. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51330. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  51331. * Recommended to be keep at 1.0 except for special cases.
  51332. */
  51333. get fovMultiplier(): number;
  51334. set fovMultiplier(value: number);
  51335. private _fovMultiplier;
  51336. /**
  51337. * Enable the FOV adjustment feature controlled by fovMultiplier.
  51338. */
  51339. useEquirectangularFOV: boolean;
  51340. private _maxSimultaneousLights;
  51341. /**
  51342. * Number of Simultaneous lights allowed on the material.
  51343. */
  51344. maxSimultaneousLights: int;
  51345. /**
  51346. * Default configuration related to image processing available in the Background Material.
  51347. */
  51348. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51349. /**
  51350. * Keep track of the image processing observer to allow dispose and replace.
  51351. */
  51352. private _imageProcessingObserver;
  51353. /**
  51354. * Attaches a new image processing configuration to the PBR Material.
  51355. * @param configuration (if null the scene configuration will be use)
  51356. */
  51357. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51358. /**
  51359. * Gets the image processing configuration used either in this material.
  51360. */
  51361. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  51362. /**
  51363. * Sets the Default image processing configuration used either in the this material.
  51364. *
  51365. * If sets to null, the scene one is in use.
  51366. */
  51367. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  51368. /**
  51369. * Gets wether the color curves effect is enabled.
  51370. */
  51371. get cameraColorCurvesEnabled(): boolean;
  51372. /**
  51373. * Sets wether the color curves effect is enabled.
  51374. */
  51375. set cameraColorCurvesEnabled(value: boolean);
  51376. /**
  51377. * Gets wether the color grading effect is enabled.
  51378. */
  51379. get cameraColorGradingEnabled(): boolean;
  51380. /**
  51381. * Gets wether the color grading effect is enabled.
  51382. */
  51383. set cameraColorGradingEnabled(value: boolean);
  51384. /**
  51385. * Gets wether tonemapping is enabled or not.
  51386. */
  51387. get cameraToneMappingEnabled(): boolean;
  51388. /**
  51389. * Sets wether tonemapping is enabled or not
  51390. */
  51391. set cameraToneMappingEnabled(value: boolean);
  51392. /**
  51393. * The camera exposure used on this material.
  51394. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51395. * This corresponds to a photographic exposure.
  51396. */
  51397. get cameraExposure(): float;
  51398. /**
  51399. * The camera exposure used on this material.
  51400. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51401. * This corresponds to a photographic exposure.
  51402. */
  51403. set cameraExposure(value: float);
  51404. /**
  51405. * Gets The camera contrast used on this material.
  51406. */
  51407. get cameraContrast(): float;
  51408. /**
  51409. * Sets The camera contrast used on this material.
  51410. */
  51411. set cameraContrast(value: float);
  51412. /**
  51413. * Gets the Color Grading 2D Lookup Texture.
  51414. */
  51415. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  51416. /**
  51417. * Sets the Color Grading 2D Lookup Texture.
  51418. */
  51419. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  51420. /**
  51421. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51422. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51423. * 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;
  51424. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51425. */
  51426. get cameraColorCurves(): Nullable<ColorCurves>;
  51427. /**
  51428. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51429. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51430. * 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;
  51431. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51432. */
  51433. set cameraColorCurves(value: Nullable<ColorCurves>);
  51434. /**
  51435. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  51436. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  51437. */
  51438. switchToBGR: boolean;
  51439. private _renderTargets;
  51440. private _reflectionControls;
  51441. private _white;
  51442. private _primaryShadowColor;
  51443. private _primaryHighlightColor;
  51444. /**
  51445. * Instantiates a Background Material in the given scene
  51446. * @param name The friendly name of the material
  51447. * @param scene The scene to add the material to
  51448. */
  51449. constructor(name: string, scene: Scene);
  51450. /**
  51451. * Gets a boolean indicating that current material needs to register RTT
  51452. */
  51453. get hasRenderTargetTextures(): boolean;
  51454. /**
  51455. * The entire material has been created in order to prevent overdraw.
  51456. * @returns false
  51457. */
  51458. needAlphaTesting(): boolean;
  51459. /**
  51460. * The entire material has been created in order to prevent overdraw.
  51461. * @returns true if blending is enable
  51462. */
  51463. needAlphaBlending(): boolean;
  51464. /**
  51465. * Checks wether the material is ready to be rendered for a given mesh.
  51466. * @param mesh The mesh to render
  51467. * @param subMesh The submesh to check against
  51468. * @param useInstances Specify wether or not the material is used with instances
  51469. * @returns true if all the dependencies are ready (Textures, Effects...)
  51470. */
  51471. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51472. /**
  51473. * Compute the primary color according to the chosen perceptual color.
  51474. */
  51475. private _computePrimaryColorFromPerceptualColor;
  51476. /**
  51477. * Compute the highlights and shadow colors according to their chosen levels.
  51478. */
  51479. private _computePrimaryColors;
  51480. /**
  51481. * Build the uniform buffer used in the material.
  51482. */
  51483. buildUniformLayout(): void;
  51484. /**
  51485. * Unbind the material.
  51486. */
  51487. unbind(): void;
  51488. /**
  51489. * Bind only the world matrix to the material.
  51490. * @param world The world matrix to bind.
  51491. */
  51492. bindOnlyWorldMatrix(world: Matrix): void;
  51493. /**
  51494. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  51495. * @param world The world matrix to bind.
  51496. * @param subMesh The submesh to bind for.
  51497. */
  51498. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51499. /**
  51500. * Checks to see if a texture is used in the material.
  51501. * @param texture - Base texture to use.
  51502. * @returns - Boolean specifying if a texture is used in the material.
  51503. */
  51504. hasTexture(texture: BaseTexture): boolean;
  51505. /**
  51506. * Dispose the material.
  51507. * @param forceDisposeEffect Force disposal of the associated effect.
  51508. * @param forceDisposeTextures Force disposal of the associated textures.
  51509. */
  51510. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51511. /**
  51512. * Clones the material.
  51513. * @param name The cloned name.
  51514. * @returns The cloned material.
  51515. */
  51516. clone(name: string): BackgroundMaterial;
  51517. /**
  51518. * Serializes the current material to its JSON representation.
  51519. * @returns The JSON representation.
  51520. */
  51521. serialize(): any;
  51522. /**
  51523. * Gets the class name of the material
  51524. * @returns "BackgroundMaterial"
  51525. */
  51526. getClassName(): string;
  51527. /**
  51528. * Parse a JSON input to create back a background material.
  51529. * @param source The JSON data to parse
  51530. * @param scene The scene to create the parsed material in
  51531. * @param rootUrl The root url of the assets the material depends upon
  51532. * @returns the instantiated BackgroundMaterial.
  51533. */
  51534. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  51535. }
  51536. }
  51537. declare module "babylonjs/Helpers/environmentHelper" {
  51538. import { Observable } from "babylonjs/Misc/observable";
  51539. import { Nullable } from "babylonjs/types";
  51540. import { Scene } from "babylonjs/scene";
  51541. import { Vector3 } from "babylonjs/Maths/math.vector";
  51542. import { Color3 } from "babylonjs/Maths/math.color";
  51543. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51544. import { Mesh } from "babylonjs/Meshes/mesh";
  51545. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51546. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  51547. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51548. import "babylonjs/Meshes/Builders/planeBuilder";
  51549. import "babylonjs/Meshes/Builders/boxBuilder";
  51550. /**
  51551. * Represents the different options available during the creation of
  51552. * a Environment helper.
  51553. *
  51554. * This can control the default ground, skybox and image processing setup of your scene.
  51555. */
  51556. export interface IEnvironmentHelperOptions {
  51557. /**
  51558. * Specifies whether or not to create a ground.
  51559. * True by default.
  51560. */
  51561. createGround: boolean;
  51562. /**
  51563. * Specifies the ground size.
  51564. * 15 by default.
  51565. */
  51566. groundSize: number;
  51567. /**
  51568. * The texture used on the ground for the main color.
  51569. * Comes from the BabylonJS CDN by default.
  51570. *
  51571. * Remarks: Can be either a texture or a url.
  51572. */
  51573. groundTexture: string | BaseTexture;
  51574. /**
  51575. * The color mixed in the ground texture by default.
  51576. * BabylonJS clearColor by default.
  51577. */
  51578. groundColor: Color3;
  51579. /**
  51580. * Specifies the ground opacity.
  51581. * 1 by default.
  51582. */
  51583. groundOpacity: number;
  51584. /**
  51585. * Enables the ground to receive shadows.
  51586. * True by default.
  51587. */
  51588. enableGroundShadow: boolean;
  51589. /**
  51590. * Helps preventing the shadow to be fully black on the ground.
  51591. * 0.5 by default.
  51592. */
  51593. groundShadowLevel: number;
  51594. /**
  51595. * Creates a mirror texture attach to the ground.
  51596. * false by default.
  51597. */
  51598. enableGroundMirror: boolean;
  51599. /**
  51600. * Specifies the ground mirror size ratio.
  51601. * 0.3 by default as the default kernel is 64.
  51602. */
  51603. groundMirrorSizeRatio: number;
  51604. /**
  51605. * Specifies the ground mirror blur kernel size.
  51606. * 64 by default.
  51607. */
  51608. groundMirrorBlurKernel: number;
  51609. /**
  51610. * Specifies the ground mirror visibility amount.
  51611. * 1 by default
  51612. */
  51613. groundMirrorAmount: number;
  51614. /**
  51615. * Specifies the ground mirror reflectance weight.
  51616. * This uses the standard weight of the background material to setup the fresnel effect
  51617. * of the mirror.
  51618. * 1 by default.
  51619. */
  51620. groundMirrorFresnelWeight: number;
  51621. /**
  51622. * Specifies the ground mirror Falloff distance.
  51623. * This can helps reducing the size of the reflection.
  51624. * 0 by Default.
  51625. */
  51626. groundMirrorFallOffDistance: number;
  51627. /**
  51628. * Specifies the ground mirror texture type.
  51629. * Unsigned Int by Default.
  51630. */
  51631. groundMirrorTextureType: number;
  51632. /**
  51633. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  51634. * the shown objects.
  51635. */
  51636. groundYBias: number;
  51637. /**
  51638. * Specifies whether or not to create a skybox.
  51639. * True by default.
  51640. */
  51641. createSkybox: boolean;
  51642. /**
  51643. * Specifies the skybox size.
  51644. * 20 by default.
  51645. */
  51646. skyboxSize: number;
  51647. /**
  51648. * The texture used on the skybox for the main color.
  51649. * Comes from the BabylonJS CDN by default.
  51650. *
  51651. * Remarks: Can be either a texture or a url.
  51652. */
  51653. skyboxTexture: string | BaseTexture;
  51654. /**
  51655. * The color mixed in the skybox texture by default.
  51656. * BabylonJS clearColor by default.
  51657. */
  51658. skyboxColor: Color3;
  51659. /**
  51660. * The background rotation around the Y axis of the scene.
  51661. * This helps aligning the key lights of your scene with the background.
  51662. * 0 by default.
  51663. */
  51664. backgroundYRotation: number;
  51665. /**
  51666. * Compute automatically the size of the elements to best fit with the scene.
  51667. */
  51668. sizeAuto: boolean;
  51669. /**
  51670. * Default position of the rootMesh if autoSize is not true.
  51671. */
  51672. rootPosition: Vector3;
  51673. /**
  51674. * Sets up the image processing in the scene.
  51675. * true by default.
  51676. */
  51677. setupImageProcessing: boolean;
  51678. /**
  51679. * The texture used as your environment texture in the scene.
  51680. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  51681. *
  51682. * Remarks: Can be either a texture or a url.
  51683. */
  51684. environmentTexture: string | BaseTexture;
  51685. /**
  51686. * The value of the exposure to apply to the scene.
  51687. * 0.6 by default if setupImageProcessing is true.
  51688. */
  51689. cameraExposure: number;
  51690. /**
  51691. * The value of the contrast to apply to the scene.
  51692. * 1.6 by default if setupImageProcessing is true.
  51693. */
  51694. cameraContrast: number;
  51695. /**
  51696. * Specifies whether or not tonemapping should be enabled in the scene.
  51697. * true by default if setupImageProcessing is true.
  51698. */
  51699. toneMappingEnabled: boolean;
  51700. }
  51701. /**
  51702. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  51703. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  51704. * It also helps with the default setup of your imageProcessing configuration.
  51705. */
  51706. export class EnvironmentHelper {
  51707. /**
  51708. * Default ground texture URL.
  51709. */
  51710. private static _groundTextureCDNUrl;
  51711. /**
  51712. * Default skybox texture URL.
  51713. */
  51714. private static _skyboxTextureCDNUrl;
  51715. /**
  51716. * Default environment texture URL.
  51717. */
  51718. private static _environmentTextureCDNUrl;
  51719. /**
  51720. * Creates the default options for the helper.
  51721. */
  51722. private static _getDefaultOptions;
  51723. private _rootMesh;
  51724. /**
  51725. * Gets the root mesh created by the helper.
  51726. */
  51727. get rootMesh(): Mesh;
  51728. private _skybox;
  51729. /**
  51730. * Gets the skybox created by the helper.
  51731. */
  51732. get skybox(): Nullable<Mesh>;
  51733. private _skyboxTexture;
  51734. /**
  51735. * Gets the skybox texture created by the helper.
  51736. */
  51737. get skyboxTexture(): Nullable<BaseTexture>;
  51738. private _skyboxMaterial;
  51739. /**
  51740. * Gets the skybox material created by the helper.
  51741. */
  51742. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  51743. private _ground;
  51744. /**
  51745. * Gets the ground mesh created by the helper.
  51746. */
  51747. get ground(): Nullable<Mesh>;
  51748. private _groundTexture;
  51749. /**
  51750. * Gets the ground texture created by the helper.
  51751. */
  51752. get groundTexture(): Nullable<BaseTexture>;
  51753. private _groundMirror;
  51754. /**
  51755. * Gets the ground mirror created by the helper.
  51756. */
  51757. get groundMirror(): Nullable<MirrorTexture>;
  51758. /**
  51759. * Gets the ground mirror render list to helps pushing the meshes
  51760. * you wish in the ground reflection.
  51761. */
  51762. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  51763. private _groundMaterial;
  51764. /**
  51765. * Gets the ground material created by the helper.
  51766. */
  51767. get groundMaterial(): Nullable<BackgroundMaterial>;
  51768. /**
  51769. * Stores the creation options.
  51770. */
  51771. private readonly _scene;
  51772. private _options;
  51773. /**
  51774. * This observable will be notified with any error during the creation of the environment,
  51775. * mainly texture creation errors.
  51776. */
  51777. onErrorObservable: Observable<{
  51778. message?: string;
  51779. exception?: any;
  51780. }>;
  51781. /**
  51782. * constructor
  51783. * @param options Defines the options we want to customize the helper
  51784. * @param scene The scene to add the material to
  51785. */
  51786. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  51787. /**
  51788. * Updates the background according to the new options
  51789. * @param options
  51790. */
  51791. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  51792. /**
  51793. * Sets the primary color of all the available elements.
  51794. * @param color the main color to affect to the ground and the background
  51795. */
  51796. setMainColor(color: Color3): void;
  51797. /**
  51798. * Setup the image processing according to the specified options.
  51799. */
  51800. private _setupImageProcessing;
  51801. /**
  51802. * Setup the environment texture according to the specified options.
  51803. */
  51804. private _setupEnvironmentTexture;
  51805. /**
  51806. * Setup the background according to the specified options.
  51807. */
  51808. private _setupBackground;
  51809. /**
  51810. * Get the scene sizes according to the setup.
  51811. */
  51812. private _getSceneSize;
  51813. /**
  51814. * Setup the ground according to the specified options.
  51815. */
  51816. private _setupGround;
  51817. /**
  51818. * Setup the ground material according to the specified options.
  51819. */
  51820. private _setupGroundMaterial;
  51821. /**
  51822. * Setup the ground diffuse texture according to the specified options.
  51823. */
  51824. private _setupGroundDiffuseTexture;
  51825. /**
  51826. * Setup the ground mirror texture according to the specified options.
  51827. */
  51828. private _setupGroundMirrorTexture;
  51829. /**
  51830. * Setup the ground to receive the mirror texture.
  51831. */
  51832. private _setupMirrorInGroundMaterial;
  51833. /**
  51834. * Setup the skybox according to the specified options.
  51835. */
  51836. private _setupSkybox;
  51837. /**
  51838. * Setup the skybox material according to the specified options.
  51839. */
  51840. private _setupSkyboxMaterial;
  51841. /**
  51842. * Setup the skybox reflection texture according to the specified options.
  51843. */
  51844. private _setupSkyboxReflectionTexture;
  51845. private _errorHandler;
  51846. /**
  51847. * Dispose all the elements created by the Helper.
  51848. */
  51849. dispose(): void;
  51850. }
  51851. }
  51852. declare module "babylonjs/Helpers/photoDome" {
  51853. import { Observable } from "babylonjs/Misc/observable";
  51854. import { Nullable } from "babylonjs/types";
  51855. import { Scene } from "babylonjs/scene";
  51856. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51857. import { Mesh } from "babylonjs/Meshes/mesh";
  51858. import { Texture } from "babylonjs/Materials/Textures/texture";
  51859. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51860. import "babylonjs/Meshes/Builders/sphereBuilder";
  51861. /**
  51862. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  51863. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  51864. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  51865. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51866. */
  51867. export class PhotoDome extends TransformNode {
  51868. /**
  51869. * Define the image as a Monoscopic panoramic 360 image.
  51870. */
  51871. static readonly MODE_MONOSCOPIC: number;
  51872. /**
  51873. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  51874. */
  51875. static readonly MODE_TOPBOTTOM: number;
  51876. /**
  51877. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  51878. */
  51879. static readonly MODE_SIDEBYSIDE: number;
  51880. private _useDirectMapping;
  51881. /**
  51882. * The texture being displayed on the sphere
  51883. */
  51884. protected _photoTexture: Texture;
  51885. /**
  51886. * Gets or sets the texture being displayed on the sphere
  51887. */
  51888. get photoTexture(): Texture;
  51889. set photoTexture(value: Texture);
  51890. /**
  51891. * Observable raised when an error occured while loading the 360 image
  51892. */
  51893. onLoadErrorObservable: Observable<string>;
  51894. /**
  51895. * The skybox material
  51896. */
  51897. protected _material: BackgroundMaterial;
  51898. /**
  51899. * The surface used for the skybox
  51900. */
  51901. protected _mesh: Mesh;
  51902. /**
  51903. * Gets the mesh used for the skybox.
  51904. */
  51905. get mesh(): Mesh;
  51906. /**
  51907. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51908. * Also see the options.resolution property.
  51909. */
  51910. get fovMultiplier(): number;
  51911. set fovMultiplier(value: number);
  51912. private _imageMode;
  51913. /**
  51914. * Gets or set the current video mode for the video. It can be:
  51915. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  51916. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  51917. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  51918. */
  51919. get imageMode(): number;
  51920. set imageMode(value: number);
  51921. /**
  51922. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  51923. * @param name Element's name, child elements will append suffixes for their own names.
  51924. * @param urlsOfPhoto defines the url of the photo to display
  51925. * @param options defines an object containing optional or exposed sub element properties
  51926. * @param onError defines a callback called when an error occured while loading the texture
  51927. */
  51928. constructor(name: string, urlOfPhoto: string, options: {
  51929. resolution?: number;
  51930. size?: number;
  51931. useDirectMapping?: boolean;
  51932. faceForward?: boolean;
  51933. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  51934. private _onBeforeCameraRenderObserver;
  51935. private _changeImageMode;
  51936. /**
  51937. * Releases resources associated with this node.
  51938. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51939. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51940. */
  51941. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51942. }
  51943. }
  51944. declare module "babylonjs/Misc/rgbdTextureTools" {
  51945. import "babylonjs/Shaders/rgbdDecode.fragment";
  51946. import "babylonjs/Engines/Extensions/engine.renderTarget";
  51947. import { Texture } from "babylonjs/Materials/Textures/texture";
  51948. /**
  51949. * Class used to host RGBD texture specific utilities
  51950. */
  51951. export class RGBDTextureTools {
  51952. /**
  51953. * Expand the RGBD Texture from RGBD to Half Float if possible.
  51954. * @param texture the texture to expand.
  51955. */
  51956. static ExpandRGBDTexture(texture: Texture): void;
  51957. }
  51958. }
  51959. declare module "babylonjs/Misc/brdfTextureTools" {
  51960. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51961. import { Scene } from "babylonjs/scene";
  51962. /**
  51963. * Class used to host texture specific utilities
  51964. */
  51965. export class BRDFTextureTools {
  51966. /**
  51967. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  51968. * @param scene defines the hosting scene
  51969. * @returns the environment BRDF texture
  51970. */
  51971. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  51972. private static _environmentBRDFBase64Texture;
  51973. }
  51974. }
  51975. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  51976. import { Nullable } from "babylonjs/types";
  51977. import { Color3 } from "babylonjs/Maths/math.color";
  51978. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51979. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  51980. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51981. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  51982. import { Engine } from "babylonjs/Engines/engine";
  51983. import { Scene } from "babylonjs/scene";
  51984. /**
  51985. * @hidden
  51986. */
  51987. export interface IMaterialClearCoatDefines {
  51988. CLEARCOAT: boolean;
  51989. CLEARCOAT_DEFAULTIOR: boolean;
  51990. CLEARCOAT_TEXTURE: boolean;
  51991. CLEARCOAT_TEXTUREDIRECTUV: number;
  51992. CLEARCOAT_BUMP: boolean;
  51993. CLEARCOAT_BUMPDIRECTUV: number;
  51994. CLEARCOAT_TINT: boolean;
  51995. CLEARCOAT_TINT_TEXTURE: boolean;
  51996. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  51997. /** @hidden */
  51998. _areTexturesDirty: boolean;
  51999. }
  52000. /**
  52001. * Define the code related to the clear coat parameters of the pbr material.
  52002. */
  52003. export class PBRClearCoatConfiguration {
  52004. /**
  52005. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52006. * The default fits with a polyurethane material.
  52007. */
  52008. private static readonly _DefaultIndexOfRefraction;
  52009. private _isEnabled;
  52010. /**
  52011. * Defines if the clear coat is enabled in the material.
  52012. */
  52013. isEnabled: boolean;
  52014. /**
  52015. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  52016. */
  52017. intensity: number;
  52018. /**
  52019. * Defines the clear coat layer roughness.
  52020. */
  52021. roughness: number;
  52022. private _indexOfRefraction;
  52023. /**
  52024. * Defines the index of refraction of the clear coat.
  52025. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52026. * The default fits with a polyurethane material.
  52027. * Changing the default value is more performance intensive.
  52028. */
  52029. indexOfRefraction: number;
  52030. private _texture;
  52031. /**
  52032. * Stores the clear coat values in a texture.
  52033. */
  52034. texture: Nullable<BaseTexture>;
  52035. private _bumpTexture;
  52036. /**
  52037. * Define the clear coat specific bump texture.
  52038. */
  52039. bumpTexture: Nullable<BaseTexture>;
  52040. private _isTintEnabled;
  52041. /**
  52042. * Defines if the clear coat tint is enabled in the material.
  52043. */
  52044. isTintEnabled: boolean;
  52045. /**
  52046. * Defines the clear coat tint of the material.
  52047. * This is only use if tint is enabled
  52048. */
  52049. tintColor: Color3;
  52050. /**
  52051. * Defines the distance at which the tint color should be found in the
  52052. * clear coat media.
  52053. * This is only use if tint is enabled
  52054. */
  52055. tintColorAtDistance: number;
  52056. /**
  52057. * Defines the clear coat layer thickness.
  52058. * This is only use if tint is enabled
  52059. */
  52060. tintThickness: number;
  52061. private _tintTexture;
  52062. /**
  52063. * Stores the clear tint values in a texture.
  52064. * rgb is tint
  52065. * a is a thickness factor
  52066. */
  52067. tintTexture: Nullable<BaseTexture>;
  52068. /** @hidden */
  52069. private _internalMarkAllSubMeshesAsTexturesDirty;
  52070. /** @hidden */
  52071. _markAllSubMeshesAsTexturesDirty(): void;
  52072. /**
  52073. * Instantiate a new istance of clear coat configuration.
  52074. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52075. */
  52076. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52077. /**
  52078. * Gets wehter the submesh is ready to be used or not.
  52079. * @param defines the list of "defines" to update.
  52080. * @param scene defines the scene the material belongs to.
  52081. * @param engine defines the engine the material belongs to.
  52082. * @param disableBumpMap defines wether the material disables bump or not.
  52083. * @returns - boolean indicating that the submesh is ready or not.
  52084. */
  52085. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  52086. /**
  52087. * Checks to see if a texture is used in the material.
  52088. * @param defines the list of "defines" to update.
  52089. * @param scene defines the scene to the material belongs to.
  52090. */
  52091. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  52092. /**
  52093. * Binds the material data.
  52094. * @param uniformBuffer defines the Uniform buffer to fill in.
  52095. * @param scene defines the scene the material belongs to.
  52096. * @param engine defines the engine the material belongs to.
  52097. * @param disableBumpMap defines wether the material disables bump or not.
  52098. * @param isFrozen defines wether the material is frozen or not.
  52099. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52100. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52101. */
  52102. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  52103. /**
  52104. * Checks to see if a texture is used in the material.
  52105. * @param texture - Base texture to use.
  52106. * @returns - Boolean specifying if a texture is used in the material.
  52107. */
  52108. hasTexture(texture: BaseTexture): boolean;
  52109. /**
  52110. * Returns an array of the actively used textures.
  52111. * @param activeTextures Array of BaseTextures
  52112. */
  52113. getActiveTextures(activeTextures: BaseTexture[]): void;
  52114. /**
  52115. * Returns the animatable textures.
  52116. * @param animatables Array of animatable textures.
  52117. */
  52118. getAnimatables(animatables: IAnimatable[]): void;
  52119. /**
  52120. * Disposes the resources of the material.
  52121. * @param forceDisposeTextures - Forces the disposal of all textures.
  52122. */
  52123. dispose(forceDisposeTextures?: boolean): void;
  52124. /**
  52125. * Get the current class name of the texture useful for serialization or dynamic coding.
  52126. * @returns "PBRClearCoatConfiguration"
  52127. */
  52128. getClassName(): string;
  52129. /**
  52130. * Add fallbacks to the effect fallbacks list.
  52131. * @param defines defines the Base texture to use.
  52132. * @param fallbacks defines the current fallback list.
  52133. * @param currentRank defines the current fallback rank.
  52134. * @returns the new fallback rank.
  52135. */
  52136. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52137. /**
  52138. * Add the required uniforms to the current list.
  52139. * @param uniforms defines the current uniform list.
  52140. */
  52141. static AddUniforms(uniforms: string[]): void;
  52142. /**
  52143. * Add the required samplers to the current list.
  52144. * @param samplers defines the current sampler list.
  52145. */
  52146. static AddSamplers(samplers: string[]): void;
  52147. /**
  52148. * Add the required uniforms to the current buffer.
  52149. * @param uniformBuffer defines the current uniform buffer.
  52150. */
  52151. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52152. /**
  52153. * Makes a duplicate of the current configuration into another one.
  52154. * @param clearCoatConfiguration define the config where to copy the info
  52155. */
  52156. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  52157. /**
  52158. * Serializes this clear coat configuration.
  52159. * @returns - An object with the serialized config.
  52160. */
  52161. serialize(): any;
  52162. /**
  52163. * Parses a anisotropy Configuration from a serialized object.
  52164. * @param source - Serialized object.
  52165. * @param scene Defines the scene we are parsing for
  52166. * @param rootUrl Defines the rootUrl to load from
  52167. */
  52168. parse(source: any, scene: Scene, rootUrl: string): void;
  52169. }
  52170. }
  52171. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  52172. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52173. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52174. import { Vector2 } from "babylonjs/Maths/math.vector";
  52175. import { Scene } from "babylonjs/scene";
  52176. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52177. import { Nullable } from "babylonjs/types";
  52178. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52179. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52180. /**
  52181. * @hidden
  52182. */
  52183. export interface IMaterialAnisotropicDefines {
  52184. ANISOTROPIC: boolean;
  52185. ANISOTROPIC_TEXTURE: boolean;
  52186. ANISOTROPIC_TEXTUREDIRECTUV: number;
  52187. MAINUV1: boolean;
  52188. _areTexturesDirty: boolean;
  52189. _needUVs: boolean;
  52190. }
  52191. /**
  52192. * Define the code related to the anisotropic parameters of the pbr material.
  52193. */
  52194. export class PBRAnisotropicConfiguration {
  52195. private _isEnabled;
  52196. /**
  52197. * Defines if the anisotropy is enabled in the material.
  52198. */
  52199. isEnabled: boolean;
  52200. /**
  52201. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  52202. */
  52203. intensity: number;
  52204. /**
  52205. * Defines if the effect is along the tangents, bitangents or in between.
  52206. * By default, the effect is "strectching" the highlights along the tangents.
  52207. */
  52208. direction: Vector2;
  52209. private _texture;
  52210. /**
  52211. * Stores the anisotropy values in a texture.
  52212. * rg is direction (like normal from -1 to 1)
  52213. * b is a intensity
  52214. */
  52215. texture: Nullable<BaseTexture>;
  52216. /** @hidden */
  52217. private _internalMarkAllSubMeshesAsTexturesDirty;
  52218. /** @hidden */
  52219. _markAllSubMeshesAsTexturesDirty(): void;
  52220. /**
  52221. * Instantiate a new istance of anisotropy configuration.
  52222. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52223. */
  52224. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52225. /**
  52226. * Specifies that the submesh is ready to be used.
  52227. * @param defines the list of "defines" to update.
  52228. * @param scene defines the scene the material belongs to.
  52229. * @returns - boolean indicating that the submesh is ready or not.
  52230. */
  52231. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  52232. /**
  52233. * Checks to see if a texture is used in the material.
  52234. * @param defines the list of "defines" to update.
  52235. * @param mesh the mesh we are preparing the defines for.
  52236. * @param scene defines the scene the material belongs to.
  52237. */
  52238. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  52239. /**
  52240. * Binds the material data.
  52241. * @param uniformBuffer defines the Uniform buffer to fill in.
  52242. * @param scene defines the scene the material belongs to.
  52243. * @param isFrozen defines wether the material is frozen or not.
  52244. */
  52245. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52246. /**
  52247. * Checks to see if a texture is used in the material.
  52248. * @param texture - Base texture to use.
  52249. * @returns - Boolean specifying if a texture is used in the material.
  52250. */
  52251. hasTexture(texture: BaseTexture): boolean;
  52252. /**
  52253. * Returns an array of the actively used textures.
  52254. * @param activeTextures Array of BaseTextures
  52255. */
  52256. getActiveTextures(activeTextures: BaseTexture[]): void;
  52257. /**
  52258. * Returns the animatable textures.
  52259. * @param animatables Array of animatable textures.
  52260. */
  52261. getAnimatables(animatables: IAnimatable[]): void;
  52262. /**
  52263. * Disposes the resources of the material.
  52264. * @param forceDisposeTextures - Forces the disposal of all textures.
  52265. */
  52266. dispose(forceDisposeTextures?: boolean): void;
  52267. /**
  52268. * Get the current class name of the texture useful for serialization or dynamic coding.
  52269. * @returns "PBRAnisotropicConfiguration"
  52270. */
  52271. getClassName(): string;
  52272. /**
  52273. * Add fallbacks to the effect fallbacks list.
  52274. * @param defines defines the Base texture to use.
  52275. * @param fallbacks defines the current fallback list.
  52276. * @param currentRank defines the current fallback rank.
  52277. * @returns the new fallback rank.
  52278. */
  52279. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52280. /**
  52281. * Add the required uniforms to the current list.
  52282. * @param uniforms defines the current uniform list.
  52283. */
  52284. static AddUniforms(uniforms: string[]): void;
  52285. /**
  52286. * Add the required uniforms to the current buffer.
  52287. * @param uniformBuffer defines the current uniform buffer.
  52288. */
  52289. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52290. /**
  52291. * Add the required samplers to the current list.
  52292. * @param samplers defines the current sampler list.
  52293. */
  52294. static AddSamplers(samplers: string[]): void;
  52295. /**
  52296. * Makes a duplicate of the current configuration into another one.
  52297. * @param anisotropicConfiguration define the config where to copy the info
  52298. */
  52299. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  52300. /**
  52301. * Serializes this anisotropy configuration.
  52302. * @returns - An object with the serialized config.
  52303. */
  52304. serialize(): any;
  52305. /**
  52306. * Parses a anisotropy Configuration from a serialized object.
  52307. * @param source - Serialized object.
  52308. * @param scene Defines the scene we are parsing for
  52309. * @param rootUrl Defines the rootUrl to load from
  52310. */
  52311. parse(source: any, scene: Scene, rootUrl: string): void;
  52312. }
  52313. }
  52314. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  52315. import { Scene } from "babylonjs/scene";
  52316. /**
  52317. * @hidden
  52318. */
  52319. export interface IMaterialBRDFDefines {
  52320. BRDF_V_HEIGHT_CORRELATED: boolean;
  52321. MS_BRDF_ENERGY_CONSERVATION: boolean;
  52322. SPHERICAL_HARMONICS: boolean;
  52323. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  52324. /** @hidden */
  52325. _areMiscDirty: boolean;
  52326. }
  52327. /**
  52328. * Define the code related to the BRDF parameters of the pbr material.
  52329. */
  52330. export class PBRBRDFConfiguration {
  52331. /**
  52332. * Default value used for the energy conservation.
  52333. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52334. */
  52335. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  52336. /**
  52337. * Default value used for the Smith Visibility Height Correlated mode.
  52338. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52339. */
  52340. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  52341. /**
  52342. * Default value used for the IBL diffuse part.
  52343. * This can help switching back to the polynomials mode globally which is a tiny bit
  52344. * less GPU intensive at the drawback of a lower quality.
  52345. */
  52346. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  52347. /**
  52348. * Default value used for activating energy conservation for the specular workflow.
  52349. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52350. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52351. */
  52352. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  52353. private _useEnergyConservation;
  52354. /**
  52355. * Defines if the material uses energy conservation.
  52356. */
  52357. useEnergyConservation: boolean;
  52358. private _useSmithVisibilityHeightCorrelated;
  52359. /**
  52360. * LEGACY Mode set to false
  52361. * Defines if the material uses height smith correlated visibility term.
  52362. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  52363. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  52364. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  52365. * Not relying on height correlated will also disable energy conservation.
  52366. */
  52367. useSmithVisibilityHeightCorrelated: boolean;
  52368. private _useSphericalHarmonics;
  52369. /**
  52370. * LEGACY Mode set to false
  52371. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  52372. * diffuse part of the IBL.
  52373. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  52374. * to the ground truth.
  52375. */
  52376. useSphericalHarmonics: boolean;
  52377. private _useSpecularGlossinessInputEnergyConservation;
  52378. /**
  52379. * Defines if the material uses energy conservation, when the specular workflow is active.
  52380. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52381. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52382. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  52383. */
  52384. useSpecularGlossinessInputEnergyConservation: boolean;
  52385. /** @hidden */
  52386. private _internalMarkAllSubMeshesAsMiscDirty;
  52387. /** @hidden */
  52388. _markAllSubMeshesAsMiscDirty(): void;
  52389. /**
  52390. * Instantiate a new istance of clear coat configuration.
  52391. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  52392. */
  52393. constructor(markAllSubMeshesAsMiscDirty: () => void);
  52394. /**
  52395. * Checks to see if a texture is used in the material.
  52396. * @param defines the list of "defines" to update.
  52397. */
  52398. prepareDefines(defines: IMaterialBRDFDefines): void;
  52399. /**
  52400. * Get the current class name of the texture useful for serialization or dynamic coding.
  52401. * @returns "PBRClearCoatConfiguration"
  52402. */
  52403. getClassName(): string;
  52404. /**
  52405. * Makes a duplicate of the current configuration into another one.
  52406. * @param brdfConfiguration define the config where to copy the info
  52407. */
  52408. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  52409. /**
  52410. * Serializes this BRDF configuration.
  52411. * @returns - An object with the serialized config.
  52412. */
  52413. serialize(): any;
  52414. /**
  52415. * Parses a anisotropy Configuration from a serialized object.
  52416. * @param source - Serialized object.
  52417. * @param scene Defines the scene we are parsing for
  52418. * @param rootUrl Defines the rootUrl to load from
  52419. */
  52420. parse(source: any, scene: Scene, rootUrl: string): void;
  52421. }
  52422. }
  52423. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  52424. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52425. import { Color3 } from "babylonjs/Maths/math.color";
  52426. import { Scene } from "babylonjs/scene";
  52427. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52428. import { Nullable } from "babylonjs/types";
  52429. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52430. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52431. /**
  52432. * @hidden
  52433. */
  52434. export interface IMaterialSheenDefines {
  52435. SHEEN: boolean;
  52436. SHEEN_TEXTURE: boolean;
  52437. SHEEN_TEXTUREDIRECTUV: number;
  52438. SHEEN_LINKWITHALBEDO: boolean;
  52439. /** @hidden */
  52440. _areTexturesDirty: boolean;
  52441. }
  52442. /**
  52443. * Define the code related to the Sheen parameters of the pbr material.
  52444. */
  52445. export class PBRSheenConfiguration {
  52446. private _isEnabled;
  52447. /**
  52448. * Defines if the material uses sheen.
  52449. */
  52450. isEnabled: boolean;
  52451. private _linkSheenWithAlbedo;
  52452. /**
  52453. * Defines if the sheen is linked to the sheen color.
  52454. */
  52455. linkSheenWithAlbedo: boolean;
  52456. /**
  52457. * Defines the sheen intensity.
  52458. */
  52459. intensity: number;
  52460. /**
  52461. * Defines the sheen color.
  52462. */
  52463. color: Color3;
  52464. private _texture;
  52465. /**
  52466. * Stores the sheen tint values in a texture.
  52467. * rgb is tint
  52468. * a is a intensity
  52469. */
  52470. texture: Nullable<BaseTexture>;
  52471. /** @hidden */
  52472. private _internalMarkAllSubMeshesAsTexturesDirty;
  52473. /** @hidden */
  52474. _markAllSubMeshesAsTexturesDirty(): void;
  52475. /**
  52476. * Instantiate a new istance of clear coat configuration.
  52477. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52478. */
  52479. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52480. /**
  52481. * Specifies that the submesh is ready to be used.
  52482. * @param defines the list of "defines" to update.
  52483. * @param scene defines the scene the material belongs to.
  52484. * @returns - boolean indicating that the submesh is ready or not.
  52485. */
  52486. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  52487. /**
  52488. * Checks to see if a texture is used in the material.
  52489. * @param defines the list of "defines" to update.
  52490. * @param scene defines the scene the material belongs to.
  52491. */
  52492. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  52493. /**
  52494. * Binds the material data.
  52495. * @param uniformBuffer defines the Uniform buffer to fill in.
  52496. * @param scene defines the scene the material belongs to.
  52497. * @param isFrozen defines wether the material is frozen or not.
  52498. */
  52499. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52500. /**
  52501. * Checks to see if a texture is used in the material.
  52502. * @param texture - Base texture to use.
  52503. * @returns - Boolean specifying if a texture is used in the material.
  52504. */
  52505. hasTexture(texture: BaseTexture): boolean;
  52506. /**
  52507. * Returns an array of the actively used textures.
  52508. * @param activeTextures Array of BaseTextures
  52509. */
  52510. getActiveTextures(activeTextures: BaseTexture[]): void;
  52511. /**
  52512. * Returns the animatable textures.
  52513. * @param animatables Array of animatable textures.
  52514. */
  52515. getAnimatables(animatables: IAnimatable[]): void;
  52516. /**
  52517. * Disposes the resources of the material.
  52518. * @param forceDisposeTextures - Forces the disposal of all textures.
  52519. */
  52520. dispose(forceDisposeTextures?: boolean): void;
  52521. /**
  52522. * Get the current class name of the texture useful for serialization or dynamic coding.
  52523. * @returns "PBRSheenConfiguration"
  52524. */
  52525. getClassName(): string;
  52526. /**
  52527. * Add fallbacks to the effect fallbacks list.
  52528. * @param defines defines the Base texture to use.
  52529. * @param fallbacks defines the current fallback list.
  52530. * @param currentRank defines the current fallback rank.
  52531. * @returns the new fallback rank.
  52532. */
  52533. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52534. /**
  52535. * Add the required uniforms to the current list.
  52536. * @param uniforms defines the current uniform list.
  52537. */
  52538. static AddUniforms(uniforms: string[]): void;
  52539. /**
  52540. * Add the required uniforms to the current buffer.
  52541. * @param uniformBuffer defines the current uniform buffer.
  52542. */
  52543. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52544. /**
  52545. * Add the required samplers to the current list.
  52546. * @param samplers defines the current sampler list.
  52547. */
  52548. static AddSamplers(samplers: string[]): void;
  52549. /**
  52550. * Makes a duplicate of the current configuration into another one.
  52551. * @param sheenConfiguration define the config where to copy the info
  52552. */
  52553. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  52554. /**
  52555. * Serializes this BRDF configuration.
  52556. * @returns - An object with the serialized config.
  52557. */
  52558. serialize(): any;
  52559. /**
  52560. * Parses a anisotropy Configuration from a serialized object.
  52561. * @param source - Serialized object.
  52562. * @param scene Defines the scene we are parsing for
  52563. * @param rootUrl Defines the rootUrl to load from
  52564. */
  52565. parse(source: any, scene: Scene, rootUrl: string): void;
  52566. }
  52567. }
  52568. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  52569. import { Nullable } from "babylonjs/types";
  52570. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52571. import { Color3 } from "babylonjs/Maths/math.color";
  52572. import { SmartArray } from "babylonjs/Misc/smartArray";
  52573. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52574. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52575. import { Effect } from "babylonjs/Materials/effect";
  52576. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52577. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52578. import { Engine } from "babylonjs/Engines/engine";
  52579. import { Scene } from "babylonjs/scene";
  52580. /**
  52581. * @hidden
  52582. */
  52583. export interface IMaterialSubSurfaceDefines {
  52584. SUBSURFACE: boolean;
  52585. SS_REFRACTION: boolean;
  52586. SS_TRANSLUCENCY: boolean;
  52587. SS_SCATERRING: boolean;
  52588. SS_THICKNESSANDMASK_TEXTURE: boolean;
  52589. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  52590. SS_REFRACTIONMAP_3D: boolean;
  52591. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  52592. SS_LODINREFRACTIONALPHA: boolean;
  52593. SS_GAMMAREFRACTION: boolean;
  52594. SS_RGBDREFRACTION: boolean;
  52595. SS_LINEARSPECULARREFRACTION: boolean;
  52596. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  52597. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  52598. /** @hidden */
  52599. _areTexturesDirty: boolean;
  52600. }
  52601. /**
  52602. * Define the code related to the sub surface parameters of the pbr material.
  52603. */
  52604. export class PBRSubSurfaceConfiguration {
  52605. private _isRefractionEnabled;
  52606. /**
  52607. * Defines if the refraction is enabled in the material.
  52608. */
  52609. isRefractionEnabled: boolean;
  52610. private _isTranslucencyEnabled;
  52611. /**
  52612. * Defines if the translucency is enabled in the material.
  52613. */
  52614. isTranslucencyEnabled: boolean;
  52615. private _isScatteringEnabled;
  52616. /**
  52617. * Defines the refraction intensity of the material.
  52618. * The refraction when enabled replaces the Diffuse part of the material.
  52619. * The intensity helps transitionning between diffuse and refraction.
  52620. */
  52621. refractionIntensity: number;
  52622. /**
  52623. * Defines the translucency intensity of the material.
  52624. * When translucency has been enabled, this defines how much of the "translucency"
  52625. * is addded to the diffuse part of the material.
  52626. */
  52627. translucencyIntensity: number;
  52628. /**
  52629. * Defines the scattering intensity of the material.
  52630. * When scattering has been enabled, this defines how much of the "scattered light"
  52631. * is addded to the diffuse part of the material.
  52632. */
  52633. scatteringIntensity: number;
  52634. private _thicknessTexture;
  52635. /**
  52636. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  52637. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  52638. * 0 would mean minimumThickness
  52639. * 1 would mean maximumThickness
  52640. * The other channels might be use as a mask to vary the different effects intensity.
  52641. */
  52642. thicknessTexture: Nullable<BaseTexture>;
  52643. private _refractionTexture;
  52644. /**
  52645. * Defines the texture to use for refraction.
  52646. */
  52647. refractionTexture: Nullable<BaseTexture>;
  52648. private _indexOfRefraction;
  52649. /**
  52650. * Defines the index of refraction used in the material.
  52651. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  52652. */
  52653. indexOfRefraction: number;
  52654. private _invertRefractionY;
  52655. /**
  52656. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52657. */
  52658. invertRefractionY: boolean;
  52659. private _linkRefractionWithTransparency;
  52660. /**
  52661. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52662. * Materials half opaque for instance using refraction could benefit from this control.
  52663. */
  52664. linkRefractionWithTransparency: boolean;
  52665. /**
  52666. * Defines the minimum thickness stored in the thickness map.
  52667. * If no thickness map is defined, this value will be used to simulate thickness.
  52668. */
  52669. minimumThickness: number;
  52670. /**
  52671. * Defines the maximum thickness stored in the thickness map.
  52672. */
  52673. maximumThickness: number;
  52674. /**
  52675. * Defines the volume tint of the material.
  52676. * This is used for both translucency and scattering.
  52677. */
  52678. tintColor: Color3;
  52679. /**
  52680. * Defines the distance at which the tint color should be found in the media.
  52681. * This is used for refraction only.
  52682. */
  52683. tintColorAtDistance: number;
  52684. /**
  52685. * Defines how far each channel transmit through the media.
  52686. * It is defined as a color to simplify it selection.
  52687. */
  52688. diffusionDistance: Color3;
  52689. private _useMaskFromThicknessTexture;
  52690. /**
  52691. * Stores the intensity of the different subsurface effects in the thickness texture.
  52692. * * the green channel is the translucency intensity.
  52693. * * the blue channel is the scattering intensity.
  52694. * * the alpha channel is the refraction intensity.
  52695. */
  52696. useMaskFromThicknessTexture: boolean;
  52697. /** @hidden */
  52698. private _internalMarkAllSubMeshesAsTexturesDirty;
  52699. /** @hidden */
  52700. _markAllSubMeshesAsTexturesDirty(): void;
  52701. /**
  52702. * Instantiate a new istance of sub surface configuration.
  52703. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52704. */
  52705. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52706. /**
  52707. * Gets wehter the submesh is ready to be used or not.
  52708. * @param defines the list of "defines" to update.
  52709. * @param scene defines the scene the material belongs to.
  52710. * @returns - boolean indicating that the submesh is ready or not.
  52711. */
  52712. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  52713. /**
  52714. * Checks to see if a texture is used in the material.
  52715. * @param defines the list of "defines" to update.
  52716. * @param scene defines the scene to the material belongs to.
  52717. */
  52718. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  52719. /**
  52720. * Binds the material data.
  52721. * @param uniformBuffer defines the Uniform buffer to fill in.
  52722. * @param scene defines the scene the material belongs to.
  52723. * @param engine defines the engine the material belongs to.
  52724. * @param isFrozen defines wether the material is frozen or not.
  52725. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  52726. */
  52727. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  52728. /**
  52729. * Unbinds the material from the mesh.
  52730. * @param activeEffect defines the effect that should be unbound from.
  52731. * @returns true if unbound, otherwise false
  52732. */
  52733. unbind(activeEffect: Effect): boolean;
  52734. /**
  52735. * Returns the texture used for refraction or null if none is used.
  52736. * @param scene defines the scene the material belongs to.
  52737. * @returns - Refraction texture if present. If no refraction texture and refraction
  52738. * is linked with transparency, returns environment texture. Otherwise, returns null.
  52739. */
  52740. private _getRefractionTexture;
  52741. /**
  52742. * Returns true if alpha blending should be disabled.
  52743. */
  52744. get disableAlphaBlending(): boolean;
  52745. /**
  52746. * Fills the list of render target textures.
  52747. * @param renderTargets the list of render targets to update
  52748. */
  52749. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  52750. /**
  52751. * Checks to see if a texture is used in the material.
  52752. * @param texture - Base texture to use.
  52753. * @returns - Boolean specifying if a texture is used in the material.
  52754. */
  52755. hasTexture(texture: BaseTexture): boolean;
  52756. /**
  52757. * Gets a boolean indicating that current material needs to register RTT
  52758. * @returns true if this uses a render target otherwise false.
  52759. */
  52760. hasRenderTargetTextures(): boolean;
  52761. /**
  52762. * Returns an array of the actively used textures.
  52763. * @param activeTextures Array of BaseTextures
  52764. */
  52765. getActiveTextures(activeTextures: BaseTexture[]): void;
  52766. /**
  52767. * Returns the animatable textures.
  52768. * @param animatables Array of animatable textures.
  52769. */
  52770. getAnimatables(animatables: IAnimatable[]): void;
  52771. /**
  52772. * Disposes the resources of the material.
  52773. * @param forceDisposeTextures - Forces the disposal of all textures.
  52774. */
  52775. dispose(forceDisposeTextures?: boolean): void;
  52776. /**
  52777. * Get the current class name of the texture useful for serialization or dynamic coding.
  52778. * @returns "PBRSubSurfaceConfiguration"
  52779. */
  52780. getClassName(): string;
  52781. /**
  52782. * Add fallbacks to the effect fallbacks list.
  52783. * @param defines defines the Base texture to use.
  52784. * @param fallbacks defines the current fallback list.
  52785. * @param currentRank defines the current fallback rank.
  52786. * @returns the new fallback rank.
  52787. */
  52788. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52789. /**
  52790. * Add the required uniforms to the current list.
  52791. * @param uniforms defines the current uniform list.
  52792. */
  52793. static AddUniforms(uniforms: string[]): void;
  52794. /**
  52795. * Add the required samplers to the current list.
  52796. * @param samplers defines the current sampler list.
  52797. */
  52798. static AddSamplers(samplers: string[]): void;
  52799. /**
  52800. * Add the required uniforms to the current buffer.
  52801. * @param uniformBuffer defines the current uniform buffer.
  52802. */
  52803. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52804. /**
  52805. * Makes a duplicate of the current configuration into another one.
  52806. * @param configuration define the config where to copy the info
  52807. */
  52808. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  52809. /**
  52810. * Serializes this Sub Surface configuration.
  52811. * @returns - An object with the serialized config.
  52812. */
  52813. serialize(): any;
  52814. /**
  52815. * Parses a anisotropy Configuration from a serialized object.
  52816. * @param source - Serialized object.
  52817. * @param scene Defines the scene we are parsing for
  52818. * @param rootUrl Defines the rootUrl to load from
  52819. */
  52820. parse(source: any, scene: Scene, rootUrl: string): void;
  52821. }
  52822. }
  52823. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  52824. /** @hidden */
  52825. export var pbrFragmentDeclaration: {
  52826. name: string;
  52827. shader: string;
  52828. };
  52829. }
  52830. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  52831. /** @hidden */
  52832. export var pbrUboDeclaration: {
  52833. name: string;
  52834. shader: string;
  52835. };
  52836. }
  52837. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  52838. /** @hidden */
  52839. export var pbrFragmentExtraDeclaration: {
  52840. name: string;
  52841. shader: string;
  52842. };
  52843. }
  52844. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  52845. /** @hidden */
  52846. export var pbrFragmentSamplersDeclaration: {
  52847. name: string;
  52848. shader: string;
  52849. };
  52850. }
  52851. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  52852. /** @hidden */
  52853. export var pbrHelperFunctions: {
  52854. name: string;
  52855. shader: string;
  52856. };
  52857. }
  52858. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  52859. /** @hidden */
  52860. export var harmonicsFunctions: {
  52861. name: string;
  52862. shader: string;
  52863. };
  52864. }
  52865. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  52866. /** @hidden */
  52867. export var pbrDirectLightingSetupFunctions: {
  52868. name: string;
  52869. shader: string;
  52870. };
  52871. }
  52872. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  52873. /** @hidden */
  52874. export var pbrDirectLightingFalloffFunctions: {
  52875. name: string;
  52876. shader: string;
  52877. };
  52878. }
  52879. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  52880. /** @hidden */
  52881. export var pbrBRDFFunctions: {
  52882. name: string;
  52883. shader: string;
  52884. };
  52885. }
  52886. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  52887. /** @hidden */
  52888. export var pbrDirectLightingFunctions: {
  52889. name: string;
  52890. shader: string;
  52891. };
  52892. }
  52893. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  52894. /** @hidden */
  52895. export var pbrIBLFunctions: {
  52896. name: string;
  52897. shader: string;
  52898. };
  52899. }
  52900. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  52901. /** @hidden */
  52902. export var pbrDebug: {
  52903. name: string;
  52904. shader: string;
  52905. };
  52906. }
  52907. declare module "babylonjs/Shaders/pbr.fragment" {
  52908. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  52909. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  52910. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  52911. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  52912. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  52913. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  52914. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  52915. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  52916. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  52917. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  52918. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52919. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  52920. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  52921. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  52922. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  52923. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  52924. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  52925. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  52926. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  52927. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  52928. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  52929. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  52930. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  52931. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  52932. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  52933. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  52934. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  52935. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  52936. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  52937. /** @hidden */
  52938. export var pbrPixelShader: {
  52939. name: string;
  52940. shader: string;
  52941. };
  52942. }
  52943. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  52944. /** @hidden */
  52945. export var pbrVertexDeclaration: {
  52946. name: string;
  52947. shader: string;
  52948. };
  52949. }
  52950. declare module "babylonjs/Shaders/pbr.vertex" {
  52951. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  52952. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  52953. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52954. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  52955. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  52956. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  52957. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  52958. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  52959. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  52960. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  52961. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  52962. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  52963. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  52964. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  52965. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  52966. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  52967. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  52968. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  52969. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  52970. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  52971. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  52972. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  52973. /** @hidden */
  52974. export var pbrVertexShader: {
  52975. name: string;
  52976. shader: string;
  52977. };
  52978. }
  52979. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  52980. import { Nullable } from "babylonjs/types";
  52981. import { Scene } from "babylonjs/scene";
  52982. import { Matrix } from "babylonjs/Maths/math.vector";
  52983. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52984. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52985. import { Mesh } from "babylonjs/Meshes/mesh";
  52986. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  52987. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  52988. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  52989. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  52990. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  52991. import { Color3 } from "babylonjs/Maths/math.color";
  52992. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  52993. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  52994. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  52995. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  52996. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52997. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52998. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  52999. import "babylonjs/Shaders/pbr.fragment";
  53000. import "babylonjs/Shaders/pbr.vertex";
  53001. /**
  53002. * Manages the defines for the PBR Material.
  53003. * @hidden
  53004. */
  53005. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  53006. PBR: boolean;
  53007. MAINUV1: boolean;
  53008. MAINUV2: boolean;
  53009. UV1: boolean;
  53010. UV2: boolean;
  53011. ALBEDO: boolean;
  53012. ALBEDODIRECTUV: number;
  53013. VERTEXCOLOR: boolean;
  53014. AMBIENT: boolean;
  53015. AMBIENTDIRECTUV: number;
  53016. AMBIENTINGRAYSCALE: boolean;
  53017. OPACITY: boolean;
  53018. VERTEXALPHA: boolean;
  53019. OPACITYDIRECTUV: number;
  53020. OPACITYRGB: boolean;
  53021. ALPHATEST: boolean;
  53022. DEPTHPREPASS: boolean;
  53023. ALPHABLEND: boolean;
  53024. ALPHAFROMALBEDO: boolean;
  53025. ALPHATESTVALUE: string;
  53026. SPECULAROVERALPHA: boolean;
  53027. RADIANCEOVERALPHA: boolean;
  53028. ALPHAFRESNEL: boolean;
  53029. LINEARALPHAFRESNEL: boolean;
  53030. PREMULTIPLYALPHA: boolean;
  53031. EMISSIVE: boolean;
  53032. EMISSIVEDIRECTUV: number;
  53033. REFLECTIVITY: boolean;
  53034. REFLECTIVITYDIRECTUV: number;
  53035. SPECULARTERM: boolean;
  53036. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  53037. MICROSURFACEAUTOMATIC: boolean;
  53038. LODBASEDMICROSFURACE: boolean;
  53039. MICROSURFACEMAP: boolean;
  53040. MICROSURFACEMAPDIRECTUV: number;
  53041. METALLICWORKFLOW: boolean;
  53042. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  53043. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  53044. METALLNESSSTOREINMETALMAPBLUE: boolean;
  53045. AOSTOREINMETALMAPRED: boolean;
  53046. METALLICF0FACTORFROMMETALLICMAP: boolean;
  53047. ENVIRONMENTBRDF: boolean;
  53048. ENVIRONMENTBRDF_RGBD: boolean;
  53049. NORMAL: boolean;
  53050. TANGENT: boolean;
  53051. BUMP: boolean;
  53052. BUMPDIRECTUV: number;
  53053. OBJECTSPACE_NORMALMAP: boolean;
  53054. PARALLAX: boolean;
  53055. PARALLAXOCCLUSION: boolean;
  53056. NORMALXYSCALE: boolean;
  53057. LIGHTMAP: boolean;
  53058. LIGHTMAPDIRECTUV: number;
  53059. USELIGHTMAPASSHADOWMAP: boolean;
  53060. GAMMALIGHTMAP: boolean;
  53061. RGBDLIGHTMAP: boolean;
  53062. REFLECTION: boolean;
  53063. REFLECTIONMAP_3D: boolean;
  53064. REFLECTIONMAP_SPHERICAL: boolean;
  53065. REFLECTIONMAP_PLANAR: boolean;
  53066. REFLECTIONMAP_CUBIC: boolean;
  53067. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  53068. REFLECTIONMAP_PROJECTION: boolean;
  53069. REFLECTIONMAP_SKYBOX: boolean;
  53070. REFLECTIONMAP_EXPLICIT: boolean;
  53071. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  53072. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  53073. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  53074. INVERTCUBICMAP: boolean;
  53075. USESPHERICALFROMREFLECTIONMAP: boolean;
  53076. USEIRRADIANCEMAP: boolean;
  53077. SPHERICAL_HARMONICS: boolean;
  53078. USESPHERICALINVERTEX: boolean;
  53079. REFLECTIONMAP_OPPOSITEZ: boolean;
  53080. LODINREFLECTIONALPHA: boolean;
  53081. GAMMAREFLECTION: boolean;
  53082. RGBDREFLECTION: boolean;
  53083. LINEARSPECULARREFLECTION: boolean;
  53084. RADIANCEOCCLUSION: boolean;
  53085. HORIZONOCCLUSION: boolean;
  53086. INSTANCES: boolean;
  53087. NUM_BONE_INFLUENCERS: number;
  53088. BonesPerMesh: number;
  53089. BONETEXTURE: boolean;
  53090. NONUNIFORMSCALING: boolean;
  53091. MORPHTARGETS: boolean;
  53092. MORPHTARGETS_NORMAL: boolean;
  53093. MORPHTARGETS_TANGENT: boolean;
  53094. MORPHTARGETS_UV: boolean;
  53095. NUM_MORPH_INFLUENCERS: number;
  53096. IMAGEPROCESSING: boolean;
  53097. VIGNETTE: boolean;
  53098. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53099. VIGNETTEBLENDMODEOPAQUE: boolean;
  53100. TONEMAPPING: boolean;
  53101. TONEMAPPING_ACES: boolean;
  53102. CONTRAST: boolean;
  53103. COLORCURVES: boolean;
  53104. COLORGRADING: boolean;
  53105. COLORGRADING3D: boolean;
  53106. SAMPLER3DGREENDEPTH: boolean;
  53107. SAMPLER3DBGRMAP: boolean;
  53108. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53109. EXPOSURE: boolean;
  53110. MULTIVIEW: boolean;
  53111. USEPHYSICALLIGHTFALLOFF: boolean;
  53112. USEGLTFLIGHTFALLOFF: boolean;
  53113. TWOSIDEDLIGHTING: boolean;
  53114. SHADOWFLOAT: boolean;
  53115. CLIPPLANE: boolean;
  53116. CLIPPLANE2: boolean;
  53117. CLIPPLANE3: boolean;
  53118. CLIPPLANE4: boolean;
  53119. CLIPPLANE5: boolean;
  53120. CLIPPLANE6: boolean;
  53121. POINTSIZE: boolean;
  53122. FOG: boolean;
  53123. LOGARITHMICDEPTH: boolean;
  53124. FORCENORMALFORWARD: boolean;
  53125. SPECULARAA: boolean;
  53126. CLEARCOAT: boolean;
  53127. CLEARCOAT_DEFAULTIOR: boolean;
  53128. CLEARCOAT_TEXTURE: boolean;
  53129. CLEARCOAT_TEXTUREDIRECTUV: number;
  53130. CLEARCOAT_BUMP: boolean;
  53131. CLEARCOAT_BUMPDIRECTUV: number;
  53132. CLEARCOAT_TINT: boolean;
  53133. CLEARCOAT_TINT_TEXTURE: boolean;
  53134. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53135. ANISOTROPIC: boolean;
  53136. ANISOTROPIC_TEXTURE: boolean;
  53137. ANISOTROPIC_TEXTUREDIRECTUV: number;
  53138. BRDF_V_HEIGHT_CORRELATED: boolean;
  53139. MS_BRDF_ENERGY_CONSERVATION: boolean;
  53140. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  53141. SHEEN: boolean;
  53142. SHEEN_TEXTURE: boolean;
  53143. SHEEN_TEXTUREDIRECTUV: number;
  53144. SHEEN_LINKWITHALBEDO: boolean;
  53145. SUBSURFACE: boolean;
  53146. SS_REFRACTION: boolean;
  53147. SS_TRANSLUCENCY: boolean;
  53148. SS_SCATERRING: boolean;
  53149. SS_THICKNESSANDMASK_TEXTURE: boolean;
  53150. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  53151. SS_REFRACTIONMAP_3D: boolean;
  53152. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  53153. SS_LODINREFRACTIONALPHA: boolean;
  53154. SS_GAMMAREFRACTION: boolean;
  53155. SS_RGBDREFRACTION: boolean;
  53156. SS_LINEARSPECULARREFRACTION: boolean;
  53157. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  53158. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  53159. UNLIT: boolean;
  53160. DEBUGMODE: number;
  53161. /**
  53162. * Initializes the PBR Material defines.
  53163. */
  53164. constructor();
  53165. /**
  53166. * Resets the PBR Material defines.
  53167. */
  53168. reset(): void;
  53169. }
  53170. /**
  53171. * The Physically based material base class of BJS.
  53172. *
  53173. * This offers the main features of a standard PBR material.
  53174. * For more information, please refer to the documentation :
  53175. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53176. */
  53177. export abstract class PBRBaseMaterial extends PushMaterial {
  53178. /**
  53179. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53180. */
  53181. static readonly PBRMATERIAL_OPAQUE: number;
  53182. /**
  53183. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53184. */
  53185. static readonly PBRMATERIAL_ALPHATEST: number;
  53186. /**
  53187. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53188. */
  53189. static readonly PBRMATERIAL_ALPHABLEND: number;
  53190. /**
  53191. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53192. * They are also discarded below the alpha cutoff threshold to improve performances.
  53193. */
  53194. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53195. /**
  53196. * Defines the default value of how much AO map is occluding the analytical lights
  53197. * (point spot...).
  53198. */
  53199. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53200. /**
  53201. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  53202. */
  53203. static readonly LIGHTFALLOFF_PHYSICAL: number;
  53204. /**
  53205. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  53206. * to enhance interoperability with other engines.
  53207. */
  53208. static readonly LIGHTFALLOFF_GLTF: number;
  53209. /**
  53210. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  53211. * to enhance interoperability with other materials.
  53212. */
  53213. static readonly LIGHTFALLOFF_STANDARD: number;
  53214. /**
  53215. * Intensity of the direct lights e.g. the four lights available in your scene.
  53216. * This impacts both the direct diffuse and specular highlights.
  53217. */
  53218. protected _directIntensity: number;
  53219. /**
  53220. * Intensity of the emissive part of the material.
  53221. * This helps controlling the emissive effect without modifying the emissive color.
  53222. */
  53223. protected _emissiveIntensity: number;
  53224. /**
  53225. * Intensity of the environment e.g. how much the environment will light the object
  53226. * either through harmonics for rough material or through the refelction for shiny ones.
  53227. */
  53228. protected _environmentIntensity: number;
  53229. /**
  53230. * This is a special control allowing the reduction of the specular highlights coming from the
  53231. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53232. */
  53233. protected _specularIntensity: number;
  53234. /**
  53235. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  53236. */
  53237. private _lightingInfos;
  53238. /**
  53239. * Debug Control allowing disabling the bump map on this material.
  53240. */
  53241. protected _disableBumpMap: boolean;
  53242. /**
  53243. * AKA Diffuse Texture in standard nomenclature.
  53244. */
  53245. protected _albedoTexture: Nullable<BaseTexture>;
  53246. /**
  53247. * AKA Occlusion Texture in other nomenclature.
  53248. */
  53249. protected _ambientTexture: Nullable<BaseTexture>;
  53250. /**
  53251. * AKA Occlusion Texture Intensity in other nomenclature.
  53252. */
  53253. protected _ambientTextureStrength: number;
  53254. /**
  53255. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53256. * 1 means it completely occludes it
  53257. * 0 mean it has no impact
  53258. */
  53259. protected _ambientTextureImpactOnAnalyticalLights: number;
  53260. /**
  53261. * Stores the alpha values in a texture.
  53262. */
  53263. protected _opacityTexture: Nullable<BaseTexture>;
  53264. /**
  53265. * Stores the reflection values in a texture.
  53266. */
  53267. protected _reflectionTexture: Nullable<BaseTexture>;
  53268. /**
  53269. * Stores the emissive values in a texture.
  53270. */
  53271. protected _emissiveTexture: Nullable<BaseTexture>;
  53272. /**
  53273. * AKA Specular texture in other nomenclature.
  53274. */
  53275. protected _reflectivityTexture: Nullable<BaseTexture>;
  53276. /**
  53277. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53278. */
  53279. protected _metallicTexture: Nullable<BaseTexture>;
  53280. /**
  53281. * Specifies the metallic scalar of the metallic/roughness workflow.
  53282. * Can also be used to scale the metalness values of the metallic texture.
  53283. */
  53284. protected _metallic: Nullable<number>;
  53285. /**
  53286. * Specifies the roughness scalar of the metallic/roughness workflow.
  53287. * Can also be used to scale the roughness values of the metallic texture.
  53288. */
  53289. protected _roughness: Nullable<number>;
  53290. /**
  53291. * Specifies the an F0 factor to help configuring the material F0.
  53292. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53293. * to 0.5 the previously hard coded value stays the same.
  53294. * Can also be used to scale the F0 values of the metallic texture.
  53295. */
  53296. protected _metallicF0Factor: number;
  53297. /**
  53298. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53299. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53300. * your expectation as it multiplies with the texture data.
  53301. */
  53302. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  53303. /**
  53304. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53305. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53306. */
  53307. protected _microSurfaceTexture: Nullable<BaseTexture>;
  53308. /**
  53309. * Stores surface normal data used to displace a mesh in a texture.
  53310. */
  53311. protected _bumpTexture: Nullable<BaseTexture>;
  53312. /**
  53313. * Stores the pre-calculated light information of a mesh in a texture.
  53314. */
  53315. protected _lightmapTexture: Nullable<BaseTexture>;
  53316. /**
  53317. * The color of a material in ambient lighting.
  53318. */
  53319. protected _ambientColor: Color3;
  53320. /**
  53321. * AKA Diffuse Color in other nomenclature.
  53322. */
  53323. protected _albedoColor: Color3;
  53324. /**
  53325. * AKA Specular Color in other nomenclature.
  53326. */
  53327. protected _reflectivityColor: Color3;
  53328. /**
  53329. * The color applied when light is reflected from a material.
  53330. */
  53331. protected _reflectionColor: Color3;
  53332. /**
  53333. * The color applied when light is emitted from a material.
  53334. */
  53335. protected _emissiveColor: Color3;
  53336. /**
  53337. * AKA Glossiness in other nomenclature.
  53338. */
  53339. protected _microSurface: number;
  53340. /**
  53341. * Specifies that the material will use the light map as a show map.
  53342. */
  53343. protected _useLightmapAsShadowmap: boolean;
  53344. /**
  53345. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  53346. * makes the reflect vector face the model (under horizon).
  53347. */
  53348. protected _useHorizonOcclusion: boolean;
  53349. /**
  53350. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  53351. * too much the area relying on ambient texture to define their ambient occlusion.
  53352. */
  53353. protected _useRadianceOcclusion: boolean;
  53354. /**
  53355. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53356. */
  53357. protected _useAlphaFromAlbedoTexture: boolean;
  53358. /**
  53359. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  53360. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53361. */
  53362. protected _useSpecularOverAlpha: boolean;
  53363. /**
  53364. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53365. */
  53366. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53367. /**
  53368. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53369. */
  53370. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  53371. /**
  53372. * Specifies if the metallic texture contains the roughness information in its green channel.
  53373. */
  53374. protected _useRoughnessFromMetallicTextureGreen: boolean;
  53375. /**
  53376. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53377. */
  53378. protected _useMetallnessFromMetallicTextureBlue: boolean;
  53379. /**
  53380. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53381. */
  53382. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  53383. /**
  53384. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53385. */
  53386. protected _useAmbientInGrayScale: boolean;
  53387. /**
  53388. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53389. * The material will try to infer what glossiness each pixel should be.
  53390. */
  53391. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  53392. /**
  53393. * Defines the falloff type used in this material.
  53394. * It by default is Physical.
  53395. */
  53396. protected _lightFalloff: number;
  53397. /**
  53398. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53399. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53400. */
  53401. protected _useRadianceOverAlpha: boolean;
  53402. /**
  53403. * Allows using an object space normal map (instead of tangent space).
  53404. */
  53405. protected _useObjectSpaceNormalMap: boolean;
  53406. /**
  53407. * Allows using the bump map in parallax mode.
  53408. */
  53409. protected _useParallax: boolean;
  53410. /**
  53411. * Allows using the bump map in parallax occlusion mode.
  53412. */
  53413. protected _useParallaxOcclusion: boolean;
  53414. /**
  53415. * Controls the scale bias of the parallax mode.
  53416. */
  53417. protected _parallaxScaleBias: number;
  53418. /**
  53419. * If sets to true, disables all the lights affecting the material.
  53420. */
  53421. protected _disableLighting: boolean;
  53422. /**
  53423. * Number of Simultaneous lights allowed on the material.
  53424. */
  53425. protected _maxSimultaneousLights: number;
  53426. /**
  53427. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53428. */
  53429. protected _invertNormalMapX: boolean;
  53430. /**
  53431. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53432. */
  53433. protected _invertNormalMapY: boolean;
  53434. /**
  53435. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53436. */
  53437. protected _twoSidedLighting: boolean;
  53438. /**
  53439. * Defines the alpha limits in alpha test mode.
  53440. */
  53441. protected _alphaCutOff: number;
  53442. /**
  53443. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53444. */
  53445. protected _forceAlphaTest: boolean;
  53446. /**
  53447. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53448. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  53449. */
  53450. protected _useAlphaFresnel: boolean;
  53451. /**
  53452. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53453. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  53454. */
  53455. protected _useLinearAlphaFresnel: boolean;
  53456. /**
  53457. * The transparency mode of the material.
  53458. */
  53459. protected _transparencyMode: Nullable<number>;
  53460. /**
  53461. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  53462. * from cos thetav and roughness:
  53463. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  53464. */
  53465. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  53466. /**
  53467. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53468. */
  53469. protected _forceIrradianceInFragment: boolean;
  53470. /**
  53471. * Force normal to face away from face.
  53472. */
  53473. protected _forceNormalForward: boolean;
  53474. /**
  53475. * Enables specular anti aliasing in the PBR shader.
  53476. * It will both interacts on the Geometry for analytical and IBL lighting.
  53477. * It also prefilter the roughness map based on the bump values.
  53478. */
  53479. protected _enableSpecularAntiAliasing: boolean;
  53480. /**
  53481. * Default configuration related to image processing available in the PBR Material.
  53482. */
  53483. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53484. /**
  53485. * Keep track of the image processing observer to allow dispose and replace.
  53486. */
  53487. private _imageProcessingObserver;
  53488. /**
  53489. * Attaches a new image processing configuration to the PBR Material.
  53490. * @param configuration
  53491. */
  53492. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53493. /**
  53494. * Stores the available render targets.
  53495. */
  53496. private _renderTargets;
  53497. /**
  53498. * Sets the global ambient color for the material used in lighting calculations.
  53499. */
  53500. private _globalAmbientColor;
  53501. /**
  53502. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  53503. */
  53504. private _useLogarithmicDepth;
  53505. /**
  53506. * If set to true, no lighting calculations will be applied.
  53507. */
  53508. private _unlit;
  53509. private _debugMode;
  53510. /**
  53511. * @hidden
  53512. * This is reserved for the inspector.
  53513. * Defines the material debug mode.
  53514. * It helps seeing only some components of the material while troubleshooting.
  53515. */
  53516. debugMode: number;
  53517. /**
  53518. * @hidden
  53519. * This is reserved for the inspector.
  53520. * Specify from where on screen the debug mode should start.
  53521. * The value goes from -1 (full screen) to 1 (not visible)
  53522. * It helps with side by side comparison against the final render
  53523. * This defaults to -1
  53524. */
  53525. private debugLimit;
  53526. /**
  53527. * @hidden
  53528. * This is reserved for the inspector.
  53529. * As the default viewing range might not be enough (if the ambient is really small for instance)
  53530. * You can use the factor to better multiply the final value.
  53531. */
  53532. private debugFactor;
  53533. /**
  53534. * Defines the clear coat layer parameters for the material.
  53535. */
  53536. readonly clearCoat: PBRClearCoatConfiguration;
  53537. /**
  53538. * Defines the anisotropic parameters for the material.
  53539. */
  53540. readonly anisotropy: PBRAnisotropicConfiguration;
  53541. /**
  53542. * Defines the BRDF parameters for the material.
  53543. */
  53544. readonly brdf: PBRBRDFConfiguration;
  53545. /**
  53546. * Defines the Sheen parameters for the material.
  53547. */
  53548. readonly sheen: PBRSheenConfiguration;
  53549. /**
  53550. * Defines the SubSurface parameters for the material.
  53551. */
  53552. readonly subSurface: PBRSubSurfaceConfiguration;
  53553. /**
  53554. * Custom callback helping to override the default shader used in the material.
  53555. */
  53556. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  53557. protected _rebuildInParallel: boolean;
  53558. /**
  53559. * Instantiates a new PBRMaterial instance.
  53560. *
  53561. * @param name The material name
  53562. * @param scene The scene the material will be use in.
  53563. */
  53564. constructor(name: string, scene: Scene);
  53565. /**
  53566. * Gets a boolean indicating that current material needs to register RTT
  53567. */
  53568. get hasRenderTargetTextures(): boolean;
  53569. /**
  53570. * Gets the name of the material class.
  53571. */
  53572. getClassName(): string;
  53573. /**
  53574. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53575. */
  53576. get useLogarithmicDepth(): boolean;
  53577. /**
  53578. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53579. */
  53580. set useLogarithmicDepth(value: boolean);
  53581. /**
  53582. * Gets the current transparency mode.
  53583. */
  53584. get transparencyMode(): Nullable<number>;
  53585. /**
  53586. * Sets the transparency mode of the material.
  53587. *
  53588. * | Value | Type | Description |
  53589. * | ----- | ----------------------------------- | ----------- |
  53590. * | 0 | OPAQUE | |
  53591. * | 1 | ALPHATEST | |
  53592. * | 2 | ALPHABLEND | |
  53593. * | 3 | ALPHATESTANDBLEND | |
  53594. *
  53595. */
  53596. set transparencyMode(value: Nullable<number>);
  53597. /**
  53598. * Returns true if alpha blending should be disabled.
  53599. */
  53600. private get _disableAlphaBlending();
  53601. /**
  53602. * Specifies whether or not this material should be rendered in alpha blend mode.
  53603. */
  53604. needAlphaBlending(): boolean;
  53605. /**
  53606. * Specifies if the mesh will require alpha blending.
  53607. * @param mesh - BJS mesh.
  53608. */
  53609. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  53610. /**
  53611. * Specifies whether or not this material should be rendered in alpha test mode.
  53612. */
  53613. needAlphaTesting(): boolean;
  53614. /**
  53615. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  53616. */
  53617. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  53618. /**
  53619. * Gets the texture used for the alpha test.
  53620. */
  53621. getAlphaTestTexture(): Nullable<BaseTexture>;
  53622. /**
  53623. * Specifies that the submesh is ready to be used.
  53624. * @param mesh - BJS mesh.
  53625. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  53626. * @param useInstances - Specifies that instances should be used.
  53627. * @returns - boolean indicating that the submesh is ready or not.
  53628. */
  53629. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53630. /**
  53631. * Specifies if the material uses metallic roughness workflow.
  53632. * @returns boolean specifiying if the material uses metallic roughness workflow.
  53633. */
  53634. isMetallicWorkflow(): boolean;
  53635. private _prepareEffect;
  53636. private _prepareDefines;
  53637. /**
  53638. * Force shader compilation
  53639. */
  53640. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  53641. /**
  53642. * Initializes the uniform buffer layout for the shader.
  53643. */
  53644. buildUniformLayout(): void;
  53645. /**
  53646. * Unbinds the material from the mesh
  53647. */
  53648. unbind(): void;
  53649. /**
  53650. * Binds the submesh data.
  53651. * @param world - The world matrix.
  53652. * @param mesh - The BJS mesh.
  53653. * @param subMesh - A submesh of the BJS mesh.
  53654. */
  53655. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53656. /**
  53657. * Returns the animatable textures.
  53658. * @returns - Array of animatable textures.
  53659. */
  53660. getAnimatables(): IAnimatable[];
  53661. /**
  53662. * Returns the texture used for reflections.
  53663. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  53664. */
  53665. private _getReflectionTexture;
  53666. /**
  53667. * Returns an array of the actively used textures.
  53668. * @returns - Array of BaseTextures
  53669. */
  53670. getActiveTextures(): BaseTexture[];
  53671. /**
  53672. * Checks to see if a texture is used in the material.
  53673. * @param texture - Base texture to use.
  53674. * @returns - Boolean specifying if a texture is used in the material.
  53675. */
  53676. hasTexture(texture: BaseTexture): boolean;
  53677. /**
  53678. * Disposes the resources of the material.
  53679. * @param forceDisposeEffect - Forces the disposal of effects.
  53680. * @param forceDisposeTextures - Forces the disposal of all textures.
  53681. */
  53682. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  53683. }
  53684. }
  53685. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  53686. import { Nullable } from "babylonjs/types";
  53687. import { Scene } from "babylonjs/scene";
  53688. import { Color3 } from "babylonjs/Maths/math.color";
  53689. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  53690. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  53691. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53692. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53693. /**
  53694. * The Physically based material of BJS.
  53695. *
  53696. * This offers the main features of a standard PBR material.
  53697. * For more information, please refer to the documentation :
  53698. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53699. */
  53700. export class PBRMaterial extends PBRBaseMaterial {
  53701. /**
  53702. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53703. */
  53704. static readonly PBRMATERIAL_OPAQUE: number;
  53705. /**
  53706. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53707. */
  53708. static readonly PBRMATERIAL_ALPHATEST: number;
  53709. /**
  53710. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53711. */
  53712. static readonly PBRMATERIAL_ALPHABLEND: number;
  53713. /**
  53714. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53715. * They are also discarded below the alpha cutoff threshold to improve performances.
  53716. */
  53717. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53718. /**
  53719. * Defines the default value of how much AO map is occluding the analytical lights
  53720. * (point spot...).
  53721. */
  53722. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53723. /**
  53724. * Intensity of the direct lights e.g. the four lights available in your scene.
  53725. * This impacts both the direct diffuse and specular highlights.
  53726. */
  53727. directIntensity: number;
  53728. /**
  53729. * Intensity of the emissive part of the material.
  53730. * This helps controlling the emissive effect without modifying the emissive color.
  53731. */
  53732. emissiveIntensity: number;
  53733. /**
  53734. * Intensity of the environment e.g. how much the environment will light the object
  53735. * either through harmonics for rough material or through the refelction for shiny ones.
  53736. */
  53737. environmentIntensity: number;
  53738. /**
  53739. * This is a special control allowing the reduction of the specular highlights coming from the
  53740. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53741. */
  53742. specularIntensity: number;
  53743. /**
  53744. * Debug Control allowing disabling the bump map on this material.
  53745. */
  53746. disableBumpMap: boolean;
  53747. /**
  53748. * AKA Diffuse Texture in standard nomenclature.
  53749. */
  53750. albedoTexture: BaseTexture;
  53751. /**
  53752. * AKA Occlusion Texture in other nomenclature.
  53753. */
  53754. ambientTexture: BaseTexture;
  53755. /**
  53756. * AKA Occlusion Texture Intensity in other nomenclature.
  53757. */
  53758. ambientTextureStrength: number;
  53759. /**
  53760. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53761. * 1 means it completely occludes it
  53762. * 0 mean it has no impact
  53763. */
  53764. ambientTextureImpactOnAnalyticalLights: number;
  53765. /**
  53766. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  53767. */
  53768. opacityTexture: BaseTexture;
  53769. /**
  53770. * Stores the reflection values in a texture.
  53771. */
  53772. reflectionTexture: Nullable<BaseTexture>;
  53773. /**
  53774. * Stores the emissive values in a texture.
  53775. */
  53776. emissiveTexture: BaseTexture;
  53777. /**
  53778. * AKA Specular texture in other nomenclature.
  53779. */
  53780. reflectivityTexture: BaseTexture;
  53781. /**
  53782. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53783. */
  53784. metallicTexture: BaseTexture;
  53785. /**
  53786. * Specifies the metallic scalar of the metallic/roughness workflow.
  53787. * Can also be used to scale the metalness values of the metallic texture.
  53788. */
  53789. metallic: Nullable<number>;
  53790. /**
  53791. * Specifies the roughness scalar of the metallic/roughness workflow.
  53792. * Can also be used to scale the roughness values of the metallic texture.
  53793. */
  53794. roughness: Nullable<number>;
  53795. /**
  53796. * Specifies the an F0 factor to help configuring the material F0.
  53797. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53798. * to 0.5 the previously hard coded value stays the same.
  53799. * Can also be used to scale the F0 values of the metallic texture.
  53800. */
  53801. metallicF0Factor: number;
  53802. /**
  53803. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53804. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53805. * your expectation as it multiplies with the texture data.
  53806. */
  53807. useMetallicF0FactorFromMetallicTexture: boolean;
  53808. /**
  53809. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53810. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53811. */
  53812. microSurfaceTexture: BaseTexture;
  53813. /**
  53814. * Stores surface normal data used to displace a mesh in a texture.
  53815. */
  53816. bumpTexture: BaseTexture;
  53817. /**
  53818. * Stores the pre-calculated light information of a mesh in a texture.
  53819. */
  53820. lightmapTexture: BaseTexture;
  53821. /**
  53822. * Stores the refracted light information in a texture.
  53823. */
  53824. get refractionTexture(): Nullable<BaseTexture>;
  53825. set refractionTexture(value: Nullable<BaseTexture>);
  53826. /**
  53827. * The color of a material in ambient lighting.
  53828. */
  53829. ambientColor: Color3;
  53830. /**
  53831. * AKA Diffuse Color in other nomenclature.
  53832. */
  53833. albedoColor: Color3;
  53834. /**
  53835. * AKA Specular Color in other nomenclature.
  53836. */
  53837. reflectivityColor: Color3;
  53838. /**
  53839. * The color reflected from the material.
  53840. */
  53841. reflectionColor: Color3;
  53842. /**
  53843. * The color emitted from the material.
  53844. */
  53845. emissiveColor: Color3;
  53846. /**
  53847. * AKA Glossiness in other nomenclature.
  53848. */
  53849. microSurface: number;
  53850. /**
  53851. * source material index of refraction (IOR)' / 'destination material IOR.
  53852. */
  53853. get indexOfRefraction(): number;
  53854. set indexOfRefraction(value: number);
  53855. /**
  53856. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  53857. */
  53858. get invertRefractionY(): boolean;
  53859. set invertRefractionY(value: boolean);
  53860. /**
  53861. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  53862. * Materials half opaque for instance using refraction could benefit from this control.
  53863. */
  53864. get linkRefractionWithTransparency(): boolean;
  53865. set linkRefractionWithTransparency(value: boolean);
  53866. /**
  53867. * If true, the light map contains occlusion information instead of lighting info.
  53868. */
  53869. useLightmapAsShadowmap: boolean;
  53870. /**
  53871. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53872. */
  53873. useAlphaFromAlbedoTexture: boolean;
  53874. /**
  53875. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53876. */
  53877. forceAlphaTest: boolean;
  53878. /**
  53879. * Defines the alpha limits in alpha test mode.
  53880. */
  53881. alphaCutOff: number;
  53882. /**
  53883. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  53884. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53885. */
  53886. useSpecularOverAlpha: boolean;
  53887. /**
  53888. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53889. */
  53890. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53891. /**
  53892. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53893. */
  53894. useRoughnessFromMetallicTextureAlpha: boolean;
  53895. /**
  53896. * Specifies if the metallic texture contains the roughness information in its green channel.
  53897. */
  53898. useRoughnessFromMetallicTextureGreen: boolean;
  53899. /**
  53900. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53901. */
  53902. useMetallnessFromMetallicTextureBlue: boolean;
  53903. /**
  53904. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53905. */
  53906. useAmbientOcclusionFromMetallicTextureRed: boolean;
  53907. /**
  53908. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53909. */
  53910. useAmbientInGrayScale: boolean;
  53911. /**
  53912. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53913. * The material will try to infer what glossiness each pixel should be.
  53914. */
  53915. useAutoMicroSurfaceFromReflectivityMap: boolean;
  53916. /**
  53917. * BJS is using an harcoded light falloff based on a manually sets up range.
  53918. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  53919. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  53920. */
  53921. get usePhysicalLightFalloff(): boolean;
  53922. /**
  53923. * BJS is using an harcoded light falloff based on a manually sets up range.
  53924. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  53925. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  53926. */
  53927. set usePhysicalLightFalloff(value: boolean);
  53928. /**
  53929. * In order to support the falloff compatibility with gltf, a special mode has been added
  53930. * to reproduce the gltf light falloff.
  53931. */
  53932. get useGLTFLightFalloff(): boolean;
  53933. /**
  53934. * In order to support the falloff compatibility with gltf, a special mode has been added
  53935. * to reproduce the gltf light falloff.
  53936. */
  53937. set useGLTFLightFalloff(value: boolean);
  53938. /**
  53939. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53940. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53941. */
  53942. useRadianceOverAlpha: boolean;
  53943. /**
  53944. * Allows using an object space normal map (instead of tangent space).
  53945. */
  53946. useObjectSpaceNormalMap: boolean;
  53947. /**
  53948. * Allows using the bump map in parallax mode.
  53949. */
  53950. useParallax: boolean;
  53951. /**
  53952. * Allows using the bump map in parallax occlusion mode.
  53953. */
  53954. useParallaxOcclusion: boolean;
  53955. /**
  53956. * Controls the scale bias of the parallax mode.
  53957. */
  53958. parallaxScaleBias: number;
  53959. /**
  53960. * If sets to true, disables all the lights affecting the material.
  53961. */
  53962. disableLighting: boolean;
  53963. /**
  53964. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53965. */
  53966. forceIrradianceInFragment: boolean;
  53967. /**
  53968. * Number of Simultaneous lights allowed on the material.
  53969. */
  53970. maxSimultaneousLights: number;
  53971. /**
  53972. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53973. */
  53974. invertNormalMapX: boolean;
  53975. /**
  53976. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53977. */
  53978. invertNormalMapY: boolean;
  53979. /**
  53980. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53981. */
  53982. twoSidedLighting: boolean;
  53983. /**
  53984. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53985. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  53986. */
  53987. useAlphaFresnel: boolean;
  53988. /**
  53989. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53990. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  53991. */
  53992. useLinearAlphaFresnel: boolean;
  53993. /**
  53994. * Let user defines the brdf lookup texture used for IBL.
  53995. * A default 8bit version is embedded but you could point at :
  53996. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  53997. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  53998. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  53999. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  54000. */
  54001. environmentBRDFTexture: Nullable<BaseTexture>;
  54002. /**
  54003. * Force normal to face away from face.
  54004. */
  54005. forceNormalForward: boolean;
  54006. /**
  54007. * Enables specular anti aliasing in the PBR shader.
  54008. * It will both interacts on the Geometry for analytical and IBL lighting.
  54009. * It also prefilter the roughness map based on the bump values.
  54010. */
  54011. enableSpecularAntiAliasing: boolean;
  54012. /**
  54013. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  54014. * makes the reflect vector face the model (under horizon).
  54015. */
  54016. useHorizonOcclusion: boolean;
  54017. /**
  54018. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  54019. * too much the area relying on ambient texture to define their ambient occlusion.
  54020. */
  54021. useRadianceOcclusion: boolean;
  54022. /**
  54023. * If set to true, no lighting calculations will be applied.
  54024. */
  54025. unlit: boolean;
  54026. /**
  54027. * Gets the image processing configuration used either in this material.
  54028. */
  54029. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  54030. /**
  54031. * Sets the Default image processing configuration used either in the this material.
  54032. *
  54033. * If sets to null, the scene one is in use.
  54034. */
  54035. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  54036. /**
  54037. * Gets wether the color curves effect is enabled.
  54038. */
  54039. get cameraColorCurvesEnabled(): boolean;
  54040. /**
  54041. * Sets wether the color curves effect is enabled.
  54042. */
  54043. set cameraColorCurvesEnabled(value: boolean);
  54044. /**
  54045. * Gets wether the color grading effect is enabled.
  54046. */
  54047. get cameraColorGradingEnabled(): boolean;
  54048. /**
  54049. * Gets wether the color grading effect is enabled.
  54050. */
  54051. set cameraColorGradingEnabled(value: boolean);
  54052. /**
  54053. * Gets wether tonemapping is enabled or not.
  54054. */
  54055. get cameraToneMappingEnabled(): boolean;
  54056. /**
  54057. * Sets wether tonemapping is enabled or not
  54058. */
  54059. set cameraToneMappingEnabled(value: boolean);
  54060. /**
  54061. * The camera exposure used on this material.
  54062. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54063. * This corresponds to a photographic exposure.
  54064. */
  54065. get cameraExposure(): number;
  54066. /**
  54067. * The camera exposure used on this material.
  54068. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54069. * This corresponds to a photographic exposure.
  54070. */
  54071. set cameraExposure(value: number);
  54072. /**
  54073. * Gets The camera contrast used on this material.
  54074. */
  54075. get cameraContrast(): number;
  54076. /**
  54077. * Sets The camera contrast used on this material.
  54078. */
  54079. set cameraContrast(value: number);
  54080. /**
  54081. * Gets the Color Grading 2D Lookup Texture.
  54082. */
  54083. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54084. /**
  54085. * Sets the Color Grading 2D Lookup Texture.
  54086. */
  54087. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54088. /**
  54089. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54090. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54091. * 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;
  54092. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54093. */
  54094. get cameraColorCurves(): Nullable<ColorCurves>;
  54095. /**
  54096. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54097. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54098. * 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;
  54099. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54100. */
  54101. set cameraColorCurves(value: Nullable<ColorCurves>);
  54102. /**
  54103. * Instantiates a new PBRMaterial instance.
  54104. *
  54105. * @param name The material name
  54106. * @param scene The scene the material will be use in.
  54107. */
  54108. constructor(name: string, scene: Scene);
  54109. /**
  54110. * Returns the name of this material class.
  54111. */
  54112. getClassName(): string;
  54113. /**
  54114. * Makes a duplicate of the current material.
  54115. * @param name - name to use for the new material.
  54116. */
  54117. clone(name: string): PBRMaterial;
  54118. /**
  54119. * Serializes this PBR Material.
  54120. * @returns - An object with the serialized material.
  54121. */
  54122. serialize(): any;
  54123. /**
  54124. * Parses a PBR Material from a serialized object.
  54125. * @param source - Serialized object.
  54126. * @param scene - BJS scene instance.
  54127. * @param rootUrl - url for the scene object
  54128. * @returns - PBRMaterial
  54129. */
  54130. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  54131. }
  54132. }
  54133. declare module "babylonjs/Misc/dds" {
  54134. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54135. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54136. import { Nullable } from "babylonjs/types";
  54137. import { Scene } from "babylonjs/scene";
  54138. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  54139. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54140. /**
  54141. * Direct draw surface info
  54142. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  54143. */
  54144. export interface DDSInfo {
  54145. /**
  54146. * Width of the texture
  54147. */
  54148. width: number;
  54149. /**
  54150. * Width of the texture
  54151. */
  54152. height: number;
  54153. /**
  54154. * Number of Mipmaps for the texture
  54155. * @see https://en.wikipedia.org/wiki/Mipmap
  54156. */
  54157. mipmapCount: number;
  54158. /**
  54159. * If the textures format is a known fourCC format
  54160. * @see https://www.fourcc.org/
  54161. */
  54162. isFourCC: boolean;
  54163. /**
  54164. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  54165. */
  54166. isRGB: boolean;
  54167. /**
  54168. * If the texture is a lumincance format
  54169. */
  54170. isLuminance: boolean;
  54171. /**
  54172. * If this is a cube texture
  54173. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  54174. */
  54175. isCube: boolean;
  54176. /**
  54177. * If the texture is a compressed format eg. FOURCC_DXT1
  54178. */
  54179. isCompressed: boolean;
  54180. /**
  54181. * The dxgiFormat of the texture
  54182. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  54183. */
  54184. dxgiFormat: number;
  54185. /**
  54186. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  54187. */
  54188. textureType: number;
  54189. /**
  54190. * Sphericle polynomial created for the dds texture
  54191. */
  54192. sphericalPolynomial?: SphericalPolynomial;
  54193. }
  54194. /**
  54195. * Class used to provide DDS decompression tools
  54196. */
  54197. export class DDSTools {
  54198. /**
  54199. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  54200. */
  54201. static StoreLODInAlphaChannel: boolean;
  54202. /**
  54203. * Gets DDS information from an array buffer
  54204. * @param data defines the array buffer view to read data from
  54205. * @returns the DDS information
  54206. */
  54207. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  54208. private static _FloatView;
  54209. private static _Int32View;
  54210. private static _ToHalfFloat;
  54211. private static _FromHalfFloat;
  54212. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  54213. private static _GetHalfFloatRGBAArrayBuffer;
  54214. private static _GetFloatRGBAArrayBuffer;
  54215. private static _GetFloatAsUIntRGBAArrayBuffer;
  54216. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  54217. private static _GetRGBAArrayBuffer;
  54218. private static _ExtractLongWordOrder;
  54219. private static _GetRGBArrayBuffer;
  54220. private static _GetLuminanceArrayBuffer;
  54221. /**
  54222. * Uploads DDS Levels to a Babylon Texture
  54223. * @hidden
  54224. */
  54225. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  54226. }
  54227. module "babylonjs/Engines/thinEngine" {
  54228. interface ThinEngine {
  54229. /**
  54230. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  54231. * @param rootUrl defines the url where the file to load is located
  54232. * @param scene defines the current scene
  54233. * @param lodScale defines scale to apply to the mip map selection
  54234. * @param lodOffset defines offset to apply to the mip map selection
  54235. * @param onLoad defines an optional callback raised when the texture is loaded
  54236. * @param onError defines an optional callback raised if there is an issue to load the texture
  54237. * @param format defines the format of the data
  54238. * @param forcedExtension defines the extension to use to pick the right loader
  54239. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  54240. * @returns the cube texture as an InternalTexture
  54241. */
  54242. 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;
  54243. }
  54244. }
  54245. }
  54246. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  54247. import { Nullable } from "babylonjs/types";
  54248. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54249. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54250. /**
  54251. * Implementation of the DDS Texture Loader.
  54252. * @hidden
  54253. */
  54254. export class _DDSTextureLoader implements IInternalTextureLoader {
  54255. /**
  54256. * Defines wether the loader supports cascade loading the different faces.
  54257. */
  54258. readonly supportCascades: boolean;
  54259. /**
  54260. * This returns if the loader support the current file information.
  54261. * @param extension defines the file extension of the file being loaded
  54262. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54263. * @param fallback defines the fallback internal texture if any
  54264. * @param isBase64 defines whether the texture is encoded as a base64
  54265. * @param isBuffer defines whether the texture data are stored as a buffer
  54266. * @returns true if the loader can load the specified file
  54267. */
  54268. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54269. /**
  54270. * Transform the url before loading if required.
  54271. * @param rootUrl the url of the texture
  54272. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54273. * @returns the transformed texture
  54274. */
  54275. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54276. /**
  54277. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54278. * @param rootUrl the url of the texture
  54279. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54280. * @returns the fallback texture
  54281. */
  54282. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54283. /**
  54284. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54285. * @param data contains the texture data
  54286. * @param texture defines the BabylonJS internal texture
  54287. * @param createPolynomials will be true if polynomials have been requested
  54288. * @param onLoad defines the callback to trigger once the texture is ready
  54289. * @param onError defines the callback to trigger in case of error
  54290. */
  54291. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54292. /**
  54293. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54294. * @param data contains the texture data
  54295. * @param texture defines the BabylonJS internal texture
  54296. * @param callback defines the method to call once ready to upload
  54297. */
  54298. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54299. }
  54300. }
  54301. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  54302. import { Nullable } from "babylonjs/types";
  54303. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54304. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54305. /**
  54306. * Implementation of the ENV Texture Loader.
  54307. * @hidden
  54308. */
  54309. export class _ENVTextureLoader implements IInternalTextureLoader {
  54310. /**
  54311. * Defines wether the loader supports cascade loading the different faces.
  54312. */
  54313. readonly supportCascades: boolean;
  54314. /**
  54315. * This returns if the loader support the current file information.
  54316. * @param extension defines the file extension of the file being loaded
  54317. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54318. * @param fallback defines the fallback internal texture if any
  54319. * @param isBase64 defines whether the texture is encoded as a base64
  54320. * @param isBuffer defines whether the texture data are stored as a buffer
  54321. * @returns true if the loader can load the specified file
  54322. */
  54323. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54324. /**
  54325. * Transform the url before loading if required.
  54326. * @param rootUrl the url of the texture
  54327. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54328. * @returns the transformed texture
  54329. */
  54330. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54331. /**
  54332. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54333. * @param rootUrl the url of the texture
  54334. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54335. * @returns the fallback texture
  54336. */
  54337. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54338. /**
  54339. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54340. * @param data contains the texture data
  54341. * @param texture defines the BabylonJS internal texture
  54342. * @param createPolynomials will be true if polynomials have been requested
  54343. * @param onLoad defines the callback to trigger once the texture is ready
  54344. * @param onError defines the callback to trigger in case of error
  54345. */
  54346. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54347. /**
  54348. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54349. * @param data contains the texture data
  54350. * @param texture defines the BabylonJS internal texture
  54351. * @param callback defines the method to call once ready to upload
  54352. */
  54353. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54354. }
  54355. }
  54356. declare module "babylonjs/Misc/khronosTextureContainer" {
  54357. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54358. /**
  54359. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54360. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54361. */
  54362. export class KhronosTextureContainer {
  54363. /** contents of the KTX container file */
  54364. data: ArrayBufferView;
  54365. private static HEADER_LEN;
  54366. private static COMPRESSED_2D;
  54367. private static COMPRESSED_3D;
  54368. private static TEX_2D;
  54369. private static TEX_3D;
  54370. /**
  54371. * Gets the openGL type
  54372. */
  54373. glType: number;
  54374. /**
  54375. * Gets the openGL type size
  54376. */
  54377. glTypeSize: number;
  54378. /**
  54379. * Gets the openGL format
  54380. */
  54381. glFormat: number;
  54382. /**
  54383. * Gets the openGL internal format
  54384. */
  54385. glInternalFormat: number;
  54386. /**
  54387. * Gets the base internal format
  54388. */
  54389. glBaseInternalFormat: number;
  54390. /**
  54391. * Gets image width in pixel
  54392. */
  54393. pixelWidth: number;
  54394. /**
  54395. * Gets image height in pixel
  54396. */
  54397. pixelHeight: number;
  54398. /**
  54399. * Gets image depth in pixels
  54400. */
  54401. pixelDepth: number;
  54402. /**
  54403. * Gets the number of array elements
  54404. */
  54405. numberOfArrayElements: number;
  54406. /**
  54407. * Gets the number of faces
  54408. */
  54409. numberOfFaces: number;
  54410. /**
  54411. * Gets the number of mipmap levels
  54412. */
  54413. numberOfMipmapLevels: number;
  54414. /**
  54415. * Gets the bytes of key value data
  54416. */
  54417. bytesOfKeyValueData: number;
  54418. /**
  54419. * Gets the load type
  54420. */
  54421. loadType: number;
  54422. /**
  54423. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  54424. */
  54425. isInvalid: boolean;
  54426. /**
  54427. * Creates a new KhronosTextureContainer
  54428. * @param data contents of the KTX container file
  54429. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  54430. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  54431. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  54432. */
  54433. constructor(
  54434. /** contents of the KTX container file */
  54435. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  54436. /**
  54437. * Uploads KTX content to a Babylon Texture.
  54438. * It is assumed that the texture has already been created & is currently bound
  54439. * @hidden
  54440. */
  54441. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  54442. private _upload2DCompressedLevels;
  54443. }
  54444. }
  54445. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  54446. import { Nullable } from "babylonjs/types";
  54447. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54448. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54449. /**
  54450. * Implementation of the KTX Texture Loader.
  54451. * @hidden
  54452. */
  54453. export class _KTXTextureLoader implements IInternalTextureLoader {
  54454. /**
  54455. * Defines wether the loader supports cascade loading the different faces.
  54456. */
  54457. readonly supportCascades: boolean;
  54458. /**
  54459. * This returns if the loader support the current file information.
  54460. * @param extension defines the file extension of the file being loaded
  54461. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54462. * @param fallback defines the fallback internal texture if any
  54463. * @param isBase64 defines whether the texture is encoded as a base64
  54464. * @param isBuffer defines whether the texture data are stored as a buffer
  54465. * @returns true if the loader can load the specified file
  54466. */
  54467. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54468. /**
  54469. * Transform the url before loading if required.
  54470. * @param rootUrl the url of the texture
  54471. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54472. * @returns the transformed texture
  54473. */
  54474. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54475. /**
  54476. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54477. * @param rootUrl the url of the texture
  54478. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54479. * @returns the fallback texture
  54480. */
  54481. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54482. /**
  54483. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54484. * @param data contains the texture data
  54485. * @param texture defines the BabylonJS internal texture
  54486. * @param createPolynomials will be true if polynomials have been requested
  54487. * @param onLoad defines the callback to trigger once the texture is ready
  54488. * @param onError defines the callback to trigger in case of error
  54489. */
  54490. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54491. /**
  54492. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54493. * @param data contains the texture data
  54494. * @param texture defines the BabylonJS internal texture
  54495. * @param callback defines the method to call once ready to upload
  54496. */
  54497. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  54498. }
  54499. }
  54500. declare module "babylonjs/Helpers/sceneHelpers" {
  54501. import { Nullable } from "babylonjs/types";
  54502. import { Mesh } from "babylonjs/Meshes/mesh";
  54503. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54504. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  54505. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  54506. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54507. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54508. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54509. import "babylonjs/Meshes/Builders/boxBuilder";
  54510. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  54511. /** @hidden */
  54512. export var _forceSceneHelpersToBundle: boolean;
  54513. module "babylonjs/scene" {
  54514. interface Scene {
  54515. /**
  54516. * Creates a default light for the scene.
  54517. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  54518. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  54519. */
  54520. createDefaultLight(replace?: boolean): void;
  54521. /**
  54522. * Creates a default camera for the scene.
  54523. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  54524. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54525. * @param replace has default false, when true replaces the active camera in the scene
  54526. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  54527. */
  54528. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54529. /**
  54530. * Creates a default camera and a default light.
  54531. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  54532. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54533. * @param replace has the default false, when true replaces the active camera/light in the scene
  54534. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  54535. */
  54536. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54537. /**
  54538. * Creates a new sky box
  54539. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  54540. * @param environmentTexture defines the texture to use as environment texture
  54541. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  54542. * @param scale defines the overall scale of the skybox
  54543. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  54544. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  54545. * @returns a new mesh holding the sky box
  54546. */
  54547. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  54548. /**
  54549. * Creates a new environment
  54550. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  54551. * @param options defines the options you can use to configure the environment
  54552. * @returns the new EnvironmentHelper
  54553. */
  54554. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  54555. /**
  54556. * Creates a new VREXperienceHelper
  54557. * @see http://doc.babylonjs.com/how_to/webvr_helper
  54558. * @param webVROptions defines the options used to create the new VREXperienceHelper
  54559. * @returns a new VREXperienceHelper
  54560. */
  54561. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  54562. /**
  54563. * Creates a new WebXRDefaultExperience
  54564. * @see http://doc.babylonjs.com/how_to/webxr
  54565. * @param options experience options
  54566. * @returns a promise for a new WebXRDefaultExperience
  54567. */
  54568. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  54569. }
  54570. }
  54571. }
  54572. declare module "babylonjs/Helpers/videoDome" {
  54573. import { Scene } from "babylonjs/scene";
  54574. import { TransformNode } from "babylonjs/Meshes/transformNode";
  54575. import { Mesh } from "babylonjs/Meshes/mesh";
  54576. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  54577. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  54578. import "babylonjs/Meshes/Builders/sphereBuilder";
  54579. /**
  54580. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  54581. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  54582. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  54583. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  54584. */
  54585. export class VideoDome extends TransformNode {
  54586. /**
  54587. * Define the video source as a Monoscopic panoramic 360 video.
  54588. */
  54589. static readonly MODE_MONOSCOPIC: number;
  54590. /**
  54591. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54592. */
  54593. static readonly MODE_TOPBOTTOM: number;
  54594. /**
  54595. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54596. */
  54597. static readonly MODE_SIDEBYSIDE: number;
  54598. private _halfDome;
  54599. private _useDirectMapping;
  54600. /**
  54601. * The video texture being displayed on the sphere
  54602. */
  54603. protected _videoTexture: VideoTexture;
  54604. /**
  54605. * Gets the video texture being displayed on the sphere
  54606. */
  54607. get videoTexture(): VideoTexture;
  54608. /**
  54609. * The skybox material
  54610. */
  54611. protected _material: BackgroundMaterial;
  54612. /**
  54613. * The surface used for the skybox
  54614. */
  54615. protected _mesh: Mesh;
  54616. /**
  54617. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  54618. */
  54619. private _halfDomeMask;
  54620. /**
  54621. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54622. * Also see the options.resolution property.
  54623. */
  54624. get fovMultiplier(): number;
  54625. set fovMultiplier(value: number);
  54626. private _videoMode;
  54627. /**
  54628. * Gets or set the current video mode for the video. It can be:
  54629. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  54630. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54631. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54632. */
  54633. get videoMode(): number;
  54634. set videoMode(value: number);
  54635. /**
  54636. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  54637. *
  54638. */
  54639. get halfDome(): boolean;
  54640. /**
  54641. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  54642. */
  54643. set halfDome(enabled: boolean);
  54644. /**
  54645. * Oberserver used in Stereoscopic VR Mode.
  54646. */
  54647. private _onBeforeCameraRenderObserver;
  54648. /**
  54649. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  54650. * @param name Element's name, child elements will append suffixes for their own names.
  54651. * @param urlsOrVideo defines the url(s) or the video element to use
  54652. * @param options An object containing optional or exposed sub element properties
  54653. */
  54654. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  54655. resolution?: number;
  54656. clickToPlay?: boolean;
  54657. autoPlay?: boolean;
  54658. loop?: boolean;
  54659. size?: number;
  54660. poster?: string;
  54661. faceForward?: boolean;
  54662. useDirectMapping?: boolean;
  54663. halfDomeMode?: boolean;
  54664. }, scene: Scene);
  54665. private _changeVideoMode;
  54666. /**
  54667. * Releases resources associated with this node.
  54668. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  54669. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  54670. */
  54671. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  54672. }
  54673. }
  54674. declare module "babylonjs/Helpers/index" {
  54675. export * from "babylonjs/Helpers/environmentHelper";
  54676. export * from "babylonjs/Helpers/photoDome";
  54677. export * from "babylonjs/Helpers/sceneHelpers";
  54678. export * from "babylonjs/Helpers/videoDome";
  54679. }
  54680. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  54681. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54682. import { IDisposable } from "babylonjs/scene";
  54683. import { Engine } from "babylonjs/Engines/engine";
  54684. /**
  54685. * This class can be used to get instrumentation data from a Babylon engine
  54686. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54687. */
  54688. export class EngineInstrumentation implements IDisposable {
  54689. /**
  54690. * Define the instrumented engine.
  54691. */
  54692. engine: Engine;
  54693. private _captureGPUFrameTime;
  54694. private _gpuFrameTimeToken;
  54695. private _gpuFrameTime;
  54696. private _captureShaderCompilationTime;
  54697. private _shaderCompilationTime;
  54698. private _onBeginFrameObserver;
  54699. private _onEndFrameObserver;
  54700. private _onBeforeShaderCompilationObserver;
  54701. private _onAfterShaderCompilationObserver;
  54702. /**
  54703. * Gets the perf counter used for GPU frame time
  54704. */
  54705. get gpuFrameTimeCounter(): PerfCounter;
  54706. /**
  54707. * Gets the GPU frame time capture status
  54708. */
  54709. get captureGPUFrameTime(): boolean;
  54710. /**
  54711. * Enable or disable the GPU frame time capture
  54712. */
  54713. set captureGPUFrameTime(value: boolean);
  54714. /**
  54715. * Gets the perf counter used for shader compilation time
  54716. */
  54717. get shaderCompilationTimeCounter(): PerfCounter;
  54718. /**
  54719. * Gets the shader compilation time capture status
  54720. */
  54721. get captureShaderCompilationTime(): boolean;
  54722. /**
  54723. * Enable or disable the shader compilation time capture
  54724. */
  54725. set captureShaderCompilationTime(value: boolean);
  54726. /**
  54727. * Instantiates a new engine instrumentation.
  54728. * This class can be used to get instrumentation data from a Babylon engine
  54729. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54730. * @param engine Defines the engine to instrument
  54731. */
  54732. constructor(
  54733. /**
  54734. * Define the instrumented engine.
  54735. */
  54736. engine: Engine);
  54737. /**
  54738. * Dispose and release associated resources.
  54739. */
  54740. dispose(): void;
  54741. }
  54742. }
  54743. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  54744. import { Scene, IDisposable } from "babylonjs/scene";
  54745. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54746. /**
  54747. * This class can be used to get instrumentation data from a Babylon engine
  54748. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  54749. */
  54750. export class SceneInstrumentation implements IDisposable {
  54751. /**
  54752. * Defines the scene to instrument
  54753. */
  54754. scene: Scene;
  54755. private _captureActiveMeshesEvaluationTime;
  54756. private _activeMeshesEvaluationTime;
  54757. private _captureRenderTargetsRenderTime;
  54758. private _renderTargetsRenderTime;
  54759. private _captureFrameTime;
  54760. private _frameTime;
  54761. private _captureRenderTime;
  54762. private _renderTime;
  54763. private _captureInterFrameTime;
  54764. private _interFrameTime;
  54765. private _captureParticlesRenderTime;
  54766. private _particlesRenderTime;
  54767. private _captureSpritesRenderTime;
  54768. private _spritesRenderTime;
  54769. private _capturePhysicsTime;
  54770. private _physicsTime;
  54771. private _captureAnimationsTime;
  54772. private _animationsTime;
  54773. private _captureCameraRenderTime;
  54774. private _cameraRenderTime;
  54775. private _onBeforeActiveMeshesEvaluationObserver;
  54776. private _onAfterActiveMeshesEvaluationObserver;
  54777. private _onBeforeRenderTargetsRenderObserver;
  54778. private _onAfterRenderTargetsRenderObserver;
  54779. private _onAfterRenderObserver;
  54780. private _onBeforeDrawPhaseObserver;
  54781. private _onAfterDrawPhaseObserver;
  54782. private _onBeforeAnimationsObserver;
  54783. private _onBeforeParticlesRenderingObserver;
  54784. private _onAfterParticlesRenderingObserver;
  54785. private _onBeforeSpritesRenderingObserver;
  54786. private _onAfterSpritesRenderingObserver;
  54787. private _onBeforePhysicsObserver;
  54788. private _onAfterPhysicsObserver;
  54789. private _onAfterAnimationsObserver;
  54790. private _onBeforeCameraRenderObserver;
  54791. private _onAfterCameraRenderObserver;
  54792. /**
  54793. * Gets the perf counter used for active meshes evaluation time
  54794. */
  54795. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  54796. /**
  54797. * Gets the active meshes evaluation time capture status
  54798. */
  54799. get captureActiveMeshesEvaluationTime(): boolean;
  54800. /**
  54801. * Enable or disable the active meshes evaluation time capture
  54802. */
  54803. set captureActiveMeshesEvaluationTime(value: boolean);
  54804. /**
  54805. * Gets the perf counter used for render targets render time
  54806. */
  54807. get renderTargetsRenderTimeCounter(): PerfCounter;
  54808. /**
  54809. * Gets the render targets render time capture status
  54810. */
  54811. get captureRenderTargetsRenderTime(): boolean;
  54812. /**
  54813. * Enable or disable the render targets render time capture
  54814. */
  54815. set captureRenderTargetsRenderTime(value: boolean);
  54816. /**
  54817. * Gets the perf counter used for particles render time
  54818. */
  54819. get particlesRenderTimeCounter(): PerfCounter;
  54820. /**
  54821. * Gets the particles render time capture status
  54822. */
  54823. get captureParticlesRenderTime(): boolean;
  54824. /**
  54825. * Enable or disable the particles render time capture
  54826. */
  54827. set captureParticlesRenderTime(value: boolean);
  54828. /**
  54829. * Gets the perf counter used for sprites render time
  54830. */
  54831. get spritesRenderTimeCounter(): PerfCounter;
  54832. /**
  54833. * Gets the sprites render time capture status
  54834. */
  54835. get captureSpritesRenderTime(): boolean;
  54836. /**
  54837. * Enable or disable the sprites render time capture
  54838. */
  54839. set captureSpritesRenderTime(value: boolean);
  54840. /**
  54841. * Gets the perf counter used for physics time
  54842. */
  54843. get physicsTimeCounter(): PerfCounter;
  54844. /**
  54845. * Gets the physics time capture status
  54846. */
  54847. get capturePhysicsTime(): boolean;
  54848. /**
  54849. * Enable or disable the physics time capture
  54850. */
  54851. set capturePhysicsTime(value: boolean);
  54852. /**
  54853. * Gets the perf counter used for animations time
  54854. */
  54855. get animationsTimeCounter(): PerfCounter;
  54856. /**
  54857. * Gets the animations time capture status
  54858. */
  54859. get captureAnimationsTime(): boolean;
  54860. /**
  54861. * Enable or disable the animations time capture
  54862. */
  54863. set captureAnimationsTime(value: boolean);
  54864. /**
  54865. * Gets the perf counter used for frame time capture
  54866. */
  54867. get frameTimeCounter(): PerfCounter;
  54868. /**
  54869. * Gets the frame time capture status
  54870. */
  54871. get captureFrameTime(): boolean;
  54872. /**
  54873. * Enable or disable the frame time capture
  54874. */
  54875. set captureFrameTime(value: boolean);
  54876. /**
  54877. * Gets the perf counter used for inter-frames time capture
  54878. */
  54879. get interFrameTimeCounter(): PerfCounter;
  54880. /**
  54881. * Gets the inter-frames time capture status
  54882. */
  54883. get captureInterFrameTime(): boolean;
  54884. /**
  54885. * Enable or disable the inter-frames time capture
  54886. */
  54887. set captureInterFrameTime(value: boolean);
  54888. /**
  54889. * Gets the perf counter used for render time capture
  54890. */
  54891. get renderTimeCounter(): PerfCounter;
  54892. /**
  54893. * Gets the render time capture status
  54894. */
  54895. get captureRenderTime(): boolean;
  54896. /**
  54897. * Enable or disable the render time capture
  54898. */
  54899. set captureRenderTime(value: boolean);
  54900. /**
  54901. * Gets the perf counter used for camera render time capture
  54902. */
  54903. get cameraRenderTimeCounter(): PerfCounter;
  54904. /**
  54905. * Gets the camera render time capture status
  54906. */
  54907. get captureCameraRenderTime(): boolean;
  54908. /**
  54909. * Enable or disable the camera render time capture
  54910. */
  54911. set captureCameraRenderTime(value: boolean);
  54912. /**
  54913. * Gets the perf counter used for draw calls
  54914. */
  54915. get drawCallsCounter(): PerfCounter;
  54916. /**
  54917. * Instantiates a new scene instrumentation.
  54918. * This class can be used to get instrumentation data from a Babylon engine
  54919. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  54920. * @param scene Defines the scene to instrument
  54921. */
  54922. constructor(
  54923. /**
  54924. * Defines the scene to instrument
  54925. */
  54926. scene: Scene);
  54927. /**
  54928. * Dispose and release associated resources.
  54929. */
  54930. dispose(): void;
  54931. }
  54932. }
  54933. declare module "babylonjs/Instrumentation/index" {
  54934. export * from "babylonjs/Instrumentation/engineInstrumentation";
  54935. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  54936. export * from "babylonjs/Instrumentation/timeToken";
  54937. }
  54938. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  54939. /** @hidden */
  54940. export var glowMapGenerationPixelShader: {
  54941. name: string;
  54942. shader: string;
  54943. };
  54944. }
  54945. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  54946. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54947. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  54948. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  54949. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54950. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  54951. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54952. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54953. /** @hidden */
  54954. export var glowMapGenerationVertexShader: {
  54955. name: string;
  54956. shader: string;
  54957. };
  54958. }
  54959. declare module "babylonjs/Layers/effectLayer" {
  54960. import { Observable } from "babylonjs/Misc/observable";
  54961. import { Nullable } from "babylonjs/types";
  54962. import { Camera } from "babylonjs/Cameras/camera";
  54963. import { Scene } from "babylonjs/scene";
  54964. import { ISize } from "babylonjs/Maths/math.size";
  54965. import { Color4 } from "babylonjs/Maths/math.color";
  54966. import { Engine } from "babylonjs/Engines/engine";
  54967. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54968. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54969. import { Mesh } from "babylonjs/Meshes/mesh";
  54970. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54971. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54972. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54973. import { Effect } from "babylonjs/Materials/effect";
  54974. import { Material } from "babylonjs/Materials/material";
  54975. import "babylonjs/Shaders/glowMapGeneration.fragment";
  54976. import "babylonjs/Shaders/glowMapGeneration.vertex";
  54977. /**
  54978. * Effect layer options. This helps customizing the behaviour
  54979. * of the effect layer.
  54980. */
  54981. export interface IEffectLayerOptions {
  54982. /**
  54983. * Multiplication factor apply to the canvas size to compute the render target size
  54984. * used to generated the objects (the smaller the faster).
  54985. */
  54986. mainTextureRatio: number;
  54987. /**
  54988. * Enforces a fixed size texture to ensure effect stability across devices.
  54989. */
  54990. mainTextureFixedSize?: number;
  54991. /**
  54992. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  54993. */
  54994. alphaBlendingMode: number;
  54995. /**
  54996. * The camera attached to the layer.
  54997. */
  54998. camera: Nullable<Camera>;
  54999. /**
  55000. * The rendering group to draw the layer in.
  55001. */
  55002. renderingGroupId: number;
  55003. }
  55004. /**
  55005. * The effect layer Helps adding post process effect blended with the main pass.
  55006. *
  55007. * This can be for instance use to generate glow or higlight effects on the scene.
  55008. *
  55009. * The effect layer class can not be used directly and is intented to inherited from to be
  55010. * customized per effects.
  55011. */
  55012. export abstract class EffectLayer {
  55013. private _vertexBuffers;
  55014. private _indexBuffer;
  55015. private _cachedDefines;
  55016. private _effectLayerMapGenerationEffect;
  55017. private _effectLayerOptions;
  55018. private _mergeEffect;
  55019. protected _scene: Scene;
  55020. protected _engine: Engine;
  55021. protected _maxSize: number;
  55022. protected _mainTextureDesiredSize: ISize;
  55023. protected _mainTexture: RenderTargetTexture;
  55024. protected _shouldRender: boolean;
  55025. protected _postProcesses: PostProcess[];
  55026. protected _textures: BaseTexture[];
  55027. protected _emissiveTextureAndColor: {
  55028. texture: Nullable<BaseTexture>;
  55029. color: Color4;
  55030. };
  55031. /**
  55032. * The name of the layer
  55033. */
  55034. name: string;
  55035. /**
  55036. * The clear color of the texture used to generate the glow map.
  55037. */
  55038. neutralColor: Color4;
  55039. /**
  55040. * Specifies whether the highlight layer is enabled or not.
  55041. */
  55042. isEnabled: boolean;
  55043. /**
  55044. * Gets the camera attached to the layer.
  55045. */
  55046. get camera(): Nullable<Camera>;
  55047. /**
  55048. * Gets the rendering group id the layer should render in.
  55049. */
  55050. get renderingGroupId(): number;
  55051. set renderingGroupId(renderingGroupId: number);
  55052. /**
  55053. * An event triggered when the effect layer has been disposed.
  55054. */
  55055. onDisposeObservable: Observable<EffectLayer>;
  55056. /**
  55057. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  55058. */
  55059. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  55060. /**
  55061. * An event triggered when the generated texture is being merged in the scene.
  55062. */
  55063. onBeforeComposeObservable: Observable<EffectLayer>;
  55064. /**
  55065. * An event triggered when the mesh is rendered into the effect render target.
  55066. */
  55067. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  55068. /**
  55069. * An event triggered after the mesh has been rendered into the effect render target.
  55070. */
  55071. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  55072. /**
  55073. * An event triggered when the generated texture has been merged in the scene.
  55074. */
  55075. onAfterComposeObservable: Observable<EffectLayer>;
  55076. /**
  55077. * An event triggered when the efffect layer changes its size.
  55078. */
  55079. onSizeChangedObservable: Observable<EffectLayer>;
  55080. /** @hidden */
  55081. static _SceneComponentInitialization: (scene: Scene) => void;
  55082. /**
  55083. * Instantiates a new effect Layer and references it in the scene.
  55084. * @param name The name of the layer
  55085. * @param scene The scene to use the layer in
  55086. */
  55087. constructor(
  55088. /** The Friendly of the effect in the scene */
  55089. name: string, scene: Scene);
  55090. /**
  55091. * Get the effect name of the layer.
  55092. * @return The effect name
  55093. */
  55094. abstract getEffectName(): string;
  55095. /**
  55096. * Checks for the readiness of the element composing the layer.
  55097. * @param subMesh the mesh to check for
  55098. * @param useInstances specify whether or not to use instances to render the mesh
  55099. * @return true if ready otherwise, false
  55100. */
  55101. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55102. /**
  55103. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  55104. * @returns true if the effect requires stencil during the main canvas render pass.
  55105. */
  55106. abstract needStencil(): boolean;
  55107. /**
  55108. * Create the merge effect. This is the shader use to blit the information back
  55109. * to the main canvas at the end of the scene rendering.
  55110. * @returns The effect containing the shader used to merge the effect on the main canvas
  55111. */
  55112. protected abstract _createMergeEffect(): Effect;
  55113. /**
  55114. * Creates the render target textures and post processes used in the effect layer.
  55115. */
  55116. protected abstract _createTextureAndPostProcesses(): void;
  55117. /**
  55118. * Implementation specific of rendering the generating effect on the main canvas.
  55119. * @param effect The effect used to render through
  55120. */
  55121. protected abstract _internalRender(effect: Effect): void;
  55122. /**
  55123. * Sets the required values for both the emissive texture and and the main color.
  55124. */
  55125. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55126. /**
  55127. * Free any resources and references associated to a mesh.
  55128. * Internal use
  55129. * @param mesh The mesh to free.
  55130. */
  55131. abstract _disposeMesh(mesh: Mesh): void;
  55132. /**
  55133. * Serializes this layer (Glow or Highlight for example)
  55134. * @returns a serialized layer object
  55135. */
  55136. abstract serialize?(): any;
  55137. /**
  55138. * Initializes the effect layer with the required options.
  55139. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  55140. */
  55141. protected _init(options: Partial<IEffectLayerOptions>): void;
  55142. /**
  55143. * Generates the index buffer of the full screen quad blending to the main canvas.
  55144. */
  55145. private _generateIndexBuffer;
  55146. /**
  55147. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  55148. */
  55149. private _generateVertexBuffer;
  55150. /**
  55151. * Sets the main texture desired size which is the closest power of two
  55152. * of the engine canvas size.
  55153. */
  55154. private _setMainTextureSize;
  55155. /**
  55156. * Creates the main texture for the effect layer.
  55157. */
  55158. protected _createMainTexture(): void;
  55159. /**
  55160. * Adds specific effects defines.
  55161. * @param defines The defines to add specifics to.
  55162. */
  55163. protected _addCustomEffectDefines(defines: string[]): void;
  55164. /**
  55165. * Checks for the readiness of the element composing the layer.
  55166. * @param subMesh the mesh to check for
  55167. * @param useInstances specify whether or not to use instances to render the mesh
  55168. * @param emissiveTexture the associated emissive texture used to generate the glow
  55169. * @return true if ready otherwise, false
  55170. */
  55171. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  55172. /**
  55173. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  55174. */
  55175. render(): void;
  55176. /**
  55177. * Determine if a given mesh will be used in the current effect.
  55178. * @param mesh mesh to test
  55179. * @returns true if the mesh will be used
  55180. */
  55181. hasMesh(mesh: AbstractMesh): boolean;
  55182. /**
  55183. * Returns true if the layer contains information to display, otherwise false.
  55184. * @returns true if the glow layer should be rendered
  55185. */
  55186. shouldRender(): boolean;
  55187. /**
  55188. * Returns true if the mesh should render, otherwise false.
  55189. * @param mesh The mesh to render
  55190. * @returns true if it should render otherwise false
  55191. */
  55192. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  55193. /**
  55194. * Returns true if the mesh can be rendered, otherwise false.
  55195. * @param mesh The mesh to render
  55196. * @param material The material used on the mesh
  55197. * @returns true if it can be rendered otherwise false
  55198. */
  55199. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55200. /**
  55201. * Returns true if the mesh should render, otherwise false.
  55202. * @param mesh The mesh to render
  55203. * @returns true if it should render otherwise false
  55204. */
  55205. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  55206. /**
  55207. * Renders the submesh passed in parameter to the generation map.
  55208. */
  55209. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  55210. /**
  55211. * Defines whether the current material of the mesh should be use to render the effect.
  55212. * @param mesh defines the current mesh to render
  55213. */
  55214. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55215. /**
  55216. * Rebuild the required buffers.
  55217. * @hidden Internal use only.
  55218. */
  55219. _rebuild(): void;
  55220. /**
  55221. * Dispose only the render target textures and post process.
  55222. */
  55223. private _disposeTextureAndPostProcesses;
  55224. /**
  55225. * Dispose the highlight layer and free resources.
  55226. */
  55227. dispose(): void;
  55228. /**
  55229. * Gets the class name of the effect layer
  55230. * @returns the string with the class name of the effect layer
  55231. */
  55232. getClassName(): string;
  55233. /**
  55234. * Creates an effect layer from parsed effect layer data
  55235. * @param parsedEffectLayer defines effect layer data
  55236. * @param scene defines the current scene
  55237. * @param rootUrl defines the root URL containing the effect layer information
  55238. * @returns a parsed effect Layer
  55239. */
  55240. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  55241. }
  55242. }
  55243. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  55244. import { Scene } from "babylonjs/scene";
  55245. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  55246. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55247. import { AbstractScene } from "babylonjs/abstractScene";
  55248. module "babylonjs/abstractScene" {
  55249. interface AbstractScene {
  55250. /**
  55251. * The list of effect layers (highlights/glow) added to the scene
  55252. * @see http://doc.babylonjs.com/how_to/highlight_layer
  55253. * @see http://doc.babylonjs.com/how_to/glow_layer
  55254. */
  55255. effectLayers: Array<EffectLayer>;
  55256. /**
  55257. * Removes the given effect layer from this scene.
  55258. * @param toRemove defines the effect layer to remove
  55259. * @returns the index of the removed effect layer
  55260. */
  55261. removeEffectLayer(toRemove: EffectLayer): number;
  55262. /**
  55263. * Adds the given effect layer to this scene
  55264. * @param newEffectLayer defines the effect layer to add
  55265. */
  55266. addEffectLayer(newEffectLayer: EffectLayer): void;
  55267. }
  55268. }
  55269. /**
  55270. * Defines the layer scene component responsible to manage any effect layers
  55271. * in a given scene.
  55272. */
  55273. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  55274. /**
  55275. * The component name helpfull to identify the component in the list of scene components.
  55276. */
  55277. readonly name: string;
  55278. /**
  55279. * The scene the component belongs to.
  55280. */
  55281. scene: Scene;
  55282. private _engine;
  55283. private _renderEffects;
  55284. private _needStencil;
  55285. private _previousStencilState;
  55286. /**
  55287. * Creates a new instance of the component for the given scene
  55288. * @param scene Defines the scene to register the component in
  55289. */
  55290. constructor(scene: Scene);
  55291. /**
  55292. * Registers the component in a given scene
  55293. */
  55294. register(): void;
  55295. /**
  55296. * Rebuilds the elements related to this component in case of
  55297. * context lost for instance.
  55298. */
  55299. rebuild(): void;
  55300. /**
  55301. * Serializes the component data to the specified json object
  55302. * @param serializationObject The object to serialize to
  55303. */
  55304. serialize(serializationObject: any): void;
  55305. /**
  55306. * Adds all the elements from the container to the scene
  55307. * @param container the container holding the elements
  55308. */
  55309. addFromContainer(container: AbstractScene): void;
  55310. /**
  55311. * Removes all the elements in the container from the scene
  55312. * @param container contains the elements to remove
  55313. * @param dispose if the removed element should be disposed (default: false)
  55314. */
  55315. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55316. /**
  55317. * Disposes the component and the associated ressources.
  55318. */
  55319. dispose(): void;
  55320. private _isReadyForMesh;
  55321. private _renderMainTexture;
  55322. private _setStencil;
  55323. private _setStencilBack;
  55324. private _draw;
  55325. private _drawCamera;
  55326. private _drawRenderingGroup;
  55327. }
  55328. }
  55329. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  55330. /** @hidden */
  55331. export var glowMapMergePixelShader: {
  55332. name: string;
  55333. shader: string;
  55334. };
  55335. }
  55336. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  55337. /** @hidden */
  55338. export var glowMapMergeVertexShader: {
  55339. name: string;
  55340. shader: string;
  55341. };
  55342. }
  55343. declare module "babylonjs/Layers/glowLayer" {
  55344. import { Nullable } from "babylonjs/types";
  55345. import { Camera } from "babylonjs/Cameras/camera";
  55346. import { Scene } from "babylonjs/scene";
  55347. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55348. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55349. import { Mesh } from "babylonjs/Meshes/mesh";
  55350. import { Texture } from "babylonjs/Materials/Textures/texture";
  55351. import { Effect } from "babylonjs/Materials/effect";
  55352. import { Material } from "babylonjs/Materials/material";
  55353. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55354. import { Color4 } from "babylonjs/Maths/math.color";
  55355. import "babylonjs/Shaders/glowMapMerge.fragment";
  55356. import "babylonjs/Shaders/glowMapMerge.vertex";
  55357. import "babylonjs/Layers/effectLayerSceneComponent";
  55358. module "babylonjs/abstractScene" {
  55359. interface AbstractScene {
  55360. /**
  55361. * Return a the first highlight layer of the scene with a given name.
  55362. * @param name The name of the highlight layer to look for.
  55363. * @return The highlight layer if found otherwise null.
  55364. */
  55365. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  55366. }
  55367. }
  55368. /**
  55369. * Glow layer options. This helps customizing the behaviour
  55370. * of the glow layer.
  55371. */
  55372. export interface IGlowLayerOptions {
  55373. /**
  55374. * Multiplication factor apply to the canvas size to compute the render target size
  55375. * used to generated the glowing objects (the smaller the faster).
  55376. */
  55377. mainTextureRatio: number;
  55378. /**
  55379. * Enforces a fixed size texture to ensure resize independant blur.
  55380. */
  55381. mainTextureFixedSize?: number;
  55382. /**
  55383. * How big is the kernel of the blur texture.
  55384. */
  55385. blurKernelSize: number;
  55386. /**
  55387. * The camera attached to the layer.
  55388. */
  55389. camera: Nullable<Camera>;
  55390. /**
  55391. * Enable MSAA by chosing the number of samples.
  55392. */
  55393. mainTextureSamples?: number;
  55394. /**
  55395. * The rendering group to draw the layer in.
  55396. */
  55397. renderingGroupId: number;
  55398. }
  55399. /**
  55400. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  55401. *
  55402. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  55403. *
  55404. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  55405. */
  55406. export class GlowLayer extends EffectLayer {
  55407. /**
  55408. * Effect Name of the layer.
  55409. */
  55410. static readonly EffectName: string;
  55411. /**
  55412. * The default blur kernel size used for the glow.
  55413. */
  55414. static DefaultBlurKernelSize: number;
  55415. /**
  55416. * The default texture size ratio used for the glow.
  55417. */
  55418. static DefaultTextureRatio: number;
  55419. /**
  55420. * Sets the kernel size of the blur.
  55421. */
  55422. set blurKernelSize(value: number);
  55423. /**
  55424. * Gets the kernel size of the blur.
  55425. */
  55426. get blurKernelSize(): number;
  55427. /**
  55428. * Sets the glow intensity.
  55429. */
  55430. set intensity(value: number);
  55431. /**
  55432. * Gets the glow intensity.
  55433. */
  55434. get intensity(): number;
  55435. private _options;
  55436. private _intensity;
  55437. private _horizontalBlurPostprocess1;
  55438. private _verticalBlurPostprocess1;
  55439. private _horizontalBlurPostprocess2;
  55440. private _verticalBlurPostprocess2;
  55441. private _blurTexture1;
  55442. private _blurTexture2;
  55443. private _postProcesses1;
  55444. private _postProcesses2;
  55445. private _includedOnlyMeshes;
  55446. private _excludedMeshes;
  55447. private _meshesUsingTheirOwnMaterials;
  55448. /**
  55449. * Callback used to let the user override the color selection on a per mesh basis
  55450. */
  55451. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  55452. /**
  55453. * Callback used to let the user override the texture selection on a per mesh basis
  55454. */
  55455. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  55456. /**
  55457. * Instantiates a new glow Layer and references it to the scene.
  55458. * @param name The name of the layer
  55459. * @param scene The scene to use the layer in
  55460. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  55461. */
  55462. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  55463. /**
  55464. * Get the effect name of the layer.
  55465. * @return The effect name
  55466. */
  55467. getEffectName(): string;
  55468. /**
  55469. * Create the merge effect. This is the shader use to blit the information back
  55470. * to the main canvas at the end of the scene rendering.
  55471. */
  55472. protected _createMergeEffect(): Effect;
  55473. /**
  55474. * Creates the render target textures and post processes used in the glow layer.
  55475. */
  55476. protected _createTextureAndPostProcesses(): void;
  55477. /**
  55478. * Checks for the readiness of the element composing the layer.
  55479. * @param subMesh the mesh to check for
  55480. * @param useInstances specify wether or not to use instances to render the mesh
  55481. * @param emissiveTexture the associated emissive texture used to generate the glow
  55482. * @return true if ready otherwise, false
  55483. */
  55484. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55485. /**
  55486. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  55487. */
  55488. needStencil(): boolean;
  55489. /**
  55490. * Returns true if the mesh can be rendered, otherwise false.
  55491. * @param mesh The mesh to render
  55492. * @param material The material used on the mesh
  55493. * @returns true if it can be rendered otherwise false
  55494. */
  55495. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55496. /**
  55497. * Implementation specific of rendering the generating effect on the main canvas.
  55498. * @param effect The effect used to render through
  55499. */
  55500. protected _internalRender(effect: Effect): void;
  55501. /**
  55502. * Sets the required values for both the emissive texture and and the main color.
  55503. */
  55504. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55505. /**
  55506. * Returns true if the mesh should render, otherwise false.
  55507. * @param mesh The mesh to render
  55508. * @returns true if it should render otherwise false
  55509. */
  55510. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55511. /**
  55512. * Adds specific effects defines.
  55513. * @param defines The defines to add specifics to.
  55514. */
  55515. protected _addCustomEffectDefines(defines: string[]): void;
  55516. /**
  55517. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  55518. * @param mesh The mesh to exclude from the glow layer
  55519. */
  55520. addExcludedMesh(mesh: Mesh): void;
  55521. /**
  55522. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  55523. * @param mesh The mesh to remove
  55524. */
  55525. removeExcludedMesh(mesh: Mesh): void;
  55526. /**
  55527. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  55528. * @param mesh The mesh to include in the glow layer
  55529. */
  55530. addIncludedOnlyMesh(mesh: Mesh): void;
  55531. /**
  55532. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  55533. * @param mesh The mesh to remove
  55534. */
  55535. removeIncludedOnlyMesh(mesh: Mesh): void;
  55536. /**
  55537. * Determine if a given mesh will be used in the glow layer
  55538. * @param mesh The mesh to test
  55539. * @returns true if the mesh will be highlighted by the current glow layer
  55540. */
  55541. hasMesh(mesh: AbstractMesh): boolean;
  55542. /**
  55543. * Defines whether the current material of the mesh should be use to render the effect.
  55544. * @param mesh defines the current mesh to render
  55545. */
  55546. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55547. /**
  55548. * Add a mesh to be rendered through its own material and not with emissive only.
  55549. * @param mesh The mesh for which we need to use its material
  55550. */
  55551. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  55552. /**
  55553. * Remove a mesh from being rendered through its own material and not with emissive only.
  55554. * @param mesh The mesh for which we need to not use its material
  55555. */
  55556. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  55557. /**
  55558. * Free any resources and references associated to a mesh.
  55559. * Internal use
  55560. * @param mesh The mesh to free.
  55561. * @hidden
  55562. */
  55563. _disposeMesh(mesh: Mesh): void;
  55564. /**
  55565. * Gets the class name of the effect layer
  55566. * @returns the string with the class name of the effect layer
  55567. */
  55568. getClassName(): string;
  55569. /**
  55570. * Serializes this glow layer
  55571. * @returns a serialized glow layer object
  55572. */
  55573. serialize(): any;
  55574. /**
  55575. * Creates a Glow Layer from parsed glow layer data
  55576. * @param parsedGlowLayer defines glow layer data
  55577. * @param scene defines the current scene
  55578. * @param rootUrl defines the root URL containing the glow layer information
  55579. * @returns a parsed Glow Layer
  55580. */
  55581. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  55582. }
  55583. }
  55584. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  55585. /** @hidden */
  55586. export var glowBlurPostProcessPixelShader: {
  55587. name: string;
  55588. shader: string;
  55589. };
  55590. }
  55591. declare module "babylonjs/Layers/highlightLayer" {
  55592. import { Observable } from "babylonjs/Misc/observable";
  55593. import { Nullable } from "babylonjs/types";
  55594. import { Camera } from "babylonjs/Cameras/camera";
  55595. import { Scene } from "babylonjs/scene";
  55596. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55597. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55598. import { Mesh } from "babylonjs/Meshes/mesh";
  55599. import { Effect } from "babylonjs/Materials/effect";
  55600. import { Material } from "babylonjs/Materials/material";
  55601. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55602. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  55603. import "babylonjs/Shaders/glowMapMerge.fragment";
  55604. import "babylonjs/Shaders/glowMapMerge.vertex";
  55605. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  55606. module "babylonjs/abstractScene" {
  55607. interface AbstractScene {
  55608. /**
  55609. * Return a the first highlight layer of the scene with a given name.
  55610. * @param name The name of the highlight layer to look for.
  55611. * @return The highlight layer if found otherwise null.
  55612. */
  55613. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  55614. }
  55615. }
  55616. /**
  55617. * Highlight layer options. This helps customizing the behaviour
  55618. * of the highlight layer.
  55619. */
  55620. export interface IHighlightLayerOptions {
  55621. /**
  55622. * Multiplication factor apply to the canvas size to compute the render target size
  55623. * used to generated the glowing objects (the smaller the faster).
  55624. */
  55625. mainTextureRatio: number;
  55626. /**
  55627. * Enforces a fixed size texture to ensure resize independant blur.
  55628. */
  55629. mainTextureFixedSize?: number;
  55630. /**
  55631. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  55632. * of the picture to blur (the smaller the faster).
  55633. */
  55634. blurTextureSizeRatio: number;
  55635. /**
  55636. * How big in texel of the blur texture is the vertical blur.
  55637. */
  55638. blurVerticalSize: number;
  55639. /**
  55640. * How big in texel of the blur texture is the horizontal blur.
  55641. */
  55642. blurHorizontalSize: number;
  55643. /**
  55644. * Alpha blending mode used to apply the blur. Default is combine.
  55645. */
  55646. alphaBlendingMode: number;
  55647. /**
  55648. * The camera attached to the layer.
  55649. */
  55650. camera: Nullable<Camera>;
  55651. /**
  55652. * Should we display highlight as a solid stroke?
  55653. */
  55654. isStroke?: boolean;
  55655. /**
  55656. * The rendering group to draw the layer in.
  55657. */
  55658. renderingGroupId: number;
  55659. }
  55660. /**
  55661. * The highlight layer Helps adding a glow effect around a mesh.
  55662. *
  55663. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  55664. * glowy meshes to your scene.
  55665. *
  55666. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  55667. */
  55668. export class HighlightLayer extends EffectLayer {
  55669. name: string;
  55670. /**
  55671. * Effect Name of the highlight layer.
  55672. */
  55673. static readonly EffectName: string;
  55674. /**
  55675. * The neutral color used during the preparation of the glow effect.
  55676. * This is black by default as the blend operation is a blend operation.
  55677. */
  55678. static NeutralColor: Color4;
  55679. /**
  55680. * Stencil value used for glowing meshes.
  55681. */
  55682. static GlowingMeshStencilReference: number;
  55683. /**
  55684. * Stencil value used for the other meshes in the scene.
  55685. */
  55686. static NormalMeshStencilReference: number;
  55687. /**
  55688. * Specifies whether or not the inner glow is ACTIVE in the layer.
  55689. */
  55690. innerGlow: boolean;
  55691. /**
  55692. * Specifies whether or not the outer glow is ACTIVE in the layer.
  55693. */
  55694. outerGlow: boolean;
  55695. /**
  55696. * Specifies the horizontal size of the blur.
  55697. */
  55698. set blurHorizontalSize(value: number);
  55699. /**
  55700. * Specifies the vertical size of the blur.
  55701. */
  55702. set blurVerticalSize(value: number);
  55703. /**
  55704. * Gets the horizontal size of the blur.
  55705. */
  55706. get blurHorizontalSize(): number;
  55707. /**
  55708. * Gets the vertical size of the blur.
  55709. */
  55710. get blurVerticalSize(): number;
  55711. /**
  55712. * An event triggered when the highlight layer is being blurred.
  55713. */
  55714. onBeforeBlurObservable: Observable<HighlightLayer>;
  55715. /**
  55716. * An event triggered when the highlight layer has been blurred.
  55717. */
  55718. onAfterBlurObservable: Observable<HighlightLayer>;
  55719. private _instanceGlowingMeshStencilReference;
  55720. private _options;
  55721. private _downSamplePostprocess;
  55722. private _horizontalBlurPostprocess;
  55723. private _verticalBlurPostprocess;
  55724. private _blurTexture;
  55725. private _meshes;
  55726. private _excludedMeshes;
  55727. /**
  55728. * Instantiates a new highlight Layer and references it to the scene..
  55729. * @param name The name of the layer
  55730. * @param scene The scene to use the layer in
  55731. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  55732. */
  55733. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  55734. /**
  55735. * Get the effect name of the layer.
  55736. * @return The effect name
  55737. */
  55738. getEffectName(): string;
  55739. /**
  55740. * Create the merge effect. This is the shader use to blit the information back
  55741. * to the main canvas at the end of the scene rendering.
  55742. */
  55743. protected _createMergeEffect(): Effect;
  55744. /**
  55745. * Creates the render target textures and post processes used in the highlight layer.
  55746. */
  55747. protected _createTextureAndPostProcesses(): void;
  55748. /**
  55749. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  55750. */
  55751. needStencil(): boolean;
  55752. /**
  55753. * Checks for the readiness of the element composing the layer.
  55754. * @param subMesh the mesh to check for
  55755. * @param useInstances specify wether or not to use instances to render the mesh
  55756. * @param emissiveTexture the associated emissive texture used to generate the glow
  55757. * @return true if ready otherwise, false
  55758. */
  55759. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55760. /**
  55761. * Implementation specific of rendering the generating effect on the main canvas.
  55762. * @param effect The effect used to render through
  55763. */
  55764. protected _internalRender(effect: Effect): void;
  55765. /**
  55766. * Returns true if the layer contains information to display, otherwise false.
  55767. */
  55768. shouldRender(): boolean;
  55769. /**
  55770. * Returns true if the mesh should render, otherwise false.
  55771. * @param mesh The mesh to render
  55772. * @returns true if it should render otherwise false
  55773. */
  55774. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55775. /**
  55776. * Sets the required values for both the emissive texture and and the main color.
  55777. */
  55778. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55779. /**
  55780. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  55781. * @param mesh The mesh to exclude from the highlight layer
  55782. */
  55783. addExcludedMesh(mesh: Mesh): void;
  55784. /**
  55785. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  55786. * @param mesh The mesh to highlight
  55787. */
  55788. removeExcludedMesh(mesh: Mesh): void;
  55789. /**
  55790. * Determine if a given mesh will be highlighted by the current HighlightLayer
  55791. * @param mesh mesh to test
  55792. * @returns true if the mesh will be highlighted by the current HighlightLayer
  55793. */
  55794. hasMesh(mesh: AbstractMesh): boolean;
  55795. /**
  55796. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  55797. * @param mesh The mesh to highlight
  55798. * @param color The color of the highlight
  55799. * @param glowEmissiveOnly Extract the glow from the emissive texture
  55800. */
  55801. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  55802. /**
  55803. * Remove a mesh from the highlight layer in order to make it stop glowing.
  55804. * @param mesh The mesh to highlight
  55805. */
  55806. removeMesh(mesh: Mesh): void;
  55807. /**
  55808. * Force the stencil to the normal expected value for none glowing parts
  55809. */
  55810. private _defaultStencilReference;
  55811. /**
  55812. * Free any resources and references associated to a mesh.
  55813. * Internal use
  55814. * @param mesh The mesh to free.
  55815. * @hidden
  55816. */
  55817. _disposeMesh(mesh: Mesh): void;
  55818. /**
  55819. * Dispose the highlight layer and free resources.
  55820. */
  55821. dispose(): void;
  55822. /**
  55823. * Gets the class name of the effect layer
  55824. * @returns the string with the class name of the effect layer
  55825. */
  55826. getClassName(): string;
  55827. /**
  55828. * Serializes this Highlight layer
  55829. * @returns a serialized Highlight layer object
  55830. */
  55831. serialize(): any;
  55832. /**
  55833. * Creates a Highlight layer from parsed Highlight layer data
  55834. * @param parsedHightlightLayer defines the Highlight layer data
  55835. * @param scene defines the current scene
  55836. * @param rootUrl defines the root URL containing the Highlight layer information
  55837. * @returns a parsed Highlight layer
  55838. */
  55839. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  55840. }
  55841. }
  55842. declare module "babylonjs/Layers/layerSceneComponent" {
  55843. import { Scene } from "babylonjs/scene";
  55844. import { ISceneComponent } from "babylonjs/sceneComponent";
  55845. import { Layer } from "babylonjs/Layers/layer";
  55846. import { AbstractScene } from "babylonjs/abstractScene";
  55847. module "babylonjs/abstractScene" {
  55848. interface AbstractScene {
  55849. /**
  55850. * The list of layers (background and foreground) of the scene
  55851. */
  55852. layers: Array<Layer>;
  55853. }
  55854. }
  55855. /**
  55856. * Defines the layer scene component responsible to manage any layers
  55857. * in a given scene.
  55858. */
  55859. export class LayerSceneComponent implements ISceneComponent {
  55860. /**
  55861. * The component name helpfull to identify the component in the list of scene components.
  55862. */
  55863. readonly name: string;
  55864. /**
  55865. * The scene the component belongs to.
  55866. */
  55867. scene: Scene;
  55868. private _engine;
  55869. /**
  55870. * Creates a new instance of the component for the given scene
  55871. * @param scene Defines the scene to register the component in
  55872. */
  55873. constructor(scene: Scene);
  55874. /**
  55875. * Registers the component in a given scene
  55876. */
  55877. register(): void;
  55878. /**
  55879. * Rebuilds the elements related to this component in case of
  55880. * context lost for instance.
  55881. */
  55882. rebuild(): void;
  55883. /**
  55884. * Disposes the component and the associated ressources.
  55885. */
  55886. dispose(): void;
  55887. private _draw;
  55888. private _drawCameraPredicate;
  55889. private _drawCameraBackground;
  55890. private _drawCameraForeground;
  55891. private _drawRenderTargetPredicate;
  55892. private _drawRenderTargetBackground;
  55893. private _drawRenderTargetForeground;
  55894. /**
  55895. * Adds all the elements from the container to the scene
  55896. * @param container the container holding the elements
  55897. */
  55898. addFromContainer(container: AbstractScene): void;
  55899. /**
  55900. * Removes all the elements in the container from the scene
  55901. * @param container contains the elements to remove
  55902. * @param dispose if the removed element should be disposed (default: false)
  55903. */
  55904. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55905. }
  55906. }
  55907. declare module "babylonjs/Shaders/layer.fragment" {
  55908. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55909. /** @hidden */
  55910. export var layerPixelShader: {
  55911. name: string;
  55912. shader: string;
  55913. };
  55914. }
  55915. declare module "babylonjs/Shaders/layer.vertex" {
  55916. /** @hidden */
  55917. export var layerVertexShader: {
  55918. name: string;
  55919. shader: string;
  55920. };
  55921. }
  55922. declare module "babylonjs/Layers/layer" {
  55923. import { Observable } from "babylonjs/Misc/observable";
  55924. import { Nullable } from "babylonjs/types";
  55925. import { Scene } from "babylonjs/scene";
  55926. import { Vector2 } from "babylonjs/Maths/math.vector";
  55927. import { Color4 } from "babylonjs/Maths/math.color";
  55928. import { Texture } from "babylonjs/Materials/Textures/texture";
  55929. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55930. import "babylonjs/Shaders/layer.fragment";
  55931. import "babylonjs/Shaders/layer.vertex";
  55932. /**
  55933. * This represents a full screen 2d layer.
  55934. * This can be useful to display a picture in the background of your scene for instance.
  55935. * @see https://www.babylonjs-playground.com/#08A2BS#1
  55936. */
  55937. export class Layer {
  55938. /**
  55939. * Define the name of the layer.
  55940. */
  55941. name: string;
  55942. /**
  55943. * Define the texture the layer should display.
  55944. */
  55945. texture: Nullable<Texture>;
  55946. /**
  55947. * Is the layer in background or foreground.
  55948. */
  55949. isBackground: boolean;
  55950. /**
  55951. * Define the color of the layer (instead of texture).
  55952. */
  55953. color: Color4;
  55954. /**
  55955. * Define the scale of the layer in order to zoom in out of the texture.
  55956. */
  55957. scale: Vector2;
  55958. /**
  55959. * Define an offset for the layer in order to shift the texture.
  55960. */
  55961. offset: Vector2;
  55962. /**
  55963. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  55964. */
  55965. alphaBlendingMode: number;
  55966. /**
  55967. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  55968. * Alpha test will not mix with the background color in case of transparency.
  55969. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  55970. */
  55971. alphaTest: boolean;
  55972. /**
  55973. * Define a mask to restrict the layer to only some of the scene cameras.
  55974. */
  55975. layerMask: number;
  55976. /**
  55977. * Define the list of render target the layer is visible into.
  55978. */
  55979. renderTargetTextures: RenderTargetTexture[];
  55980. /**
  55981. * Define if the layer is only used in renderTarget or if it also
  55982. * renders in the main frame buffer of the canvas.
  55983. */
  55984. renderOnlyInRenderTargetTextures: boolean;
  55985. private _scene;
  55986. private _vertexBuffers;
  55987. private _indexBuffer;
  55988. private _effect;
  55989. private _previousDefines;
  55990. /**
  55991. * An event triggered when the layer is disposed.
  55992. */
  55993. onDisposeObservable: Observable<Layer>;
  55994. private _onDisposeObserver;
  55995. /**
  55996. * Back compatibility with callback before the onDisposeObservable existed.
  55997. * The set callback will be triggered when the layer has been disposed.
  55998. */
  55999. set onDispose(callback: () => void);
  56000. /**
  56001. * An event triggered before rendering the scene
  56002. */
  56003. onBeforeRenderObservable: Observable<Layer>;
  56004. private _onBeforeRenderObserver;
  56005. /**
  56006. * Back compatibility with callback before the onBeforeRenderObservable existed.
  56007. * The set callback will be triggered just before rendering the layer.
  56008. */
  56009. set onBeforeRender(callback: () => void);
  56010. /**
  56011. * An event triggered after rendering the scene
  56012. */
  56013. onAfterRenderObservable: Observable<Layer>;
  56014. private _onAfterRenderObserver;
  56015. /**
  56016. * Back compatibility with callback before the onAfterRenderObservable existed.
  56017. * The set callback will be triggered just after rendering the layer.
  56018. */
  56019. set onAfterRender(callback: () => void);
  56020. /**
  56021. * Instantiates a new layer.
  56022. * This represents a full screen 2d layer.
  56023. * This can be useful to display a picture in the background of your scene for instance.
  56024. * @see https://www.babylonjs-playground.com/#08A2BS#1
  56025. * @param name Define the name of the layer in the scene
  56026. * @param imgUrl Define the url of the texture to display in the layer
  56027. * @param scene Define the scene the layer belongs to
  56028. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  56029. * @param color Defines a color for the layer
  56030. */
  56031. constructor(
  56032. /**
  56033. * Define the name of the layer.
  56034. */
  56035. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  56036. private _createIndexBuffer;
  56037. /** @hidden */
  56038. _rebuild(): void;
  56039. /**
  56040. * Renders the layer in the scene.
  56041. */
  56042. render(): void;
  56043. /**
  56044. * Disposes and releases the associated ressources.
  56045. */
  56046. dispose(): void;
  56047. }
  56048. }
  56049. declare module "babylonjs/Layers/index" {
  56050. export * from "babylonjs/Layers/effectLayer";
  56051. export * from "babylonjs/Layers/effectLayerSceneComponent";
  56052. export * from "babylonjs/Layers/glowLayer";
  56053. export * from "babylonjs/Layers/highlightLayer";
  56054. export * from "babylonjs/Layers/layer";
  56055. export * from "babylonjs/Layers/layerSceneComponent";
  56056. }
  56057. declare module "babylonjs/Shaders/lensFlare.fragment" {
  56058. /** @hidden */
  56059. export var lensFlarePixelShader: {
  56060. name: string;
  56061. shader: string;
  56062. };
  56063. }
  56064. declare module "babylonjs/Shaders/lensFlare.vertex" {
  56065. /** @hidden */
  56066. export var lensFlareVertexShader: {
  56067. name: string;
  56068. shader: string;
  56069. };
  56070. }
  56071. declare module "babylonjs/LensFlares/lensFlareSystem" {
  56072. import { Scene } from "babylonjs/scene";
  56073. import { Vector3 } from "babylonjs/Maths/math.vector";
  56074. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56075. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  56076. import "babylonjs/Shaders/lensFlare.fragment";
  56077. import "babylonjs/Shaders/lensFlare.vertex";
  56078. import { Viewport } from "babylonjs/Maths/math.viewport";
  56079. /**
  56080. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56081. * It is usually composed of several `lensFlare`.
  56082. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56083. */
  56084. export class LensFlareSystem {
  56085. /**
  56086. * Define the name of the lens flare system
  56087. */
  56088. name: string;
  56089. /**
  56090. * List of lens flares used in this system.
  56091. */
  56092. lensFlares: LensFlare[];
  56093. /**
  56094. * Define a limit from the border the lens flare can be visible.
  56095. */
  56096. borderLimit: number;
  56097. /**
  56098. * Define a viewport border we do not want to see the lens flare in.
  56099. */
  56100. viewportBorder: number;
  56101. /**
  56102. * Define a predicate which could limit the list of meshes able to occlude the effect.
  56103. */
  56104. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  56105. /**
  56106. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  56107. */
  56108. layerMask: number;
  56109. /**
  56110. * Define the id of the lens flare system in the scene.
  56111. * (equal to name by default)
  56112. */
  56113. id: string;
  56114. private _scene;
  56115. private _emitter;
  56116. private _vertexBuffers;
  56117. private _indexBuffer;
  56118. private _effect;
  56119. private _positionX;
  56120. private _positionY;
  56121. private _isEnabled;
  56122. /** @hidden */
  56123. static _SceneComponentInitialization: (scene: Scene) => void;
  56124. /**
  56125. * Instantiates a lens flare system.
  56126. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56127. * It is usually composed of several `lensFlare`.
  56128. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56129. * @param name Define the name of the lens flare system in the scene
  56130. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  56131. * @param scene Define the scene the lens flare system belongs to
  56132. */
  56133. constructor(
  56134. /**
  56135. * Define the name of the lens flare system
  56136. */
  56137. name: string, emitter: any, scene: Scene);
  56138. /**
  56139. * Define if the lens flare system is enabled.
  56140. */
  56141. get isEnabled(): boolean;
  56142. set isEnabled(value: boolean);
  56143. /**
  56144. * Get the scene the effects belongs to.
  56145. * @returns the scene holding the lens flare system
  56146. */
  56147. getScene(): Scene;
  56148. /**
  56149. * Get the emitter of the lens flare system.
  56150. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56151. * @returns the emitter of the lens flare system
  56152. */
  56153. getEmitter(): any;
  56154. /**
  56155. * Set the emitter of the lens flare system.
  56156. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56157. * @param newEmitter Define the new emitter of the system
  56158. */
  56159. setEmitter(newEmitter: any): void;
  56160. /**
  56161. * Get the lens flare system emitter position.
  56162. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  56163. * @returns the position
  56164. */
  56165. getEmitterPosition(): Vector3;
  56166. /**
  56167. * @hidden
  56168. */
  56169. computeEffectivePosition(globalViewport: Viewport): boolean;
  56170. /** @hidden */
  56171. _isVisible(): boolean;
  56172. /**
  56173. * @hidden
  56174. */
  56175. render(): boolean;
  56176. /**
  56177. * Dispose and release the lens flare with its associated resources.
  56178. */
  56179. dispose(): void;
  56180. /**
  56181. * Parse a lens flare system from a JSON repressentation
  56182. * @param parsedLensFlareSystem Define the JSON to parse
  56183. * @param scene Define the scene the parsed system should be instantiated in
  56184. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  56185. * @returns the parsed system
  56186. */
  56187. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  56188. /**
  56189. * Serialize the current Lens Flare System into a JSON representation.
  56190. * @returns the serialized JSON
  56191. */
  56192. serialize(): any;
  56193. }
  56194. }
  56195. declare module "babylonjs/LensFlares/lensFlare" {
  56196. import { Nullable } from "babylonjs/types";
  56197. import { Color3 } from "babylonjs/Maths/math.color";
  56198. import { Texture } from "babylonjs/Materials/Textures/texture";
  56199. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56200. /**
  56201. * This represents one of the lens effect in a `lensFlareSystem`.
  56202. * It controls one of the indiviual texture used in the effect.
  56203. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56204. */
  56205. export class LensFlare {
  56206. /**
  56207. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56208. */
  56209. size: number;
  56210. /**
  56211. * 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.
  56212. */
  56213. position: number;
  56214. /**
  56215. * Define the lens color.
  56216. */
  56217. color: Color3;
  56218. /**
  56219. * Define the lens texture.
  56220. */
  56221. texture: Nullable<Texture>;
  56222. /**
  56223. * Define the alpha mode to render this particular lens.
  56224. */
  56225. alphaMode: number;
  56226. private _system;
  56227. /**
  56228. * Creates a new Lens Flare.
  56229. * This represents one of the lens effect in a `lensFlareSystem`.
  56230. * It controls one of the indiviual texture used in the effect.
  56231. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56232. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  56233. * @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.
  56234. * @param color Define the lens color
  56235. * @param imgUrl Define the lens texture url
  56236. * @param system Define the `lensFlareSystem` this flare is part of
  56237. * @returns The newly created Lens Flare
  56238. */
  56239. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  56240. /**
  56241. * Instantiates a new Lens Flare.
  56242. * This represents one of the lens effect in a `lensFlareSystem`.
  56243. * It controls one of the indiviual texture used in the effect.
  56244. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56245. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  56246. * @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.
  56247. * @param color Define the lens color
  56248. * @param imgUrl Define the lens texture url
  56249. * @param system Define the `lensFlareSystem` this flare is part of
  56250. */
  56251. constructor(
  56252. /**
  56253. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56254. */
  56255. size: number,
  56256. /**
  56257. * 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.
  56258. */
  56259. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  56260. /**
  56261. * Dispose and release the lens flare with its associated resources.
  56262. */
  56263. dispose(): void;
  56264. }
  56265. }
  56266. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  56267. import { Nullable } from "babylonjs/types";
  56268. import { Scene } from "babylonjs/scene";
  56269. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56270. import { AbstractScene } from "babylonjs/abstractScene";
  56271. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56272. module "babylonjs/abstractScene" {
  56273. interface AbstractScene {
  56274. /**
  56275. * The list of lens flare system added to the scene
  56276. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56277. */
  56278. lensFlareSystems: Array<LensFlareSystem>;
  56279. /**
  56280. * Removes the given lens flare system from this scene.
  56281. * @param toRemove The lens flare system to remove
  56282. * @returns The index of the removed lens flare system
  56283. */
  56284. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  56285. /**
  56286. * Adds the given lens flare system to this scene
  56287. * @param newLensFlareSystem The lens flare system to add
  56288. */
  56289. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  56290. /**
  56291. * Gets a lens flare system using its name
  56292. * @param name defines the name to look for
  56293. * @returns the lens flare system or null if not found
  56294. */
  56295. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  56296. /**
  56297. * Gets a lens flare system using its id
  56298. * @param id defines the id to look for
  56299. * @returns the lens flare system or null if not found
  56300. */
  56301. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  56302. }
  56303. }
  56304. /**
  56305. * Defines the lens flare scene component responsible to manage any lens flares
  56306. * in a given scene.
  56307. */
  56308. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  56309. /**
  56310. * The component name helpfull to identify the component in the list of scene components.
  56311. */
  56312. readonly name: string;
  56313. /**
  56314. * The scene the component belongs to.
  56315. */
  56316. scene: Scene;
  56317. /**
  56318. * Creates a new instance of the component for the given scene
  56319. * @param scene Defines the scene to register the component in
  56320. */
  56321. constructor(scene: Scene);
  56322. /**
  56323. * Registers the component in a given scene
  56324. */
  56325. register(): void;
  56326. /**
  56327. * Rebuilds the elements related to this component in case of
  56328. * context lost for instance.
  56329. */
  56330. rebuild(): void;
  56331. /**
  56332. * Adds all the elements from the container to the scene
  56333. * @param container the container holding the elements
  56334. */
  56335. addFromContainer(container: AbstractScene): void;
  56336. /**
  56337. * Removes all the elements in the container from the scene
  56338. * @param container contains the elements to remove
  56339. * @param dispose if the removed element should be disposed (default: false)
  56340. */
  56341. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56342. /**
  56343. * Serializes the component data to the specified json object
  56344. * @param serializationObject The object to serialize to
  56345. */
  56346. serialize(serializationObject: any): void;
  56347. /**
  56348. * Disposes the component and the associated ressources.
  56349. */
  56350. dispose(): void;
  56351. private _draw;
  56352. }
  56353. }
  56354. declare module "babylonjs/LensFlares/index" {
  56355. export * from "babylonjs/LensFlares/lensFlare";
  56356. export * from "babylonjs/LensFlares/lensFlareSystem";
  56357. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  56358. }
  56359. declare module "babylonjs/Shaders/depth.fragment" {
  56360. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  56361. /** @hidden */
  56362. export var depthPixelShader: {
  56363. name: string;
  56364. shader: string;
  56365. };
  56366. }
  56367. declare module "babylonjs/Shaders/depth.vertex" {
  56368. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56369. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56370. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56371. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56372. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  56373. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56374. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56375. /** @hidden */
  56376. export var depthVertexShader: {
  56377. name: string;
  56378. shader: string;
  56379. };
  56380. }
  56381. declare module "babylonjs/Rendering/depthRenderer" {
  56382. import { Nullable } from "babylonjs/types";
  56383. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56384. import { Scene } from "babylonjs/scene";
  56385. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56386. import { Camera } from "babylonjs/Cameras/camera";
  56387. import "babylonjs/Shaders/depth.fragment";
  56388. import "babylonjs/Shaders/depth.vertex";
  56389. /**
  56390. * This represents a depth renderer in Babylon.
  56391. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56392. */
  56393. export class DepthRenderer {
  56394. private _scene;
  56395. private _depthMap;
  56396. private _effect;
  56397. private readonly _storeNonLinearDepth;
  56398. private readonly _clearColor;
  56399. /** Get if the depth renderer is using packed depth or not */
  56400. readonly isPacked: boolean;
  56401. private _cachedDefines;
  56402. private _camera;
  56403. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  56404. enabled: boolean;
  56405. /**
  56406. * Specifiess that the depth renderer will only be used within
  56407. * the camera it is created for.
  56408. * This can help forcing its rendering during the camera processing.
  56409. */
  56410. useOnlyInActiveCamera: boolean;
  56411. /** @hidden */
  56412. static _SceneComponentInitialization: (scene: Scene) => void;
  56413. /**
  56414. * Instantiates a depth renderer
  56415. * @param scene The scene the renderer belongs to
  56416. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56417. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56418. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  56419. */
  56420. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  56421. /**
  56422. * Creates the depth rendering effect and checks if the effect is ready.
  56423. * @param subMesh The submesh to be used to render the depth map of
  56424. * @param useInstances If multiple world instances should be used
  56425. * @returns if the depth renderer is ready to render the depth map
  56426. */
  56427. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56428. /**
  56429. * Gets the texture which the depth map will be written to.
  56430. * @returns The depth map texture
  56431. */
  56432. getDepthMap(): RenderTargetTexture;
  56433. /**
  56434. * Disposes of the depth renderer.
  56435. */
  56436. dispose(): void;
  56437. }
  56438. }
  56439. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  56440. /** @hidden */
  56441. export var minmaxReduxPixelShader: {
  56442. name: string;
  56443. shader: string;
  56444. };
  56445. }
  56446. declare module "babylonjs/Misc/minMaxReducer" {
  56447. import { Nullable } from "babylonjs/types";
  56448. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56449. import { Camera } from "babylonjs/Cameras/camera";
  56450. import { Observer } from "babylonjs/Misc/observable";
  56451. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56452. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  56453. import { Observable } from "babylonjs/Misc/observable";
  56454. import "babylonjs/Shaders/minmaxRedux.fragment";
  56455. /**
  56456. * This class computes a min/max reduction from a texture: it means it computes the minimum
  56457. * and maximum values from all values of the texture.
  56458. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  56459. * The source values are read from the red channel of the texture.
  56460. */
  56461. export class MinMaxReducer {
  56462. /**
  56463. * Observable triggered when the computation has been performed
  56464. */
  56465. onAfterReductionPerformed: Observable<{
  56466. min: number;
  56467. max: number;
  56468. }>;
  56469. protected _camera: Camera;
  56470. protected _sourceTexture: Nullable<RenderTargetTexture>;
  56471. protected _reductionSteps: Nullable<Array<PostProcess>>;
  56472. protected _postProcessManager: PostProcessManager;
  56473. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  56474. protected _forceFullscreenViewport: boolean;
  56475. /**
  56476. * Creates a min/max reducer
  56477. * @param camera The camera to use for the post processes
  56478. */
  56479. constructor(camera: Camera);
  56480. /**
  56481. * Gets the texture used to read the values from.
  56482. */
  56483. get sourceTexture(): Nullable<RenderTargetTexture>;
  56484. /**
  56485. * Sets the source texture to read the values from.
  56486. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  56487. * because in such textures '1' value must not be taken into account to compute the maximum
  56488. * as this value is used to clear the texture.
  56489. * Note that the computation is not activated by calling this function, you must call activate() for that!
  56490. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  56491. * @param depthRedux Indicates if the texture is a depth texture or not
  56492. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  56493. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56494. */
  56495. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56496. /**
  56497. * Defines the refresh rate of the computation.
  56498. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  56499. */
  56500. get refreshRate(): number;
  56501. set refreshRate(value: number);
  56502. protected _activated: boolean;
  56503. /**
  56504. * Gets the activation status of the reducer
  56505. */
  56506. get activated(): boolean;
  56507. /**
  56508. * Activates the reduction computation.
  56509. * When activated, the observers registered in onAfterReductionPerformed are
  56510. * called after the compuation is performed
  56511. */
  56512. activate(): void;
  56513. /**
  56514. * Deactivates the reduction computation.
  56515. */
  56516. deactivate(): void;
  56517. /**
  56518. * Disposes the min/max reducer
  56519. * @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.
  56520. */
  56521. dispose(disposeAll?: boolean): void;
  56522. }
  56523. }
  56524. declare module "babylonjs/Misc/depthReducer" {
  56525. import { Nullable } from "babylonjs/types";
  56526. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56527. import { Camera } from "babylonjs/Cameras/camera";
  56528. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56529. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  56530. /**
  56531. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  56532. */
  56533. export class DepthReducer extends MinMaxReducer {
  56534. private _depthRenderer;
  56535. private _depthRendererId;
  56536. /**
  56537. * Gets the depth renderer used for the computation.
  56538. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  56539. */
  56540. get depthRenderer(): Nullable<DepthRenderer>;
  56541. /**
  56542. * Creates a depth reducer
  56543. * @param camera The camera used to render the depth texture
  56544. */
  56545. constructor(camera: Camera);
  56546. /**
  56547. * Sets the depth renderer to use to generate the depth map
  56548. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  56549. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  56550. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56551. */
  56552. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  56553. /** @hidden */
  56554. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56555. /**
  56556. * Activates the reduction computation.
  56557. * When activated, the observers registered in onAfterReductionPerformed are
  56558. * called after the compuation is performed
  56559. */
  56560. activate(): void;
  56561. /**
  56562. * Deactivates the reduction computation.
  56563. */
  56564. deactivate(): void;
  56565. /**
  56566. * Disposes the depth reducer
  56567. * @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.
  56568. */
  56569. dispose(disposeAll?: boolean): void;
  56570. }
  56571. }
  56572. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  56573. import { Nullable } from "babylonjs/types";
  56574. import { Scene } from "babylonjs/scene";
  56575. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56576. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56577. import { Effect } from "babylonjs/Materials/effect";
  56578. import "babylonjs/Shaders/shadowMap.fragment";
  56579. import "babylonjs/Shaders/shadowMap.vertex";
  56580. import "babylonjs/Shaders/depthBoxBlur.fragment";
  56581. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  56582. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  56583. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  56584. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56585. /**
  56586. * A CSM implementation allowing casting shadows on large scenes.
  56587. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  56588. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  56589. */
  56590. export class CascadedShadowGenerator extends ShadowGenerator {
  56591. private static readonly frustumCornersNDCSpace;
  56592. /**
  56593. * Name of the CSM class
  56594. */
  56595. static CLASSNAME: string;
  56596. /**
  56597. * Defines the default number of cascades used by the CSM.
  56598. */
  56599. static readonly DEFAULT_CASCADES_COUNT: number;
  56600. /**
  56601. * Defines the minimum number of cascades used by the CSM.
  56602. */
  56603. static readonly MIN_CASCADES_COUNT: number;
  56604. /**
  56605. * Defines the maximum number of cascades used by the CSM.
  56606. */
  56607. static readonly MAX_CASCADES_COUNT: number;
  56608. protected _validateFilter(filter: number): number;
  56609. /**
  56610. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  56611. */
  56612. penumbraDarkness: number;
  56613. private _numCascades;
  56614. /**
  56615. * Gets or set the number of cascades used by the CSM.
  56616. */
  56617. get numCascades(): number;
  56618. set numCascades(value: number);
  56619. /**
  56620. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  56621. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  56622. */
  56623. stabilizeCascades: boolean;
  56624. private _freezeShadowCastersBoundingInfo;
  56625. private _freezeShadowCastersBoundingInfoObservable;
  56626. /**
  56627. * Enables or disables the shadow casters bounding info computation.
  56628. * If your shadow casters don't move, you can disable this feature.
  56629. * If it is enabled, the bounding box computation is done every frame.
  56630. */
  56631. get freezeShadowCastersBoundingInfo(): boolean;
  56632. set freezeShadowCastersBoundingInfo(freeze: boolean);
  56633. private _scbiMin;
  56634. private _scbiMax;
  56635. protected _computeShadowCastersBoundingInfo(): void;
  56636. protected _shadowCastersBoundingInfo: BoundingInfo;
  56637. /**
  56638. * Gets or sets the shadow casters bounding info.
  56639. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  56640. * so that the system won't overwrite the bounds you provide
  56641. */
  56642. get shadowCastersBoundingInfo(): BoundingInfo;
  56643. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  56644. protected _breaksAreDirty: boolean;
  56645. protected _minDistance: number;
  56646. protected _maxDistance: number;
  56647. /**
  56648. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  56649. *
  56650. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  56651. * If you don't know these values, simply leave them to their defaults and don't call this function.
  56652. * @param min minimal distance for the breaks (default to 0.)
  56653. * @param max maximal distance for the breaks (default to 1.)
  56654. */
  56655. setMinMaxDistance(min: number, max: number): void;
  56656. /** Gets the minimal distance used in the cascade break computation */
  56657. get minDistance(): number;
  56658. /** Gets the maximal distance used in the cascade break computation */
  56659. get maxDistance(): number;
  56660. /**
  56661. * Gets the class name of that object
  56662. * @returns "CascadedShadowGenerator"
  56663. */
  56664. getClassName(): string;
  56665. private _cascadeMinExtents;
  56666. private _cascadeMaxExtents;
  56667. /**
  56668. * Gets a cascade minimum extents
  56669. * @param cascadeIndex index of the cascade
  56670. * @returns the minimum cascade extents
  56671. */
  56672. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  56673. /**
  56674. * Gets a cascade maximum extents
  56675. * @param cascadeIndex index of the cascade
  56676. * @returns the maximum cascade extents
  56677. */
  56678. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  56679. private _cascades;
  56680. private _currentLayer;
  56681. private _viewSpaceFrustumsZ;
  56682. private _viewMatrices;
  56683. private _projectionMatrices;
  56684. private _transformMatrices;
  56685. private _transformMatricesAsArray;
  56686. private _frustumLengths;
  56687. private _lightSizeUVCorrection;
  56688. private _depthCorrection;
  56689. private _frustumCornersWorldSpace;
  56690. private _frustumCenter;
  56691. private _shadowCameraPos;
  56692. private _shadowMaxZ;
  56693. /**
  56694. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  56695. * It defaults to camera.maxZ
  56696. */
  56697. get shadowMaxZ(): number;
  56698. /**
  56699. * Sets the shadow max z distance.
  56700. */
  56701. set shadowMaxZ(value: number);
  56702. protected _debug: boolean;
  56703. /**
  56704. * Gets or sets the debug flag.
  56705. * When enabled, the cascades are materialized by different colors on the screen.
  56706. */
  56707. get debug(): boolean;
  56708. set debug(dbg: boolean);
  56709. private _depthClamp;
  56710. /**
  56711. * Gets or sets the depth clamping value.
  56712. *
  56713. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  56714. * to account for the shadow casters far away.
  56715. *
  56716. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  56717. */
  56718. get depthClamp(): boolean;
  56719. set depthClamp(value: boolean);
  56720. private _cascadeBlendPercentage;
  56721. /**
  56722. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  56723. * It defaults to 0.1 (10% blending).
  56724. */
  56725. get cascadeBlendPercentage(): number;
  56726. set cascadeBlendPercentage(value: number);
  56727. private _lambda;
  56728. /**
  56729. * Gets or set the lambda parameter.
  56730. * This parameter is used to split the camera frustum and create the cascades.
  56731. * 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.
  56732. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  56733. */
  56734. get lambda(): number;
  56735. set lambda(value: number);
  56736. /**
  56737. * Gets the view matrix corresponding to a given cascade
  56738. * @param cascadeNum cascade to retrieve the view matrix from
  56739. * @returns the cascade view matrix
  56740. */
  56741. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  56742. /**
  56743. * Gets the projection matrix corresponding to a given cascade
  56744. * @param cascadeNum cascade to retrieve the projection matrix from
  56745. * @returns the cascade projection matrix
  56746. */
  56747. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  56748. /**
  56749. * Gets the transformation matrix corresponding to a given cascade
  56750. * @param cascadeNum cascade to retrieve the transformation matrix from
  56751. * @returns the cascade transformation matrix
  56752. */
  56753. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  56754. private _depthRenderer;
  56755. /**
  56756. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  56757. *
  56758. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  56759. *
  56760. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  56761. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  56762. * @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
  56763. */
  56764. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  56765. private _depthReducer;
  56766. private _autoCalcDepthBounds;
  56767. /**
  56768. * Gets or sets the autoCalcDepthBounds property.
  56769. *
  56770. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  56771. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  56772. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  56773. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  56774. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  56775. */
  56776. get autoCalcDepthBounds(): boolean;
  56777. set autoCalcDepthBounds(value: boolean);
  56778. /**
  56779. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  56780. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  56781. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  56782. * for setting the refresh rate on the renderer yourself!
  56783. */
  56784. get autoCalcDepthBoundsRefreshRate(): number;
  56785. set autoCalcDepthBoundsRefreshRate(value: number);
  56786. /**
  56787. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  56788. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  56789. * you change the camera near/far planes!
  56790. */
  56791. splitFrustum(): void;
  56792. private _splitFrustum;
  56793. private _computeMatrices;
  56794. private _computeFrustumInWorldSpace;
  56795. private _computeCascadeFrustum;
  56796. /** @hidden */
  56797. static _SceneComponentInitialization: (scene: Scene) => void;
  56798. /**
  56799. * Creates a Cascaded Shadow Generator object.
  56800. * A ShadowGenerator is the required tool to use the shadows.
  56801. * Each directional light casting shadows needs to use its own ShadowGenerator.
  56802. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  56803. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  56804. * @param light The directional light object generating the shadows.
  56805. * @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.
  56806. */
  56807. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  56808. protected _initializeGenerator(): void;
  56809. protected _createTargetRenderTexture(): void;
  56810. protected _initializeShadowMap(): void;
  56811. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  56812. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  56813. /**
  56814. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  56815. * @param defines Defines of the material we want to update
  56816. * @param lightIndex Index of the light in the enabled light list of the material
  56817. */
  56818. prepareDefines(defines: any, lightIndex: number): void;
  56819. /**
  56820. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  56821. * defined in the generator but impacting the effect).
  56822. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  56823. * @param effect The effect we are binfing the information for
  56824. */
  56825. bindShadowLight(lightIndex: string, effect: Effect): void;
  56826. /**
  56827. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  56828. * (eq to view projection * shadow projection matrices)
  56829. * @returns The transform matrix used to create the shadow map
  56830. */
  56831. getTransformMatrix(): Matrix;
  56832. /**
  56833. * Disposes the ShadowGenerator.
  56834. * Returns nothing.
  56835. */
  56836. dispose(): void;
  56837. /**
  56838. * Serializes the shadow generator setup to a json object.
  56839. * @returns The serialized JSON object
  56840. */
  56841. serialize(): any;
  56842. /**
  56843. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  56844. * @param parsedShadowGenerator The JSON object to parse
  56845. * @param scene The scene to create the shadow map for
  56846. * @returns The parsed shadow generator
  56847. */
  56848. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  56849. }
  56850. }
  56851. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  56852. import { Scene } from "babylonjs/scene";
  56853. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56854. import { AbstractScene } from "babylonjs/abstractScene";
  56855. /**
  56856. * Defines the shadow generator component responsible to manage any shadow generators
  56857. * in a given scene.
  56858. */
  56859. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  56860. /**
  56861. * The component name helpfull to identify the component in the list of scene components.
  56862. */
  56863. readonly name: string;
  56864. /**
  56865. * The scene the component belongs to.
  56866. */
  56867. scene: Scene;
  56868. /**
  56869. * Creates a new instance of the component for the given scene
  56870. * @param scene Defines the scene to register the component in
  56871. */
  56872. constructor(scene: Scene);
  56873. /**
  56874. * Registers the component in a given scene
  56875. */
  56876. register(): void;
  56877. /**
  56878. * Rebuilds the elements related to this component in case of
  56879. * context lost for instance.
  56880. */
  56881. rebuild(): void;
  56882. /**
  56883. * Serializes the component data to the specified json object
  56884. * @param serializationObject The object to serialize to
  56885. */
  56886. serialize(serializationObject: any): void;
  56887. /**
  56888. * Adds all the elements from the container to the scene
  56889. * @param container the container holding the elements
  56890. */
  56891. addFromContainer(container: AbstractScene): void;
  56892. /**
  56893. * Removes all the elements in the container from the scene
  56894. * @param container contains the elements to remove
  56895. * @param dispose if the removed element should be disposed (default: false)
  56896. */
  56897. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56898. /**
  56899. * Rebuilds the elements related to this component in case of
  56900. * context lost for instance.
  56901. */
  56902. dispose(): void;
  56903. private _gatherRenderTargets;
  56904. }
  56905. }
  56906. declare module "babylonjs/Lights/Shadows/index" {
  56907. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  56908. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  56909. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  56910. }
  56911. declare module "babylonjs/Lights/pointLight" {
  56912. import { Scene } from "babylonjs/scene";
  56913. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56914. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56915. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56916. import { Effect } from "babylonjs/Materials/effect";
  56917. /**
  56918. * A point light is a light defined by an unique point in world space.
  56919. * The light is emitted in every direction from this point.
  56920. * A good example of a point light is a standard light bulb.
  56921. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56922. */
  56923. export class PointLight extends ShadowLight {
  56924. private _shadowAngle;
  56925. /**
  56926. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56927. * This specifies what angle the shadow will use to be created.
  56928. *
  56929. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  56930. */
  56931. get shadowAngle(): number;
  56932. /**
  56933. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56934. * This specifies what angle the shadow will use to be created.
  56935. *
  56936. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  56937. */
  56938. set shadowAngle(value: number);
  56939. /**
  56940. * Gets the direction if it has been set.
  56941. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56942. */
  56943. get direction(): Vector3;
  56944. /**
  56945. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56946. */
  56947. set direction(value: Vector3);
  56948. /**
  56949. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  56950. * A PointLight emits the light in every direction.
  56951. * It can cast shadows.
  56952. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  56953. * ```javascript
  56954. * var pointLight = new PointLight("pl", camera.position, scene);
  56955. * ```
  56956. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56957. * @param name The light friendly name
  56958. * @param position The position of the point light in the scene
  56959. * @param scene The scene the lights belongs to
  56960. */
  56961. constructor(name: string, position: Vector3, scene: Scene);
  56962. /**
  56963. * Returns the string "PointLight"
  56964. * @returns the class name
  56965. */
  56966. getClassName(): string;
  56967. /**
  56968. * Returns the integer 0.
  56969. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56970. */
  56971. getTypeID(): number;
  56972. /**
  56973. * Specifies wether or not the shadowmap should be a cube texture.
  56974. * @returns true if the shadowmap needs to be a cube texture.
  56975. */
  56976. needCube(): boolean;
  56977. /**
  56978. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  56979. * @param faceIndex The index of the face we are computed the direction to generate shadow
  56980. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  56981. */
  56982. getShadowDirection(faceIndex?: number): Vector3;
  56983. /**
  56984. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  56985. * - fov = PI / 2
  56986. * - aspect ratio : 1.0
  56987. * - z-near and far equal to the active camera minZ and maxZ.
  56988. * Returns the PointLight.
  56989. */
  56990. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56991. protected _buildUniformLayout(): void;
  56992. /**
  56993. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  56994. * @param effect The effect to update
  56995. * @param lightIndex The index of the light in the effect to update
  56996. * @returns The point light
  56997. */
  56998. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  56999. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  57000. /**
  57001. * Prepares the list of defines specific to the light type.
  57002. * @param defines the list of defines
  57003. * @param lightIndex defines the index of the light for the effect
  57004. */
  57005. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57006. }
  57007. }
  57008. declare module "babylonjs/Lights/index" {
  57009. export * from "babylonjs/Lights/light";
  57010. export * from "babylonjs/Lights/shadowLight";
  57011. export * from "babylonjs/Lights/Shadows/index";
  57012. export * from "babylonjs/Lights/directionalLight";
  57013. export * from "babylonjs/Lights/hemisphericLight";
  57014. export * from "babylonjs/Lights/pointLight";
  57015. export * from "babylonjs/Lights/spotLight";
  57016. }
  57017. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  57018. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  57019. /**
  57020. * Header information of HDR texture files.
  57021. */
  57022. export interface HDRInfo {
  57023. /**
  57024. * The height of the texture in pixels.
  57025. */
  57026. height: number;
  57027. /**
  57028. * The width of the texture in pixels.
  57029. */
  57030. width: number;
  57031. /**
  57032. * The index of the beginning of the data in the binary file.
  57033. */
  57034. dataPosition: number;
  57035. }
  57036. /**
  57037. * This groups tools to convert HDR texture to native colors array.
  57038. */
  57039. export class HDRTools {
  57040. private static Ldexp;
  57041. private static Rgbe2float;
  57042. private static readStringLine;
  57043. /**
  57044. * Reads header information from an RGBE texture stored in a native array.
  57045. * More information on this format are available here:
  57046. * https://en.wikipedia.org/wiki/RGBE_image_format
  57047. *
  57048. * @param uint8array The binary file stored in native array.
  57049. * @return The header information.
  57050. */
  57051. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  57052. /**
  57053. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  57054. * This RGBE texture needs to store the information as a panorama.
  57055. *
  57056. * More information on this format are available here:
  57057. * https://en.wikipedia.org/wiki/RGBE_image_format
  57058. *
  57059. * @param buffer The binary file stored in an array buffer.
  57060. * @param size The expected size of the extracted cubemap.
  57061. * @return The Cube Map information.
  57062. */
  57063. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  57064. /**
  57065. * Returns the pixels data extracted from an RGBE texture.
  57066. * This pixels will be stored left to right up to down in the R G B order in one array.
  57067. *
  57068. * More information on this format are available here:
  57069. * https://en.wikipedia.org/wiki/RGBE_image_format
  57070. *
  57071. * @param uint8array The binary file stored in an array buffer.
  57072. * @param hdrInfo The header information of the file.
  57073. * @return The pixels data in RGB right to left up to down order.
  57074. */
  57075. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  57076. private static RGBE_ReadPixels_RLE;
  57077. }
  57078. }
  57079. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  57080. import { Nullable } from "babylonjs/types";
  57081. import { Scene } from "babylonjs/scene";
  57082. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57083. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57084. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57085. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57086. /**
  57087. * This represents a texture coming from an HDR input.
  57088. *
  57089. * The only supported format is currently panorama picture stored in RGBE format.
  57090. * Example of such files can be found on HDRLib: http://hdrlib.com/
  57091. */
  57092. export class HDRCubeTexture extends BaseTexture {
  57093. private static _facesMapping;
  57094. private _generateHarmonics;
  57095. private _noMipmap;
  57096. private _textureMatrix;
  57097. private _size;
  57098. private _onLoad;
  57099. private _onError;
  57100. /**
  57101. * The texture URL.
  57102. */
  57103. url: string;
  57104. /**
  57105. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  57106. */
  57107. coordinatesMode: number;
  57108. protected _isBlocking: boolean;
  57109. /**
  57110. * Sets wether or not the texture is blocking during loading.
  57111. */
  57112. set isBlocking(value: boolean);
  57113. /**
  57114. * Gets wether or not the texture is blocking during loading.
  57115. */
  57116. get isBlocking(): boolean;
  57117. protected _rotationY: number;
  57118. /**
  57119. * Sets texture matrix rotation angle around Y axis in radians.
  57120. */
  57121. set rotationY(value: number);
  57122. /**
  57123. * Gets texture matrix rotation angle around Y axis radians.
  57124. */
  57125. get rotationY(): number;
  57126. /**
  57127. * Gets or sets the center of the bounding box associated with the cube texture
  57128. * It must define where the camera used to render the texture was set
  57129. */
  57130. boundingBoxPosition: Vector3;
  57131. private _boundingBoxSize;
  57132. /**
  57133. * Gets or sets the size of the bounding box associated with the cube texture
  57134. * When defined, the cubemap will switch to local mode
  57135. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  57136. * @example https://www.babylonjs-playground.com/#RNASML
  57137. */
  57138. set boundingBoxSize(value: Vector3);
  57139. get boundingBoxSize(): Vector3;
  57140. /**
  57141. * Instantiates an HDRTexture from the following parameters.
  57142. *
  57143. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  57144. * @param scene The scene the texture will be used in
  57145. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  57146. * @param noMipmap Forces to not generate the mipmap if true
  57147. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  57148. * @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)
  57149. * @param reserved Reserved flag for internal use.
  57150. */
  57151. 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>);
  57152. /**
  57153. * Get the current class name of the texture useful for serialization or dynamic coding.
  57154. * @returns "HDRCubeTexture"
  57155. */
  57156. getClassName(): string;
  57157. /**
  57158. * Occurs when the file is raw .hdr file.
  57159. */
  57160. private loadTexture;
  57161. clone(): HDRCubeTexture;
  57162. delayLoad(): void;
  57163. /**
  57164. * Get the texture reflection matrix used to rotate/transform the reflection.
  57165. * @returns the reflection matrix
  57166. */
  57167. getReflectionTextureMatrix(): Matrix;
  57168. /**
  57169. * Set the texture reflection matrix used to rotate/transform the reflection.
  57170. * @param value Define the reflection matrix to set
  57171. */
  57172. setReflectionTextureMatrix(value: Matrix): void;
  57173. /**
  57174. * Parses a JSON representation of an HDR Texture in order to create the texture
  57175. * @param parsedTexture Define the JSON representation
  57176. * @param scene Define the scene the texture should be created in
  57177. * @param rootUrl Define the root url in case we need to load relative dependencies
  57178. * @returns the newly created texture after parsing
  57179. */
  57180. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  57181. serialize(): any;
  57182. }
  57183. }
  57184. declare module "babylonjs/Physics/physicsEngine" {
  57185. import { Nullable } from "babylonjs/types";
  57186. import { Vector3 } from "babylonjs/Maths/math.vector";
  57187. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  57188. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  57189. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  57190. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57191. /**
  57192. * Class used to control physics engine
  57193. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57194. */
  57195. export class PhysicsEngine implements IPhysicsEngine {
  57196. private _physicsPlugin;
  57197. /**
  57198. * Global value used to control the smallest number supported by the simulation
  57199. */
  57200. static Epsilon: number;
  57201. private _impostors;
  57202. private _joints;
  57203. private _subTimeStep;
  57204. /**
  57205. * Gets the gravity vector used by the simulation
  57206. */
  57207. gravity: Vector3;
  57208. /**
  57209. * Factory used to create the default physics plugin.
  57210. * @returns The default physics plugin
  57211. */
  57212. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  57213. /**
  57214. * Creates a new Physics Engine
  57215. * @param gravity defines the gravity vector used by the simulation
  57216. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  57217. */
  57218. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  57219. /**
  57220. * Sets the gravity vector used by the simulation
  57221. * @param gravity defines the gravity vector to use
  57222. */
  57223. setGravity(gravity: Vector3): void;
  57224. /**
  57225. * Set the time step of the physics engine.
  57226. * Default is 1/60.
  57227. * To slow it down, enter 1/600 for example.
  57228. * To speed it up, 1/30
  57229. * @param newTimeStep defines the new timestep to apply to this world.
  57230. */
  57231. setTimeStep(newTimeStep?: number): void;
  57232. /**
  57233. * Get the time step of the physics engine.
  57234. * @returns the current time step
  57235. */
  57236. getTimeStep(): number;
  57237. /**
  57238. * Set the sub time step of the physics engine.
  57239. * Default is 0 meaning there is no sub steps
  57240. * To increase physics resolution precision, set a small value (like 1 ms)
  57241. * @param subTimeStep defines the new sub timestep used for physics resolution.
  57242. */
  57243. setSubTimeStep(subTimeStep?: number): void;
  57244. /**
  57245. * Get the sub time step of the physics engine.
  57246. * @returns the current sub time step
  57247. */
  57248. getSubTimeStep(): number;
  57249. /**
  57250. * Release all resources
  57251. */
  57252. dispose(): void;
  57253. /**
  57254. * Gets the name of the current physics plugin
  57255. * @returns the name of the plugin
  57256. */
  57257. getPhysicsPluginName(): string;
  57258. /**
  57259. * Adding a new impostor for the impostor tracking.
  57260. * This will be done by the impostor itself.
  57261. * @param impostor the impostor to add
  57262. */
  57263. addImpostor(impostor: PhysicsImpostor): void;
  57264. /**
  57265. * Remove an impostor from the engine.
  57266. * This impostor and its mesh will not longer be updated by the physics engine.
  57267. * @param impostor the impostor to remove
  57268. */
  57269. removeImpostor(impostor: PhysicsImpostor): void;
  57270. /**
  57271. * Add a joint to the physics engine
  57272. * @param mainImpostor defines the main impostor to which the joint is added.
  57273. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  57274. * @param joint defines the joint that will connect both impostors.
  57275. */
  57276. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57277. /**
  57278. * Removes a joint from the simulation
  57279. * @param mainImpostor defines the impostor used with the joint
  57280. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  57281. * @param joint defines the joint to remove
  57282. */
  57283. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57284. /**
  57285. * Called by the scene. No need to call it.
  57286. * @param delta defines the timespam between frames
  57287. */
  57288. _step(delta: number): void;
  57289. /**
  57290. * Gets the current plugin used to run the simulation
  57291. * @returns current plugin
  57292. */
  57293. getPhysicsPlugin(): IPhysicsEnginePlugin;
  57294. /**
  57295. * Gets the list of physic impostors
  57296. * @returns an array of PhysicsImpostor
  57297. */
  57298. getImpostors(): Array<PhysicsImpostor>;
  57299. /**
  57300. * Gets the impostor for a physics enabled object
  57301. * @param object defines the object impersonated by the impostor
  57302. * @returns the PhysicsImpostor or null if not found
  57303. */
  57304. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  57305. /**
  57306. * Gets the impostor for a physics body object
  57307. * @param body defines physics body used by the impostor
  57308. * @returns the PhysicsImpostor or null if not found
  57309. */
  57310. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  57311. /**
  57312. * Does a raycast in the physics world
  57313. * @param from when should the ray start?
  57314. * @param to when should the ray end?
  57315. * @returns PhysicsRaycastResult
  57316. */
  57317. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57318. }
  57319. }
  57320. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  57321. import { Nullable } from "babylonjs/types";
  57322. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57323. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57324. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57325. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57326. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57327. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57328. /** @hidden */
  57329. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  57330. private _useDeltaForWorldStep;
  57331. world: any;
  57332. name: string;
  57333. private _physicsMaterials;
  57334. private _fixedTimeStep;
  57335. private _cannonRaycastResult;
  57336. private _raycastResult;
  57337. private _physicsBodysToRemoveAfterStep;
  57338. BJSCANNON: any;
  57339. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  57340. setGravity(gravity: Vector3): void;
  57341. setTimeStep(timeStep: number): void;
  57342. getTimeStep(): number;
  57343. executeStep(delta: number): void;
  57344. private _removeMarkedPhysicsBodiesFromWorld;
  57345. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57346. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57347. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57348. private _processChildMeshes;
  57349. removePhysicsBody(impostor: PhysicsImpostor): void;
  57350. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57351. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57352. private _addMaterial;
  57353. private _checkWithEpsilon;
  57354. private _createShape;
  57355. private _createHeightmap;
  57356. private _minus90X;
  57357. private _plus90X;
  57358. private _tmpPosition;
  57359. private _tmpDeltaPosition;
  57360. private _tmpUnityRotation;
  57361. private _updatePhysicsBodyTransformation;
  57362. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57363. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57364. isSupported(): boolean;
  57365. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57366. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57367. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57368. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57369. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57370. getBodyMass(impostor: PhysicsImpostor): number;
  57371. getBodyFriction(impostor: PhysicsImpostor): number;
  57372. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57373. getBodyRestitution(impostor: PhysicsImpostor): number;
  57374. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57375. sleepBody(impostor: PhysicsImpostor): void;
  57376. wakeUpBody(impostor: PhysicsImpostor): void;
  57377. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  57378. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57379. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57380. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57381. getRadius(impostor: PhysicsImpostor): number;
  57382. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57383. dispose(): void;
  57384. private _extendNamespace;
  57385. /**
  57386. * Does a raycast in the physics world
  57387. * @param from when should the ray start?
  57388. * @param to when should the ray end?
  57389. * @returns PhysicsRaycastResult
  57390. */
  57391. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57392. }
  57393. }
  57394. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  57395. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57396. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57397. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57398. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57399. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57400. import { Nullable } from "babylonjs/types";
  57401. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57402. /** @hidden */
  57403. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  57404. world: any;
  57405. name: string;
  57406. BJSOIMO: any;
  57407. private _raycastResult;
  57408. constructor(iterations?: number, oimoInjection?: any);
  57409. setGravity(gravity: Vector3): void;
  57410. setTimeStep(timeStep: number): void;
  57411. getTimeStep(): number;
  57412. private _tmpImpostorsArray;
  57413. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57414. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57415. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57416. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57417. private _tmpPositionVector;
  57418. removePhysicsBody(impostor: PhysicsImpostor): void;
  57419. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57420. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57421. isSupported(): boolean;
  57422. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57423. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57424. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57425. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57426. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57427. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57428. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57429. getBodyMass(impostor: PhysicsImpostor): number;
  57430. getBodyFriction(impostor: PhysicsImpostor): number;
  57431. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57432. getBodyRestitution(impostor: PhysicsImpostor): number;
  57433. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57434. sleepBody(impostor: PhysicsImpostor): void;
  57435. wakeUpBody(impostor: PhysicsImpostor): void;
  57436. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  57437. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  57438. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  57439. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57440. getRadius(impostor: PhysicsImpostor): number;
  57441. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57442. dispose(): void;
  57443. /**
  57444. * Does a raycast in the physics world
  57445. * @param from when should the ray start?
  57446. * @param to when should the ray end?
  57447. * @returns PhysicsRaycastResult
  57448. */
  57449. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57450. }
  57451. }
  57452. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  57453. import { Nullable } from "babylonjs/types";
  57454. import { Scene } from "babylonjs/scene";
  57455. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  57456. import { Color4 } from "babylonjs/Maths/math.color";
  57457. import { Mesh } from "babylonjs/Meshes/mesh";
  57458. /**
  57459. * Class containing static functions to help procedurally build meshes
  57460. */
  57461. export class RibbonBuilder {
  57462. /**
  57463. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57464. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  57465. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  57466. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  57467. * * 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
  57468. * * 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
  57469. * * 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
  57470. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57471. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57472. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57473. * * 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
  57474. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  57475. * * 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
  57476. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  57477. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57478. * @param name defines the name of the mesh
  57479. * @param options defines the options used to create the mesh
  57480. * @param scene defines the hosting scene
  57481. * @returns the ribbon mesh
  57482. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  57483. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57484. */
  57485. static CreateRibbon(name: string, options: {
  57486. pathArray: Vector3[][];
  57487. closeArray?: boolean;
  57488. closePath?: boolean;
  57489. offset?: number;
  57490. updatable?: boolean;
  57491. sideOrientation?: number;
  57492. frontUVs?: Vector4;
  57493. backUVs?: Vector4;
  57494. instance?: Mesh;
  57495. invertUV?: boolean;
  57496. uvs?: Vector2[];
  57497. colors?: Color4[];
  57498. }, scene?: Nullable<Scene>): Mesh;
  57499. }
  57500. }
  57501. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  57502. import { Nullable } from "babylonjs/types";
  57503. import { Scene } from "babylonjs/scene";
  57504. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57505. import { Mesh } from "babylonjs/Meshes/mesh";
  57506. /**
  57507. * Class containing static functions to help procedurally build meshes
  57508. */
  57509. export class ShapeBuilder {
  57510. /**
  57511. * 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.
  57512. * * 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.
  57513. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57514. * * 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.
  57515. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  57516. * * 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
  57517. * * 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
  57518. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  57519. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57520. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57521. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  57522. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57523. * @param name defines the name of the mesh
  57524. * @param options defines the options used to create the mesh
  57525. * @param scene defines the hosting scene
  57526. * @returns the extruded shape mesh
  57527. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57528. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57529. */
  57530. static ExtrudeShape(name: string, options: {
  57531. shape: Vector3[];
  57532. path: Vector3[];
  57533. scale?: number;
  57534. rotation?: number;
  57535. cap?: number;
  57536. updatable?: boolean;
  57537. sideOrientation?: number;
  57538. frontUVs?: Vector4;
  57539. backUVs?: Vector4;
  57540. instance?: Mesh;
  57541. invertUV?: boolean;
  57542. }, scene?: Nullable<Scene>): Mesh;
  57543. /**
  57544. * Creates an custom extruded shape mesh.
  57545. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  57546. * * 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.
  57547. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57548. * * 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
  57549. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  57550. * * 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
  57551. * * It must returns a float value that will be the scale value applied to the shape on each path point
  57552. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  57553. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  57554. * * 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
  57555. * * 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
  57556. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  57557. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57558. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57559. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57560. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57561. * @param name defines the name of the mesh
  57562. * @param options defines the options used to create the mesh
  57563. * @param scene defines the hosting scene
  57564. * @returns the custom extruded shape mesh
  57565. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  57566. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57567. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57568. */
  57569. static ExtrudeShapeCustom(name: string, options: {
  57570. shape: Vector3[];
  57571. path: Vector3[];
  57572. scaleFunction?: any;
  57573. rotationFunction?: any;
  57574. ribbonCloseArray?: boolean;
  57575. ribbonClosePath?: boolean;
  57576. cap?: number;
  57577. updatable?: boolean;
  57578. sideOrientation?: number;
  57579. frontUVs?: Vector4;
  57580. backUVs?: Vector4;
  57581. instance?: Mesh;
  57582. invertUV?: boolean;
  57583. }, scene?: Nullable<Scene>): Mesh;
  57584. private static _ExtrudeShapeGeneric;
  57585. }
  57586. }
  57587. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  57588. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  57589. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57590. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57591. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57592. import { Nullable } from "babylonjs/types";
  57593. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57594. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57595. /**
  57596. * AmmoJS Physics plugin
  57597. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  57598. * @see https://github.com/kripken/ammo.js/
  57599. */
  57600. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  57601. private _useDeltaForWorldStep;
  57602. /**
  57603. * Reference to the Ammo library
  57604. */
  57605. bjsAMMO: any;
  57606. /**
  57607. * Created ammoJS world which physics bodies are added to
  57608. */
  57609. world: any;
  57610. /**
  57611. * Name of the plugin
  57612. */
  57613. name: string;
  57614. private _timeStep;
  57615. private _fixedTimeStep;
  57616. private _maxSteps;
  57617. private _tmpQuaternion;
  57618. private _tmpAmmoTransform;
  57619. private _tmpAmmoQuaternion;
  57620. private _tmpAmmoConcreteContactResultCallback;
  57621. private _collisionConfiguration;
  57622. private _dispatcher;
  57623. private _overlappingPairCache;
  57624. private _solver;
  57625. private _softBodySolver;
  57626. private _tmpAmmoVectorA;
  57627. private _tmpAmmoVectorB;
  57628. private _tmpAmmoVectorC;
  57629. private _tmpAmmoVectorD;
  57630. private _tmpContactCallbackResult;
  57631. private _tmpAmmoVectorRCA;
  57632. private _tmpAmmoVectorRCB;
  57633. private _raycastResult;
  57634. private static readonly DISABLE_COLLISION_FLAG;
  57635. private static readonly KINEMATIC_FLAG;
  57636. private static readonly DISABLE_DEACTIVATION_FLAG;
  57637. /**
  57638. * Initializes the ammoJS plugin
  57639. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  57640. * @param ammoInjection can be used to inject your own ammo reference
  57641. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  57642. */
  57643. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  57644. /**
  57645. * Sets the gravity of the physics world (m/(s^2))
  57646. * @param gravity Gravity to set
  57647. */
  57648. setGravity(gravity: Vector3): void;
  57649. /**
  57650. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  57651. * @param timeStep timestep to use in seconds
  57652. */
  57653. setTimeStep(timeStep: number): void;
  57654. /**
  57655. * 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)
  57656. * @param fixedTimeStep fixedTimeStep to use in seconds
  57657. */
  57658. setFixedTimeStep(fixedTimeStep: number): void;
  57659. /**
  57660. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  57661. * @param maxSteps the maximum number of steps by the physics engine per frame
  57662. */
  57663. setMaxSteps(maxSteps: number): void;
  57664. /**
  57665. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  57666. * @returns the current timestep in seconds
  57667. */
  57668. getTimeStep(): number;
  57669. /**
  57670. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  57671. */
  57672. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  57673. private _isImpostorInContact;
  57674. private _isImpostorPairInContact;
  57675. private _stepSimulation;
  57676. /**
  57677. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  57678. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  57679. * After the step the babylon meshes are set to the position of the physics imposters
  57680. * @param delta amount of time to step forward
  57681. * @param impostors array of imposters to update before/after the step
  57682. */
  57683. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57684. /**
  57685. * Update babylon mesh to match physics world object
  57686. * @param impostor imposter to match
  57687. */
  57688. private _afterSoftStep;
  57689. /**
  57690. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  57691. * @param impostor imposter to match
  57692. */
  57693. private _ropeStep;
  57694. /**
  57695. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  57696. * @param impostor imposter to match
  57697. */
  57698. private _softbodyOrClothStep;
  57699. private _tmpVector;
  57700. private _tmpMatrix;
  57701. /**
  57702. * Applies an impulse on the imposter
  57703. * @param impostor imposter to apply impulse to
  57704. * @param force amount of force to be applied to the imposter
  57705. * @param contactPoint the location to apply the impulse on the imposter
  57706. */
  57707. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57708. /**
  57709. * Applies a force on the imposter
  57710. * @param impostor imposter to apply force
  57711. * @param force amount of force to be applied to the imposter
  57712. * @param contactPoint the location to apply the force on the imposter
  57713. */
  57714. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57715. /**
  57716. * Creates a physics body using the plugin
  57717. * @param impostor the imposter to create the physics body on
  57718. */
  57719. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57720. /**
  57721. * Removes the physics body from the imposter and disposes of the body's memory
  57722. * @param impostor imposter to remove the physics body from
  57723. */
  57724. removePhysicsBody(impostor: PhysicsImpostor): void;
  57725. /**
  57726. * Generates a joint
  57727. * @param impostorJoint the imposter joint to create the joint with
  57728. */
  57729. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57730. /**
  57731. * Removes a joint
  57732. * @param impostorJoint the imposter joint to remove the joint from
  57733. */
  57734. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57735. private _addMeshVerts;
  57736. /**
  57737. * Initialise the soft body vertices to match its object's (mesh) vertices
  57738. * Softbody vertices (nodes) are in world space and to match this
  57739. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  57740. * @param impostor to create the softbody for
  57741. */
  57742. private _softVertexData;
  57743. /**
  57744. * Create an impostor's soft body
  57745. * @param impostor to create the softbody for
  57746. */
  57747. private _createSoftbody;
  57748. /**
  57749. * Create cloth for an impostor
  57750. * @param impostor to create the softbody for
  57751. */
  57752. private _createCloth;
  57753. /**
  57754. * Create rope for an impostor
  57755. * @param impostor to create the softbody for
  57756. */
  57757. private _createRope;
  57758. /**
  57759. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  57760. * @param impostor to create the custom physics shape for
  57761. */
  57762. private _createCustom;
  57763. private _addHullVerts;
  57764. private _createShape;
  57765. /**
  57766. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  57767. * @param impostor imposter containing the physics body and babylon object
  57768. */
  57769. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57770. /**
  57771. * Sets the babylon object's position/rotation from the physics body's position/rotation
  57772. * @param impostor imposter containing the physics body and babylon object
  57773. * @param newPosition new position
  57774. * @param newRotation new rotation
  57775. */
  57776. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57777. /**
  57778. * If this plugin is supported
  57779. * @returns true if its supported
  57780. */
  57781. isSupported(): boolean;
  57782. /**
  57783. * Sets the linear velocity of the physics body
  57784. * @param impostor imposter to set the velocity on
  57785. * @param velocity velocity to set
  57786. */
  57787. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57788. /**
  57789. * Sets the angular velocity of the physics body
  57790. * @param impostor imposter to set the velocity on
  57791. * @param velocity velocity to set
  57792. */
  57793. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57794. /**
  57795. * gets the linear velocity
  57796. * @param impostor imposter to get linear velocity from
  57797. * @returns linear velocity
  57798. */
  57799. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57800. /**
  57801. * gets the angular velocity
  57802. * @param impostor imposter to get angular velocity from
  57803. * @returns angular velocity
  57804. */
  57805. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57806. /**
  57807. * Sets the mass of physics body
  57808. * @param impostor imposter to set the mass on
  57809. * @param mass mass to set
  57810. */
  57811. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57812. /**
  57813. * Gets the mass of the physics body
  57814. * @param impostor imposter to get the mass from
  57815. * @returns mass
  57816. */
  57817. getBodyMass(impostor: PhysicsImpostor): number;
  57818. /**
  57819. * Gets friction of the impostor
  57820. * @param impostor impostor to get friction from
  57821. * @returns friction value
  57822. */
  57823. getBodyFriction(impostor: PhysicsImpostor): number;
  57824. /**
  57825. * Sets friction of the impostor
  57826. * @param impostor impostor to set friction on
  57827. * @param friction friction value
  57828. */
  57829. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57830. /**
  57831. * Gets restitution of the impostor
  57832. * @param impostor impostor to get restitution from
  57833. * @returns restitution value
  57834. */
  57835. getBodyRestitution(impostor: PhysicsImpostor): number;
  57836. /**
  57837. * Sets resitution of the impostor
  57838. * @param impostor impostor to set resitution on
  57839. * @param restitution resitution value
  57840. */
  57841. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57842. /**
  57843. * Gets pressure inside the impostor
  57844. * @param impostor impostor to get pressure from
  57845. * @returns pressure value
  57846. */
  57847. getBodyPressure(impostor: PhysicsImpostor): number;
  57848. /**
  57849. * Sets pressure inside a soft body impostor
  57850. * Cloth and rope must remain 0 pressure
  57851. * @param impostor impostor to set pressure on
  57852. * @param pressure pressure value
  57853. */
  57854. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  57855. /**
  57856. * Gets stiffness of the impostor
  57857. * @param impostor impostor to get stiffness from
  57858. * @returns pressure value
  57859. */
  57860. getBodyStiffness(impostor: PhysicsImpostor): number;
  57861. /**
  57862. * Sets stiffness of the impostor
  57863. * @param impostor impostor to set stiffness on
  57864. * @param stiffness stiffness value from 0 to 1
  57865. */
  57866. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  57867. /**
  57868. * Gets velocityIterations of the impostor
  57869. * @param impostor impostor to get velocity iterations from
  57870. * @returns velocityIterations value
  57871. */
  57872. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  57873. /**
  57874. * Sets velocityIterations of the impostor
  57875. * @param impostor impostor to set velocity iterations on
  57876. * @param velocityIterations velocityIterations value
  57877. */
  57878. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  57879. /**
  57880. * Gets positionIterations of the impostor
  57881. * @param impostor impostor to get position iterations from
  57882. * @returns positionIterations value
  57883. */
  57884. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  57885. /**
  57886. * Sets positionIterations of the impostor
  57887. * @param impostor impostor to set position on
  57888. * @param positionIterations positionIterations value
  57889. */
  57890. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  57891. /**
  57892. * Append an anchor to a cloth object
  57893. * @param impostor is the cloth impostor to add anchor to
  57894. * @param otherImpostor is the rigid impostor to anchor to
  57895. * @param width ratio across width from 0 to 1
  57896. * @param height ratio up height from 0 to 1
  57897. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  57898. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  57899. */
  57900. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  57901. /**
  57902. * Append an hook to a rope object
  57903. * @param impostor is the rope impostor to add hook to
  57904. * @param otherImpostor is the rigid impostor to hook to
  57905. * @param length ratio along the rope from 0 to 1
  57906. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  57907. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  57908. */
  57909. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  57910. /**
  57911. * Sleeps the physics body and stops it from being active
  57912. * @param impostor impostor to sleep
  57913. */
  57914. sleepBody(impostor: PhysicsImpostor): void;
  57915. /**
  57916. * Activates the physics body
  57917. * @param impostor impostor to activate
  57918. */
  57919. wakeUpBody(impostor: PhysicsImpostor): void;
  57920. /**
  57921. * Updates the distance parameters of the joint
  57922. * @param joint joint to update
  57923. * @param maxDistance maximum distance of the joint
  57924. * @param minDistance minimum distance of the joint
  57925. */
  57926. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  57927. /**
  57928. * Sets a motor on the joint
  57929. * @param joint joint to set motor on
  57930. * @param speed speed of the motor
  57931. * @param maxForce maximum force of the motor
  57932. * @param motorIndex index of the motor
  57933. */
  57934. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57935. /**
  57936. * Sets the motors limit
  57937. * @param joint joint to set limit on
  57938. * @param upperLimit upper limit
  57939. * @param lowerLimit lower limit
  57940. */
  57941. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57942. /**
  57943. * Syncs the position and rotation of a mesh with the impostor
  57944. * @param mesh mesh to sync
  57945. * @param impostor impostor to update the mesh with
  57946. */
  57947. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57948. /**
  57949. * Gets the radius of the impostor
  57950. * @param impostor impostor to get radius from
  57951. * @returns the radius
  57952. */
  57953. getRadius(impostor: PhysicsImpostor): number;
  57954. /**
  57955. * Gets the box size of the impostor
  57956. * @param impostor impostor to get box size from
  57957. * @param result the resulting box size
  57958. */
  57959. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57960. /**
  57961. * Disposes of the impostor
  57962. */
  57963. dispose(): void;
  57964. /**
  57965. * Does a raycast in the physics world
  57966. * @param from when should the ray start?
  57967. * @param to when should the ray end?
  57968. * @returns PhysicsRaycastResult
  57969. */
  57970. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57971. }
  57972. }
  57973. declare module "babylonjs/Probes/reflectionProbe" {
  57974. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57975. import { Vector3 } from "babylonjs/Maths/math.vector";
  57976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57977. import { Nullable } from "babylonjs/types";
  57978. import { Scene } from "babylonjs/scene";
  57979. module "babylonjs/abstractScene" {
  57980. interface AbstractScene {
  57981. /**
  57982. * The list of reflection probes added to the scene
  57983. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  57984. */
  57985. reflectionProbes: Array<ReflectionProbe>;
  57986. /**
  57987. * Removes the given reflection probe from this scene.
  57988. * @param toRemove The reflection probe to remove
  57989. * @returns The index of the removed reflection probe
  57990. */
  57991. removeReflectionProbe(toRemove: ReflectionProbe): number;
  57992. /**
  57993. * Adds the given reflection probe to this scene.
  57994. * @param newReflectionProbe The reflection probe to add
  57995. */
  57996. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  57997. }
  57998. }
  57999. /**
  58000. * Class used to generate realtime reflection / refraction cube textures
  58001. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  58002. */
  58003. export class ReflectionProbe {
  58004. /** defines the name of the probe */
  58005. name: string;
  58006. private _scene;
  58007. private _renderTargetTexture;
  58008. private _projectionMatrix;
  58009. private _viewMatrix;
  58010. private _target;
  58011. private _add;
  58012. private _attachedMesh;
  58013. private _invertYAxis;
  58014. /** Gets or sets probe position (center of the cube map) */
  58015. position: Vector3;
  58016. /**
  58017. * Creates a new reflection probe
  58018. * @param name defines the name of the probe
  58019. * @param size defines the texture resolution (for each face)
  58020. * @param scene defines the hosting scene
  58021. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  58022. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  58023. */
  58024. constructor(
  58025. /** defines the name of the probe */
  58026. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  58027. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  58028. get samples(): number;
  58029. set samples(value: number);
  58030. /** Gets or sets the refresh rate to use (on every frame by default) */
  58031. get refreshRate(): number;
  58032. set refreshRate(value: number);
  58033. /**
  58034. * Gets the hosting scene
  58035. * @returns a Scene
  58036. */
  58037. getScene(): Scene;
  58038. /** Gets the internal CubeTexture used to render to */
  58039. get cubeTexture(): RenderTargetTexture;
  58040. /** Gets the list of meshes to render */
  58041. get renderList(): Nullable<AbstractMesh[]>;
  58042. /**
  58043. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  58044. * @param mesh defines the mesh to attach to
  58045. */
  58046. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  58047. /**
  58048. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  58049. * @param renderingGroupId The rendering group id corresponding to its index
  58050. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  58051. */
  58052. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  58053. /**
  58054. * Clean all associated resources
  58055. */
  58056. dispose(): void;
  58057. /**
  58058. * Converts the reflection probe information to a readable string for debug purpose.
  58059. * @param fullDetails Supports for multiple levels of logging within scene loading
  58060. * @returns the human readable reflection probe info
  58061. */
  58062. toString(fullDetails?: boolean): string;
  58063. /**
  58064. * Get the class name of the relfection probe.
  58065. * @returns "ReflectionProbe"
  58066. */
  58067. getClassName(): string;
  58068. /**
  58069. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  58070. * @returns The JSON representation of the texture
  58071. */
  58072. serialize(): any;
  58073. /**
  58074. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  58075. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  58076. * @param scene Define the scene the parsed reflection probe should be instantiated in
  58077. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  58078. * @returns The parsed reflection probe if successful
  58079. */
  58080. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  58081. }
  58082. }
  58083. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  58084. /** @hidden */
  58085. export var _BabylonLoaderRegistered: boolean;
  58086. /**
  58087. * Helps setting up some configuration for the babylon file loader.
  58088. */
  58089. export class BabylonFileLoaderConfiguration {
  58090. /**
  58091. * The loader does not allow injecting custom physix engine into the plugins.
  58092. * Unfortunately in ES6, we need to manually inject them into the plugin.
  58093. * So you could set this variable to your engine import to make it work.
  58094. */
  58095. static LoaderInjectedPhysicsEngine: any;
  58096. }
  58097. }
  58098. declare module "babylonjs/Loading/Plugins/index" {
  58099. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  58100. }
  58101. declare module "babylonjs/Loading/index" {
  58102. export * from "babylonjs/Loading/loadingScreen";
  58103. export * from "babylonjs/Loading/Plugins/index";
  58104. export * from "babylonjs/Loading/sceneLoader";
  58105. export * from "babylonjs/Loading/sceneLoaderFlags";
  58106. }
  58107. declare module "babylonjs/Materials/Background/index" {
  58108. export * from "babylonjs/Materials/Background/backgroundMaterial";
  58109. }
  58110. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  58111. import { Scene } from "babylonjs/scene";
  58112. import { Color3 } from "babylonjs/Maths/math.color";
  58113. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58114. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58115. /**
  58116. * The Physically based simple base material of BJS.
  58117. *
  58118. * This enables better naming and convention enforcements on top of the pbrMaterial.
  58119. * It is used as the base class for both the specGloss and metalRough conventions.
  58120. */
  58121. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  58122. /**
  58123. * Number of Simultaneous lights allowed on the material.
  58124. */
  58125. maxSimultaneousLights: number;
  58126. /**
  58127. * If sets to true, disables all the lights affecting the material.
  58128. */
  58129. disableLighting: boolean;
  58130. /**
  58131. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  58132. */
  58133. environmentTexture: BaseTexture;
  58134. /**
  58135. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  58136. */
  58137. invertNormalMapX: boolean;
  58138. /**
  58139. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  58140. */
  58141. invertNormalMapY: boolean;
  58142. /**
  58143. * Normal map used in the model.
  58144. */
  58145. normalTexture: BaseTexture;
  58146. /**
  58147. * Emissivie color used to self-illuminate the model.
  58148. */
  58149. emissiveColor: Color3;
  58150. /**
  58151. * Emissivie texture used to self-illuminate the model.
  58152. */
  58153. emissiveTexture: BaseTexture;
  58154. /**
  58155. * Occlusion Channel Strenght.
  58156. */
  58157. occlusionStrength: number;
  58158. /**
  58159. * Occlusion Texture of the material (adding extra occlusion effects).
  58160. */
  58161. occlusionTexture: BaseTexture;
  58162. /**
  58163. * Defines the alpha limits in alpha test mode.
  58164. */
  58165. alphaCutOff: number;
  58166. /**
  58167. * Gets the current double sided mode.
  58168. */
  58169. get doubleSided(): boolean;
  58170. /**
  58171. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58172. */
  58173. set doubleSided(value: boolean);
  58174. /**
  58175. * Stores the pre-calculated light information of a mesh in a texture.
  58176. */
  58177. lightmapTexture: BaseTexture;
  58178. /**
  58179. * If true, the light map contains occlusion information instead of lighting info.
  58180. */
  58181. useLightmapAsShadowmap: boolean;
  58182. /**
  58183. * Instantiates a new PBRMaterial instance.
  58184. *
  58185. * @param name The material name
  58186. * @param scene The scene the material will be use in.
  58187. */
  58188. constructor(name: string, scene: Scene);
  58189. getClassName(): string;
  58190. }
  58191. }
  58192. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  58193. import { Scene } from "babylonjs/scene";
  58194. import { Color3 } from "babylonjs/Maths/math.color";
  58195. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58196. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58197. /**
  58198. * The PBR material of BJS following the metal roughness convention.
  58199. *
  58200. * This fits to the PBR convention in the GLTF definition:
  58201. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  58202. */
  58203. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  58204. /**
  58205. * The base color has two different interpretations depending on the value of metalness.
  58206. * When the material is a metal, the base color is the specific measured reflectance value
  58207. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  58208. * of the material.
  58209. */
  58210. baseColor: Color3;
  58211. /**
  58212. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  58213. * well as opacity information in the alpha channel.
  58214. */
  58215. baseTexture: BaseTexture;
  58216. /**
  58217. * Specifies the metallic scalar value of the material.
  58218. * Can also be used to scale the metalness values of the metallic texture.
  58219. */
  58220. metallic: number;
  58221. /**
  58222. * Specifies the roughness scalar value of the material.
  58223. * Can also be used to scale the roughness values of the metallic texture.
  58224. */
  58225. roughness: number;
  58226. /**
  58227. * Texture containing both the metallic value in the B channel and the
  58228. * roughness value in the G channel to keep better precision.
  58229. */
  58230. metallicRoughnessTexture: BaseTexture;
  58231. /**
  58232. * Instantiates a new PBRMetalRoughnessMaterial instance.
  58233. *
  58234. * @param name The material name
  58235. * @param scene The scene the material will be use in.
  58236. */
  58237. constructor(name: string, scene: Scene);
  58238. /**
  58239. * Return the currrent class name of the material.
  58240. */
  58241. getClassName(): string;
  58242. /**
  58243. * Makes a duplicate of the current material.
  58244. * @param name - name to use for the new material.
  58245. */
  58246. clone(name: string): PBRMetallicRoughnessMaterial;
  58247. /**
  58248. * Serialize the material to a parsable JSON object.
  58249. */
  58250. serialize(): any;
  58251. /**
  58252. * Parses a JSON object correponding to the serialize function.
  58253. */
  58254. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  58255. }
  58256. }
  58257. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  58258. import { Scene } from "babylonjs/scene";
  58259. import { Color3 } from "babylonjs/Maths/math.color";
  58260. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58261. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58262. /**
  58263. * The PBR material of BJS following the specular glossiness convention.
  58264. *
  58265. * This fits to the PBR convention in the GLTF definition:
  58266. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  58267. */
  58268. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  58269. /**
  58270. * Specifies the diffuse color of the material.
  58271. */
  58272. diffuseColor: Color3;
  58273. /**
  58274. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  58275. * channel.
  58276. */
  58277. diffuseTexture: BaseTexture;
  58278. /**
  58279. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  58280. */
  58281. specularColor: Color3;
  58282. /**
  58283. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  58284. */
  58285. glossiness: number;
  58286. /**
  58287. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  58288. */
  58289. specularGlossinessTexture: BaseTexture;
  58290. /**
  58291. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  58292. *
  58293. * @param name The material name
  58294. * @param scene The scene the material will be use in.
  58295. */
  58296. constructor(name: string, scene: Scene);
  58297. /**
  58298. * Return the currrent class name of the material.
  58299. */
  58300. getClassName(): string;
  58301. /**
  58302. * Makes a duplicate of the current material.
  58303. * @param name - name to use for the new material.
  58304. */
  58305. clone(name: string): PBRSpecularGlossinessMaterial;
  58306. /**
  58307. * Serialize the material to a parsable JSON object.
  58308. */
  58309. serialize(): any;
  58310. /**
  58311. * Parses a JSON object correponding to the serialize function.
  58312. */
  58313. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  58314. }
  58315. }
  58316. declare module "babylonjs/Materials/PBR/index" {
  58317. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58318. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58319. export * from "babylonjs/Materials/PBR/pbrMaterial";
  58320. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  58321. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  58322. }
  58323. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  58324. import { Nullable } from "babylonjs/types";
  58325. import { Scene } from "babylonjs/scene";
  58326. import { Matrix } from "babylonjs/Maths/math.vector";
  58327. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58328. /**
  58329. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  58330. * It can help converting any input color in a desired output one. This can then be used to create effects
  58331. * from sepia, black and white to sixties or futuristic rendering...
  58332. *
  58333. * The only supported format is currently 3dl.
  58334. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  58335. */
  58336. export class ColorGradingTexture extends BaseTexture {
  58337. /**
  58338. * The current texture matrix. (will always be identity in color grading texture)
  58339. */
  58340. private _textureMatrix;
  58341. /**
  58342. * The texture URL.
  58343. */
  58344. url: string;
  58345. /**
  58346. * Empty line regex stored for GC.
  58347. */
  58348. private static _noneEmptyLineRegex;
  58349. private _engine;
  58350. /**
  58351. * Instantiates a ColorGradingTexture from the following parameters.
  58352. *
  58353. * @param url The location of the color gradind data (currently only supporting 3dl)
  58354. * @param scene The scene the texture will be used in
  58355. */
  58356. constructor(url: string, scene: Scene);
  58357. /**
  58358. * Returns the texture matrix used in most of the material.
  58359. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  58360. */
  58361. getTextureMatrix(): Matrix;
  58362. /**
  58363. * Occurs when the file being loaded is a .3dl LUT file.
  58364. */
  58365. private load3dlTexture;
  58366. /**
  58367. * Starts the loading process of the texture.
  58368. */
  58369. private loadTexture;
  58370. /**
  58371. * Clones the color gradind texture.
  58372. */
  58373. clone(): ColorGradingTexture;
  58374. /**
  58375. * Called during delayed load for textures.
  58376. */
  58377. delayLoad(): void;
  58378. /**
  58379. * Parses a color grading texture serialized by Babylon.
  58380. * @param parsedTexture The texture information being parsedTexture
  58381. * @param scene The scene to load the texture in
  58382. * @param rootUrl The root url of the data assets to load
  58383. * @return A color gradind texture
  58384. */
  58385. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  58386. /**
  58387. * Serializes the LUT texture to json format.
  58388. */
  58389. serialize(): any;
  58390. }
  58391. }
  58392. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  58393. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58394. import { Scene } from "babylonjs/scene";
  58395. import { Nullable } from "babylonjs/types";
  58396. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58397. /**
  58398. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  58399. */
  58400. export class EquiRectangularCubeTexture extends BaseTexture {
  58401. /** The six faces of the cube. */
  58402. private static _FacesMapping;
  58403. private _noMipmap;
  58404. private _onLoad;
  58405. private _onError;
  58406. /** The size of the cubemap. */
  58407. private _size;
  58408. /** The buffer of the image. */
  58409. private _buffer;
  58410. /** The width of the input image. */
  58411. private _width;
  58412. /** The height of the input image. */
  58413. private _height;
  58414. /** The URL to the image. */
  58415. url: string;
  58416. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  58417. coordinatesMode: number;
  58418. /**
  58419. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  58420. * @param url The location of the image
  58421. * @param scene The scene the texture will be used in
  58422. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58423. * @param noMipmap Forces to not generate the mipmap if true
  58424. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58425. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58426. * @param onLoad — defines a callback called when texture is loaded
  58427. * @param onError — defines a callback called if there is an error
  58428. */
  58429. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  58430. /**
  58431. * Load the image data, by putting the image on a canvas and extracting its buffer.
  58432. */
  58433. private loadImage;
  58434. /**
  58435. * Convert the image buffer into a cubemap and create a CubeTexture.
  58436. */
  58437. private loadTexture;
  58438. /**
  58439. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  58440. * @param buffer The ArrayBuffer that should be converted.
  58441. * @returns The buffer as Float32Array.
  58442. */
  58443. private getFloat32ArrayFromArrayBuffer;
  58444. /**
  58445. * Get the current class name of the texture useful for serialization or dynamic coding.
  58446. * @returns "EquiRectangularCubeTexture"
  58447. */
  58448. getClassName(): string;
  58449. /**
  58450. * Create a clone of the current EquiRectangularCubeTexture and return it.
  58451. * @returns A clone of the current EquiRectangularCubeTexture.
  58452. */
  58453. clone(): EquiRectangularCubeTexture;
  58454. }
  58455. }
  58456. declare module "babylonjs/Misc/tga" {
  58457. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58458. /**
  58459. * Based on jsTGALoader - Javascript loader for TGA file
  58460. * By Vincent Thibault
  58461. * @see http://blog.robrowser.com/javascript-tga-loader.html
  58462. */
  58463. export class TGATools {
  58464. private static _TYPE_INDEXED;
  58465. private static _TYPE_RGB;
  58466. private static _TYPE_GREY;
  58467. private static _TYPE_RLE_INDEXED;
  58468. private static _TYPE_RLE_RGB;
  58469. private static _TYPE_RLE_GREY;
  58470. private static _ORIGIN_MASK;
  58471. private static _ORIGIN_SHIFT;
  58472. private static _ORIGIN_BL;
  58473. private static _ORIGIN_BR;
  58474. private static _ORIGIN_UL;
  58475. private static _ORIGIN_UR;
  58476. /**
  58477. * Gets the header of a TGA file
  58478. * @param data defines the TGA data
  58479. * @returns the header
  58480. */
  58481. static GetTGAHeader(data: Uint8Array): any;
  58482. /**
  58483. * Uploads TGA content to a Babylon Texture
  58484. * @hidden
  58485. */
  58486. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  58487. /** @hidden */
  58488. 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;
  58489. /** @hidden */
  58490. 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;
  58491. /** @hidden */
  58492. 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;
  58493. /** @hidden */
  58494. 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;
  58495. /** @hidden */
  58496. 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;
  58497. /** @hidden */
  58498. 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;
  58499. }
  58500. }
  58501. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  58502. import { Nullable } from "babylonjs/types";
  58503. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58504. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58505. /**
  58506. * Implementation of the TGA Texture Loader.
  58507. * @hidden
  58508. */
  58509. export class _TGATextureLoader implements IInternalTextureLoader {
  58510. /**
  58511. * Defines wether the loader supports cascade loading the different faces.
  58512. */
  58513. readonly supportCascades: boolean;
  58514. /**
  58515. * This returns if the loader support the current file information.
  58516. * @param extension defines the file extension of the file being loaded
  58517. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58518. * @param fallback defines the fallback internal texture if any
  58519. * @param isBase64 defines whether the texture is encoded as a base64
  58520. * @param isBuffer defines whether the texture data are stored as a buffer
  58521. * @returns true if the loader can load the specified file
  58522. */
  58523. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  58524. /**
  58525. * Transform the url before loading if required.
  58526. * @param rootUrl the url of the texture
  58527. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58528. * @returns the transformed texture
  58529. */
  58530. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  58531. /**
  58532. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  58533. * @param rootUrl the url of the texture
  58534. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58535. * @returns the fallback texture
  58536. */
  58537. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  58538. /**
  58539. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  58540. * @param data contains the texture data
  58541. * @param texture defines the BabylonJS internal texture
  58542. * @param createPolynomials will be true if polynomials have been requested
  58543. * @param onLoad defines the callback to trigger once the texture is ready
  58544. * @param onError defines the callback to trigger in case of error
  58545. */
  58546. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58547. /**
  58548. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  58549. * @param data contains the texture data
  58550. * @param texture defines the BabylonJS internal texture
  58551. * @param callback defines the method to call once ready to upload
  58552. */
  58553. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58554. }
  58555. }
  58556. declare module "babylonjs/Misc/basis" {
  58557. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58558. /**
  58559. * Info about the .basis files
  58560. */
  58561. class BasisFileInfo {
  58562. /**
  58563. * If the file has alpha
  58564. */
  58565. hasAlpha: boolean;
  58566. /**
  58567. * Info about each image of the basis file
  58568. */
  58569. images: Array<{
  58570. levels: Array<{
  58571. width: number;
  58572. height: number;
  58573. transcodedPixels: ArrayBufferView;
  58574. }>;
  58575. }>;
  58576. }
  58577. /**
  58578. * Result of transcoding a basis file
  58579. */
  58580. class TranscodeResult {
  58581. /**
  58582. * Info about the .basis file
  58583. */
  58584. fileInfo: BasisFileInfo;
  58585. /**
  58586. * Format to use when loading the file
  58587. */
  58588. format: number;
  58589. }
  58590. /**
  58591. * Configuration options for the Basis transcoder
  58592. */
  58593. export class BasisTranscodeConfiguration {
  58594. /**
  58595. * Supported compression formats used to determine the supported output format of the transcoder
  58596. */
  58597. supportedCompressionFormats?: {
  58598. /**
  58599. * etc1 compression format
  58600. */
  58601. etc1?: boolean;
  58602. /**
  58603. * s3tc compression format
  58604. */
  58605. s3tc?: boolean;
  58606. /**
  58607. * pvrtc compression format
  58608. */
  58609. pvrtc?: boolean;
  58610. /**
  58611. * etc2 compression format
  58612. */
  58613. etc2?: boolean;
  58614. };
  58615. /**
  58616. * If mipmap levels should be loaded for transcoded images (Default: true)
  58617. */
  58618. loadMipmapLevels?: boolean;
  58619. /**
  58620. * Index of a single image to load (Default: all images)
  58621. */
  58622. loadSingleImage?: number;
  58623. }
  58624. /**
  58625. * Used to load .Basis files
  58626. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  58627. */
  58628. export class BasisTools {
  58629. private static _IgnoreSupportedFormats;
  58630. /**
  58631. * URL to use when loading the basis transcoder
  58632. */
  58633. static JSModuleURL: string;
  58634. /**
  58635. * URL to use when loading the wasm module for the transcoder
  58636. */
  58637. static WasmModuleURL: string;
  58638. /**
  58639. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  58640. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  58641. * @returns internal format corresponding to the Basis format
  58642. */
  58643. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  58644. private static _WorkerPromise;
  58645. private static _Worker;
  58646. private static _actionId;
  58647. private static _CreateWorkerAsync;
  58648. /**
  58649. * Transcodes a loaded image file to compressed pixel data
  58650. * @param data image data to transcode
  58651. * @param config configuration options for the transcoding
  58652. * @returns a promise resulting in the transcoded image
  58653. */
  58654. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  58655. /**
  58656. * Loads a texture from the transcode result
  58657. * @param texture texture load to
  58658. * @param transcodeResult the result of transcoding the basis file to load from
  58659. */
  58660. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  58661. }
  58662. }
  58663. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  58664. import { Nullable } from "babylonjs/types";
  58665. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58666. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58667. /**
  58668. * Loader for .basis file format
  58669. */
  58670. export class _BasisTextureLoader implements IInternalTextureLoader {
  58671. /**
  58672. * Defines whether the loader supports cascade loading the different faces.
  58673. */
  58674. readonly supportCascades: boolean;
  58675. /**
  58676. * This returns if the loader support the current file information.
  58677. * @param extension defines the file extension of the file being loaded
  58678. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58679. * @param fallback defines the fallback internal texture if any
  58680. * @param isBase64 defines whether the texture is encoded as a base64
  58681. * @param isBuffer defines whether the texture data are stored as a buffer
  58682. * @returns true if the loader can load the specified file
  58683. */
  58684. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  58685. /**
  58686. * Transform the url before loading if required.
  58687. * @param rootUrl the url of the texture
  58688. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58689. * @returns the transformed texture
  58690. */
  58691. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  58692. /**
  58693. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  58694. * @param rootUrl the url of the texture
  58695. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58696. * @returns the fallback texture
  58697. */
  58698. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  58699. /**
  58700. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  58701. * @param data contains the texture data
  58702. * @param texture defines the BabylonJS internal texture
  58703. * @param createPolynomials will be true if polynomials have been requested
  58704. * @param onLoad defines the callback to trigger once the texture is ready
  58705. * @param onError defines the callback to trigger in case of error
  58706. */
  58707. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58708. /**
  58709. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  58710. * @param data contains the texture data
  58711. * @param texture defines the BabylonJS internal texture
  58712. * @param callback defines the method to call once ready to upload
  58713. */
  58714. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58715. }
  58716. }
  58717. declare module "babylonjs/Materials/Textures/Loaders/index" {
  58718. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  58719. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  58720. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  58721. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  58722. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  58723. }
  58724. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  58725. import { Scene } from "babylonjs/scene";
  58726. import { Texture } from "babylonjs/Materials/Textures/texture";
  58727. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58728. /**
  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. */
  58733. export class CustomProceduralTexture extends ProceduralTexture {
  58734. private _animate;
  58735. private _time;
  58736. private _config;
  58737. private _texturePath;
  58738. /**
  58739. * Instantiates a new Custom Procedural Texture.
  58740. * 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.
  58741. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  58742. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  58743. * @param name Define the name of the texture
  58744. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  58745. * @param size Define the size of the texture to create
  58746. * @param scene Define the scene the texture belongs to
  58747. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  58748. * @param generateMipMaps Define if the texture should creates mip maps or not
  58749. */
  58750. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  58751. private _loadJson;
  58752. /**
  58753. * Is the texture ready to be used ? (rendered at least once)
  58754. * @returns true if ready, otherwise, false.
  58755. */
  58756. isReady(): boolean;
  58757. /**
  58758. * Render the texture to its associated render target.
  58759. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  58760. */
  58761. render(useCameraPostProcess?: boolean): void;
  58762. /**
  58763. * Update the list of dependant textures samplers in the shader.
  58764. */
  58765. updateTextures(): void;
  58766. /**
  58767. * Update the uniform values of the procedural texture in the shader.
  58768. */
  58769. updateShaderUniforms(): void;
  58770. /**
  58771. * Define if the texture animates or not.
  58772. */
  58773. get animate(): boolean;
  58774. set animate(value: boolean);
  58775. }
  58776. }
  58777. declare module "babylonjs/Shaders/noise.fragment" {
  58778. /** @hidden */
  58779. export var noisePixelShader: {
  58780. name: string;
  58781. shader: string;
  58782. };
  58783. }
  58784. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  58785. import { Nullable } from "babylonjs/types";
  58786. import { Scene } from "babylonjs/scene";
  58787. import { Texture } from "babylonjs/Materials/Textures/texture";
  58788. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58789. import "babylonjs/Shaders/noise.fragment";
  58790. /**
  58791. * Class used to generate noise procedural textures
  58792. */
  58793. export class NoiseProceduralTexture extends ProceduralTexture {
  58794. private _time;
  58795. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  58796. brightness: number;
  58797. /** Defines the number of octaves to process */
  58798. octaves: number;
  58799. /** Defines the level of persistence (0.8 by default) */
  58800. persistence: number;
  58801. /** Gets or sets animation speed factor (default is 1) */
  58802. animationSpeedFactor: number;
  58803. /**
  58804. * Creates a new NoiseProceduralTexture
  58805. * @param name defines the name fo the texture
  58806. * @param size defines the size of the texture (default is 256)
  58807. * @param scene defines the hosting scene
  58808. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  58809. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  58810. */
  58811. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  58812. private _updateShaderUniforms;
  58813. protected _getDefines(): string;
  58814. /** Generate the current state of the procedural texture */
  58815. render(useCameraPostProcess?: boolean): void;
  58816. /**
  58817. * Serializes this noise procedural texture
  58818. * @returns a serialized noise procedural texture object
  58819. */
  58820. serialize(): any;
  58821. /**
  58822. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  58823. * @param parsedTexture defines parsed texture data
  58824. * @param scene defines the current scene
  58825. * @param rootUrl defines the root URL containing noise procedural texture information
  58826. * @returns a parsed NoiseProceduralTexture
  58827. */
  58828. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  58829. }
  58830. }
  58831. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  58832. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  58833. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  58834. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58835. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  58836. }
  58837. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  58838. import { Nullable } from "babylonjs/types";
  58839. import { Scene } from "babylonjs/scene";
  58840. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  58841. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58842. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  58843. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58844. /**
  58845. * Raw cube texture where the raw buffers are passed in
  58846. */
  58847. export class RawCubeTexture extends CubeTexture {
  58848. /**
  58849. * Creates a cube texture where the raw buffers are passed in.
  58850. * @param scene defines the scene the texture is attached to
  58851. * @param data defines the array of data to use to create each face
  58852. * @param size defines the size of the textures
  58853. * @param format defines the format of the data
  58854. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  58855. * @param generateMipMaps defines if the engine should generate the mip levels
  58856. * @param invertY defines if data must be stored with Y axis inverted
  58857. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  58858. * @param compression defines the compression used (null by default)
  58859. */
  58860. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  58861. /**
  58862. * Updates the raw cube texture.
  58863. * @param data defines the data to store
  58864. * @param format defines the data format
  58865. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  58866. * @param invertY defines if data must be stored with Y axis inverted
  58867. * @param compression defines the compression used (null by default)
  58868. * @param level defines which level of the texture to update
  58869. */
  58870. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  58871. /**
  58872. * Updates a raw cube texture with RGBD encoded data.
  58873. * @param data defines the array of data [mipmap][face] to use to create each face
  58874. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  58875. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  58876. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  58877. * @returns a promsie that resolves when the operation is complete
  58878. */
  58879. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  58880. /**
  58881. * Clones the raw cube texture.
  58882. * @return a new cube texture
  58883. */
  58884. clone(): CubeTexture;
  58885. /** @hidden */
  58886. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  58887. }
  58888. }
  58889. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  58890. import { Scene } from "babylonjs/scene";
  58891. import { Texture } from "babylonjs/Materials/Textures/texture";
  58892. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58893. /**
  58894. * Class used to store 3D textures containing user data
  58895. */
  58896. export class RawTexture3D extends Texture {
  58897. /** Gets or sets the texture format to use */
  58898. format: number;
  58899. private _engine;
  58900. /**
  58901. * Create a new RawTexture3D
  58902. * @param data defines the data of the texture
  58903. * @param width defines the width of the texture
  58904. * @param height defines the height of the texture
  58905. * @param depth defines the depth of the texture
  58906. * @param format defines the texture format to use
  58907. * @param scene defines the hosting scene
  58908. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  58909. * @param invertY defines if texture must be stored with Y axis inverted
  58910. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58911. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  58912. */
  58913. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  58914. /** Gets or sets the texture format to use */
  58915. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  58916. /**
  58917. * Update the texture with new data
  58918. * @param data defines the data to store in the texture
  58919. */
  58920. update(data: ArrayBufferView): void;
  58921. }
  58922. }
  58923. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  58924. import { Scene } from "babylonjs/scene";
  58925. import { Texture } from "babylonjs/Materials/Textures/texture";
  58926. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58927. /**
  58928. * Class used to store 2D array textures containing user data
  58929. */
  58930. export class RawTexture2DArray extends Texture {
  58931. /** Gets or sets the texture format to use */
  58932. format: number;
  58933. private _engine;
  58934. /**
  58935. * Create a new RawTexture2DArray
  58936. * @param data defines the data of the texture
  58937. * @param width defines the width of the texture
  58938. * @param height defines the height of the texture
  58939. * @param depth defines the number of layers of the texture
  58940. * @param format defines the texture format to use
  58941. * @param scene defines the hosting scene
  58942. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  58943. * @param invertY defines if texture must be stored with Y axis inverted
  58944. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58945. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  58946. */
  58947. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  58948. /** Gets or sets the texture format to use */
  58949. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  58950. /**
  58951. * Update the texture with new data
  58952. * @param data defines the data to store in the texture
  58953. */
  58954. update(data: ArrayBufferView): void;
  58955. }
  58956. }
  58957. declare module "babylonjs/Materials/Textures/refractionTexture" {
  58958. import { Scene } from "babylonjs/scene";
  58959. import { Plane } from "babylonjs/Maths/math.plane";
  58960. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58961. /**
  58962. * Creates a refraction texture used by refraction channel of the standard material.
  58963. * It is like a mirror but to see through a material.
  58964. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58965. */
  58966. export class RefractionTexture extends RenderTargetTexture {
  58967. /**
  58968. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  58969. * 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.
  58970. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58971. */
  58972. refractionPlane: Plane;
  58973. /**
  58974. * Define how deep under the surface we should see.
  58975. */
  58976. depth: number;
  58977. /**
  58978. * Creates a refraction texture used by refraction channel of the standard material.
  58979. * It is like a mirror but to see through a material.
  58980. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58981. * @param name Define the texture name
  58982. * @param size Define the size of the underlying texture
  58983. * @param scene Define the scene the refraction belongs to
  58984. * @param generateMipMaps Define if we need to generate mips level for the refraction
  58985. */
  58986. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  58987. /**
  58988. * Clone the refraction texture.
  58989. * @returns the cloned texture
  58990. */
  58991. clone(): RefractionTexture;
  58992. /**
  58993. * Serialize the texture to a JSON representation you could use in Parse later on
  58994. * @returns the serialized JSON representation
  58995. */
  58996. serialize(): any;
  58997. }
  58998. }
  58999. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  59000. import { Nullable } from "babylonjs/types";
  59001. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59002. import { Matrix } from "babylonjs/Maths/math.vector";
  59003. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  59004. import "babylonjs/Engines/Extensions/engine.videoTexture";
  59005. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59006. import { Scene } from "babylonjs/scene";
  59007. /**
  59008. * Defines the options related to the creation of an HtmlElementTexture
  59009. */
  59010. export interface IHtmlElementTextureOptions {
  59011. /**
  59012. * Defines wether mip maps should be created or not.
  59013. */
  59014. generateMipMaps?: boolean;
  59015. /**
  59016. * Defines the sampling mode of the texture.
  59017. */
  59018. samplingMode?: number;
  59019. /**
  59020. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  59021. */
  59022. engine: Nullable<ThinEngine>;
  59023. /**
  59024. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  59025. */
  59026. scene: Nullable<Scene>;
  59027. }
  59028. /**
  59029. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  59030. * To be as efficient as possible depending on your constraints nothing aside the first upload
  59031. * is automatically managed.
  59032. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  59033. * in your application.
  59034. *
  59035. * As the update is not automatic, you need to call them manually.
  59036. */
  59037. export class HtmlElementTexture extends BaseTexture {
  59038. /**
  59039. * The texture URL.
  59040. */
  59041. element: HTMLVideoElement | HTMLCanvasElement;
  59042. private static readonly DefaultOptions;
  59043. private _textureMatrix;
  59044. private _engine;
  59045. private _isVideo;
  59046. private _generateMipMaps;
  59047. private _samplingMode;
  59048. /**
  59049. * Instantiates a HtmlElementTexture from the following parameters.
  59050. *
  59051. * @param name Defines the name of the texture
  59052. * @param element Defines the video or canvas the texture is filled with
  59053. * @param options Defines the other none mandatory texture creation options
  59054. */
  59055. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  59056. private _createInternalTexture;
  59057. /**
  59058. * Returns the texture matrix used in most of the material.
  59059. */
  59060. getTextureMatrix(): Matrix;
  59061. /**
  59062. * Updates the content of the texture.
  59063. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  59064. */
  59065. update(invertY?: Nullable<boolean>): void;
  59066. }
  59067. }
  59068. declare module "babylonjs/Materials/Textures/Packer/frame" {
  59069. import { Vector2 } from "babylonjs/Maths/math.vector";
  59070. /**
  59071. * Defines the basic options interface of a TexturePacker Frame
  59072. */
  59073. export interface ITexturePackerFrame {
  59074. /**
  59075. * The frame ID
  59076. */
  59077. id: number;
  59078. /**
  59079. * The frames Scale
  59080. */
  59081. scale: Vector2;
  59082. /**
  59083. * The Frames offset
  59084. */
  59085. offset: Vector2;
  59086. }
  59087. /**
  59088. * This is a support class for frame Data on texture packer sets.
  59089. */
  59090. export class TexturePackerFrame implements ITexturePackerFrame {
  59091. /**
  59092. * The frame ID
  59093. */
  59094. id: number;
  59095. /**
  59096. * The frames Scale
  59097. */
  59098. scale: Vector2;
  59099. /**
  59100. * The Frames offset
  59101. */
  59102. offset: Vector2;
  59103. /**
  59104. * Initializes a texture package frame.
  59105. * @param id The numerical frame identifier
  59106. * @param scale Scalar Vector2 for UV frame
  59107. * @param offset Vector2 for the frame position in UV units.
  59108. * @returns TexturePackerFrame
  59109. */
  59110. constructor(id: number, scale: Vector2, offset: Vector2);
  59111. }
  59112. }
  59113. declare module "babylonjs/Materials/Textures/Packer/packer" {
  59114. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59115. import { Scene } from "babylonjs/scene";
  59116. import { Nullable } from "babylonjs/types";
  59117. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  59118. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  59119. /**
  59120. * Defines the basic options interface of a TexturePacker
  59121. */
  59122. export interface ITexturePackerOptions {
  59123. /**
  59124. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  59125. */
  59126. map?: string[];
  59127. /**
  59128. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59129. */
  59130. uvsIn?: string;
  59131. /**
  59132. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59133. */
  59134. uvsOut?: string;
  59135. /**
  59136. * number representing the layout style. Defaults to LAYOUT_STRIP
  59137. */
  59138. layout?: number;
  59139. /**
  59140. * number of columns if using custom column count layout(2). This defaults to 4.
  59141. */
  59142. colnum?: number;
  59143. /**
  59144. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  59145. */
  59146. updateInputMeshes?: boolean;
  59147. /**
  59148. * boolean flag to dispose all the source textures. Defaults to true.
  59149. */
  59150. disposeSources?: boolean;
  59151. /**
  59152. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  59153. */
  59154. fillBlanks?: boolean;
  59155. /**
  59156. * string value representing the context fill style color. Defaults to 'black'.
  59157. */
  59158. customFillColor?: string;
  59159. /**
  59160. * Width and Height Value of each Frame in the TexturePacker Sets
  59161. */
  59162. frameSize?: number;
  59163. /**
  59164. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  59165. */
  59166. paddingRatio?: number;
  59167. /**
  59168. * Number that declares the fill method for the padding gutter.
  59169. */
  59170. paddingMode?: number;
  59171. /**
  59172. * If in SUBUV_COLOR padding mode what color to use.
  59173. */
  59174. paddingColor?: Color3 | Color4;
  59175. }
  59176. /**
  59177. * Defines the basic interface of a TexturePacker JSON File
  59178. */
  59179. export interface ITexturePackerJSON {
  59180. /**
  59181. * The frame ID
  59182. */
  59183. name: string;
  59184. /**
  59185. * The base64 channel data
  59186. */
  59187. sets: any;
  59188. /**
  59189. * The options of the Packer
  59190. */
  59191. options: ITexturePackerOptions;
  59192. /**
  59193. * The frame data of the Packer
  59194. */
  59195. frames: Array<number>;
  59196. }
  59197. /**
  59198. * This is a support class that generates a series of packed texture sets.
  59199. * @see https://doc.babylonjs.com/babylon101/materials
  59200. */
  59201. export class TexturePacker {
  59202. /** Packer Layout Constant 0 */
  59203. static readonly LAYOUT_STRIP: number;
  59204. /** Packer Layout Constant 1 */
  59205. static readonly LAYOUT_POWER2: number;
  59206. /** Packer Layout Constant 2 */
  59207. static readonly LAYOUT_COLNUM: number;
  59208. /** Packer Layout Constant 0 */
  59209. static readonly SUBUV_WRAP: number;
  59210. /** Packer Layout Constant 1 */
  59211. static readonly SUBUV_EXTEND: number;
  59212. /** Packer Layout Constant 2 */
  59213. static readonly SUBUV_COLOR: number;
  59214. /** The Name of the Texture Package */
  59215. name: string;
  59216. /** The scene scope of the TexturePacker */
  59217. scene: Scene;
  59218. /** The Meshes to target */
  59219. meshes: AbstractMesh[];
  59220. /** Arguments passed with the Constructor */
  59221. options: ITexturePackerOptions;
  59222. /** The promise that is started upon initialization */
  59223. promise: Nullable<Promise<TexturePacker | string>>;
  59224. /** The Container object for the channel sets that are generated */
  59225. sets: object;
  59226. /** The Container array for the frames that are generated */
  59227. frames: TexturePackerFrame[];
  59228. /** The expected number of textures the system is parsing. */
  59229. private _expecting;
  59230. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  59231. private _paddingValue;
  59232. /**
  59233. * Initializes a texture package series from an array of meshes or a single mesh.
  59234. * @param name The name of the package
  59235. * @param meshes The target meshes to compose the package from
  59236. * @param options The arguments that texture packer should follow while building.
  59237. * @param scene The scene which the textures are scoped to.
  59238. * @returns TexturePacker
  59239. */
  59240. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  59241. /**
  59242. * Starts the package process
  59243. * @param resolve The promises resolution function
  59244. * @returns TexturePacker
  59245. */
  59246. private _createFrames;
  59247. /**
  59248. * Calculates the Size of the Channel Sets
  59249. * @returns Vector2
  59250. */
  59251. private _calculateSize;
  59252. /**
  59253. * Calculates the UV data for the frames.
  59254. * @param baseSize the base frameSize
  59255. * @param padding the base frame padding
  59256. * @param dtSize size of the Dynamic Texture for that channel
  59257. * @param dtUnits is 1/dtSize
  59258. * @param update flag to update the input meshes
  59259. */
  59260. private _calculateMeshUVFrames;
  59261. /**
  59262. * Calculates the frames Offset.
  59263. * @param index of the frame
  59264. * @returns Vector2
  59265. */
  59266. private _getFrameOffset;
  59267. /**
  59268. * Updates a Mesh to the frame data
  59269. * @param mesh that is the target
  59270. * @param frameID or the frame index
  59271. */
  59272. private _updateMeshUV;
  59273. /**
  59274. * Updates a Meshes materials to use the texture packer channels
  59275. * @param m is the mesh to target
  59276. * @param force all channels on the packer to be set.
  59277. */
  59278. private _updateTextureReferences;
  59279. /**
  59280. * Public method to set a Mesh to a frame
  59281. * @param m that is the target
  59282. * @param frameID or the frame index
  59283. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  59284. */
  59285. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  59286. /**
  59287. * Starts the async promise to compile the texture packer.
  59288. * @returns Promise<void>
  59289. */
  59290. processAsync(): Promise<void>;
  59291. /**
  59292. * Disposes all textures associated with this packer
  59293. */
  59294. dispose(): void;
  59295. /**
  59296. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  59297. * @param imageType is the image type to use.
  59298. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  59299. */
  59300. download(imageType?: string, quality?: number): void;
  59301. /**
  59302. * Public method to load a texturePacker JSON file.
  59303. * @param data of the JSON file in string format.
  59304. */
  59305. updateFromJSON(data: string): void;
  59306. }
  59307. }
  59308. declare module "babylonjs/Materials/Textures/Packer/index" {
  59309. export * from "babylonjs/Materials/Textures/Packer/packer";
  59310. export * from "babylonjs/Materials/Textures/Packer/frame";
  59311. }
  59312. declare module "babylonjs/Materials/Textures/index" {
  59313. export * from "babylonjs/Materials/Textures/baseTexture";
  59314. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  59315. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  59316. export * from "babylonjs/Materials/Textures/cubeTexture";
  59317. export * from "babylonjs/Materials/Textures/dynamicTexture";
  59318. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  59319. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  59320. export * from "babylonjs/Materials/Textures/internalTexture";
  59321. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  59322. export * from "babylonjs/Materials/Textures/Loaders/index";
  59323. export * from "babylonjs/Materials/Textures/mirrorTexture";
  59324. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  59325. export * from "babylonjs/Materials/Textures/Procedurals/index";
  59326. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  59327. export * from "babylonjs/Materials/Textures/rawTexture";
  59328. export * from "babylonjs/Materials/Textures/rawTexture3D";
  59329. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  59330. export * from "babylonjs/Materials/Textures/refractionTexture";
  59331. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  59332. export * from "babylonjs/Materials/Textures/texture";
  59333. export * from "babylonjs/Materials/Textures/videoTexture";
  59334. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  59335. export * from "babylonjs/Materials/Textures/Packer/index";
  59336. }
  59337. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  59338. /**
  59339. * Enum used to define the target of a block
  59340. */
  59341. export enum NodeMaterialBlockTargets {
  59342. /** Vertex shader */
  59343. Vertex = 1,
  59344. /** Fragment shader */
  59345. Fragment = 2,
  59346. /** Neutral */
  59347. Neutral = 4,
  59348. /** Vertex and Fragment */
  59349. VertexAndFragment = 3
  59350. }
  59351. }
  59352. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  59353. /**
  59354. * Defines the kind of connection point for node based material
  59355. */
  59356. export enum NodeMaterialBlockConnectionPointTypes {
  59357. /** Float */
  59358. Float = 1,
  59359. /** Int */
  59360. Int = 2,
  59361. /** Vector2 */
  59362. Vector2 = 4,
  59363. /** Vector3 */
  59364. Vector3 = 8,
  59365. /** Vector4 */
  59366. Vector4 = 16,
  59367. /** Color3 */
  59368. Color3 = 32,
  59369. /** Color4 */
  59370. Color4 = 64,
  59371. /** Matrix */
  59372. Matrix = 128,
  59373. /** Detect type based on connection */
  59374. AutoDetect = 1024,
  59375. /** Output type that will be defined by input type */
  59376. BasedOnInput = 2048
  59377. }
  59378. }
  59379. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  59380. /**
  59381. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  59382. */
  59383. export enum NodeMaterialBlockConnectionPointMode {
  59384. /** Value is an uniform */
  59385. Uniform = 0,
  59386. /** Value is a mesh attribute */
  59387. Attribute = 1,
  59388. /** Value is a varying between vertex and fragment shaders */
  59389. Varying = 2,
  59390. /** Mode is undefined */
  59391. Undefined = 3
  59392. }
  59393. }
  59394. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  59395. /**
  59396. * Enum used to define system values e.g. values automatically provided by the system
  59397. */
  59398. export enum NodeMaterialSystemValues {
  59399. /** World */
  59400. World = 1,
  59401. /** View */
  59402. View = 2,
  59403. /** Projection */
  59404. Projection = 3,
  59405. /** ViewProjection */
  59406. ViewProjection = 4,
  59407. /** WorldView */
  59408. WorldView = 5,
  59409. /** WorldViewProjection */
  59410. WorldViewProjection = 6,
  59411. /** CameraPosition */
  59412. CameraPosition = 7,
  59413. /** Fog Color */
  59414. FogColor = 8,
  59415. /** Delta time */
  59416. DeltaTime = 9
  59417. }
  59418. }
  59419. declare module "babylonjs/Materials/Node/Enums/index" {
  59420. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59421. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  59422. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  59423. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  59424. }
  59425. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  59426. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59427. /**
  59428. * Root class for all node material optimizers
  59429. */
  59430. export class NodeMaterialOptimizer {
  59431. /**
  59432. * Function used to optimize a NodeMaterial graph
  59433. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  59434. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  59435. */
  59436. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  59437. }
  59438. }
  59439. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  59440. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59441. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59442. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59443. import { Scene } from "babylonjs/scene";
  59444. /**
  59445. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  59446. */
  59447. export class TransformBlock extends NodeMaterialBlock {
  59448. /**
  59449. * Defines the value to use to complement W value to transform it to a Vector4
  59450. */
  59451. complementW: number;
  59452. /**
  59453. * Defines the value to use to complement z value to transform it to a Vector4
  59454. */
  59455. complementZ: number;
  59456. /**
  59457. * Creates a new TransformBlock
  59458. * @param name defines the block name
  59459. */
  59460. constructor(name: string);
  59461. /**
  59462. * Gets the current class name
  59463. * @returns the class name
  59464. */
  59465. getClassName(): string;
  59466. /**
  59467. * Gets the vector input
  59468. */
  59469. get vector(): NodeMaterialConnectionPoint;
  59470. /**
  59471. * Gets the output component
  59472. */
  59473. get output(): NodeMaterialConnectionPoint;
  59474. /**
  59475. * Gets the matrix transform input
  59476. */
  59477. get transform(): NodeMaterialConnectionPoint;
  59478. protected _buildBlock(state: NodeMaterialBuildState): this;
  59479. serialize(): any;
  59480. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59481. protected _dumpPropertiesCode(): string;
  59482. }
  59483. }
  59484. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  59485. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59486. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59487. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59488. /**
  59489. * Block used to output the vertex position
  59490. */
  59491. export class VertexOutputBlock extends NodeMaterialBlock {
  59492. /**
  59493. * Creates a new VertexOutputBlock
  59494. * @param name defines the block name
  59495. */
  59496. constructor(name: string);
  59497. /**
  59498. * Gets the current class name
  59499. * @returns the class name
  59500. */
  59501. getClassName(): string;
  59502. /**
  59503. * Gets the vector input component
  59504. */
  59505. get vector(): NodeMaterialConnectionPoint;
  59506. protected _buildBlock(state: NodeMaterialBuildState): this;
  59507. }
  59508. }
  59509. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  59510. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59511. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59512. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59513. /**
  59514. * Block used to output the final color
  59515. */
  59516. export class FragmentOutputBlock extends NodeMaterialBlock {
  59517. /**
  59518. * Create a new FragmentOutputBlock
  59519. * @param name defines the block name
  59520. */
  59521. constructor(name: string);
  59522. /**
  59523. * Gets the current class name
  59524. * @returns the class name
  59525. */
  59526. getClassName(): string;
  59527. /**
  59528. * Gets the rgba input component
  59529. */
  59530. get rgba(): NodeMaterialConnectionPoint;
  59531. /**
  59532. * Gets the rgb input component
  59533. */
  59534. get rgb(): NodeMaterialConnectionPoint;
  59535. /**
  59536. * Gets the a input component
  59537. */
  59538. get a(): NodeMaterialConnectionPoint;
  59539. protected _buildBlock(state: NodeMaterialBuildState): this;
  59540. }
  59541. }
  59542. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  59543. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59544. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59545. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59546. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59547. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59548. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59549. import { Effect } from "babylonjs/Materials/effect";
  59550. import { Mesh } from "babylonjs/Meshes/mesh";
  59551. import { Nullable } from "babylonjs/types";
  59552. import { Scene } from "babylonjs/scene";
  59553. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  59554. /**
  59555. * Block used to read a reflection texture from a sampler
  59556. */
  59557. export class ReflectionTextureBlock extends NodeMaterialBlock {
  59558. private _define3DName;
  59559. private _defineCubicName;
  59560. private _defineExplicitName;
  59561. private _defineProjectionName;
  59562. private _defineLocalCubicName;
  59563. private _defineSphericalName;
  59564. private _definePlanarName;
  59565. private _defineEquirectangularName;
  59566. private _defineMirroredEquirectangularFixedName;
  59567. private _defineEquirectangularFixedName;
  59568. private _defineSkyboxName;
  59569. private _cubeSamplerName;
  59570. private _2DSamplerName;
  59571. private _positionUVWName;
  59572. private _directionWName;
  59573. private _reflectionCoordsName;
  59574. private _reflection2DCoordsName;
  59575. private _reflectionColorName;
  59576. private _reflectionMatrixName;
  59577. /**
  59578. * Gets or sets the texture associated with the node
  59579. */
  59580. texture: Nullable<BaseTexture>;
  59581. /**
  59582. * Create a new TextureBlock
  59583. * @param name defines the block name
  59584. */
  59585. constructor(name: string);
  59586. /**
  59587. * Gets the current class name
  59588. * @returns the class name
  59589. */
  59590. getClassName(): string;
  59591. /**
  59592. * Gets the world position input component
  59593. */
  59594. get position(): NodeMaterialConnectionPoint;
  59595. /**
  59596. * Gets the world position input component
  59597. */
  59598. get worldPosition(): NodeMaterialConnectionPoint;
  59599. /**
  59600. * Gets the world normal input component
  59601. */
  59602. get worldNormal(): NodeMaterialConnectionPoint;
  59603. /**
  59604. * Gets the world input component
  59605. */
  59606. get world(): NodeMaterialConnectionPoint;
  59607. /**
  59608. * Gets the camera (or eye) position component
  59609. */
  59610. get cameraPosition(): NodeMaterialConnectionPoint;
  59611. /**
  59612. * Gets the view input component
  59613. */
  59614. get view(): NodeMaterialConnectionPoint;
  59615. /**
  59616. * Gets the rgb output component
  59617. */
  59618. get rgb(): NodeMaterialConnectionPoint;
  59619. /**
  59620. * Gets the r output component
  59621. */
  59622. get r(): NodeMaterialConnectionPoint;
  59623. /**
  59624. * Gets the g output component
  59625. */
  59626. get g(): NodeMaterialConnectionPoint;
  59627. /**
  59628. * Gets the b output component
  59629. */
  59630. get b(): NodeMaterialConnectionPoint;
  59631. autoConfigure(material: NodeMaterial): void;
  59632. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59633. isReady(): boolean;
  59634. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59635. private _injectVertexCode;
  59636. private _writeOutput;
  59637. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59638. protected _dumpPropertiesCode(): string;
  59639. serialize(): any;
  59640. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59641. }
  59642. }
  59643. declare module "babylonjs/Materials/Node/nodeMaterial" {
  59644. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59645. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  59646. import { Scene } from "babylonjs/scene";
  59647. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59648. import { Matrix } from "babylonjs/Maths/math.vector";
  59649. import { Mesh } from "babylonjs/Meshes/mesh";
  59650. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59651. import { Observable } from "babylonjs/Misc/observable";
  59652. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59653. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  59654. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  59655. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  59656. import { Nullable } from "babylonjs/types";
  59657. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  59658. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  59659. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  59660. /**
  59661. * Interface used to configure the node material editor
  59662. */
  59663. export interface INodeMaterialEditorOptions {
  59664. /** Define the URl to load node editor script */
  59665. editorURL?: string;
  59666. }
  59667. /** @hidden */
  59668. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  59669. NORMAL: boolean;
  59670. TANGENT: boolean;
  59671. UV1: boolean;
  59672. /** BONES */
  59673. NUM_BONE_INFLUENCERS: number;
  59674. BonesPerMesh: number;
  59675. BONETEXTURE: boolean;
  59676. /** MORPH TARGETS */
  59677. MORPHTARGETS: boolean;
  59678. MORPHTARGETS_NORMAL: boolean;
  59679. MORPHTARGETS_TANGENT: boolean;
  59680. MORPHTARGETS_UV: boolean;
  59681. NUM_MORPH_INFLUENCERS: number;
  59682. /** IMAGE PROCESSING */
  59683. IMAGEPROCESSING: boolean;
  59684. VIGNETTE: boolean;
  59685. VIGNETTEBLENDMODEMULTIPLY: boolean;
  59686. VIGNETTEBLENDMODEOPAQUE: boolean;
  59687. TONEMAPPING: boolean;
  59688. TONEMAPPING_ACES: boolean;
  59689. CONTRAST: boolean;
  59690. EXPOSURE: boolean;
  59691. COLORCURVES: boolean;
  59692. COLORGRADING: boolean;
  59693. COLORGRADING3D: boolean;
  59694. SAMPLER3DGREENDEPTH: boolean;
  59695. SAMPLER3DBGRMAP: boolean;
  59696. IMAGEPROCESSINGPOSTPROCESS: boolean;
  59697. /** MISC. */
  59698. BUMPDIRECTUV: number;
  59699. constructor();
  59700. setValue(name: string, value: boolean): void;
  59701. }
  59702. /**
  59703. * Class used to configure NodeMaterial
  59704. */
  59705. export interface INodeMaterialOptions {
  59706. /**
  59707. * Defines if blocks should emit comments
  59708. */
  59709. emitComments: boolean;
  59710. }
  59711. /**
  59712. * Class used to create a node based material built by assembling shader blocks
  59713. */
  59714. export class NodeMaterial extends PushMaterial {
  59715. private static _BuildIdGenerator;
  59716. private _options;
  59717. private _vertexCompilationState;
  59718. private _fragmentCompilationState;
  59719. private _sharedData;
  59720. private _buildId;
  59721. private _buildWasSuccessful;
  59722. private _cachedWorldViewMatrix;
  59723. private _cachedWorldViewProjectionMatrix;
  59724. private _optimizers;
  59725. private _animationFrame;
  59726. /** Define the Url to load node editor script */
  59727. static EditorURL: string;
  59728. /** Define the Url to load snippets */
  59729. static SnippetUrl: string;
  59730. private BJSNODEMATERIALEDITOR;
  59731. /** Get the inspector from bundle or global */
  59732. private _getGlobalNodeMaterialEditor;
  59733. /**
  59734. * Gets or sets data used by visual editor
  59735. * @see https://nme.babylonjs.com
  59736. */
  59737. editorData: any;
  59738. /**
  59739. * 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)
  59740. */
  59741. ignoreAlpha: boolean;
  59742. /**
  59743. * Defines the maximum number of lights that can be used in the material
  59744. */
  59745. maxSimultaneousLights: number;
  59746. /**
  59747. * Observable raised when the material is built
  59748. */
  59749. onBuildObservable: Observable<NodeMaterial>;
  59750. /**
  59751. * Gets or sets the root nodes of the material vertex shader
  59752. */
  59753. _vertexOutputNodes: NodeMaterialBlock[];
  59754. /**
  59755. * Gets or sets the root nodes of the material fragment (pixel) shader
  59756. */
  59757. _fragmentOutputNodes: NodeMaterialBlock[];
  59758. /** Gets or sets options to control the node material overall behavior */
  59759. get options(): INodeMaterialOptions;
  59760. set options(options: INodeMaterialOptions);
  59761. /**
  59762. * Default configuration related to image processing available in the standard Material.
  59763. */
  59764. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  59765. /**
  59766. * Gets the image processing configuration used either in this material.
  59767. */
  59768. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  59769. /**
  59770. * Sets the Default image processing configuration used either in the this material.
  59771. *
  59772. * If sets to null, the scene one is in use.
  59773. */
  59774. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  59775. /**
  59776. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  59777. */
  59778. attachedBlocks: NodeMaterialBlock[];
  59779. /**
  59780. * Create a new node based material
  59781. * @param name defines the material name
  59782. * @param scene defines the hosting scene
  59783. * @param options defines creation option
  59784. */
  59785. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  59786. /**
  59787. * Gets the current class name of the material e.g. "NodeMaterial"
  59788. * @returns the class name
  59789. */
  59790. getClassName(): string;
  59791. /**
  59792. * Keep track of the image processing observer to allow dispose and replace.
  59793. */
  59794. private _imageProcessingObserver;
  59795. /**
  59796. * Attaches a new image processing configuration to the Standard Material.
  59797. * @param configuration
  59798. */
  59799. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  59800. /**
  59801. * Get a block by its name
  59802. * @param name defines the name of the block to retrieve
  59803. * @returns the required block or null if not found
  59804. */
  59805. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  59806. /**
  59807. * Get a block by its name
  59808. * @param predicate defines the predicate used to find the good candidate
  59809. * @returns the required block or null if not found
  59810. */
  59811. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  59812. /**
  59813. * Get an input block by its name
  59814. * @param predicate defines the predicate used to find the good candidate
  59815. * @returns the required input block or null if not found
  59816. */
  59817. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  59818. /**
  59819. * Gets the list of input blocks attached to this material
  59820. * @returns an array of InputBlocks
  59821. */
  59822. getInputBlocks(): InputBlock[];
  59823. /**
  59824. * Adds a new optimizer to the list of optimizers
  59825. * @param optimizer defines the optimizers to add
  59826. * @returns the current material
  59827. */
  59828. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  59829. /**
  59830. * Remove an optimizer from the list of optimizers
  59831. * @param optimizer defines the optimizers to remove
  59832. * @returns the current material
  59833. */
  59834. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  59835. /**
  59836. * Add a new block to the list of output nodes
  59837. * @param node defines the node to add
  59838. * @returns the current material
  59839. */
  59840. addOutputNode(node: NodeMaterialBlock): this;
  59841. /**
  59842. * Remove a block from the list of root nodes
  59843. * @param node defines the node to remove
  59844. * @returns the current material
  59845. */
  59846. removeOutputNode(node: NodeMaterialBlock): this;
  59847. private _addVertexOutputNode;
  59848. private _removeVertexOutputNode;
  59849. private _addFragmentOutputNode;
  59850. private _removeFragmentOutputNode;
  59851. /**
  59852. * Specifies if the material will require alpha blending
  59853. * @returns a boolean specifying if alpha blending is needed
  59854. */
  59855. needAlphaBlending(): boolean;
  59856. /**
  59857. * Specifies if this material should be rendered in alpha test mode
  59858. * @returns a boolean specifying if an alpha test is needed.
  59859. */
  59860. needAlphaTesting(): boolean;
  59861. private _initializeBlock;
  59862. private _resetDualBlocks;
  59863. /**
  59864. * Remove a block from the current node material
  59865. * @param block defines the block to remove
  59866. */
  59867. removeBlock(block: NodeMaterialBlock): void;
  59868. /**
  59869. * Build the material and generates the inner effect
  59870. * @param verbose defines if the build should log activity
  59871. */
  59872. build(verbose?: boolean): void;
  59873. /**
  59874. * Runs an otpimization phase to try to improve the shader code
  59875. */
  59876. optimize(): void;
  59877. private _prepareDefinesForAttributes;
  59878. /**
  59879. * Get if the submesh is ready to be used and all its information available.
  59880. * Child classes can use it to update shaders
  59881. * @param mesh defines the mesh to check
  59882. * @param subMesh defines which submesh to check
  59883. * @param useInstances specifies that instances should be used
  59884. * @returns a boolean indicating that the submesh is ready or not
  59885. */
  59886. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  59887. /**
  59888. * Get a string representing the shaders built by the current node graph
  59889. */
  59890. get compiledShaders(): string;
  59891. /**
  59892. * Binds the world matrix to the material
  59893. * @param world defines the world transformation matrix
  59894. */
  59895. bindOnlyWorldMatrix(world: Matrix): void;
  59896. /**
  59897. * Binds the submesh to this material by preparing the effect and shader to draw
  59898. * @param world defines the world transformation matrix
  59899. * @param mesh defines the mesh containing the submesh
  59900. * @param subMesh defines the submesh to bind the material to
  59901. */
  59902. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  59903. /**
  59904. * Gets the active textures from the material
  59905. * @returns an array of textures
  59906. */
  59907. getActiveTextures(): BaseTexture[];
  59908. /**
  59909. * Gets the list of texture blocks
  59910. * @returns an array of texture blocks
  59911. */
  59912. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  59913. /**
  59914. * Specifies if the material uses a texture
  59915. * @param texture defines the texture to check against the material
  59916. * @returns a boolean specifying if the material uses the texture
  59917. */
  59918. hasTexture(texture: BaseTexture): boolean;
  59919. /**
  59920. * Disposes the material
  59921. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  59922. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  59923. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  59924. */
  59925. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  59926. /** Creates the node editor window. */
  59927. private _createNodeEditor;
  59928. /**
  59929. * Launch the node material editor
  59930. * @param config Define the configuration of the editor
  59931. * @return a promise fulfilled when the node editor is visible
  59932. */
  59933. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  59934. /**
  59935. * Clear the current material
  59936. */
  59937. clear(): void;
  59938. /**
  59939. * Clear the current material and set it to a default state
  59940. */
  59941. setToDefault(): void;
  59942. /**
  59943. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  59944. * @param url defines the url to load from
  59945. * @returns a promise that will fullfil when the material is fully loaded
  59946. */
  59947. loadAsync(url: string): Promise<void>;
  59948. private _gatherBlocks;
  59949. /**
  59950. * Generate a string containing the code declaration required to create an equivalent of this material
  59951. * @returns a string
  59952. */
  59953. generateCode(): string;
  59954. /**
  59955. * Serializes this material in a JSON representation
  59956. * @returns the serialized material object
  59957. */
  59958. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  59959. private _restoreConnections;
  59960. /**
  59961. * Clear the current graph and load a new one from a serialization object
  59962. * @param source defines the JSON representation of the material
  59963. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59964. */
  59965. loadFromSerialization(source: any, rootUrl?: string): void;
  59966. /**
  59967. * Creates a node material from parsed material data
  59968. * @param source defines the JSON representation of the material
  59969. * @param scene defines the hosting scene
  59970. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59971. * @returns a new node material
  59972. */
  59973. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  59974. /**
  59975. * Creates a node material from a snippet saved in a remote file
  59976. * @param name defines the name of the material to create
  59977. * @param url defines the url to load from
  59978. * @param scene defines the hosting scene
  59979. * @returns a promise that will resolve to the new node material
  59980. */
  59981. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  59982. /**
  59983. * Creates a node material from a snippet saved by the node material editor
  59984. * @param snippetId defines the snippet to load
  59985. * @param scene defines the hosting scene
  59986. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59987. * @returns a promise that will resolve to the new node material
  59988. */
  59989. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  59990. /**
  59991. * Creates a new node material set to default basic configuration
  59992. * @param name defines the name of the material
  59993. * @param scene defines the hosting scene
  59994. * @returns a new NodeMaterial
  59995. */
  59996. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  59997. }
  59998. }
  59999. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  60000. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60001. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60002. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60003. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60004. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60005. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60006. import { Effect } from "babylonjs/Materials/effect";
  60007. import { Mesh } from "babylonjs/Meshes/mesh";
  60008. import { Nullable } from "babylonjs/types";
  60009. import { Texture } from "babylonjs/Materials/Textures/texture";
  60010. import { Scene } from "babylonjs/scene";
  60011. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60012. /**
  60013. * Block used to read a texture from a sampler
  60014. */
  60015. export class TextureBlock extends NodeMaterialBlock {
  60016. private _defineName;
  60017. private _linearDefineName;
  60018. private _tempTextureRead;
  60019. private _samplerName;
  60020. private _transformedUVName;
  60021. private _textureTransformName;
  60022. private _textureInfoName;
  60023. private _mainUVName;
  60024. private _mainUVDefineName;
  60025. /**
  60026. * Gets or sets the texture associated with the node
  60027. */
  60028. texture: Nullable<Texture>;
  60029. /**
  60030. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  60031. */
  60032. convertToGammaSpace: boolean;
  60033. /**
  60034. * Create a new TextureBlock
  60035. * @param name defines the block name
  60036. */
  60037. constructor(name: string);
  60038. /**
  60039. * Gets the current class name
  60040. * @returns the class name
  60041. */
  60042. getClassName(): string;
  60043. /**
  60044. * Gets the uv input component
  60045. */
  60046. get uv(): NodeMaterialConnectionPoint;
  60047. /**
  60048. * Gets the rgba output component
  60049. */
  60050. get rgba(): NodeMaterialConnectionPoint;
  60051. /**
  60052. * Gets the rgb output component
  60053. */
  60054. get rgb(): NodeMaterialConnectionPoint;
  60055. /**
  60056. * Gets the r output component
  60057. */
  60058. get r(): NodeMaterialConnectionPoint;
  60059. /**
  60060. * Gets the g output component
  60061. */
  60062. get g(): NodeMaterialConnectionPoint;
  60063. /**
  60064. * Gets the b output component
  60065. */
  60066. get b(): NodeMaterialConnectionPoint;
  60067. /**
  60068. * Gets the a output component
  60069. */
  60070. get a(): NodeMaterialConnectionPoint;
  60071. get target(): NodeMaterialBlockTargets;
  60072. autoConfigure(material: NodeMaterial): void;
  60073. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60074. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60075. isReady(): boolean;
  60076. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60077. private get _isMixed();
  60078. private _injectVertexCode;
  60079. private _writeTextureRead;
  60080. private _writeOutput;
  60081. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60082. protected _dumpPropertiesCode(): string;
  60083. serialize(): any;
  60084. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60085. }
  60086. }
  60087. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  60088. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60089. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60090. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60091. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  60092. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  60093. import { Scene } from "babylonjs/scene";
  60094. /**
  60095. * Class used to store shared data between 2 NodeMaterialBuildState
  60096. */
  60097. export class NodeMaterialBuildStateSharedData {
  60098. /**
  60099. * Gets the list of emitted varyings
  60100. */
  60101. temps: string[];
  60102. /**
  60103. * Gets the list of emitted varyings
  60104. */
  60105. varyings: string[];
  60106. /**
  60107. * Gets the varying declaration string
  60108. */
  60109. varyingDeclaration: string;
  60110. /**
  60111. * Input blocks
  60112. */
  60113. inputBlocks: InputBlock[];
  60114. /**
  60115. * Input blocks
  60116. */
  60117. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  60118. /**
  60119. * Bindable blocks (Blocks that need to set data to the effect)
  60120. */
  60121. bindableBlocks: NodeMaterialBlock[];
  60122. /**
  60123. * List of blocks that can provide a compilation fallback
  60124. */
  60125. blocksWithFallbacks: NodeMaterialBlock[];
  60126. /**
  60127. * List of blocks that can provide a define update
  60128. */
  60129. blocksWithDefines: NodeMaterialBlock[];
  60130. /**
  60131. * List of blocks that can provide a repeatable content
  60132. */
  60133. repeatableContentBlocks: NodeMaterialBlock[];
  60134. /**
  60135. * List of blocks that can provide a dynamic list of uniforms
  60136. */
  60137. dynamicUniformBlocks: NodeMaterialBlock[];
  60138. /**
  60139. * List of blocks that can block the isReady function for the material
  60140. */
  60141. blockingBlocks: NodeMaterialBlock[];
  60142. /**
  60143. * Gets the list of animated inputs
  60144. */
  60145. animatedInputs: InputBlock[];
  60146. /**
  60147. * Build Id used to avoid multiple recompilations
  60148. */
  60149. buildId: number;
  60150. /** List of emitted variables */
  60151. variableNames: {
  60152. [key: string]: number;
  60153. };
  60154. /** List of emitted defines */
  60155. defineNames: {
  60156. [key: string]: number;
  60157. };
  60158. /** Should emit comments? */
  60159. emitComments: boolean;
  60160. /** Emit build activity */
  60161. verbose: boolean;
  60162. /** Gets or sets the hosting scene */
  60163. scene: Scene;
  60164. /**
  60165. * Gets the compilation hints emitted at compilation time
  60166. */
  60167. hints: {
  60168. needWorldViewMatrix: boolean;
  60169. needWorldViewProjectionMatrix: boolean;
  60170. needAlphaBlending: boolean;
  60171. needAlphaTesting: boolean;
  60172. };
  60173. /**
  60174. * List of compilation checks
  60175. */
  60176. checks: {
  60177. emitVertex: boolean;
  60178. emitFragment: boolean;
  60179. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  60180. };
  60181. /** Creates a new shared data */
  60182. constructor();
  60183. /**
  60184. * Emits console errors and exceptions if there is a failing check
  60185. */
  60186. emitErrors(): void;
  60187. }
  60188. }
  60189. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  60190. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60191. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60192. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  60193. /**
  60194. * Class used to store node based material build state
  60195. */
  60196. export class NodeMaterialBuildState {
  60197. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  60198. supportUniformBuffers: boolean;
  60199. /**
  60200. * Gets the list of emitted attributes
  60201. */
  60202. attributes: string[];
  60203. /**
  60204. * Gets the list of emitted uniforms
  60205. */
  60206. uniforms: string[];
  60207. /**
  60208. * Gets the list of emitted constants
  60209. */
  60210. constants: string[];
  60211. /**
  60212. * Gets the list of emitted samplers
  60213. */
  60214. samplers: string[];
  60215. /**
  60216. * Gets the list of emitted functions
  60217. */
  60218. functions: {
  60219. [key: string]: string;
  60220. };
  60221. /**
  60222. * Gets the list of emitted extensions
  60223. */
  60224. extensions: {
  60225. [key: string]: string;
  60226. };
  60227. /**
  60228. * Gets the target of the compilation state
  60229. */
  60230. target: NodeMaterialBlockTargets;
  60231. /**
  60232. * Gets the list of emitted counters
  60233. */
  60234. counters: {
  60235. [key: string]: number;
  60236. };
  60237. /**
  60238. * Shared data between multiple NodeMaterialBuildState instances
  60239. */
  60240. sharedData: NodeMaterialBuildStateSharedData;
  60241. /** @hidden */
  60242. _vertexState: NodeMaterialBuildState;
  60243. /** @hidden */
  60244. _attributeDeclaration: string;
  60245. /** @hidden */
  60246. _uniformDeclaration: string;
  60247. /** @hidden */
  60248. _constantDeclaration: string;
  60249. /** @hidden */
  60250. _samplerDeclaration: string;
  60251. /** @hidden */
  60252. _varyingTransfer: string;
  60253. private _repeatableContentAnchorIndex;
  60254. /** @hidden */
  60255. _builtCompilationString: string;
  60256. /**
  60257. * Gets the emitted compilation strings
  60258. */
  60259. compilationString: string;
  60260. /**
  60261. * Finalize the compilation strings
  60262. * @param state defines the current compilation state
  60263. */
  60264. finalize(state: NodeMaterialBuildState): void;
  60265. /** @hidden */
  60266. get _repeatableContentAnchor(): string;
  60267. /** @hidden */
  60268. _getFreeVariableName(prefix: string): string;
  60269. /** @hidden */
  60270. _getFreeDefineName(prefix: string): string;
  60271. /** @hidden */
  60272. _excludeVariableName(name: string): void;
  60273. /** @hidden */
  60274. _emit2DSampler(name: string): void;
  60275. /** @hidden */
  60276. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  60277. /** @hidden */
  60278. _emitExtension(name: string, extension: string): void;
  60279. /** @hidden */
  60280. _emitFunction(name: string, code: string, comments: string): void;
  60281. /** @hidden */
  60282. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  60283. replaceStrings?: {
  60284. search: RegExp;
  60285. replace: string;
  60286. }[];
  60287. repeatKey?: string;
  60288. }): string;
  60289. /** @hidden */
  60290. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  60291. repeatKey?: string;
  60292. removeAttributes?: boolean;
  60293. removeUniforms?: boolean;
  60294. removeVaryings?: boolean;
  60295. removeIfDef?: boolean;
  60296. replaceStrings?: {
  60297. search: RegExp;
  60298. replace: string;
  60299. }[];
  60300. }, storeKey?: string): void;
  60301. /** @hidden */
  60302. _registerTempVariable(name: string): boolean;
  60303. /** @hidden */
  60304. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  60305. /** @hidden */
  60306. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  60307. /** @hidden */
  60308. _emitFloat(value: number): string;
  60309. }
  60310. }
  60311. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  60312. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60313. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60314. import { Nullable } from "babylonjs/types";
  60315. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60316. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60317. import { Effect } from "babylonjs/Materials/effect";
  60318. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60319. import { Mesh } from "babylonjs/Meshes/mesh";
  60320. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60321. import { Scene } from "babylonjs/scene";
  60322. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60323. /**
  60324. * Defines a block that can be used inside a node based material
  60325. */
  60326. export class NodeMaterialBlock {
  60327. private _buildId;
  60328. private _buildTarget;
  60329. private _target;
  60330. private _isFinalMerger;
  60331. private _isInput;
  60332. protected _isUnique: boolean;
  60333. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  60334. inputsAreExclusive: boolean;
  60335. /** @hidden */
  60336. _codeVariableName: string;
  60337. /** @hidden */
  60338. _inputs: NodeMaterialConnectionPoint[];
  60339. /** @hidden */
  60340. _outputs: NodeMaterialConnectionPoint[];
  60341. /** @hidden */
  60342. _preparationId: number;
  60343. /**
  60344. * Gets or sets the name of the block
  60345. */
  60346. name: string;
  60347. /**
  60348. * Gets or sets the unique id of the node
  60349. */
  60350. uniqueId: number;
  60351. /**
  60352. * Gets or sets the comments associated with this block
  60353. */
  60354. comments: string;
  60355. /**
  60356. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  60357. */
  60358. get isUnique(): boolean;
  60359. /**
  60360. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  60361. */
  60362. get isFinalMerger(): boolean;
  60363. /**
  60364. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  60365. */
  60366. get isInput(): boolean;
  60367. /**
  60368. * Gets or sets the build Id
  60369. */
  60370. get buildId(): number;
  60371. set buildId(value: number);
  60372. /**
  60373. * Gets or sets the target of the block
  60374. */
  60375. get target(): NodeMaterialBlockTargets;
  60376. set target(value: NodeMaterialBlockTargets);
  60377. /**
  60378. * Gets the list of input points
  60379. */
  60380. get inputs(): NodeMaterialConnectionPoint[];
  60381. /** Gets the list of output points */
  60382. get outputs(): NodeMaterialConnectionPoint[];
  60383. /**
  60384. * Find an input by its name
  60385. * @param name defines the name of the input to look for
  60386. * @returns the input or null if not found
  60387. */
  60388. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60389. /**
  60390. * Find an output by its name
  60391. * @param name defines the name of the outputto look for
  60392. * @returns the output or null if not found
  60393. */
  60394. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60395. /**
  60396. * Creates a new NodeMaterialBlock
  60397. * @param name defines the block name
  60398. * @param target defines the target of that block (Vertex by default)
  60399. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  60400. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  60401. */
  60402. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  60403. /**
  60404. * Initialize the block and prepare the context for build
  60405. * @param state defines the state that will be used for the build
  60406. */
  60407. initialize(state: NodeMaterialBuildState): void;
  60408. /**
  60409. * Bind data to effect. Will only be called for blocks with isBindable === true
  60410. * @param effect defines the effect to bind data to
  60411. * @param nodeMaterial defines the hosting NodeMaterial
  60412. * @param mesh defines the mesh that will be rendered
  60413. */
  60414. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60415. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  60416. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  60417. protected _writeFloat(value: number): string;
  60418. /**
  60419. * Gets the current class name e.g. "NodeMaterialBlock"
  60420. * @returns the class name
  60421. */
  60422. getClassName(): string;
  60423. /**
  60424. * Register a new input. Must be called inside a block constructor
  60425. * @param name defines the connection point name
  60426. * @param type defines the connection point type
  60427. * @param isOptional defines a boolean indicating that this input can be omitted
  60428. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60429. * @returns the current block
  60430. */
  60431. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  60432. /**
  60433. * Register a new output. Must be called inside a block constructor
  60434. * @param name defines the connection point name
  60435. * @param type defines the connection point type
  60436. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60437. * @returns the current block
  60438. */
  60439. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  60440. /**
  60441. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  60442. * @param forOutput defines an optional connection point to check compatibility with
  60443. * @returns the first available input or null
  60444. */
  60445. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  60446. /**
  60447. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  60448. * @param forBlock defines an optional block to check compatibility with
  60449. * @returns the first available input or null
  60450. */
  60451. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  60452. /**
  60453. * Gets the sibling of the given output
  60454. * @param current defines the current output
  60455. * @returns the next output in the list or null
  60456. */
  60457. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  60458. /**
  60459. * Connect current block with another block
  60460. * @param other defines the block to connect with
  60461. * @param options define the various options to help pick the right connections
  60462. * @returns the current block
  60463. */
  60464. connectTo(other: NodeMaterialBlock, options?: {
  60465. input?: string;
  60466. output?: string;
  60467. outputSwizzle?: string;
  60468. }): this | undefined;
  60469. protected _buildBlock(state: NodeMaterialBuildState): void;
  60470. /**
  60471. * Add uniforms, samplers and uniform buffers at compilation time
  60472. * @param state defines the state to update
  60473. * @param nodeMaterial defines the node material requesting the update
  60474. * @param defines defines the material defines to update
  60475. * @param uniformBuffers defines the list of uniform buffer names
  60476. */
  60477. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  60478. /**
  60479. * Add potential fallbacks if shader compilation fails
  60480. * @param mesh defines the mesh to be rendered
  60481. * @param fallbacks defines the current prioritized list of fallbacks
  60482. */
  60483. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60484. /**
  60485. * Initialize defines for shader compilation
  60486. * @param mesh defines the mesh to be rendered
  60487. * @param nodeMaterial defines the node material requesting the update
  60488. * @param defines defines the material defines to update
  60489. * @param useInstances specifies that instances should be used
  60490. */
  60491. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60492. /**
  60493. * Update defines for shader compilation
  60494. * @param mesh defines the mesh to be rendered
  60495. * @param nodeMaterial defines the node material requesting the update
  60496. * @param defines defines the material defines to update
  60497. * @param useInstances specifies that instances should be used
  60498. */
  60499. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60500. /**
  60501. * Lets the block try to connect some inputs automatically
  60502. * @param material defines the hosting NodeMaterial
  60503. */
  60504. autoConfigure(material: NodeMaterial): void;
  60505. /**
  60506. * Function called when a block is declared as repeatable content generator
  60507. * @param vertexShaderState defines the current compilation state for the vertex shader
  60508. * @param fragmentShaderState defines the current compilation state for the fragment shader
  60509. * @param mesh defines the mesh to be rendered
  60510. * @param defines defines the material defines to update
  60511. */
  60512. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  60513. /**
  60514. * Checks if the block is ready
  60515. * @param mesh defines the mesh to be rendered
  60516. * @param nodeMaterial defines the node material requesting the update
  60517. * @param defines defines the material defines to update
  60518. * @param useInstances specifies that instances should be used
  60519. * @returns true if the block is ready
  60520. */
  60521. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  60522. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  60523. private _processBuild;
  60524. /**
  60525. * Compile the current node and generate the shader code
  60526. * @param state defines the current compilation state (uniforms, samplers, current string)
  60527. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  60528. * @returns true if already built
  60529. */
  60530. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  60531. protected _inputRename(name: string): string;
  60532. protected _outputRename(name: string): string;
  60533. protected _dumpPropertiesCode(): string;
  60534. /** @hidden */
  60535. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  60536. /** @hidden */
  60537. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  60538. /**
  60539. * Clone the current block to a new identical block
  60540. * @param scene defines the hosting scene
  60541. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60542. * @returns a copy of the current block
  60543. */
  60544. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  60545. /**
  60546. * Serializes this block in a JSON representation
  60547. * @returns the serialized block object
  60548. */
  60549. serialize(): any;
  60550. /** @hidden */
  60551. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60552. /**
  60553. * Release resources
  60554. */
  60555. dispose(): void;
  60556. }
  60557. }
  60558. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  60559. /**
  60560. * Enum defining the type of animations supported by InputBlock
  60561. */
  60562. export enum AnimatedInputBlockTypes {
  60563. /** No animation */
  60564. None = 0,
  60565. /** Time based animation. Will only work for floats */
  60566. Time = 1
  60567. }
  60568. }
  60569. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  60570. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60571. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60572. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  60573. import { Nullable } from "babylonjs/types";
  60574. import { Effect } from "babylonjs/Materials/effect";
  60575. import { Matrix } from "babylonjs/Maths/math.vector";
  60576. import { Scene } from "babylonjs/scene";
  60577. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60578. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60579. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60580. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  60581. /**
  60582. * Block used to expose an input value
  60583. */
  60584. export class InputBlock extends NodeMaterialBlock {
  60585. private _mode;
  60586. private _associatedVariableName;
  60587. private _storedValue;
  60588. private _valueCallback;
  60589. private _type;
  60590. private _animationType;
  60591. /** Gets or set a value used to limit the range of float values */
  60592. min: number;
  60593. /** Gets or set a value used to limit the range of float values */
  60594. max: number;
  60595. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  60596. isBoolean: boolean;
  60597. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  60598. matrixMode: number;
  60599. /** @hidden */
  60600. _systemValue: Nullable<NodeMaterialSystemValues>;
  60601. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  60602. visibleInInspector: boolean;
  60603. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  60604. isConstant: boolean;
  60605. /** Gets or sets the group to use to display this block in the Inspector */
  60606. groupInInspector: string;
  60607. /**
  60608. * Gets or sets the connection point type (default is float)
  60609. */
  60610. get type(): NodeMaterialBlockConnectionPointTypes;
  60611. /**
  60612. * Creates a new InputBlock
  60613. * @param name defines the block name
  60614. * @param target defines the target of that block (Vertex by default)
  60615. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  60616. */
  60617. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  60618. /**
  60619. * Gets the output component
  60620. */
  60621. get output(): NodeMaterialConnectionPoint;
  60622. /**
  60623. * Set the source of this connection point to a vertex attribute
  60624. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  60625. * @returns the current connection point
  60626. */
  60627. setAsAttribute(attributeName?: string): InputBlock;
  60628. /**
  60629. * Set the source of this connection point to a system value
  60630. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  60631. * @returns the current connection point
  60632. */
  60633. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  60634. /**
  60635. * Gets or sets the value of that point.
  60636. * Please note that this value will be ignored if valueCallback is defined
  60637. */
  60638. get value(): any;
  60639. set value(value: any);
  60640. /**
  60641. * Gets or sets a callback used to get the value of that point.
  60642. * Please note that setting this value will force the connection point to ignore the value property
  60643. */
  60644. get valueCallback(): () => any;
  60645. set valueCallback(value: () => any);
  60646. /**
  60647. * Gets or sets the associated variable name in the shader
  60648. */
  60649. get associatedVariableName(): string;
  60650. set associatedVariableName(value: string);
  60651. /** Gets or sets the type of animation applied to the input */
  60652. get animationType(): AnimatedInputBlockTypes;
  60653. set animationType(value: AnimatedInputBlockTypes);
  60654. /**
  60655. * Gets a boolean indicating that this connection point not defined yet
  60656. */
  60657. get isUndefined(): boolean;
  60658. /**
  60659. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  60660. * In this case the connection point name must be the name of the uniform to use.
  60661. * Can only be set on inputs
  60662. */
  60663. get isUniform(): boolean;
  60664. set isUniform(value: boolean);
  60665. /**
  60666. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  60667. * In this case the connection point name must be the name of the attribute to use
  60668. * Can only be set on inputs
  60669. */
  60670. get isAttribute(): boolean;
  60671. set isAttribute(value: boolean);
  60672. /**
  60673. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  60674. * Can only be set on exit points
  60675. */
  60676. get isVarying(): boolean;
  60677. set isVarying(value: boolean);
  60678. /**
  60679. * Gets a boolean indicating that the current connection point is a system value
  60680. */
  60681. get isSystemValue(): boolean;
  60682. /**
  60683. * Gets or sets the current well known value or null if not defined as a system value
  60684. */
  60685. get systemValue(): Nullable<NodeMaterialSystemValues>;
  60686. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  60687. /**
  60688. * Gets the current class name
  60689. * @returns the class name
  60690. */
  60691. getClassName(): string;
  60692. /**
  60693. * Animate the input if animationType !== None
  60694. * @param scene defines the rendering scene
  60695. */
  60696. animate(scene: Scene): void;
  60697. private _emitDefine;
  60698. initialize(state: NodeMaterialBuildState): void;
  60699. /**
  60700. * Set the input block to its default value (based on its type)
  60701. */
  60702. setDefaultValue(): void;
  60703. private _emitConstant;
  60704. private _emit;
  60705. /** @hidden */
  60706. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  60707. /** @hidden */
  60708. _transmit(effect: Effect, scene: Scene): void;
  60709. protected _buildBlock(state: NodeMaterialBuildState): void;
  60710. protected _dumpPropertiesCode(): string;
  60711. serialize(): any;
  60712. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60713. }
  60714. }
  60715. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  60716. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60717. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60718. import { Nullable } from "babylonjs/types";
  60719. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60720. import { Observable } from "babylonjs/Misc/observable";
  60721. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60722. /**
  60723. * Enum used to define the compatibility state between two connection points
  60724. */
  60725. export enum NodeMaterialConnectionPointCompatibilityStates {
  60726. /** Points are compatibles */
  60727. Compatible = 0,
  60728. /** Points are incompatible because of their types */
  60729. TypeIncompatible = 1,
  60730. /** Points are incompatible because of their targets (vertex vs fragment) */
  60731. TargetIncompatible = 2
  60732. }
  60733. /**
  60734. * Defines the direction of a connection point
  60735. */
  60736. export enum NodeMaterialConnectionPointDirection {
  60737. /** Input */
  60738. Input = 0,
  60739. /** Output */
  60740. Output = 1
  60741. }
  60742. /**
  60743. * Defines a connection point for a block
  60744. */
  60745. export class NodeMaterialConnectionPoint {
  60746. /** @hidden */
  60747. _ownerBlock: NodeMaterialBlock;
  60748. /** @hidden */
  60749. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  60750. private _endpoints;
  60751. private _associatedVariableName;
  60752. private _direction;
  60753. /** @hidden */
  60754. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  60755. /** @hidden */
  60756. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  60757. private _type;
  60758. /** @hidden */
  60759. _enforceAssociatedVariableName: boolean;
  60760. /** Gets the direction of the point */
  60761. get direction(): NodeMaterialConnectionPointDirection;
  60762. /**
  60763. * Gets or sets the additional types supported by this connection point
  60764. */
  60765. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  60766. /**
  60767. * Gets or sets the additional types excluded by this connection point
  60768. */
  60769. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  60770. /**
  60771. * Observable triggered when this point is connected
  60772. */
  60773. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  60774. /**
  60775. * Gets or sets the associated variable name in the shader
  60776. */
  60777. get associatedVariableName(): string;
  60778. set associatedVariableName(value: string);
  60779. /** Get the inner type (ie AutoDetect for isntance instead of the inferred one) */
  60780. get innerType(): NodeMaterialBlockConnectionPointTypes;
  60781. /**
  60782. * Gets or sets the connection point type (default is float)
  60783. */
  60784. get type(): NodeMaterialBlockConnectionPointTypes;
  60785. set type(value: NodeMaterialBlockConnectionPointTypes);
  60786. /**
  60787. * Gets or sets the connection point name
  60788. */
  60789. name: string;
  60790. /**
  60791. * Gets or sets a boolean indicating that this connection point can be omitted
  60792. */
  60793. isOptional: boolean;
  60794. /**
  60795. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  60796. */
  60797. define: string;
  60798. /** @hidden */
  60799. _prioritizeVertex: boolean;
  60800. private _target;
  60801. /** Gets or sets the target of that connection point */
  60802. get target(): NodeMaterialBlockTargets;
  60803. set target(value: NodeMaterialBlockTargets);
  60804. /**
  60805. * Gets a boolean indicating that the current point is connected
  60806. */
  60807. get isConnected(): boolean;
  60808. /**
  60809. * Gets a boolean indicating that the current point is connected to an input block
  60810. */
  60811. get isConnectedToInputBlock(): boolean;
  60812. /**
  60813. * Gets a the connected input block (if any)
  60814. */
  60815. get connectInputBlock(): Nullable<InputBlock>;
  60816. /** Get the other side of the connection (if any) */
  60817. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  60818. /** Get the block that owns this connection point */
  60819. get ownerBlock(): NodeMaterialBlock;
  60820. /** Get the block connected on the other side of this connection (if any) */
  60821. get sourceBlock(): Nullable<NodeMaterialBlock>;
  60822. /** Get the block connected on the endpoints of this connection (if any) */
  60823. get connectedBlocks(): Array<NodeMaterialBlock>;
  60824. /** Gets the list of connected endpoints */
  60825. get endpoints(): NodeMaterialConnectionPoint[];
  60826. /** Gets a boolean indicating if that output point is connected to at least one input */
  60827. get hasEndpoints(): boolean;
  60828. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  60829. get isConnectedInVertexShader(): boolean;
  60830. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  60831. get isConnectedInFragmentShader(): boolean;
  60832. /**
  60833. * Creates a new connection point
  60834. * @param name defines the connection point name
  60835. * @param ownerBlock defines the block hosting this connection point
  60836. * @param direction defines the direction of the connection point
  60837. */
  60838. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  60839. /**
  60840. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  60841. * @returns the class name
  60842. */
  60843. getClassName(): string;
  60844. /**
  60845. * Gets a boolean indicating if the current point can be connected to another point
  60846. * @param connectionPoint defines the other connection point
  60847. * @returns a boolean
  60848. */
  60849. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  60850. /**
  60851. * Gets a number indicating if the current point can be connected to another point
  60852. * @param connectionPoint defines the other connection point
  60853. * @returns a number defining the compatibility state
  60854. */
  60855. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  60856. /**
  60857. * Connect this point to another connection point
  60858. * @param connectionPoint defines the other connection point
  60859. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  60860. * @returns the current connection point
  60861. */
  60862. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  60863. /**
  60864. * Disconnect this point from one of his endpoint
  60865. * @param endpoint defines the other connection point
  60866. * @returns the current connection point
  60867. */
  60868. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  60869. /**
  60870. * Serializes this point in a JSON representation
  60871. * @returns the serialized point object
  60872. */
  60873. serialize(): any;
  60874. /**
  60875. * Release resources
  60876. */
  60877. dispose(): void;
  60878. }
  60879. }
  60880. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  60881. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60882. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60883. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60884. import { Mesh } from "babylonjs/Meshes/mesh";
  60885. import { Effect } from "babylonjs/Materials/effect";
  60886. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60887. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60888. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60889. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60890. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60891. /**
  60892. * Block used to add support for vertex skinning (bones)
  60893. */
  60894. export class BonesBlock extends NodeMaterialBlock {
  60895. /**
  60896. * Creates a new BonesBlock
  60897. * @param name defines the block name
  60898. */
  60899. constructor(name: string);
  60900. /**
  60901. * Initialize the block and prepare the context for build
  60902. * @param state defines the state that will be used for the build
  60903. */
  60904. initialize(state: NodeMaterialBuildState): void;
  60905. /**
  60906. * Gets the current class name
  60907. * @returns the class name
  60908. */
  60909. getClassName(): string;
  60910. /**
  60911. * Gets the matrix indices input component
  60912. */
  60913. get matricesIndices(): NodeMaterialConnectionPoint;
  60914. /**
  60915. * Gets the matrix weights input component
  60916. */
  60917. get matricesWeights(): NodeMaterialConnectionPoint;
  60918. /**
  60919. * Gets the extra matrix indices input component
  60920. */
  60921. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  60922. /**
  60923. * Gets the extra matrix weights input component
  60924. */
  60925. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  60926. /**
  60927. * Gets the world input component
  60928. */
  60929. get world(): NodeMaterialConnectionPoint;
  60930. /**
  60931. * Gets the output component
  60932. */
  60933. get output(): NodeMaterialConnectionPoint;
  60934. autoConfigure(material: NodeMaterial): void;
  60935. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60936. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60937. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60938. protected _buildBlock(state: NodeMaterialBuildState): this;
  60939. }
  60940. }
  60941. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  60942. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60943. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60944. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60945. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60946. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60947. /**
  60948. * Block used to add support for instances
  60949. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  60950. */
  60951. export class InstancesBlock extends NodeMaterialBlock {
  60952. /**
  60953. * Creates a new InstancesBlock
  60954. * @param name defines the block name
  60955. */
  60956. constructor(name: string);
  60957. /**
  60958. * Gets the current class name
  60959. * @returns the class name
  60960. */
  60961. getClassName(): string;
  60962. /**
  60963. * Gets the first world row input component
  60964. */
  60965. get world0(): NodeMaterialConnectionPoint;
  60966. /**
  60967. * Gets the second world row input component
  60968. */
  60969. get world1(): NodeMaterialConnectionPoint;
  60970. /**
  60971. * Gets the third world row input component
  60972. */
  60973. get world2(): NodeMaterialConnectionPoint;
  60974. /**
  60975. * Gets the forth world row input component
  60976. */
  60977. get world3(): NodeMaterialConnectionPoint;
  60978. /**
  60979. * Gets the world input component
  60980. */
  60981. get world(): NodeMaterialConnectionPoint;
  60982. /**
  60983. * Gets the output component
  60984. */
  60985. get output(): NodeMaterialConnectionPoint;
  60986. /**
  60987. * Gets the isntanceID component
  60988. */
  60989. get instanceID(): NodeMaterialConnectionPoint;
  60990. autoConfigure(material: NodeMaterial): void;
  60991. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60992. protected _buildBlock(state: NodeMaterialBuildState): this;
  60993. }
  60994. }
  60995. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  60996. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60997. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60998. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60999. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61000. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61001. import { Effect } from "babylonjs/Materials/effect";
  61002. import { Mesh } from "babylonjs/Meshes/mesh";
  61003. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61004. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61005. /**
  61006. * Block used to add morph targets support to vertex shader
  61007. */
  61008. export class MorphTargetsBlock extends NodeMaterialBlock {
  61009. private _repeatableContentAnchor;
  61010. /**
  61011. * Create a new MorphTargetsBlock
  61012. * @param name defines the block name
  61013. */
  61014. constructor(name: string);
  61015. /**
  61016. * Gets the current class name
  61017. * @returns the class name
  61018. */
  61019. getClassName(): string;
  61020. /**
  61021. * Gets the position input component
  61022. */
  61023. get position(): NodeMaterialConnectionPoint;
  61024. /**
  61025. * Gets the normal input component
  61026. */
  61027. get normal(): NodeMaterialConnectionPoint;
  61028. /**
  61029. * Gets the tangent input component
  61030. */
  61031. get tangent(): NodeMaterialConnectionPoint;
  61032. /**
  61033. * Gets the tangent input component
  61034. */
  61035. get uv(): NodeMaterialConnectionPoint;
  61036. /**
  61037. * Gets the position output component
  61038. */
  61039. get positionOutput(): NodeMaterialConnectionPoint;
  61040. /**
  61041. * Gets the normal output component
  61042. */
  61043. get normalOutput(): NodeMaterialConnectionPoint;
  61044. /**
  61045. * Gets the tangent output component
  61046. */
  61047. get tangentOutput(): NodeMaterialConnectionPoint;
  61048. /**
  61049. * Gets the tangent output component
  61050. */
  61051. get uvOutput(): NodeMaterialConnectionPoint;
  61052. initialize(state: NodeMaterialBuildState): void;
  61053. autoConfigure(material: NodeMaterial): void;
  61054. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61055. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61056. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61057. protected _buildBlock(state: NodeMaterialBuildState): this;
  61058. }
  61059. }
  61060. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  61061. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61062. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61063. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61064. import { Nullable } from "babylonjs/types";
  61065. import { Scene } from "babylonjs/scene";
  61066. import { Effect } from "babylonjs/Materials/effect";
  61067. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61068. import { Mesh } from "babylonjs/Meshes/mesh";
  61069. import { Light } from "babylonjs/Lights/light";
  61070. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61071. /**
  61072. * Block used to get data information from a light
  61073. */
  61074. export class LightInformationBlock extends NodeMaterialBlock {
  61075. private _lightDataUniformName;
  61076. private _lightColorUniformName;
  61077. private _lightTypeDefineName;
  61078. /**
  61079. * Gets or sets the light associated with this block
  61080. */
  61081. light: Nullable<Light>;
  61082. /**
  61083. * Creates a new LightInformationBlock
  61084. * @param name defines the block name
  61085. */
  61086. constructor(name: string);
  61087. /**
  61088. * Gets the current class name
  61089. * @returns the class name
  61090. */
  61091. getClassName(): string;
  61092. /**
  61093. * Gets the world position input component
  61094. */
  61095. get worldPosition(): NodeMaterialConnectionPoint;
  61096. /**
  61097. * Gets the direction output component
  61098. */
  61099. get direction(): NodeMaterialConnectionPoint;
  61100. /**
  61101. * Gets the direction output component
  61102. */
  61103. get color(): NodeMaterialConnectionPoint;
  61104. /**
  61105. * Gets the direction output component
  61106. */
  61107. get intensity(): NodeMaterialConnectionPoint;
  61108. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61109. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61110. protected _buildBlock(state: NodeMaterialBuildState): this;
  61111. serialize(): any;
  61112. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61113. }
  61114. }
  61115. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  61116. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  61117. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  61118. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  61119. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  61120. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  61121. }
  61122. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  61123. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61124. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61125. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61126. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61127. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61128. import { Effect } from "babylonjs/Materials/effect";
  61129. import { Mesh } from "babylonjs/Meshes/mesh";
  61130. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61131. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  61132. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  61133. /**
  61134. * Block used to add image processing support to fragment shader
  61135. */
  61136. export class ImageProcessingBlock extends NodeMaterialBlock {
  61137. /**
  61138. * Create a new ImageProcessingBlock
  61139. * @param name defines the block name
  61140. */
  61141. constructor(name: string);
  61142. /**
  61143. * Gets the current class name
  61144. * @returns the class name
  61145. */
  61146. getClassName(): string;
  61147. /**
  61148. * Gets the color input component
  61149. */
  61150. get color(): NodeMaterialConnectionPoint;
  61151. /**
  61152. * Gets the output component
  61153. */
  61154. get output(): NodeMaterialConnectionPoint;
  61155. /**
  61156. * Initialize the block and prepare the context for build
  61157. * @param state defines the state that will be used for the build
  61158. */
  61159. initialize(state: NodeMaterialBuildState): void;
  61160. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  61161. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61162. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61163. protected _buildBlock(state: NodeMaterialBuildState): this;
  61164. }
  61165. }
  61166. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  61167. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61168. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61169. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61170. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61171. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61172. import { Effect } from "babylonjs/Materials/effect";
  61173. import { Mesh } from "babylonjs/Meshes/mesh";
  61174. import { Scene } from "babylonjs/scene";
  61175. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  61176. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  61177. /**
  61178. * Block used to pertub normals based on a normal map
  61179. */
  61180. export class PerturbNormalBlock extends NodeMaterialBlock {
  61181. private _tangentSpaceParameterName;
  61182. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61183. invertX: boolean;
  61184. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  61185. invertY: boolean;
  61186. /**
  61187. * Create a new PerturbNormalBlock
  61188. * @param name defines the block name
  61189. */
  61190. constructor(name: string);
  61191. /**
  61192. * Gets the current class name
  61193. * @returns the class name
  61194. */
  61195. getClassName(): string;
  61196. /**
  61197. * Gets the world position input component
  61198. */
  61199. get worldPosition(): NodeMaterialConnectionPoint;
  61200. /**
  61201. * Gets the world normal input component
  61202. */
  61203. get worldNormal(): NodeMaterialConnectionPoint;
  61204. /**
  61205. * Gets the world tangent input component
  61206. */
  61207. get worldTangent(): NodeMaterialConnectionPoint;
  61208. /**
  61209. * Gets the uv input component
  61210. */
  61211. get uv(): NodeMaterialConnectionPoint;
  61212. /**
  61213. * Gets the normal map color input component
  61214. */
  61215. get normalMapColor(): NodeMaterialConnectionPoint;
  61216. /**
  61217. * Gets the strength input component
  61218. */
  61219. get strength(): NodeMaterialConnectionPoint;
  61220. /**
  61221. * Gets the output component
  61222. */
  61223. get output(): NodeMaterialConnectionPoint;
  61224. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61225. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61226. autoConfigure(material: NodeMaterial): void;
  61227. protected _buildBlock(state: NodeMaterialBuildState): this;
  61228. protected _dumpPropertiesCode(): string;
  61229. serialize(): any;
  61230. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61231. }
  61232. }
  61233. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  61234. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61235. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61236. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61237. /**
  61238. * Block used to discard a pixel if a value is smaller than a cutoff
  61239. */
  61240. export class DiscardBlock extends NodeMaterialBlock {
  61241. /**
  61242. * Create a new DiscardBlock
  61243. * @param name defines the block name
  61244. */
  61245. constructor(name: string);
  61246. /**
  61247. * Gets the current class name
  61248. * @returns the class name
  61249. */
  61250. getClassName(): string;
  61251. /**
  61252. * Gets the color input component
  61253. */
  61254. get value(): NodeMaterialConnectionPoint;
  61255. /**
  61256. * Gets the cutoff input component
  61257. */
  61258. get cutoff(): NodeMaterialConnectionPoint;
  61259. protected _buildBlock(state: NodeMaterialBuildState): this;
  61260. }
  61261. }
  61262. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  61263. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61264. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61265. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61266. /**
  61267. * Block used to test if the fragment shader is front facing
  61268. */
  61269. export class FrontFacingBlock extends NodeMaterialBlock {
  61270. /**
  61271. * Creates a new FrontFacingBlock
  61272. * @param name defines the block name
  61273. */
  61274. constructor(name: string);
  61275. /**
  61276. * Gets the current class name
  61277. * @returns the class name
  61278. */
  61279. getClassName(): string;
  61280. /**
  61281. * Gets the output component
  61282. */
  61283. get output(): NodeMaterialConnectionPoint;
  61284. protected _buildBlock(state: NodeMaterialBuildState): this;
  61285. }
  61286. }
  61287. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  61288. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61289. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61290. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61291. /**
  61292. * Block used to get the derivative value on x and y of a given input
  61293. */
  61294. export class DerivativeBlock extends NodeMaterialBlock {
  61295. /**
  61296. * Create a new DerivativeBlock
  61297. * @param name defines the block name
  61298. */
  61299. constructor(name: string);
  61300. /**
  61301. * Gets the current class name
  61302. * @returns the class name
  61303. */
  61304. getClassName(): string;
  61305. /**
  61306. * Gets the input component
  61307. */
  61308. get input(): NodeMaterialConnectionPoint;
  61309. /**
  61310. * Gets the derivative output on x
  61311. */
  61312. get dx(): NodeMaterialConnectionPoint;
  61313. /**
  61314. * Gets the derivative output on y
  61315. */
  61316. get dy(): NodeMaterialConnectionPoint;
  61317. protected _buildBlock(state: NodeMaterialBuildState): this;
  61318. }
  61319. }
  61320. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  61321. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  61322. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  61323. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  61324. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  61325. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  61326. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  61327. }
  61328. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  61329. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61330. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61331. import { Mesh } from "babylonjs/Meshes/mesh";
  61332. import { Effect } from "babylonjs/Materials/effect";
  61333. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61334. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61335. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61336. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  61337. /**
  61338. * Block used to add support for scene fog
  61339. */
  61340. export class FogBlock extends NodeMaterialBlock {
  61341. private _fogDistanceName;
  61342. private _fogParameters;
  61343. /**
  61344. * Create a new FogBlock
  61345. * @param name defines the block name
  61346. */
  61347. constructor(name: string);
  61348. /**
  61349. * Gets the current class name
  61350. * @returns the class name
  61351. */
  61352. getClassName(): string;
  61353. /**
  61354. * Gets the world position input component
  61355. */
  61356. get worldPosition(): NodeMaterialConnectionPoint;
  61357. /**
  61358. * Gets the view input component
  61359. */
  61360. get view(): NodeMaterialConnectionPoint;
  61361. /**
  61362. * Gets the color input component
  61363. */
  61364. get input(): NodeMaterialConnectionPoint;
  61365. /**
  61366. * Gets the fog color input component
  61367. */
  61368. get fogColor(): NodeMaterialConnectionPoint;
  61369. /**
  61370. * Gets the output component
  61371. */
  61372. get output(): NodeMaterialConnectionPoint;
  61373. autoConfigure(material: NodeMaterial): void;
  61374. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61375. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61376. protected _buildBlock(state: NodeMaterialBuildState): this;
  61377. }
  61378. }
  61379. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  61380. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61381. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61382. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61383. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61384. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61385. import { Effect } from "babylonjs/Materials/effect";
  61386. import { Mesh } from "babylonjs/Meshes/mesh";
  61387. import { Light } from "babylonjs/Lights/light";
  61388. import { Nullable } from "babylonjs/types";
  61389. import { Scene } from "babylonjs/scene";
  61390. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  61391. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  61392. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  61393. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61394. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  61395. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  61396. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  61397. /**
  61398. * Block used to add light in the fragment shader
  61399. */
  61400. export class LightBlock extends NodeMaterialBlock {
  61401. private _lightId;
  61402. /**
  61403. * Gets or sets the light associated with this block
  61404. */
  61405. light: Nullable<Light>;
  61406. /**
  61407. * Create a new LightBlock
  61408. * @param name defines the block name
  61409. */
  61410. constructor(name: string);
  61411. /**
  61412. * Gets the current class name
  61413. * @returns the class name
  61414. */
  61415. getClassName(): string;
  61416. /**
  61417. * Gets the world position input component
  61418. */
  61419. get worldPosition(): NodeMaterialConnectionPoint;
  61420. /**
  61421. * Gets the world normal input component
  61422. */
  61423. get worldNormal(): NodeMaterialConnectionPoint;
  61424. /**
  61425. * Gets the camera (or eye) position component
  61426. */
  61427. get cameraPosition(): NodeMaterialConnectionPoint;
  61428. /**
  61429. * Gets the glossiness component
  61430. */
  61431. get glossiness(): NodeMaterialConnectionPoint;
  61432. /**
  61433. * Gets the glossinness power component
  61434. */
  61435. get glossPower(): NodeMaterialConnectionPoint;
  61436. /**
  61437. * Gets the diffuse color component
  61438. */
  61439. get diffuseColor(): NodeMaterialConnectionPoint;
  61440. /**
  61441. * Gets the specular color component
  61442. */
  61443. get specularColor(): NodeMaterialConnectionPoint;
  61444. /**
  61445. * Gets the diffuse output component
  61446. */
  61447. get diffuseOutput(): NodeMaterialConnectionPoint;
  61448. /**
  61449. * Gets the specular output component
  61450. */
  61451. get specularOutput(): NodeMaterialConnectionPoint;
  61452. /**
  61453. * Gets the shadow output component
  61454. */
  61455. get shadow(): NodeMaterialConnectionPoint;
  61456. autoConfigure(material: NodeMaterial): void;
  61457. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61458. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61459. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61460. private _injectVertexCode;
  61461. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61462. serialize(): any;
  61463. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61464. }
  61465. }
  61466. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  61467. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  61468. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  61469. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  61470. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  61471. }
  61472. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  61473. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  61474. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  61475. }
  61476. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  61477. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61478. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61479. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61480. /**
  61481. * Block used to multiply 2 values
  61482. */
  61483. export class MultiplyBlock extends NodeMaterialBlock {
  61484. /**
  61485. * Creates a new MultiplyBlock
  61486. * @param name defines the block name
  61487. */
  61488. constructor(name: string);
  61489. /**
  61490. * Gets the current class name
  61491. * @returns the class name
  61492. */
  61493. getClassName(): string;
  61494. /**
  61495. * Gets the left operand input component
  61496. */
  61497. get left(): NodeMaterialConnectionPoint;
  61498. /**
  61499. * Gets the right operand input component
  61500. */
  61501. get right(): NodeMaterialConnectionPoint;
  61502. /**
  61503. * Gets the output component
  61504. */
  61505. get output(): NodeMaterialConnectionPoint;
  61506. protected _buildBlock(state: NodeMaterialBuildState): this;
  61507. }
  61508. }
  61509. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  61510. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61511. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61512. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61513. /**
  61514. * Block used to add 2 vectors
  61515. */
  61516. export class AddBlock extends NodeMaterialBlock {
  61517. /**
  61518. * Creates a new AddBlock
  61519. * @param name defines the block name
  61520. */
  61521. constructor(name: string);
  61522. /**
  61523. * Gets the current class name
  61524. * @returns the class name
  61525. */
  61526. getClassName(): string;
  61527. /**
  61528. * Gets the left operand input component
  61529. */
  61530. get left(): NodeMaterialConnectionPoint;
  61531. /**
  61532. * Gets the right operand input component
  61533. */
  61534. get right(): NodeMaterialConnectionPoint;
  61535. /**
  61536. * Gets the output component
  61537. */
  61538. get output(): NodeMaterialConnectionPoint;
  61539. protected _buildBlock(state: NodeMaterialBuildState): this;
  61540. }
  61541. }
  61542. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  61543. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61544. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61545. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61546. /**
  61547. * Block used to scale a vector by a float
  61548. */
  61549. export class ScaleBlock extends NodeMaterialBlock {
  61550. /**
  61551. * Creates a new ScaleBlock
  61552. * @param name defines the block name
  61553. */
  61554. constructor(name: string);
  61555. /**
  61556. * Gets the current class name
  61557. * @returns the class name
  61558. */
  61559. getClassName(): string;
  61560. /**
  61561. * Gets the input component
  61562. */
  61563. get input(): NodeMaterialConnectionPoint;
  61564. /**
  61565. * Gets the factor input component
  61566. */
  61567. get factor(): NodeMaterialConnectionPoint;
  61568. /**
  61569. * Gets the output component
  61570. */
  61571. get output(): NodeMaterialConnectionPoint;
  61572. protected _buildBlock(state: NodeMaterialBuildState): this;
  61573. }
  61574. }
  61575. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  61576. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61577. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61578. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61579. import { Scene } from "babylonjs/scene";
  61580. /**
  61581. * Block used to clamp a float
  61582. */
  61583. export class ClampBlock extends NodeMaterialBlock {
  61584. /** Gets or sets the minimum range */
  61585. minimum: number;
  61586. /** Gets or sets the maximum range */
  61587. maximum: number;
  61588. /**
  61589. * Creates a new ClampBlock
  61590. * @param name defines the block name
  61591. */
  61592. constructor(name: string);
  61593. /**
  61594. * Gets the current class name
  61595. * @returns the class name
  61596. */
  61597. getClassName(): string;
  61598. /**
  61599. * Gets the value input component
  61600. */
  61601. get value(): NodeMaterialConnectionPoint;
  61602. /**
  61603. * Gets the output component
  61604. */
  61605. get output(): NodeMaterialConnectionPoint;
  61606. protected _buildBlock(state: NodeMaterialBuildState): this;
  61607. protected _dumpPropertiesCode(): string;
  61608. serialize(): any;
  61609. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61610. }
  61611. }
  61612. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  61613. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61614. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61615. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61616. /**
  61617. * Block used to apply a cross product between 2 vectors
  61618. */
  61619. export class CrossBlock extends NodeMaterialBlock {
  61620. /**
  61621. * Creates a new CrossBlock
  61622. * @param name defines the block name
  61623. */
  61624. constructor(name: string);
  61625. /**
  61626. * Gets the current class name
  61627. * @returns the class name
  61628. */
  61629. getClassName(): string;
  61630. /**
  61631. * Gets the left operand input component
  61632. */
  61633. get left(): NodeMaterialConnectionPoint;
  61634. /**
  61635. * Gets the right operand input component
  61636. */
  61637. get right(): NodeMaterialConnectionPoint;
  61638. /**
  61639. * Gets the output component
  61640. */
  61641. get output(): NodeMaterialConnectionPoint;
  61642. protected _buildBlock(state: NodeMaterialBuildState): this;
  61643. }
  61644. }
  61645. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  61646. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61647. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61648. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61649. /**
  61650. * Block used to apply a dot product between 2 vectors
  61651. */
  61652. export class DotBlock extends NodeMaterialBlock {
  61653. /**
  61654. * Creates a new DotBlock
  61655. * @param name defines the block name
  61656. */
  61657. constructor(name: string);
  61658. /**
  61659. * Gets the current class name
  61660. * @returns the class name
  61661. */
  61662. getClassName(): string;
  61663. /**
  61664. * Gets the left operand input component
  61665. */
  61666. get left(): NodeMaterialConnectionPoint;
  61667. /**
  61668. * Gets the right operand input component
  61669. */
  61670. get right(): NodeMaterialConnectionPoint;
  61671. /**
  61672. * Gets the output component
  61673. */
  61674. get output(): NodeMaterialConnectionPoint;
  61675. protected _buildBlock(state: NodeMaterialBuildState): this;
  61676. }
  61677. }
  61678. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  61679. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61680. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61681. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61682. import { Vector2 } from "babylonjs/Maths/math.vector";
  61683. import { Scene } from "babylonjs/scene";
  61684. /**
  61685. * Block used to remap a float from a range to a new one
  61686. */
  61687. export class RemapBlock extends NodeMaterialBlock {
  61688. /**
  61689. * Gets or sets the source range
  61690. */
  61691. sourceRange: Vector2;
  61692. /**
  61693. * Gets or sets the target range
  61694. */
  61695. targetRange: Vector2;
  61696. /**
  61697. * Creates a new RemapBlock
  61698. * @param name defines the block name
  61699. */
  61700. constructor(name: string);
  61701. /**
  61702. * Gets the current class name
  61703. * @returns the class name
  61704. */
  61705. getClassName(): string;
  61706. /**
  61707. * Gets the input component
  61708. */
  61709. get input(): NodeMaterialConnectionPoint;
  61710. /**
  61711. * Gets the source min input component
  61712. */
  61713. get sourceMin(): NodeMaterialConnectionPoint;
  61714. /**
  61715. * Gets the source max input component
  61716. */
  61717. get sourceMax(): NodeMaterialConnectionPoint;
  61718. /**
  61719. * Gets the target min input component
  61720. */
  61721. get targetMin(): NodeMaterialConnectionPoint;
  61722. /**
  61723. * Gets the target max input component
  61724. */
  61725. get targetMax(): NodeMaterialConnectionPoint;
  61726. /**
  61727. * Gets the output component
  61728. */
  61729. get output(): NodeMaterialConnectionPoint;
  61730. protected _buildBlock(state: NodeMaterialBuildState): this;
  61731. protected _dumpPropertiesCode(): string;
  61732. serialize(): any;
  61733. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61734. }
  61735. }
  61736. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  61737. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61738. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61739. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61740. /**
  61741. * Block used to normalize a vector
  61742. */
  61743. export class NormalizeBlock extends NodeMaterialBlock {
  61744. /**
  61745. * Creates a new NormalizeBlock
  61746. * @param name defines the block name
  61747. */
  61748. constructor(name: string);
  61749. /**
  61750. * Gets the current class name
  61751. * @returns the class name
  61752. */
  61753. getClassName(): string;
  61754. /**
  61755. * Gets the input component
  61756. */
  61757. get input(): NodeMaterialConnectionPoint;
  61758. /**
  61759. * Gets the output component
  61760. */
  61761. get output(): NodeMaterialConnectionPoint;
  61762. protected _buildBlock(state: NodeMaterialBuildState): this;
  61763. }
  61764. }
  61765. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  61766. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61767. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61768. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61769. import { Scene } from "babylonjs/scene";
  61770. /**
  61771. * Operations supported by the Trigonometry block
  61772. */
  61773. export enum TrigonometryBlockOperations {
  61774. /** Cos */
  61775. Cos = 0,
  61776. /** Sin */
  61777. Sin = 1,
  61778. /** Abs */
  61779. Abs = 2,
  61780. /** Exp */
  61781. Exp = 3,
  61782. /** Exp2 */
  61783. Exp2 = 4,
  61784. /** Round */
  61785. Round = 5,
  61786. /** Floor */
  61787. Floor = 6,
  61788. /** Ceiling */
  61789. Ceiling = 7,
  61790. /** Square root */
  61791. Sqrt = 8,
  61792. /** Log */
  61793. Log = 9,
  61794. /** Tangent */
  61795. Tan = 10,
  61796. /** Arc tangent */
  61797. ArcTan = 11,
  61798. /** Arc cosinus */
  61799. ArcCos = 12,
  61800. /** Arc sinus */
  61801. ArcSin = 13,
  61802. /** Fraction */
  61803. Fract = 14,
  61804. /** Sign */
  61805. Sign = 15,
  61806. /** To radians (from degrees) */
  61807. Radians = 16,
  61808. /** To degrees (from radians) */
  61809. Degrees = 17
  61810. }
  61811. /**
  61812. * Block used to apply trigonometry operation to floats
  61813. */
  61814. export class TrigonometryBlock extends NodeMaterialBlock {
  61815. /**
  61816. * Gets or sets the operation applied by the block
  61817. */
  61818. operation: TrigonometryBlockOperations;
  61819. /**
  61820. * Creates a new TrigonometryBlock
  61821. * @param name defines the block name
  61822. */
  61823. constructor(name: string);
  61824. /**
  61825. * Gets the current class name
  61826. * @returns the class name
  61827. */
  61828. getClassName(): string;
  61829. /**
  61830. * Gets the input component
  61831. */
  61832. get input(): NodeMaterialConnectionPoint;
  61833. /**
  61834. * Gets the output component
  61835. */
  61836. get output(): NodeMaterialConnectionPoint;
  61837. protected _buildBlock(state: NodeMaterialBuildState): this;
  61838. serialize(): any;
  61839. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61840. protected _dumpPropertiesCode(): string;
  61841. }
  61842. }
  61843. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  61844. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61845. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61846. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61847. /**
  61848. * Block used to create a Color3/4 out of individual inputs (one for each component)
  61849. */
  61850. export class ColorMergerBlock extends NodeMaterialBlock {
  61851. /**
  61852. * Create a new ColorMergerBlock
  61853. * @param name defines the block name
  61854. */
  61855. constructor(name: string);
  61856. /**
  61857. * Gets the current class name
  61858. * @returns the class name
  61859. */
  61860. getClassName(): string;
  61861. /**
  61862. * Gets the rgb component (input)
  61863. */
  61864. get rgbIn(): NodeMaterialConnectionPoint;
  61865. /**
  61866. * Gets the r component (input)
  61867. */
  61868. get r(): NodeMaterialConnectionPoint;
  61869. /**
  61870. * Gets the g component (input)
  61871. */
  61872. get g(): NodeMaterialConnectionPoint;
  61873. /**
  61874. * Gets the b component (input)
  61875. */
  61876. get b(): NodeMaterialConnectionPoint;
  61877. /**
  61878. * Gets the a component (input)
  61879. */
  61880. get a(): NodeMaterialConnectionPoint;
  61881. /**
  61882. * Gets the rgba component (output)
  61883. */
  61884. get rgba(): NodeMaterialConnectionPoint;
  61885. /**
  61886. * Gets the rgb component (output)
  61887. */
  61888. get rgbOut(): NodeMaterialConnectionPoint;
  61889. /**
  61890. * Gets the rgb component (output)
  61891. * @deprecated Please use rgbOut instead.
  61892. */
  61893. get rgb(): NodeMaterialConnectionPoint;
  61894. protected _buildBlock(state: NodeMaterialBuildState): this;
  61895. }
  61896. }
  61897. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  61898. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61899. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61900. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61901. /**
  61902. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  61903. */
  61904. export class VectorMergerBlock extends NodeMaterialBlock {
  61905. /**
  61906. * Create a new VectorMergerBlock
  61907. * @param name defines the block name
  61908. */
  61909. constructor(name: string);
  61910. /**
  61911. * Gets the current class name
  61912. * @returns the class name
  61913. */
  61914. getClassName(): string;
  61915. /**
  61916. * Gets the xyz component (input)
  61917. */
  61918. get xyzIn(): NodeMaterialConnectionPoint;
  61919. /**
  61920. * Gets the xy component (input)
  61921. */
  61922. get xyIn(): NodeMaterialConnectionPoint;
  61923. /**
  61924. * Gets the x component (input)
  61925. */
  61926. get x(): NodeMaterialConnectionPoint;
  61927. /**
  61928. * Gets the y component (input)
  61929. */
  61930. get y(): NodeMaterialConnectionPoint;
  61931. /**
  61932. * Gets the z component (input)
  61933. */
  61934. get z(): NodeMaterialConnectionPoint;
  61935. /**
  61936. * Gets the w component (input)
  61937. */
  61938. get w(): NodeMaterialConnectionPoint;
  61939. /**
  61940. * Gets the xyzw component (output)
  61941. */
  61942. get xyzw(): NodeMaterialConnectionPoint;
  61943. /**
  61944. * Gets the xyz component (output)
  61945. */
  61946. get xyzOut(): NodeMaterialConnectionPoint;
  61947. /**
  61948. * Gets the xy component (output)
  61949. */
  61950. get xyOut(): NodeMaterialConnectionPoint;
  61951. /**
  61952. * Gets the xy component (output)
  61953. * @deprecated Please use xyOut instead.
  61954. */
  61955. get xy(): NodeMaterialConnectionPoint;
  61956. /**
  61957. * Gets the xyz component (output)
  61958. * @deprecated Please use xyzOut instead.
  61959. */
  61960. get xyz(): NodeMaterialConnectionPoint;
  61961. protected _buildBlock(state: NodeMaterialBuildState): this;
  61962. }
  61963. }
  61964. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  61965. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61966. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61967. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61968. /**
  61969. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  61970. */
  61971. export class ColorSplitterBlock extends NodeMaterialBlock {
  61972. /**
  61973. * Create a new ColorSplitterBlock
  61974. * @param name defines the block name
  61975. */
  61976. constructor(name: string);
  61977. /**
  61978. * Gets the current class name
  61979. * @returns the class name
  61980. */
  61981. getClassName(): string;
  61982. /**
  61983. * Gets the rgba component (input)
  61984. */
  61985. get rgba(): NodeMaterialConnectionPoint;
  61986. /**
  61987. * Gets the rgb component (input)
  61988. */
  61989. get rgbIn(): NodeMaterialConnectionPoint;
  61990. /**
  61991. * Gets the rgb component (output)
  61992. */
  61993. get rgbOut(): NodeMaterialConnectionPoint;
  61994. /**
  61995. * Gets the r component (output)
  61996. */
  61997. get r(): NodeMaterialConnectionPoint;
  61998. /**
  61999. * Gets the g component (output)
  62000. */
  62001. get g(): NodeMaterialConnectionPoint;
  62002. /**
  62003. * Gets the b component (output)
  62004. */
  62005. get b(): NodeMaterialConnectionPoint;
  62006. /**
  62007. * Gets the a component (output)
  62008. */
  62009. get a(): NodeMaterialConnectionPoint;
  62010. protected _inputRename(name: string): string;
  62011. protected _outputRename(name: string): string;
  62012. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62013. }
  62014. }
  62015. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  62016. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62017. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62018. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62019. /**
  62020. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  62021. */
  62022. export class VectorSplitterBlock extends NodeMaterialBlock {
  62023. /**
  62024. * Create a new VectorSplitterBlock
  62025. * @param name defines the block name
  62026. */
  62027. constructor(name: string);
  62028. /**
  62029. * Gets the current class name
  62030. * @returns the class name
  62031. */
  62032. getClassName(): string;
  62033. /**
  62034. * Gets the xyzw component (input)
  62035. */
  62036. get xyzw(): NodeMaterialConnectionPoint;
  62037. /**
  62038. * Gets the xyz component (input)
  62039. */
  62040. get xyzIn(): NodeMaterialConnectionPoint;
  62041. /**
  62042. * Gets the xy component (input)
  62043. */
  62044. get xyIn(): NodeMaterialConnectionPoint;
  62045. /**
  62046. * Gets the xyz component (output)
  62047. */
  62048. get xyzOut(): NodeMaterialConnectionPoint;
  62049. /**
  62050. * Gets the xy component (output)
  62051. */
  62052. get xyOut(): NodeMaterialConnectionPoint;
  62053. /**
  62054. * Gets the x component (output)
  62055. */
  62056. get x(): NodeMaterialConnectionPoint;
  62057. /**
  62058. * Gets the y component (output)
  62059. */
  62060. get y(): NodeMaterialConnectionPoint;
  62061. /**
  62062. * Gets the z component (output)
  62063. */
  62064. get z(): NodeMaterialConnectionPoint;
  62065. /**
  62066. * Gets the w component (output)
  62067. */
  62068. get w(): NodeMaterialConnectionPoint;
  62069. protected _inputRename(name: string): string;
  62070. protected _outputRename(name: string): string;
  62071. protected _buildBlock(state: NodeMaterialBuildState): this;
  62072. }
  62073. }
  62074. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  62075. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62076. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62077. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62078. /**
  62079. * Block used to lerp between 2 values
  62080. */
  62081. export class LerpBlock extends NodeMaterialBlock {
  62082. /**
  62083. * Creates a new LerpBlock
  62084. * @param name defines the block name
  62085. */
  62086. constructor(name: string);
  62087. /**
  62088. * Gets the current class name
  62089. * @returns the class name
  62090. */
  62091. getClassName(): string;
  62092. /**
  62093. * Gets the left operand input component
  62094. */
  62095. get left(): NodeMaterialConnectionPoint;
  62096. /**
  62097. * Gets the right operand input component
  62098. */
  62099. get right(): NodeMaterialConnectionPoint;
  62100. /**
  62101. * Gets the gradient operand input component
  62102. */
  62103. get gradient(): NodeMaterialConnectionPoint;
  62104. /**
  62105. * Gets the output component
  62106. */
  62107. get output(): NodeMaterialConnectionPoint;
  62108. protected _buildBlock(state: NodeMaterialBuildState): this;
  62109. }
  62110. }
  62111. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  62112. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62113. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62114. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62115. /**
  62116. * Block used to divide 2 vectors
  62117. */
  62118. export class DivideBlock extends NodeMaterialBlock {
  62119. /**
  62120. * Creates a new DivideBlock
  62121. * @param name defines the block name
  62122. */
  62123. constructor(name: string);
  62124. /**
  62125. * Gets the current class name
  62126. * @returns the class name
  62127. */
  62128. getClassName(): string;
  62129. /**
  62130. * Gets the left operand input component
  62131. */
  62132. get left(): NodeMaterialConnectionPoint;
  62133. /**
  62134. * Gets the right operand input component
  62135. */
  62136. get right(): NodeMaterialConnectionPoint;
  62137. /**
  62138. * Gets the output component
  62139. */
  62140. get output(): NodeMaterialConnectionPoint;
  62141. protected _buildBlock(state: NodeMaterialBuildState): this;
  62142. }
  62143. }
  62144. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  62145. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62146. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62147. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62148. /**
  62149. * Block used to subtract 2 vectors
  62150. */
  62151. export class SubtractBlock extends NodeMaterialBlock {
  62152. /**
  62153. * Creates a new SubtractBlock
  62154. * @param name defines the block name
  62155. */
  62156. constructor(name: string);
  62157. /**
  62158. * Gets the current class name
  62159. * @returns the class name
  62160. */
  62161. getClassName(): string;
  62162. /**
  62163. * Gets the left operand input component
  62164. */
  62165. get left(): NodeMaterialConnectionPoint;
  62166. /**
  62167. * Gets the right operand input component
  62168. */
  62169. get right(): NodeMaterialConnectionPoint;
  62170. /**
  62171. * Gets the output component
  62172. */
  62173. get output(): NodeMaterialConnectionPoint;
  62174. protected _buildBlock(state: NodeMaterialBuildState): this;
  62175. }
  62176. }
  62177. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  62178. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62179. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62180. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62181. /**
  62182. * Block used to step a value
  62183. */
  62184. export class StepBlock extends NodeMaterialBlock {
  62185. /**
  62186. * Creates a new StepBlock
  62187. * @param name defines the block name
  62188. */
  62189. constructor(name: string);
  62190. /**
  62191. * Gets the current class name
  62192. * @returns the class name
  62193. */
  62194. getClassName(): string;
  62195. /**
  62196. * Gets the value operand input component
  62197. */
  62198. get value(): NodeMaterialConnectionPoint;
  62199. /**
  62200. * Gets the edge operand input component
  62201. */
  62202. get edge(): NodeMaterialConnectionPoint;
  62203. /**
  62204. * Gets the output component
  62205. */
  62206. get output(): NodeMaterialConnectionPoint;
  62207. protected _buildBlock(state: NodeMaterialBuildState): this;
  62208. }
  62209. }
  62210. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  62211. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62212. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62213. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62214. /**
  62215. * Block used to get the opposite (1 - x) of a value
  62216. */
  62217. export class OneMinusBlock extends NodeMaterialBlock {
  62218. /**
  62219. * Creates a new OneMinusBlock
  62220. * @param name defines the block name
  62221. */
  62222. constructor(name: string);
  62223. /**
  62224. * Gets the current class name
  62225. * @returns the class name
  62226. */
  62227. getClassName(): string;
  62228. /**
  62229. * Gets the input component
  62230. */
  62231. get input(): NodeMaterialConnectionPoint;
  62232. /**
  62233. * Gets the output component
  62234. */
  62235. get output(): NodeMaterialConnectionPoint;
  62236. protected _buildBlock(state: NodeMaterialBuildState): this;
  62237. }
  62238. }
  62239. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  62240. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62241. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62242. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62243. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62244. /**
  62245. * Block used to get the view direction
  62246. */
  62247. export class ViewDirectionBlock extends NodeMaterialBlock {
  62248. /**
  62249. * Creates a new ViewDirectionBlock
  62250. * @param name defines the block name
  62251. */
  62252. constructor(name: string);
  62253. /**
  62254. * Gets the current class name
  62255. * @returns the class name
  62256. */
  62257. getClassName(): string;
  62258. /**
  62259. * Gets the world position component
  62260. */
  62261. get worldPosition(): NodeMaterialConnectionPoint;
  62262. /**
  62263. * Gets the camera position component
  62264. */
  62265. get cameraPosition(): NodeMaterialConnectionPoint;
  62266. /**
  62267. * Gets the output component
  62268. */
  62269. get output(): NodeMaterialConnectionPoint;
  62270. autoConfigure(material: NodeMaterial): void;
  62271. protected _buildBlock(state: NodeMaterialBuildState): this;
  62272. }
  62273. }
  62274. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  62275. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62276. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62277. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62278. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62279. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  62280. /**
  62281. * Block used to compute fresnel value
  62282. */
  62283. export class FresnelBlock extends NodeMaterialBlock {
  62284. /**
  62285. * Create a new FresnelBlock
  62286. * @param name defines the block name
  62287. */
  62288. constructor(name: string);
  62289. /**
  62290. * Gets the current class name
  62291. * @returns the class name
  62292. */
  62293. getClassName(): string;
  62294. /**
  62295. * Gets the world normal input component
  62296. */
  62297. get worldNormal(): NodeMaterialConnectionPoint;
  62298. /**
  62299. * Gets the view direction input component
  62300. */
  62301. get viewDirection(): NodeMaterialConnectionPoint;
  62302. /**
  62303. * Gets the bias input component
  62304. */
  62305. get bias(): NodeMaterialConnectionPoint;
  62306. /**
  62307. * Gets the camera (or eye) position component
  62308. */
  62309. get power(): NodeMaterialConnectionPoint;
  62310. /**
  62311. * Gets the fresnel output component
  62312. */
  62313. get fresnel(): NodeMaterialConnectionPoint;
  62314. autoConfigure(material: NodeMaterial): void;
  62315. protected _buildBlock(state: NodeMaterialBuildState): this;
  62316. }
  62317. }
  62318. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  62319. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62320. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62321. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62322. /**
  62323. * Block used to get the max of 2 values
  62324. */
  62325. export class MaxBlock extends NodeMaterialBlock {
  62326. /**
  62327. * Creates a new MaxBlock
  62328. * @param name defines the block name
  62329. */
  62330. constructor(name: string);
  62331. /**
  62332. * Gets the current class name
  62333. * @returns the class name
  62334. */
  62335. getClassName(): string;
  62336. /**
  62337. * Gets the left operand input component
  62338. */
  62339. get left(): NodeMaterialConnectionPoint;
  62340. /**
  62341. * Gets the right operand input component
  62342. */
  62343. get right(): NodeMaterialConnectionPoint;
  62344. /**
  62345. * Gets the output component
  62346. */
  62347. get output(): NodeMaterialConnectionPoint;
  62348. protected _buildBlock(state: NodeMaterialBuildState): this;
  62349. }
  62350. }
  62351. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  62352. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62353. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62354. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62355. /**
  62356. * Block used to get the min of 2 values
  62357. */
  62358. export class MinBlock extends NodeMaterialBlock {
  62359. /**
  62360. * Creates a new MinBlock
  62361. * @param name defines the block name
  62362. */
  62363. constructor(name: string);
  62364. /**
  62365. * Gets the current class name
  62366. * @returns the class name
  62367. */
  62368. getClassName(): string;
  62369. /**
  62370. * Gets the left operand input component
  62371. */
  62372. get left(): NodeMaterialConnectionPoint;
  62373. /**
  62374. * Gets the right operand input component
  62375. */
  62376. get right(): NodeMaterialConnectionPoint;
  62377. /**
  62378. * Gets the output component
  62379. */
  62380. get output(): NodeMaterialConnectionPoint;
  62381. protected _buildBlock(state: NodeMaterialBuildState): this;
  62382. }
  62383. }
  62384. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  62385. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62386. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62387. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62388. /**
  62389. * Block used to get the distance between 2 values
  62390. */
  62391. export class DistanceBlock extends NodeMaterialBlock {
  62392. /**
  62393. * Creates a new DistanceBlock
  62394. * @param name defines the block name
  62395. */
  62396. constructor(name: string);
  62397. /**
  62398. * Gets the current class name
  62399. * @returns the class name
  62400. */
  62401. getClassName(): string;
  62402. /**
  62403. * Gets the left operand input component
  62404. */
  62405. get left(): NodeMaterialConnectionPoint;
  62406. /**
  62407. * Gets the right operand input component
  62408. */
  62409. get right(): NodeMaterialConnectionPoint;
  62410. /**
  62411. * Gets the output component
  62412. */
  62413. get output(): NodeMaterialConnectionPoint;
  62414. protected _buildBlock(state: NodeMaterialBuildState): this;
  62415. }
  62416. }
  62417. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  62418. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62419. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62420. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62421. /**
  62422. * Block used to get the length of a vector
  62423. */
  62424. export class LengthBlock extends NodeMaterialBlock {
  62425. /**
  62426. * Creates a new LengthBlock
  62427. * @param name defines the block name
  62428. */
  62429. constructor(name: string);
  62430. /**
  62431. * Gets the current class name
  62432. * @returns the class name
  62433. */
  62434. getClassName(): string;
  62435. /**
  62436. * Gets the value input component
  62437. */
  62438. get value(): NodeMaterialConnectionPoint;
  62439. /**
  62440. * Gets the output component
  62441. */
  62442. get output(): NodeMaterialConnectionPoint;
  62443. protected _buildBlock(state: NodeMaterialBuildState): this;
  62444. }
  62445. }
  62446. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  62447. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62448. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62449. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62450. /**
  62451. * Block used to get negative version of a value (i.e. x * -1)
  62452. */
  62453. export class NegateBlock extends NodeMaterialBlock {
  62454. /**
  62455. * Creates a new NegateBlock
  62456. * @param name defines the block name
  62457. */
  62458. constructor(name: string);
  62459. /**
  62460. * Gets the current class name
  62461. * @returns the class name
  62462. */
  62463. getClassName(): string;
  62464. /**
  62465. * Gets the value input component
  62466. */
  62467. get value(): NodeMaterialConnectionPoint;
  62468. /**
  62469. * Gets the output component
  62470. */
  62471. get output(): NodeMaterialConnectionPoint;
  62472. protected _buildBlock(state: NodeMaterialBuildState): this;
  62473. }
  62474. }
  62475. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  62476. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62477. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62478. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62479. /**
  62480. * Block used to get the value of the first parameter raised to the power of the second
  62481. */
  62482. export class PowBlock extends NodeMaterialBlock {
  62483. /**
  62484. * Creates a new PowBlock
  62485. * @param name defines the block name
  62486. */
  62487. constructor(name: string);
  62488. /**
  62489. * Gets the current class name
  62490. * @returns the class name
  62491. */
  62492. getClassName(): string;
  62493. /**
  62494. * Gets the value operand input component
  62495. */
  62496. get value(): NodeMaterialConnectionPoint;
  62497. /**
  62498. * Gets the power operand input component
  62499. */
  62500. get power(): NodeMaterialConnectionPoint;
  62501. /**
  62502. * Gets the output component
  62503. */
  62504. get output(): NodeMaterialConnectionPoint;
  62505. protected _buildBlock(state: NodeMaterialBuildState): this;
  62506. }
  62507. }
  62508. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  62509. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62510. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62511. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62512. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62513. /**
  62514. * Block used to get a random number
  62515. */
  62516. export class RandomNumberBlock extends NodeMaterialBlock {
  62517. /**
  62518. * Creates a new RandomNumberBlock
  62519. * @param name defines the block name
  62520. */
  62521. constructor(name: string);
  62522. /**
  62523. * Gets the current class name
  62524. * @returns the class name
  62525. */
  62526. getClassName(): string;
  62527. /**
  62528. * Gets the seed input component
  62529. */
  62530. get seed(): NodeMaterialConnectionPoint;
  62531. /**
  62532. * Gets the output component
  62533. */
  62534. get output(): NodeMaterialConnectionPoint;
  62535. protected _buildBlock(state: NodeMaterialBuildState): this;
  62536. }
  62537. }
  62538. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  62539. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62540. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62541. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62542. /**
  62543. * Block used to compute arc tangent of 2 values
  62544. */
  62545. export class ArcTan2Block extends NodeMaterialBlock {
  62546. /**
  62547. * Creates a new ArcTan2Block
  62548. * @param name defines the block name
  62549. */
  62550. constructor(name: string);
  62551. /**
  62552. * Gets the current class name
  62553. * @returns the class name
  62554. */
  62555. getClassName(): string;
  62556. /**
  62557. * Gets the x operand input component
  62558. */
  62559. get x(): NodeMaterialConnectionPoint;
  62560. /**
  62561. * Gets the y operand input component
  62562. */
  62563. get y(): NodeMaterialConnectionPoint;
  62564. /**
  62565. * Gets the output component
  62566. */
  62567. get output(): NodeMaterialConnectionPoint;
  62568. protected _buildBlock(state: NodeMaterialBuildState): this;
  62569. }
  62570. }
  62571. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  62572. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62573. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62574. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62575. /**
  62576. * Block used to smooth step a value
  62577. */
  62578. export class SmoothStepBlock extends NodeMaterialBlock {
  62579. /**
  62580. * Creates a new SmoothStepBlock
  62581. * @param name defines the block name
  62582. */
  62583. constructor(name: string);
  62584. /**
  62585. * Gets the current class name
  62586. * @returns the class name
  62587. */
  62588. getClassName(): string;
  62589. /**
  62590. * Gets the value operand input component
  62591. */
  62592. get value(): NodeMaterialConnectionPoint;
  62593. /**
  62594. * Gets the first edge operand input component
  62595. */
  62596. get edge0(): NodeMaterialConnectionPoint;
  62597. /**
  62598. * Gets the second edge operand input component
  62599. */
  62600. get edge1(): NodeMaterialConnectionPoint;
  62601. /**
  62602. * Gets the output component
  62603. */
  62604. get output(): NodeMaterialConnectionPoint;
  62605. protected _buildBlock(state: NodeMaterialBuildState): this;
  62606. }
  62607. }
  62608. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  62609. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62610. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62611. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62612. /**
  62613. * Block used to get the reciprocal (1 / x) of a value
  62614. */
  62615. export class ReciprocalBlock extends NodeMaterialBlock {
  62616. /**
  62617. * Creates a new ReciprocalBlock
  62618. * @param name defines the block name
  62619. */
  62620. constructor(name: string);
  62621. /**
  62622. * Gets the current class name
  62623. * @returns the class name
  62624. */
  62625. getClassName(): string;
  62626. /**
  62627. * Gets the input component
  62628. */
  62629. get input(): NodeMaterialConnectionPoint;
  62630. /**
  62631. * Gets the output component
  62632. */
  62633. get output(): NodeMaterialConnectionPoint;
  62634. protected _buildBlock(state: NodeMaterialBuildState): this;
  62635. }
  62636. }
  62637. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  62638. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62639. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62640. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62641. /**
  62642. * Block used to replace a color by another one
  62643. */
  62644. export class ReplaceColorBlock extends NodeMaterialBlock {
  62645. /**
  62646. * Creates a new ReplaceColorBlock
  62647. * @param name defines the block name
  62648. */
  62649. constructor(name: string);
  62650. /**
  62651. * Gets the current class name
  62652. * @returns the class name
  62653. */
  62654. getClassName(): string;
  62655. /**
  62656. * Gets the value input component
  62657. */
  62658. get value(): NodeMaterialConnectionPoint;
  62659. /**
  62660. * Gets the reference input component
  62661. */
  62662. get reference(): NodeMaterialConnectionPoint;
  62663. /**
  62664. * Gets the distance input component
  62665. */
  62666. get distance(): NodeMaterialConnectionPoint;
  62667. /**
  62668. * Gets the replacement input component
  62669. */
  62670. get replacement(): NodeMaterialConnectionPoint;
  62671. /**
  62672. * Gets the output component
  62673. */
  62674. get output(): NodeMaterialConnectionPoint;
  62675. protected _buildBlock(state: NodeMaterialBuildState): this;
  62676. }
  62677. }
  62678. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  62679. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62680. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62681. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62682. /**
  62683. * Block used to posterize a value
  62684. * @see https://en.wikipedia.org/wiki/Posterization
  62685. */
  62686. export class PosterizeBlock extends NodeMaterialBlock {
  62687. /**
  62688. * Creates a new PosterizeBlock
  62689. * @param name defines the block name
  62690. */
  62691. constructor(name: string);
  62692. /**
  62693. * Gets the current class name
  62694. * @returns the class name
  62695. */
  62696. getClassName(): string;
  62697. /**
  62698. * Gets the value input component
  62699. */
  62700. get value(): NodeMaterialConnectionPoint;
  62701. /**
  62702. * Gets the steps input component
  62703. */
  62704. get steps(): NodeMaterialConnectionPoint;
  62705. /**
  62706. * Gets the output component
  62707. */
  62708. get output(): NodeMaterialConnectionPoint;
  62709. protected _buildBlock(state: NodeMaterialBuildState): this;
  62710. }
  62711. }
  62712. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  62713. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62714. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62715. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62716. import { Scene } from "babylonjs/scene";
  62717. /**
  62718. * Operations supported by the Wave block
  62719. */
  62720. export enum WaveBlockKind {
  62721. /** SawTooth */
  62722. SawTooth = 0,
  62723. /** Square */
  62724. Square = 1,
  62725. /** Triangle */
  62726. Triangle = 2
  62727. }
  62728. /**
  62729. * Block used to apply wave operation to floats
  62730. */
  62731. export class WaveBlock extends NodeMaterialBlock {
  62732. /**
  62733. * Gets or sets the kibnd of wave to be applied by the block
  62734. */
  62735. kind: WaveBlockKind;
  62736. /**
  62737. * Creates a new WaveBlock
  62738. * @param name defines the block name
  62739. */
  62740. constructor(name: string);
  62741. /**
  62742. * Gets the current class name
  62743. * @returns the class name
  62744. */
  62745. getClassName(): string;
  62746. /**
  62747. * Gets the input component
  62748. */
  62749. get input(): NodeMaterialConnectionPoint;
  62750. /**
  62751. * Gets the output component
  62752. */
  62753. get output(): NodeMaterialConnectionPoint;
  62754. protected _buildBlock(state: NodeMaterialBuildState): this;
  62755. serialize(): any;
  62756. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62757. }
  62758. }
  62759. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  62760. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62761. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62762. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62763. import { Color3 } from "babylonjs/Maths/math.color";
  62764. import { Scene } from "babylonjs/scene";
  62765. /**
  62766. * Class used to store a color step for the GradientBlock
  62767. */
  62768. export class GradientBlockColorStep {
  62769. /**
  62770. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62771. */
  62772. step: number;
  62773. /**
  62774. * Gets or sets the color associated with this step
  62775. */
  62776. color: Color3;
  62777. /**
  62778. * Creates a new GradientBlockColorStep
  62779. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  62780. * @param color defines the color associated with this step
  62781. */
  62782. constructor(
  62783. /**
  62784. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62785. */
  62786. step: number,
  62787. /**
  62788. * Gets or sets the color associated with this step
  62789. */
  62790. color: Color3);
  62791. }
  62792. /**
  62793. * Block used to return a color from a gradient based on an input value between 0 and 1
  62794. */
  62795. export class GradientBlock extends NodeMaterialBlock {
  62796. /**
  62797. * Gets or sets the list of color steps
  62798. */
  62799. colorSteps: GradientBlockColorStep[];
  62800. /**
  62801. * Creates a new GradientBlock
  62802. * @param name defines the block name
  62803. */
  62804. constructor(name: string);
  62805. /**
  62806. * Gets the current class name
  62807. * @returns the class name
  62808. */
  62809. getClassName(): string;
  62810. /**
  62811. * Gets the gradient input component
  62812. */
  62813. get gradient(): NodeMaterialConnectionPoint;
  62814. /**
  62815. * Gets the output component
  62816. */
  62817. get output(): NodeMaterialConnectionPoint;
  62818. private _writeColorConstant;
  62819. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62820. serialize(): any;
  62821. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62822. protected _dumpPropertiesCode(): string;
  62823. }
  62824. }
  62825. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  62826. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62827. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62828. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62829. /**
  62830. * Block used to normalize lerp between 2 values
  62831. */
  62832. export class NLerpBlock extends NodeMaterialBlock {
  62833. /**
  62834. * Creates a new NLerpBlock
  62835. * @param name defines the block name
  62836. */
  62837. constructor(name: string);
  62838. /**
  62839. * Gets the current class name
  62840. * @returns the class name
  62841. */
  62842. getClassName(): string;
  62843. /**
  62844. * Gets the left operand input component
  62845. */
  62846. get left(): NodeMaterialConnectionPoint;
  62847. /**
  62848. * Gets the right operand input component
  62849. */
  62850. get right(): NodeMaterialConnectionPoint;
  62851. /**
  62852. * Gets the gradient operand input component
  62853. */
  62854. get gradient(): NodeMaterialConnectionPoint;
  62855. /**
  62856. * Gets the output component
  62857. */
  62858. get output(): NodeMaterialConnectionPoint;
  62859. protected _buildBlock(state: NodeMaterialBuildState): this;
  62860. }
  62861. }
  62862. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  62863. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62864. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62865. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62866. import { Scene } from "babylonjs/scene";
  62867. /**
  62868. * block used to Generate a Worley Noise 3D Noise Pattern
  62869. */
  62870. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  62871. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62872. manhattanDistance: boolean;
  62873. /**
  62874. * Creates a new WorleyNoise3DBlock
  62875. * @param name defines the block name
  62876. */
  62877. constructor(name: string);
  62878. /**
  62879. * Gets the current class name
  62880. * @returns the class name
  62881. */
  62882. getClassName(): string;
  62883. /**
  62884. * Gets the seed input component
  62885. */
  62886. get seed(): NodeMaterialConnectionPoint;
  62887. /**
  62888. * Gets the jitter input component
  62889. */
  62890. get jitter(): NodeMaterialConnectionPoint;
  62891. /**
  62892. * Gets the output component
  62893. */
  62894. get output(): NodeMaterialConnectionPoint;
  62895. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62896. /**
  62897. * Exposes the properties to the UI?
  62898. */
  62899. protected _dumpPropertiesCode(): string;
  62900. /**
  62901. * Exposes the properties to the Seralize?
  62902. */
  62903. serialize(): any;
  62904. /**
  62905. * Exposes the properties to the deseralize?
  62906. */
  62907. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62908. }
  62909. }
  62910. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  62911. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62912. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62913. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62914. /**
  62915. * block used to Generate a Simplex Perlin 3d Noise Pattern
  62916. */
  62917. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  62918. /**
  62919. * Creates a new SimplexPerlin3DBlock
  62920. * @param name defines the block name
  62921. */
  62922. constructor(name: string);
  62923. /**
  62924. * Gets the current class name
  62925. * @returns the class name
  62926. */
  62927. getClassName(): string;
  62928. /**
  62929. * Gets the seed operand input component
  62930. */
  62931. get seed(): NodeMaterialConnectionPoint;
  62932. /**
  62933. * Gets the output component
  62934. */
  62935. get output(): NodeMaterialConnectionPoint;
  62936. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62937. }
  62938. }
  62939. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  62940. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62941. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62942. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62943. /**
  62944. * Block used to blend normals
  62945. */
  62946. export class NormalBlendBlock extends NodeMaterialBlock {
  62947. /**
  62948. * Creates a new NormalBlendBlock
  62949. * @param name defines the block name
  62950. */
  62951. constructor(name: string);
  62952. /**
  62953. * Gets the current class name
  62954. * @returns the class name
  62955. */
  62956. getClassName(): string;
  62957. /**
  62958. * Gets the first input component
  62959. */
  62960. get normalMap0(): NodeMaterialConnectionPoint;
  62961. /**
  62962. * Gets the second input component
  62963. */
  62964. get normalMap1(): NodeMaterialConnectionPoint;
  62965. /**
  62966. * Gets the output component
  62967. */
  62968. get output(): NodeMaterialConnectionPoint;
  62969. protected _buildBlock(state: NodeMaterialBuildState): this;
  62970. }
  62971. }
  62972. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  62973. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62974. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62975. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62976. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62977. /**
  62978. * Block used to rotate a 2d vector by a given angle
  62979. */
  62980. export class Rotate2dBlock extends NodeMaterialBlock {
  62981. /**
  62982. * Creates a new Rotate2dBlock
  62983. * @param name defines the block name
  62984. */
  62985. constructor(name: string);
  62986. /**
  62987. * Gets the current class name
  62988. * @returns the class name
  62989. */
  62990. getClassName(): string;
  62991. /**
  62992. * Gets the input vector
  62993. */
  62994. get input(): NodeMaterialConnectionPoint;
  62995. /**
  62996. * Gets the input angle
  62997. */
  62998. get angle(): NodeMaterialConnectionPoint;
  62999. /**
  63000. * Gets the output component
  63001. */
  63002. get output(): NodeMaterialConnectionPoint;
  63003. autoConfigure(material: NodeMaterial): void;
  63004. protected _buildBlock(state: NodeMaterialBuildState): this;
  63005. }
  63006. }
  63007. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  63008. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63009. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63010. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63011. /**
  63012. * Block used to get the reflected vector from a direction and a normal
  63013. */
  63014. export class ReflectBlock extends NodeMaterialBlock {
  63015. /**
  63016. * Creates a new ReflectBlock
  63017. * @param name defines the block name
  63018. */
  63019. constructor(name: string);
  63020. /**
  63021. * Gets the current class name
  63022. * @returns the class name
  63023. */
  63024. getClassName(): string;
  63025. /**
  63026. * Gets the incident component
  63027. */
  63028. get incident(): NodeMaterialConnectionPoint;
  63029. /**
  63030. * Gets the normal component
  63031. */
  63032. get normal(): NodeMaterialConnectionPoint;
  63033. /**
  63034. * Gets the output component
  63035. */
  63036. get output(): NodeMaterialConnectionPoint;
  63037. protected _buildBlock(state: NodeMaterialBuildState): this;
  63038. }
  63039. }
  63040. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  63041. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63042. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63043. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63044. /**
  63045. * Block used to get the refracted vector from a direction and a normal
  63046. */
  63047. export class RefractBlock extends NodeMaterialBlock {
  63048. /**
  63049. * Creates a new RefractBlock
  63050. * @param name defines the block name
  63051. */
  63052. constructor(name: string);
  63053. /**
  63054. * Gets the current class name
  63055. * @returns the class name
  63056. */
  63057. getClassName(): string;
  63058. /**
  63059. * Gets the incident component
  63060. */
  63061. get incident(): NodeMaterialConnectionPoint;
  63062. /**
  63063. * Gets the normal component
  63064. */
  63065. get normal(): NodeMaterialConnectionPoint;
  63066. /**
  63067. * Gets the index of refraction component
  63068. */
  63069. get ior(): NodeMaterialConnectionPoint;
  63070. /**
  63071. * Gets the output component
  63072. */
  63073. get output(): NodeMaterialConnectionPoint;
  63074. protected _buildBlock(state: NodeMaterialBuildState): this;
  63075. }
  63076. }
  63077. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  63078. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63079. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63080. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63081. /**
  63082. * Block used to desaturate a color
  63083. */
  63084. export class DesaturateBlock extends NodeMaterialBlock {
  63085. /**
  63086. * Creates a new DesaturateBlock
  63087. * @param name defines the block name
  63088. */
  63089. constructor(name: string);
  63090. /**
  63091. * Gets the current class name
  63092. * @returns the class name
  63093. */
  63094. getClassName(): string;
  63095. /**
  63096. * Gets the color operand input component
  63097. */
  63098. get color(): NodeMaterialConnectionPoint;
  63099. /**
  63100. * Gets the level operand input component
  63101. */
  63102. get level(): NodeMaterialConnectionPoint;
  63103. /**
  63104. * Gets the output component
  63105. */
  63106. get output(): NodeMaterialConnectionPoint;
  63107. protected _buildBlock(state: NodeMaterialBuildState): this;
  63108. }
  63109. }
  63110. declare module "babylonjs/Materials/Node/Blocks/index" {
  63111. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  63112. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  63113. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  63114. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  63115. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  63116. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  63117. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  63118. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  63119. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  63120. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  63121. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  63122. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  63123. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  63124. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  63125. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  63126. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  63127. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  63128. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  63129. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  63130. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  63131. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  63132. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  63133. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  63134. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  63135. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  63136. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  63137. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  63138. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  63139. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  63140. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  63141. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  63142. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  63143. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  63144. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  63145. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  63146. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  63147. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  63148. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  63149. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  63150. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  63151. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  63152. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  63153. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  63154. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  63155. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  63156. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  63157. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  63158. }
  63159. declare module "babylonjs/Materials/Node/Optimizers/index" {
  63160. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  63161. }
  63162. declare module "babylonjs/Materials/Node/index" {
  63163. export * from "babylonjs/Materials/Node/Enums/index";
  63164. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63165. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  63166. export * from "babylonjs/Materials/Node/nodeMaterial";
  63167. export * from "babylonjs/Materials/Node/Blocks/index";
  63168. export * from "babylonjs/Materials/Node/Optimizers/index";
  63169. }
  63170. declare module "babylonjs/Materials/effectRenderer" {
  63171. import { Nullable } from "babylonjs/types";
  63172. import { Texture } from "babylonjs/Materials/Textures/texture";
  63173. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63174. import { Viewport } from "babylonjs/Maths/math.viewport";
  63175. import { Observable } from "babylonjs/Misc/observable";
  63176. import { Effect } from "babylonjs/Materials/effect";
  63177. import "babylonjs/Engines/Extensions/engine.renderTarget";
  63178. import "babylonjs/Shaders/postprocess.vertex";
  63179. /**
  63180. * Effect Render Options
  63181. */
  63182. export interface IEffectRendererOptions {
  63183. /**
  63184. * Defines the vertices positions.
  63185. */
  63186. positions?: number[];
  63187. /**
  63188. * Defines the indices.
  63189. */
  63190. indices?: number[];
  63191. }
  63192. /**
  63193. * Helper class to render one or more effects
  63194. */
  63195. export class EffectRenderer {
  63196. private engine;
  63197. private static _DefaultOptions;
  63198. private _vertexBuffers;
  63199. private _indexBuffer;
  63200. private _ringBufferIndex;
  63201. private _ringScreenBuffer;
  63202. private _fullscreenViewport;
  63203. private _getNextFrameBuffer;
  63204. /**
  63205. * Creates an effect renderer
  63206. * @param engine the engine to use for rendering
  63207. * @param options defines the options of the effect renderer
  63208. */
  63209. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63210. /**
  63211. * Sets the current viewport in normalized coordinates 0-1
  63212. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63213. */
  63214. setViewport(viewport?: Viewport): void;
  63215. /**
  63216. * Binds the embedded attributes buffer to the effect.
  63217. * @param effect Defines the effect to bind the attributes for
  63218. */
  63219. bindBuffers(effect: Effect): void;
  63220. /**
  63221. * Sets the current effect wrapper to use during draw.
  63222. * The effect needs to be ready before calling this api.
  63223. * This also sets the default full screen position attribute.
  63224. * @param effectWrapper Defines the effect to draw with
  63225. */
  63226. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63227. /**
  63228. * Draws a full screen quad.
  63229. */
  63230. draw(): void;
  63231. /**
  63232. * renders one or more effects to a specified texture
  63233. * @param effectWrappers list of effects to renderer
  63234. * @param outputTexture texture to draw to, if null it will render to the screen
  63235. */
  63236. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  63237. /**
  63238. * Disposes of the effect renderer
  63239. */
  63240. dispose(): void;
  63241. }
  63242. /**
  63243. * Options to create an EffectWrapper
  63244. */
  63245. interface EffectWrapperCreationOptions {
  63246. /**
  63247. * Engine to use to create the effect
  63248. */
  63249. engine: ThinEngine;
  63250. /**
  63251. * Fragment shader for the effect
  63252. */
  63253. fragmentShader: string;
  63254. /**
  63255. * Vertex shader for the effect
  63256. */
  63257. vertexShader?: string;
  63258. /**
  63259. * Attributes to use in the shader
  63260. */
  63261. attributeNames?: Array<string>;
  63262. /**
  63263. * Uniforms to use in the shader
  63264. */
  63265. uniformNames?: Array<string>;
  63266. /**
  63267. * Texture sampler names to use in the shader
  63268. */
  63269. samplerNames?: Array<string>;
  63270. /**
  63271. * The friendly name of the effect displayed in Spector.
  63272. */
  63273. name?: string;
  63274. }
  63275. /**
  63276. * Wraps an effect to be used for rendering
  63277. */
  63278. export class EffectWrapper {
  63279. /**
  63280. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63281. */
  63282. onApplyObservable: Observable<{}>;
  63283. /**
  63284. * The underlying effect
  63285. */
  63286. effect: Effect;
  63287. /**
  63288. * Creates an effect to be renderer
  63289. * @param creationOptions options to create the effect
  63290. */
  63291. constructor(creationOptions: EffectWrapperCreationOptions);
  63292. /**
  63293. * Disposes of the effect wrapper
  63294. */
  63295. dispose(): void;
  63296. }
  63297. }
  63298. declare module "babylonjs/Materials/index" {
  63299. export * from "babylonjs/Materials/Background/index";
  63300. export * from "babylonjs/Materials/colorCurves";
  63301. export * from "babylonjs/Materials/iEffectFallbacks";
  63302. export * from "babylonjs/Materials/effectFallbacks";
  63303. export * from "babylonjs/Materials/effect";
  63304. export * from "babylonjs/Materials/fresnelParameters";
  63305. export * from "babylonjs/Materials/imageProcessingConfiguration";
  63306. export * from "babylonjs/Materials/material";
  63307. export * from "babylonjs/Materials/materialDefines";
  63308. export * from "babylonjs/Materials/materialHelper";
  63309. export * from "babylonjs/Materials/multiMaterial";
  63310. export * from "babylonjs/Materials/PBR/index";
  63311. export * from "babylonjs/Materials/pushMaterial";
  63312. export * from "babylonjs/Materials/shaderMaterial";
  63313. export * from "babylonjs/Materials/standardMaterial";
  63314. export * from "babylonjs/Materials/Textures/index";
  63315. export * from "babylonjs/Materials/uniformBuffer";
  63316. export * from "babylonjs/Materials/materialFlags";
  63317. export * from "babylonjs/Materials/Node/index";
  63318. export * from "babylonjs/Materials/effectRenderer";
  63319. }
  63320. declare module "babylonjs/Maths/index" {
  63321. export * from "babylonjs/Maths/math.scalar";
  63322. export * from "babylonjs/Maths/math";
  63323. export * from "babylonjs/Maths/sphericalPolynomial";
  63324. }
  63325. declare module "babylonjs/Misc/workerPool" {
  63326. import { IDisposable } from "babylonjs/scene";
  63327. /**
  63328. * Helper class to push actions to a pool of workers.
  63329. */
  63330. export class WorkerPool implements IDisposable {
  63331. private _workerInfos;
  63332. private _pendingActions;
  63333. /**
  63334. * Constructor
  63335. * @param workers Array of workers to use for actions
  63336. */
  63337. constructor(workers: Array<Worker>);
  63338. /**
  63339. * Terminates all workers and clears any pending actions.
  63340. */
  63341. dispose(): void;
  63342. /**
  63343. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63344. * pended until a worker has completed its action.
  63345. * @param action The action to perform. Call onComplete when the action is complete.
  63346. */
  63347. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63348. private _execute;
  63349. }
  63350. }
  63351. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  63352. import { IDisposable } from "babylonjs/scene";
  63353. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63354. /**
  63355. * Configuration for Draco compression
  63356. */
  63357. export interface IDracoCompressionConfiguration {
  63358. /**
  63359. * Configuration for the decoder.
  63360. */
  63361. decoder: {
  63362. /**
  63363. * The url to the WebAssembly module.
  63364. */
  63365. wasmUrl?: string;
  63366. /**
  63367. * The url to the WebAssembly binary.
  63368. */
  63369. wasmBinaryUrl?: string;
  63370. /**
  63371. * The url to the fallback JavaScript module.
  63372. */
  63373. fallbackUrl?: string;
  63374. };
  63375. }
  63376. /**
  63377. * Draco compression (https://google.github.io/draco/)
  63378. *
  63379. * This class wraps the Draco module.
  63380. *
  63381. * **Encoder**
  63382. *
  63383. * The encoder is not currently implemented.
  63384. *
  63385. * **Decoder**
  63386. *
  63387. * 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.
  63388. *
  63389. * To update the configuration, use the following code:
  63390. * ```javascript
  63391. * DracoCompression.Configuration = {
  63392. * decoder: {
  63393. * wasmUrl: "<url to the WebAssembly library>",
  63394. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  63395. * fallbackUrl: "<url to the fallback JavaScript library>",
  63396. * }
  63397. * };
  63398. * ```
  63399. *
  63400. * 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.
  63401. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  63402. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  63403. *
  63404. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  63405. * ```javascript
  63406. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  63407. * ```
  63408. *
  63409. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  63410. */
  63411. export class DracoCompression implements IDisposable {
  63412. private _workerPoolPromise?;
  63413. private _decoderModulePromise?;
  63414. /**
  63415. * The configuration. Defaults to the following urls:
  63416. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  63417. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  63418. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  63419. */
  63420. static Configuration: IDracoCompressionConfiguration;
  63421. /**
  63422. * Returns true if the decoder configuration is available.
  63423. */
  63424. static get DecoderAvailable(): boolean;
  63425. /**
  63426. * Default number of workers to create when creating the draco compression object.
  63427. */
  63428. static DefaultNumWorkers: number;
  63429. private static GetDefaultNumWorkers;
  63430. private static _Default;
  63431. /**
  63432. * Default instance for the draco compression object.
  63433. */
  63434. static get Default(): DracoCompression;
  63435. /**
  63436. * Constructor
  63437. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  63438. */
  63439. constructor(numWorkers?: number);
  63440. /**
  63441. * Stop all async operations and release resources.
  63442. */
  63443. dispose(): void;
  63444. /**
  63445. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  63446. * @returns a promise that resolves when ready
  63447. */
  63448. whenReadyAsync(): Promise<void>;
  63449. /**
  63450. * Decode Draco compressed mesh data to vertex data.
  63451. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  63452. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  63453. * @returns A promise that resolves with the decoded vertex data
  63454. */
  63455. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  63456. [kind: string]: number;
  63457. }): Promise<VertexData>;
  63458. }
  63459. }
  63460. declare module "babylonjs/Meshes/Compression/index" {
  63461. export * from "babylonjs/Meshes/Compression/dracoCompression";
  63462. }
  63463. declare module "babylonjs/Meshes/csg" {
  63464. import { Nullable } from "babylonjs/types";
  63465. import { Scene } from "babylonjs/scene";
  63466. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63467. import { Mesh } from "babylonjs/Meshes/mesh";
  63468. import { Material } from "babylonjs/Materials/material";
  63469. /**
  63470. * Class for building Constructive Solid Geometry
  63471. */
  63472. export class CSG {
  63473. private polygons;
  63474. /**
  63475. * The world matrix
  63476. */
  63477. matrix: Matrix;
  63478. /**
  63479. * Stores the position
  63480. */
  63481. position: Vector3;
  63482. /**
  63483. * Stores the rotation
  63484. */
  63485. rotation: Vector3;
  63486. /**
  63487. * Stores the rotation quaternion
  63488. */
  63489. rotationQuaternion: Nullable<Quaternion>;
  63490. /**
  63491. * Stores the scaling vector
  63492. */
  63493. scaling: Vector3;
  63494. /**
  63495. * Convert the Mesh to CSG
  63496. * @param mesh The Mesh to convert to CSG
  63497. * @returns A new CSG from the Mesh
  63498. */
  63499. static FromMesh(mesh: Mesh): CSG;
  63500. /**
  63501. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  63502. * @param polygons Polygons used to construct a CSG solid
  63503. */
  63504. private static FromPolygons;
  63505. /**
  63506. * Clones, or makes a deep copy, of the CSG
  63507. * @returns A new CSG
  63508. */
  63509. clone(): CSG;
  63510. /**
  63511. * Unions this CSG with another CSG
  63512. * @param csg The CSG to union against this CSG
  63513. * @returns The unioned CSG
  63514. */
  63515. union(csg: CSG): CSG;
  63516. /**
  63517. * Unions this CSG with another CSG in place
  63518. * @param csg The CSG to union against this CSG
  63519. */
  63520. unionInPlace(csg: CSG): void;
  63521. /**
  63522. * Subtracts this CSG with another CSG
  63523. * @param csg The CSG to subtract against this CSG
  63524. * @returns A new CSG
  63525. */
  63526. subtract(csg: CSG): CSG;
  63527. /**
  63528. * Subtracts this CSG with another CSG in place
  63529. * @param csg The CSG to subtact against this CSG
  63530. */
  63531. subtractInPlace(csg: CSG): void;
  63532. /**
  63533. * Intersect this CSG with another CSG
  63534. * @param csg The CSG to intersect against this CSG
  63535. * @returns A new CSG
  63536. */
  63537. intersect(csg: CSG): CSG;
  63538. /**
  63539. * Intersects this CSG with another CSG in place
  63540. * @param csg The CSG to intersect against this CSG
  63541. */
  63542. intersectInPlace(csg: CSG): void;
  63543. /**
  63544. * Return a new CSG solid with solid and empty space switched. This solid is
  63545. * not modified.
  63546. * @returns A new CSG solid with solid and empty space switched
  63547. */
  63548. inverse(): CSG;
  63549. /**
  63550. * Inverses the CSG in place
  63551. */
  63552. inverseInPlace(): void;
  63553. /**
  63554. * This is used to keep meshes transformations so they can be restored
  63555. * when we build back a Babylon Mesh
  63556. * NB : All CSG operations are performed in world coordinates
  63557. * @param csg The CSG to copy the transform attributes from
  63558. * @returns This CSG
  63559. */
  63560. copyTransformAttributes(csg: CSG): CSG;
  63561. /**
  63562. * Build Raw mesh from CSG
  63563. * Coordinates here are in world space
  63564. * @param name The name of the mesh geometry
  63565. * @param scene The Scene
  63566. * @param keepSubMeshes Specifies if the submeshes should be kept
  63567. * @returns A new Mesh
  63568. */
  63569. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63570. /**
  63571. * Build Mesh from CSG taking material and transforms into account
  63572. * @param name The name of the Mesh
  63573. * @param material The material of the Mesh
  63574. * @param scene The Scene
  63575. * @param keepSubMeshes Specifies if submeshes should be kept
  63576. * @returns The new Mesh
  63577. */
  63578. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63579. }
  63580. }
  63581. declare module "babylonjs/Meshes/trailMesh" {
  63582. import { Mesh } from "babylonjs/Meshes/mesh";
  63583. import { Scene } from "babylonjs/scene";
  63584. import { TransformNode } from "babylonjs/Meshes/transformNode";
  63585. /**
  63586. * Class used to create a trail following a mesh
  63587. */
  63588. export class TrailMesh extends Mesh {
  63589. private _generator;
  63590. private _autoStart;
  63591. private _running;
  63592. private _diameter;
  63593. private _length;
  63594. private _sectionPolygonPointsCount;
  63595. private _sectionVectors;
  63596. private _sectionNormalVectors;
  63597. private _beforeRenderObserver;
  63598. /**
  63599. * @constructor
  63600. * @param name The value used by scene.getMeshByName() to do a lookup.
  63601. * @param generator The mesh or transform node to generate a trail.
  63602. * @param scene The scene to add this mesh to.
  63603. * @param diameter Diameter of trailing mesh. Default is 1.
  63604. * @param length Length of trailing mesh. Default is 60.
  63605. * @param autoStart Automatically start trailing mesh. Default true.
  63606. */
  63607. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  63608. /**
  63609. * "TrailMesh"
  63610. * @returns "TrailMesh"
  63611. */
  63612. getClassName(): string;
  63613. private _createMesh;
  63614. /**
  63615. * Start trailing mesh.
  63616. */
  63617. start(): void;
  63618. /**
  63619. * Stop trailing mesh.
  63620. */
  63621. stop(): void;
  63622. /**
  63623. * Update trailing mesh geometry.
  63624. */
  63625. update(): void;
  63626. /**
  63627. * Returns a new TrailMesh object.
  63628. * @param name is a string, the name given to the new mesh
  63629. * @param newGenerator use new generator object for cloned trail mesh
  63630. * @returns a new mesh
  63631. */
  63632. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  63633. /**
  63634. * Serializes this trail mesh
  63635. * @param serializationObject object to write serialization to
  63636. */
  63637. serialize(serializationObject: any): void;
  63638. /**
  63639. * Parses a serialized trail mesh
  63640. * @param parsedMesh the serialized mesh
  63641. * @param scene the scene to create the trail mesh in
  63642. * @returns the created trail mesh
  63643. */
  63644. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  63645. }
  63646. }
  63647. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  63648. import { Nullable } from "babylonjs/types";
  63649. import { Scene } from "babylonjs/scene";
  63650. import { Vector4 } from "babylonjs/Maths/math.vector";
  63651. import { Color4 } from "babylonjs/Maths/math.color";
  63652. import { Mesh } from "babylonjs/Meshes/mesh";
  63653. /**
  63654. * Class containing static functions to help procedurally build meshes
  63655. */
  63656. export class TiledBoxBuilder {
  63657. /**
  63658. * Creates a box mesh
  63659. * 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)
  63660. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63661. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63662. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63663. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63664. * @param name defines the name of the mesh
  63665. * @param options defines the options used to create the mesh
  63666. * @param scene defines the hosting scene
  63667. * @returns the box mesh
  63668. */
  63669. static CreateTiledBox(name: string, options: {
  63670. pattern?: number;
  63671. width?: number;
  63672. height?: number;
  63673. depth?: number;
  63674. tileSize?: number;
  63675. tileWidth?: number;
  63676. tileHeight?: number;
  63677. alignHorizontal?: number;
  63678. alignVertical?: number;
  63679. faceUV?: Vector4[];
  63680. faceColors?: Color4[];
  63681. sideOrientation?: number;
  63682. updatable?: boolean;
  63683. }, scene?: Nullable<Scene>): Mesh;
  63684. }
  63685. }
  63686. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  63687. import { Vector4 } from "babylonjs/Maths/math.vector";
  63688. import { Mesh } from "babylonjs/Meshes/mesh";
  63689. /**
  63690. * Class containing static functions to help procedurally build meshes
  63691. */
  63692. export class TorusKnotBuilder {
  63693. /**
  63694. * Creates a torus knot mesh
  63695. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  63696. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  63697. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  63698. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  63699. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63700. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63701. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63702. * @param name defines the name of the mesh
  63703. * @param options defines the options used to create the mesh
  63704. * @param scene defines the hosting scene
  63705. * @returns the torus knot mesh
  63706. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  63707. */
  63708. static CreateTorusKnot(name: string, options: {
  63709. radius?: number;
  63710. tube?: number;
  63711. radialSegments?: number;
  63712. tubularSegments?: number;
  63713. p?: number;
  63714. q?: number;
  63715. updatable?: boolean;
  63716. sideOrientation?: number;
  63717. frontUVs?: Vector4;
  63718. backUVs?: Vector4;
  63719. }, scene: any): Mesh;
  63720. }
  63721. }
  63722. declare module "babylonjs/Meshes/polygonMesh" {
  63723. import { Scene } from "babylonjs/scene";
  63724. import { Vector2 } from "babylonjs/Maths/math.vector";
  63725. import { Mesh } from "babylonjs/Meshes/mesh";
  63726. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63727. import { Path2 } from "babylonjs/Maths/math.path";
  63728. /**
  63729. * Polygon
  63730. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  63731. */
  63732. export class Polygon {
  63733. /**
  63734. * Creates a rectangle
  63735. * @param xmin bottom X coord
  63736. * @param ymin bottom Y coord
  63737. * @param xmax top X coord
  63738. * @param ymax top Y coord
  63739. * @returns points that make the resulting rectation
  63740. */
  63741. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  63742. /**
  63743. * Creates a circle
  63744. * @param radius radius of circle
  63745. * @param cx scale in x
  63746. * @param cy scale in y
  63747. * @param numberOfSides number of sides that make up the circle
  63748. * @returns points that make the resulting circle
  63749. */
  63750. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  63751. /**
  63752. * Creates a polygon from input string
  63753. * @param input Input polygon data
  63754. * @returns the parsed points
  63755. */
  63756. static Parse(input: string): Vector2[];
  63757. /**
  63758. * Starts building a polygon from x and y coordinates
  63759. * @param x x coordinate
  63760. * @param y y coordinate
  63761. * @returns the started path2
  63762. */
  63763. static StartingAt(x: number, y: number): Path2;
  63764. }
  63765. /**
  63766. * Builds a polygon
  63767. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  63768. */
  63769. export class PolygonMeshBuilder {
  63770. private _points;
  63771. private _outlinepoints;
  63772. private _holes;
  63773. private _name;
  63774. private _scene;
  63775. private _epoints;
  63776. private _eholes;
  63777. private _addToepoint;
  63778. /**
  63779. * Babylon reference to the earcut plugin.
  63780. */
  63781. bjsEarcut: any;
  63782. /**
  63783. * Creates a PolygonMeshBuilder
  63784. * @param name name of the builder
  63785. * @param contours Path of the polygon
  63786. * @param scene scene to add to when creating the mesh
  63787. * @param earcutInjection can be used to inject your own earcut reference
  63788. */
  63789. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  63790. /**
  63791. * Adds a whole within the polygon
  63792. * @param hole Array of points defining the hole
  63793. * @returns this
  63794. */
  63795. addHole(hole: Vector2[]): PolygonMeshBuilder;
  63796. /**
  63797. * Creates the polygon
  63798. * @param updatable If the mesh should be updatable
  63799. * @param depth The depth of the mesh created
  63800. * @returns the created mesh
  63801. */
  63802. build(updatable?: boolean, depth?: number): Mesh;
  63803. /**
  63804. * Creates the polygon
  63805. * @param depth The depth of the mesh created
  63806. * @returns the created VertexData
  63807. */
  63808. buildVertexData(depth?: number): VertexData;
  63809. /**
  63810. * Adds a side to the polygon
  63811. * @param positions points that make the polygon
  63812. * @param normals normals of the polygon
  63813. * @param uvs uvs of the polygon
  63814. * @param indices indices of the polygon
  63815. * @param bounds bounds of the polygon
  63816. * @param points points of the polygon
  63817. * @param depth depth of the polygon
  63818. * @param flip flip of the polygon
  63819. */
  63820. private addSide;
  63821. }
  63822. }
  63823. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  63824. import { Scene } from "babylonjs/scene";
  63825. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63826. import { Color4 } from "babylonjs/Maths/math.color";
  63827. import { Mesh } from "babylonjs/Meshes/mesh";
  63828. import { Nullable } from "babylonjs/types";
  63829. /**
  63830. * Class containing static functions to help procedurally build meshes
  63831. */
  63832. export class PolygonBuilder {
  63833. /**
  63834. * Creates a polygon mesh
  63835. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  63836. * * 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
  63837. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63838. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63839. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  63840. * * Remember you can only change the shape positions, not their number when updating a polygon
  63841. * @param name defines the name of the mesh
  63842. * @param options defines the options used to create the mesh
  63843. * @param scene defines the hosting scene
  63844. * @param earcutInjection can be used to inject your own earcut reference
  63845. * @returns the polygon mesh
  63846. */
  63847. static CreatePolygon(name: string, options: {
  63848. shape: Vector3[];
  63849. holes?: Vector3[][];
  63850. depth?: number;
  63851. faceUV?: Vector4[];
  63852. faceColors?: Color4[];
  63853. updatable?: boolean;
  63854. sideOrientation?: number;
  63855. frontUVs?: Vector4;
  63856. backUVs?: Vector4;
  63857. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63858. /**
  63859. * Creates an extruded polygon mesh, with depth in the Y direction.
  63860. * * 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)
  63861. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63862. * @param name defines the name of the mesh
  63863. * @param options defines the options used to create the mesh
  63864. * @param scene defines the hosting scene
  63865. * @param earcutInjection can be used to inject your own earcut reference
  63866. * @returns the polygon mesh
  63867. */
  63868. static ExtrudePolygon(name: string, options: {
  63869. shape: Vector3[];
  63870. holes?: Vector3[][];
  63871. depth?: number;
  63872. faceUV?: Vector4[];
  63873. faceColors?: Color4[];
  63874. updatable?: boolean;
  63875. sideOrientation?: number;
  63876. frontUVs?: Vector4;
  63877. backUVs?: Vector4;
  63878. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63879. }
  63880. }
  63881. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  63882. import { Scene } from "babylonjs/scene";
  63883. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63884. import { Mesh } from "babylonjs/Meshes/mesh";
  63885. import { Nullable } from "babylonjs/types";
  63886. /**
  63887. * Class containing static functions to help procedurally build meshes
  63888. */
  63889. export class LatheBuilder {
  63890. /**
  63891. * Creates lathe mesh.
  63892. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  63893. * * 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
  63894. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  63895. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  63896. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  63897. * * 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
  63898. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  63899. * * 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
  63900. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63901. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63902. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63903. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63904. * @param name defines the name of the mesh
  63905. * @param options defines the options used to create the mesh
  63906. * @param scene defines the hosting scene
  63907. * @returns the lathe mesh
  63908. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  63909. */
  63910. static CreateLathe(name: string, options: {
  63911. shape: Vector3[];
  63912. radius?: number;
  63913. tessellation?: number;
  63914. clip?: number;
  63915. arc?: number;
  63916. closed?: boolean;
  63917. updatable?: boolean;
  63918. sideOrientation?: number;
  63919. frontUVs?: Vector4;
  63920. backUVs?: Vector4;
  63921. cap?: number;
  63922. invertUV?: boolean;
  63923. }, scene?: Nullable<Scene>): Mesh;
  63924. }
  63925. }
  63926. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  63927. import { Nullable } from "babylonjs/types";
  63928. import { Scene } from "babylonjs/scene";
  63929. import { Vector4 } from "babylonjs/Maths/math.vector";
  63930. import { Mesh } from "babylonjs/Meshes/mesh";
  63931. /**
  63932. * Class containing static functions to help procedurally build meshes
  63933. */
  63934. export class TiledPlaneBuilder {
  63935. /**
  63936. * Creates a tiled plane mesh
  63937. * * The parameter `pattern` will, depending on value, do nothing or
  63938. * * * flip (reflect about central vertical) alternate tiles across and up
  63939. * * * flip every tile on alternate rows
  63940. * * * rotate (180 degs) alternate tiles across and up
  63941. * * * rotate every tile on alternate rows
  63942. * * * flip and rotate alternate tiles across and up
  63943. * * * flip and rotate every tile on alternate rows
  63944. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  63945. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  63946. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63947. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63948. * * 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)
  63949. * * 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)
  63950. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  63951. * @param name defines the name of the mesh
  63952. * @param options defines the options used to create the mesh
  63953. * @param scene defines the hosting scene
  63954. * @returns the box mesh
  63955. */
  63956. static CreateTiledPlane(name: string, options: {
  63957. pattern?: number;
  63958. tileSize?: number;
  63959. tileWidth?: number;
  63960. tileHeight?: number;
  63961. size?: number;
  63962. width?: number;
  63963. height?: number;
  63964. alignHorizontal?: number;
  63965. alignVertical?: number;
  63966. sideOrientation?: number;
  63967. frontUVs?: Vector4;
  63968. backUVs?: Vector4;
  63969. updatable?: boolean;
  63970. }, scene?: Nullable<Scene>): Mesh;
  63971. }
  63972. }
  63973. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  63974. import { Nullable } from "babylonjs/types";
  63975. import { Scene } from "babylonjs/scene";
  63976. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63977. import { Mesh } from "babylonjs/Meshes/mesh";
  63978. /**
  63979. * Class containing static functions to help procedurally build meshes
  63980. */
  63981. export class TubeBuilder {
  63982. /**
  63983. * Creates a tube mesh.
  63984. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  63985. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  63986. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  63987. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  63988. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  63989. * * 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)
  63990. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  63991. * * 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
  63992. * * 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
  63993. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63994. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63995. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63996. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63997. * @param name defines the name of the mesh
  63998. * @param options defines the options used to create the mesh
  63999. * @param scene defines the hosting scene
  64000. * @returns the tube mesh
  64001. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64002. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64003. */
  64004. static CreateTube(name: string, options: {
  64005. path: Vector3[];
  64006. radius?: number;
  64007. tessellation?: number;
  64008. radiusFunction?: {
  64009. (i: number, distance: number): number;
  64010. };
  64011. cap?: number;
  64012. arc?: number;
  64013. updatable?: boolean;
  64014. sideOrientation?: number;
  64015. frontUVs?: Vector4;
  64016. backUVs?: Vector4;
  64017. instance?: Mesh;
  64018. invertUV?: boolean;
  64019. }, scene?: Nullable<Scene>): Mesh;
  64020. }
  64021. }
  64022. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  64023. import { Scene } from "babylonjs/scene";
  64024. import { Vector4 } from "babylonjs/Maths/math.vector";
  64025. import { Mesh } from "babylonjs/Meshes/mesh";
  64026. import { Nullable } from "babylonjs/types";
  64027. /**
  64028. * Class containing static functions to help procedurally build meshes
  64029. */
  64030. export class IcoSphereBuilder {
  64031. /**
  64032. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64033. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64034. * * 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`)
  64035. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64036. * * 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
  64037. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64038. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64039. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64040. * @param name defines the name of the mesh
  64041. * @param options defines the options used to create the mesh
  64042. * @param scene defines the hosting scene
  64043. * @returns the icosahedron mesh
  64044. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64045. */
  64046. static CreateIcoSphere(name: string, options: {
  64047. radius?: number;
  64048. radiusX?: number;
  64049. radiusY?: number;
  64050. radiusZ?: number;
  64051. flat?: boolean;
  64052. subdivisions?: number;
  64053. sideOrientation?: number;
  64054. frontUVs?: Vector4;
  64055. backUVs?: Vector4;
  64056. updatable?: boolean;
  64057. }, scene?: Nullable<Scene>): Mesh;
  64058. }
  64059. }
  64060. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  64061. import { Vector3 } from "babylonjs/Maths/math.vector";
  64062. import { Mesh } from "babylonjs/Meshes/mesh";
  64063. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64064. /**
  64065. * Class containing static functions to help procedurally build meshes
  64066. */
  64067. export class DecalBuilder {
  64068. /**
  64069. * Creates a decal mesh.
  64070. * 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
  64071. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64072. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64073. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64074. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64075. * @param name defines the name of the mesh
  64076. * @param sourceMesh defines the mesh where the decal must be applied
  64077. * @param options defines the options used to create the mesh
  64078. * @param scene defines the hosting scene
  64079. * @returns the decal mesh
  64080. * @see https://doc.babylonjs.com/how_to/decals
  64081. */
  64082. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64083. position?: Vector3;
  64084. normal?: Vector3;
  64085. size?: Vector3;
  64086. angle?: number;
  64087. }): Mesh;
  64088. }
  64089. }
  64090. declare module "babylonjs/Meshes/meshBuilder" {
  64091. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  64092. import { Nullable } from "babylonjs/types";
  64093. import { Scene } from "babylonjs/scene";
  64094. import { Mesh } from "babylonjs/Meshes/mesh";
  64095. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  64096. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  64097. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64098. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  64099. import { Plane } from "babylonjs/Maths/math.plane";
  64100. /**
  64101. * Class containing static functions to help procedurally build meshes
  64102. */
  64103. export class MeshBuilder {
  64104. /**
  64105. * Creates a box mesh
  64106. * * The parameter `size` sets the size (float) of each box side (default 1)
  64107. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  64108. * * 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)
  64109. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64110. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64111. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64112. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64113. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64114. * @param name defines the name of the mesh
  64115. * @param options defines the options used to create the mesh
  64116. * @param scene defines the hosting scene
  64117. * @returns the box mesh
  64118. */
  64119. static CreateBox(name: string, options: {
  64120. size?: number;
  64121. width?: number;
  64122. height?: number;
  64123. depth?: number;
  64124. faceUV?: Vector4[];
  64125. faceColors?: Color4[];
  64126. sideOrientation?: number;
  64127. frontUVs?: Vector4;
  64128. backUVs?: Vector4;
  64129. updatable?: boolean;
  64130. }, scene?: Nullable<Scene>): Mesh;
  64131. /**
  64132. * Creates a tiled box mesh
  64133. * * faceTiles sets the pattern, tile size and number of tiles for a face
  64134. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64135. * @param name defines the name of the mesh
  64136. * @param options defines the options used to create the mesh
  64137. * @param scene defines the hosting scene
  64138. * @returns the tiled box mesh
  64139. */
  64140. static CreateTiledBox(name: string, options: {
  64141. pattern?: number;
  64142. size?: number;
  64143. width?: number;
  64144. height?: number;
  64145. depth: number;
  64146. tileSize?: number;
  64147. tileWidth?: number;
  64148. tileHeight?: number;
  64149. faceUV?: Vector4[];
  64150. faceColors?: Color4[];
  64151. alignHorizontal?: number;
  64152. alignVertical?: number;
  64153. sideOrientation?: number;
  64154. updatable?: boolean;
  64155. }, scene?: Nullable<Scene>): Mesh;
  64156. /**
  64157. * Creates a sphere mesh
  64158. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  64159. * * 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`)
  64160. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  64161. * * 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
  64162. * * 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)
  64163. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64164. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64165. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64166. * @param name defines the name of the mesh
  64167. * @param options defines the options used to create the mesh
  64168. * @param scene defines the hosting scene
  64169. * @returns the sphere mesh
  64170. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  64171. */
  64172. static CreateSphere(name: string, options: {
  64173. segments?: number;
  64174. diameter?: number;
  64175. diameterX?: number;
  64176. diameterY?: number;
  64177. diameterZ?: number;
  64178. arc?: number;
  64179. slice?: number;
  64180. sideOrientation?: number;
  64181. frontUVs?: Vector4;
  64182. backUVs?: Vector4;
  64183. updatable?: boolean;
  64184. }, scene?: Nullable<Scene>): Mesh;
  64185. /**
  64186. * Creates a plane polygonal mesh. By default, this is a disc
  64187. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64188. * * 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
  64189. * * 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
  64190. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64191. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64192. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64193. * @param name defines the name of the mesh
  64194. * @param options defines the options used to create the mesh
  64195. * @param scene defines the hosting scene
  64196. * @returns the plane polygonal mesh
  64197. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64198. */
  64199. static CreateDisc(name: string, options: {
  64200. radius?: number;
  64201. tessellation?: number;
  64202. arc?: number;
  64203. updatable?: boolean;
  64204. sideOrientation?: number;
  64205. frontUVs?: Vector4;
  64206. backUVs?: Vector4;
  64207. }, scene?: Nullable<Scene>): Mesh;
  64208. /**
  64209. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64210. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64211. * * 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`)
  64212. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64213. * * 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
  64214. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64215. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64216. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64217. * @param name defines the name of the mesh
  64218. * @param options defines the options used to create the mesh
  64219. * @param scene defines the hosting scene
  64220. * @returns the icosahedron mesh
  64221. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64222. */
  64223. static CreateIcoSphere(name: string, options: {
  64224. radius?: number;
  64225. radiusX?: number;
  64226. radiusY?: number;
  64227. radiusZ?: number;
  64228. flat?: boolean;
  64229. subdivisions?: number;
  64230. sideOrientation?: number;
  64231. frontUVs?: Vector4;
  64232. backUVs?: Vector4;
  64233. updatable?: boolean;
  64234. }, scene?: Nullable<Scene>): Mesh;
  64235. /**
  64236. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64237. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64238. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64239. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64240. * * 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
  64241. * * 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
  64242. * * 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
  64243. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64244. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64245. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64246. * * 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
  64247. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64248. * * 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
  64249. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  64250. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64251. * @param name defines the name of the mesh
  64252. * @param options defines the options used to create the mesh
  64253. * @param scene defines the hosting scene
  64254. * @returns the ribbon mesh
  64255. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64256. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64257. */
  64258. static CreateRibbon(name: string, options: {
  64259. pathArray: Vector3[][];
  64260. closeArray?: boolean;
  64261. closePath?: boolean;
  64262. offset?: number;
  64263. updatable?: boolean;
  64264. sideOrientation?: number;
  64265. frontUVs?: Vector4;
  64266. backUVs?: Vector4;
  64267. instance?: Mesh;
  64268. invertUV?: boolean;
  64269. uvs?: Vector2[];
  64270. colors?: Color4[];
  64271. }, scene?: Nullable<Scene>): Mesh;
  64272. /**
  64273. * Creates a cylinder or a cone mesh
  64274. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64275. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64276. * * 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.
  64277. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64278. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64279. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64280. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64281. * * 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).
  64282. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64283. * * 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).
  64284. * * 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
  64285. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64286. * * 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
  64287. * * 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.
  64288. * * If `enclose` is false, a ring surface is one element.
  64289. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64290. * * 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
  64291. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64292. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64293. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64294. * @param name defines the name of the mesh
  64295. * @param options defines the options used to create the mesh
  64296. * @param scene defines the hosting scene
  64297. * @returns the cylinder mesh
  64298. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64299. */
  64300. static CreateCylinder(name: string, options: {
  64301. height?: number;
  64302. diameterTop?: number;
  64303. diameterBottom?: number;
  64304. diameter?: number;
  64305. tessellation?: number;
  64306. subdivisions?: number;
  64307. arc?: number;
  64308. faceColors?: Color4[];
  64309. faceUV?: Vector4[];
  64310. updatable?: boolean;
  64311. hasRings?: boolean;
  64312. enclose?: boolean;
  64313. cap?: number;
  64314. sideOrientation?: number;
  64315. frontUVs?: Vector4;
  64316. backUVs?: Vector4;
  64317. }, scene?: Nullable<Scene>): Mesh;
  64318. /**
  64319. * Creates a torus mesh
  64320. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64321. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64322. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64323. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64324. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64325. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64326. * @param name defines the name of the mesh
  64327. * @param options defines the options used to create the mesh
  64328. * @param scene defines the hosting scene
  64329. * @returns the torus mesh
  64330. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64331. */
  64332. static CreateTorus(name: string, options: {
  64333. diameter?: number;
  64334. thickness?: number;
  64335. tessellation?: number;
  64336. updatable?: boolean;
  64337. sideOrientation?: number;
  64338. frontUVs?: Vector4;
  64339. backUVs?: Vector4;
  64340. }, scene?: Nullable<Scene>): Mesh;
  64341. /**
  64342. * Creates a torus knot mesh
  64343. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64344. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64345. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64346. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64347. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64348. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64349. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64350. * @param name defines the name of the mesh
  64351. * @param options defines the options used to create the mesh
  64352. * @param scene defines the hosting scene
  64353. * @returns the torus knot mesh
  64354. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64355. */
  64356. static CreateTorusKnot(name: string, options: {
  64357. radius?: number;
  64358. tube?: number;
  64359. radialSegments?: number;
  64360. tubularSegments?: number;
  64361. p?: number;
  64362. q?: number;
  64363. updatable?: boolean;
  64364. sideOrientation?: number;
  64365. frontUVs?: Vector4;
  64366. backUVs?: Vector4;
  64367. }, scene?: Nullable<Scene>): Mesh;
  64368. /**
  64369. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64370. * * 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
  64371. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64372. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64373. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64374. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64375. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64376. * * 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
  64377. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  64378. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64379. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64380. * @param name defines the name of the new line system
  64381. * @param options defines the options used to create the line system
  64382. * @param scene defines the hosting scene
  64383. * @returns a new line system mesh
  64384. */
  64385. static CreateLineSystem(name: string, options: {
  64386. lines: Vector3[][];
  64387. updatable?: boolean;
  64388. instance?: Nullable<LinesMesh>;
  64389. colors?: Nullable<Color4[][]>;
  64390. useVertexAlpha?: boolean;
  64391. }, scene: Nullable<Scene>): LinesMesh;
  64392. /**
  64393. * Creates a line mesh
  64394. * 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
  64395. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64396. * * The parameter `points` is an array successive Vector3
  64397. * * 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
  64398. * * The optional parameter `colors` is an array of successive Color4, one per line point
  64399. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  64400. * * When updating an instance, remember that only point positions can change, not the number of points
  64401. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64402. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  64403. * @param name defines the name of the new line system
  64404. * @param options defines the options used to create the line system
  64405. * @param scene defines the hosting scene
  64406. * @returns a new line mesh
  64407. */
  64408. static CreateLines(name: string, options: {
  64409. points: Vector3[];
  64410. updatable?: boolean;
  64411. instance?: Nullable<LinesMesh>;
  64412. colors?: Color4[];
  64413. useVertexAlpha?: boolean;
  64414. }, scene?: Nullable<Scene>): LinesMesh;
  64415. /**
  64416. * Creates a dashed line mesh
  64417. * * 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
  64418. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64419. * * The parameter `points` is an array successive Vector3
  64420. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  64421. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  64422. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  64423. * * 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
  64424. * * When updating an instance, remember that only point positions can change, not the number of points
  64425. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64426. * @param name defines the name of the mesh
  64427. * @param options defines the options used to create the mesh
  64428. * @param scene defines the hosting scene
  64429. * @returns the dashed line mesh
  64430. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  64431. */
  64432. static CreateDashedLines(name: string, options: {
  64433. points: Vector3[];
  64434. dashSize?: number;
  64435. gapSize?: number;
  64436. dashNb?: number;
  64437. updatable?: boolean;
  64438. instance?: LinesMesh;
  64439. }, scene?: Nullable<Scene>): LinesMesh;
  64440. /**
  64441. * 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.
  64442. * * 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.
  64443. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64444. * * 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.
  64445. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  64446. * * 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
  64447. * * 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
  64448. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  64449. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64450. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64451. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  64452. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64453. * @param name defines the name of the mesh
  64454. * @param options defines the options used to create the mesh
  64455. * @param scene defines the hosting scene
  64456. * @returns the extruded shape mesh
  64457. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64458. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64459. */
  64460. static ExtrudeShape(name: string, options: {
  64461. shape: Vector3[];
  64462. path: Vector3[];
  64463. scale?: number;
  64464. rotation?: number;
  64465. cap?: number;
  64466. updatable?: boolean;
  64467. sideOrientation?: number;
  64468. frontUVs?: Vector4;
  64469. backUVs?: Vector4;
  64470. instance?: Mesh;
  64471. invertUV?: boolean;
  64472. }, scene?: Nullable<Scene>): Mesh;
  64473. /**
  64474. * Creates an custom extruded shape mesh.
  64475. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  64476. * * 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.
  64477. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64478. * * 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
  64479. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  64480. * * 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
  64481. * * It must returns a float value that will be the scale value applied to the shape on each path point
  64482. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  64483. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  64484. * * 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
  64485. * * 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
  64486. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  64487. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64488. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64489. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64490. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64491. * @param name defines the name of the mesh
  64492. * @param options defines the options used to create the mesh
  64493. * @param scene defines the hosting scene
  64494. * @returns the custom extruded shape mesh
  64495. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  64496. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64497. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64498. */
  64499. static ExtrudeShapeCustom(name: string, options: {
  64500. shape: Vector3[];
  64501. path: Vector3[];
  64502. scaleFunction?: any;
  64503. rotationFunction?: any;
  64504. ribbonCloseArray?: boolean;
  64505. ribbonClosePath?: boolean;
  64506. cap?: number;
  64507. updatable?: boolean;
  64508. sideOrientation?: number;
  64509. frontUVs?: Vector4;
  64510. backUVs?: Vector4;
  64511. instance?: Mesh;
  64512. invertUV?: boolean;
  64513. }, scene?: Nullable<Scene>): Mesh;
  64514. /**
  64515. * Creates lathe mesh.
  64516. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64517. * * 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
  64518. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64519. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64520. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64521. * * 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
  64522. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64523. * * 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
  64524. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64525. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64526. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64527. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64528. * @param name defines the name of the mesh
  64529. * @param options defines the options used to create the mesh
  64530. * @param scene defines the hosting scene
  64531. * @returns the lathe mesh
  64532. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64533. */
  64534. static CreateLathe(name: string, options: {
  64535. shape: Vector3[];
  64536. radius?: number;
  64537. tessellation?: number;
  64538. clip?: number;
  64539. arc?: number;
  64540. closed?: boolean;
  64541. updatable?: boolean;
  64542. sideOrientation?: number;
  64543. frontUVs?: Vector4;
  64544. backUVs?: Vector4;
  64545. cap?: number;
  64546. invertUV?: boolean;
  64547. }, scene?: Nullable<Scene>): Mesh;
  64548. /**
  64549. * Creates a tiled plane mesh
  64550. * * You can set a limited pattern arrangement with the tiles
  64551. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64552. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64553. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64554. * @param name defines the name of the mesh
  64555. * @param options defines the options used to create the mesh
  64556. * @param scene defines the hosting scene
  64557. * @returns the plane mesh
  64558. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64559. */
  64560. static CreateTiledPlane(name: string, options: {
  64561. pattern?: number;
  64562. tileSize?: number;
  64563. tileWidth?: number;
  64564. tileHeight?: number;
  64565. size?: number;
  64566. width?: number;
  64567. height?: number;
  64568. alignHorizontal?: number;
  64569. alignVertical?: number;
  64570. sideOrientation?: number;
  64571. frontUVs?: Vector4;
  64572. backUVs?: Vector4;
  64573. updatable?: boolean;
  64574. }, scene?: Nullable<Scene>): Mesh;
  64575. /**
  64576. * Creates a plane mesh
  64577. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  64578. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  64579. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  64580. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64581. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64582. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64583. * @param name defines the name of the mesh
  64584. * @param options defines the options used to create the mesh
  64585. * @param scene defines the hosting scene
  64586. * @returns the plane mesh
  64587. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64588. */
  64589. static CreatePlane(name: string, options: {
  64590. size?: number;
  64591. width?: number;
  64592. height?: number;
  64593. sideOrientation?: number;
  64594. frontUVs?: Vector4;
  64595. backUVs?: Vector4;
  64596. updatable?: boolean;
  64597. sourcePlane?: Plane;
  64598. }, scene?: Nullable<Scene>): Mesh;
  64599. /**
  64600. * Creates a ground mesh
  64601. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  64602. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  64603. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64604. * @param name defines the name of the mesh
  64605. * @param options defines the options used to create the mesh
  64606. * @param scene defines the hosting scene
  64607. * @returns the ground mesh
  64608. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  64609. */
  64610. static CreateGround(name: string, options: {
  64611. width?: number;
  64612. height?: number;
  64613. subdivisions?: number;
  64614. subdivisionsX?: number;
  64615. subdivisionsY?: number;
  64616. updatable?: boolean;
  64617. }, scene?: Nullable<Scene>): Mesh;
  64618. /**
  64619. * Creates a tiled ground mesh
  64620. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  64621. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  64622. * * 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
  64623. * * 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
  64624. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64625. * @param name defines the name of the mesh
  64626. * @param options defines the options used to create the mesh
  64627. * @param scene defines the hosting scene
  64628. * @returns the tiled ground mesh
  64629. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  64630. */
  64631. static CreateTiledGround(name: string, options: {
  64632. xmin: number;
  64633. zmin: number;
  64634. xmax: number;
  64635. zmax: number;
  64636. subdivisions?: {
  64637. w: number;
  64638. h: number;
  64639. };
  64640. precision?: {
  64641. w: number;
  64642. h: number;
  64643. };
  64644. updatable?: boolean;
  64645. }, scene?: Nullable<Scene>): Mesh;
  64646. /**
  64647. * Creates a ground mesh from a height map
  64648. * * The parameter `url` sets the URL of the height map image resource.
  64649. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  64650. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  64651. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  64652. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  64653. * * 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.
  64654. * * 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).
  64655. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  64656. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64657. * @param name defines the name of the mesh
  64658. * @param url defines the url to the height map
  64659. * @param options defines the options used to create the mesh
  64660. * @param scene defines the hosting scene
  64661. * @returns the ground mesh
  64662. * @see https://doc.babylonjs.com/babylon101/height_map
  64663. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  64664. */
  64665. static CreateGroundFromHeightMap(name: string, url: string, options: {
  64666. width?: number;
  64667. height?: number;
  64668. subdivisions?: number;
  64669. minHeight?: number;
  64670. maxHeight?: number;
  64671. colorFilter?: Color3;
  64672. alphaFilter?: number;
  64673. updatable?: boolean;
  64674. onReady?: (mesh: GroundMesh) => void;
  64675. }, scene?: Nullable<Scene>): GroundMesh;
  64676. /**
  64677. * Creates a polygon mesh
  64678. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64679. * * 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
  64680. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64681. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64682. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  64683. * * Remember you can only change the shape positions, not their number when updating a polygon
  64684. * @param name defines the name of the mesh
  64685. * @param options defines the options used to create the mesh
  64686. * @param scene defines the hosting scene
  64687. * @param earcutInjection can be used to inject your own earcut reference
  64688. * @returns the polygon mesh
  64689. */
  64690. static CreatePolygon(name: string, options: {
  64691. shape: Vector3[];
  64692. holes?: Vector3[][];
  64693. depth?: number;
  64694. faceUV?: Vector4[];
  64695. faceColors?: Color4[];
  64696. updatable?: boolean;
  64697. sideOrientation?: number;
  64698. frontUVs?: Vector4;
  64699. backUVs?: Vector4;
  64700. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64701. /**
  64702. * Creates an extruded polygon mesh, with depth in the Y direction.
  64703. * * 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)
  64704. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64705. * @param name defines the name of the mesh
  64706. * @param options defines the options used to create the mesh
  64707. * @param scene defines the hosting scene
  64708. * @param earcutInjection can be used to inject your own earcut reference
  64709. * @returns the polygon mesh
  64710. */
  64711. static ExtrudePolygon(name: string, options: {
  64712. shape: Vector3[];
  64713. holes?: Vector3[][];
  64714. depth?: number;
  64715. faceUV?: Vector4[];
  64716. faceColors?: Color4[];
  64717. updatable?: boolean;
  64718. sideOrientation?: number;
  64719. frontUVs?: Vector4;
  64720. backUVs?: Vector4;
  64721. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64722. /**
  64723. * Creates a tube mesh.
  64724. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64725. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64726. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64727. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64728. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64729. * * 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)
  64730. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64731. * * 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
  64732. * * 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
  64733. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64734. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64735. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64736. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64737. * @param name defines the name of the mesh
  64738. * @param options defines the options used to create the mesh
  64739. * @param scene defines the hosting scene
  64740. * @returns the tube mesh
  64741. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64742. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64743. */
  64744. static CreateTube(name: string, options: {
  64745. path: Vector3[];
  64746. radius?: number;
  64747. tessellation?: number;
  64748. radiusFunction?: {
  64749. (i: number, distance: number): number;
  64750. };
  64751. cap?: number;
  64752. arc?: number;
  64753. updatable?: boolean;
  64754. sideOrientation?: number;
  64755. frontUVs?: Vector4;
  64756. backUVs?: Vector4;
  64757. instance?: Mesh;
  64758. invertUV?: boolean;
  64759. }, scene?: Nullable<Scene>): Mesh;
  64760. /**
  64761. * Creates a polyhedron mesh
  64762. * * 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
  64763. * * The parameter `size` (positive float, default 1) sets the polygon size
  64764. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  64765. * * 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`
  64766. * * 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
  64767. * * 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)`)
  64768. * * 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
  64769. * * 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
  64770. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64771. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64772. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64773. * @param name defines the name of the mesh
  64774. * @param options defines the options used to create the mesh
  64775. * @param scene defines the hosting scene
  64776. * @returns the polyhedron mesh
  64777. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  64778. */
  64779. static CreatePolyhedron(name: string, options: {
  64780. type?: number;
  64781. size?: number;
  64782. sizeX?: number;
  64783. sizeY?: number;
  64784. sizeZ?: number;
  64785. custom?: any;
  64786. faceUV?: Vector4[];
  64787. faceColors?: Color4[];
  64788. flat?: boolean;
  64789. updatable?: boolean;
  64790. sideOrientation?: number;
  64791. frontUVs?: Vector4;
  64792. backUVs?: Vector4;
  64793. }, scene?: Nullable<Scene>): Mesh;
  64794. /**
  64795. * Creates a decal mesh.
  64796. * 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
  64797. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64798. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64799. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64800. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64801. * @param name defines the name of the mesh
  64802. * @param sourceMesh defines the mesh where the decal must be applied
  64803. * @param options defines the options used to create the mesh
  64804. * @param scene defines the hosting scene
  64805. * @returns the decal mesh
  64806. * @see https://doc.babylonjs.com/how_to/decals
  64807. */
  64808. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64809. position?: Vector3;
  64810. normal?: Vector3;
  64811. size?: Vector3;
  64812. angle?: number;
  64813. }): Mesh;
  64814. }
  64815. }
  64816. declare module "babylonjs/Meshes/meshSimplification" {
  64817. import { Mesh } from "babylonjs/Meshes/mesh";
  64818. /**
  64819. * A simplifier interface for future simplification implementations
  64820. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64821. */
  64822. export interface ISimplifier {
  64823. /**
  64824. * Simplification of a given mesh according to the given settings.
  64825. * Since this requires computation, it is assumed that the function runs async.
  64826. * @param settings The settings of the simplification, including quality and distance
  64827. * @param successCallback A callback that will be called after the mesh was simplified.
  64828. * @param errorCallback in case of an error, this callback will be called. optional.
  64829. */
  64830. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  64831. }
  64832. /**
  64833. * Expected simplification settings.
  64834. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  64835. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64836. */
  64837. export interface ISimplificationSettings {
  64838. /**
  64839. * Gets or sets the expected quality
  64840. */
  64841. quality: number;
  64842. /**
  64843. * Gets or sets the distance when this optimized version should be used
  64844. */
  64845. distance: number;
  64846. /**
  64847. * Gets an already optimized mesh
  64848. */
  64849. optimizeMesh?: boolean;
  64850. }
  64851. /**
  64852. * Class used to specify simplification options
  64853. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64854. */
  64855. export class SimplificationSettings implements ISimplificationSettings {
  64856. /** expected quality */
  64857. quality: number;
  64858. /** distance when this optimized version should be used */
  64859. distance: number;
  64860. /** already optimized mesh */
  64861. optimizeMesh?: boolean | undefined;
  64862. /**
  64863. * Creates a SimplificationSettings
  64864. * @param quality expected quality
  64865. * @param distance distance when this optimized version should be used
  64866. * @param optimizeMesh already optimized mesh
  64867. */
  64868. constructor(
  64869. /** expected quality */
  64870. quality: number,
  64871. /** distance when this optimized version should be used */
  64872. distance: number,
  64873. /** already optimized mesh */
  64874. optimizeMesh?: boolean | undefined);
  64875. }
  64876. /**
  64877. * Interface used to define a simplification task
  64878. */
  64879. export interface ISimplificationTask {
  64880. /**
  64881. * Array of settings
  64882. */
  64883. settings: Array<ISimplificationSettings>;
  64884. /**
  64885. * Simplification type
  64886. */
  64887. simplificationType: SimplificationType;
  64888. /**
  64889. * Mesh to simplify
  64890. */
  64891. mesh: Mesh;
  64892. /**
  64893. * Callback called on success
  64894. */
  64895. successCallback?: () => void;
  64896. /**
  64897. * Defines if parallel processing can be used
  64898. */
  64899. parallelProcessing: boolean;
  64900. }
  64901. /**
  64902. * Queue used to order the simplification tasks
  64903. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64904. */
  64905. export class SimplificationQueue {
  64906. private _simplificationArray;
  64907. /**
  64908. * Gets a boolean indicating that the process is still running
  64909. */
  64910. running: boolean;
  64911. /**
  64912. * Creates a new queue
  64913. */
  64914. constructor();
  64915. /**
  64916. * Adds a new simplification task
  64917. * @param task defines a task to add
  64918. */
  64919. addTask(task: ISimplificationTask): void;
  64920. /**
  64921. * Execute next task
  64922. */
  64923. executeNext(): void;
  64924. /**
  64925. * Execute a simplification task
  64926. * @param task defines the task to run
  64927. */
  64928. runSimplification(task: ISimplificationTask): void;
  64929. private getSimplifier;
  64930. }
  64931. /**
  64932. * The implemented types of simplification
  64933. * At the moment only Quadratic Error Decimation is implemented
  64934. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64935. */
  64936. export enum SimplificationType {
  64937. /** Quadratic error decimation */
  64938. QUADRATIC = 0
  64939. }
  64940. }
  64941. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  64942. import { Scene } from "babylonjs/scene";
  64943. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  64944. import { ISceneComponent } from "babylonjs/sceneComponent";
  64945. module "babylonjs/scene" {
  64946. interface Scene {
  64947. /** @hidden (Backing field) */
  64948. _simplificationQueue: SimplificationQueue;
  64949. /**
  64950. * Gets or sets the simplification queue attached to the scene
  64951. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64952. */
  64953. simplificationQueue: SimplificationQueue;
  64954. }
  64955. }
  64956. module "babylonjs/Meshes/mesh" {
  64957. interface Mesh {
  64958. /**
  64959. * Simplify the mesh according to the given array of settings.
  64960. * Function will return immediately and will simplify async
  64961. * @param settings a collection of simplification settings
  64962. * @param parallelProcessing should all levels calculate parallel or one after the other
  64963. * @param simplificationType the type of simplification to run
  64964. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  64965. * @returns the current mesh
  64966. */
  64967. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  64968. }
  64969. }
  64970. /**
  64971. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  64972. * created in a scene
  64973. */
  64974. export class SimplicationQueueSceneComponent implements ISceneComponent {
  64975. /**
  64976. * The component name helpfull to identify the component in the list of scene components.
  64977. */
  64978. readonly name: string;
  64979. /**
  64980. * The scene the component belongs to.
  64981. */
  64982. scene: Scene;
  64983. /**
  64984. * Creates a new instance of the component for the given scene
  64985. * @param scene Defines the scene to register the component in
  64986. */
  64987. constructor(scene: Scene);
  64988. /**
  64989. * Registers the component in a given scene
  64990. */
  64991. register(): void;
  64992. /**
  64993. * Rebuilds the elements related to this component in case of
  64994. * context lost for instance.
  64995. */
  64996. rebuild(): void;
  64997. /**
  64998. * Disposes the component and the associated ressources
  64999. */
  65000. dispose(): void;
  65001. private _beforeCameraUpdate;
  65002. }
  65003. }
  65004. declare module "babylonjs/Meshes/Builders/index" {
  65005. export * from "babylonjs/Meshes/Builders/boxBuilder";
  65006. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  65007. export * from "babylonjs/Meshes/Builders/discBuilder";
  65008. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  65009. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  65010. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  65011. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  65012. export * from "babylonjs/Meshes/Builders/torusBuilder";
  65013. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  65014. export * from "babylonjs/Meshes/Builders/linesBuilder";
  65015. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  65016. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  65017. export * from "babylonjs/Meshes/Builders/latheBuilder";
  65018. export * from "babylonjs/Meshes/Builders/planeBuilder";
  65019. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  65020. export * from "babylonjs/Meshes/Builders/groundBuilder";
  65021. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  65022. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  65023. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  65024. export * from "babylonjs/Meshes/Builders/decalBuilder";
  65025. }
  65026. declare module "babylonjs/Meshes/index" {
  65027. export * from "babylonjs/Meshes/abstractMesh";
  65028. export * from "babylonjs/Meshes/buffer";
  65029. export * from "babylonjs/Meshes/Compression/index";
  65030. export * from "babylonjs/Meshes/csg";
  65031. export * from "babylonjs/Meshes/geometry";
  65032. export * from "babylonjs/Meshes/groundMesh";
  65033. export * from "babylonjs/Meshes/trailMesh";
  65034. export * from "babylonjs/Meshes/instancedMesh";
  65035. export * from "babylonjs/Meshes/linesMesh";
  65036. export * from "babylonjs/Meshes/mesh";
  65037. export * from "babylonjs/Meshes/mesh.vertexData";
  65038. export * from "babylonjs/Meshes/meshBuilder";
  65039. export * from "babylonjs/Meshes/meshSimplification";
  65040. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  65041. export * from "babylonjs/Meshes/polygonMesh";
  65042. export * from "babylonjs/Meshes/subMesh";
  65043. export * from "babylonjs/Meshes/meshLODLevel";
  65044. export * from "babylonjs/Meshes/transformNode";
  65045. export * from "babylonjs/Meshes/Builders/index";
  65046. export * from "babylonjs/Meshes/dataBuffer";
  65047. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  65048. }
  65049. declare module "babylonjs/Morph/index" {
  65050. export * from "babylonjs/Morph/morphTarget";
  65051. export * from "babylonjs/Morph/morphTargetManager";
  65052. }
  65053. declare module "babylonjs/Navigation/INavigationEngine" {
  65054. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65055. import { Vector3 } from "babylonjs/Maths/math";
  65056. import { Mesh } from "babylonjs/Meshes/mesh";
  65057. import { Scene } from "babylonjs/scene";
  65058. /**
  65059. * Navigation plugin interface to add navigation constrained by a navigation mesh
  65060. */
  65061. export interface INavigationEnginePlugin {
  65062. /**
  65063. * plugin name
  65064. */
  65065. name: string;
  65066. /**
  65067. * Creates a navigation mesh
  65068. * @param meshes array of all the geometry used to compute the navigatio mesh
  65069. * @param parameters bunch of parameters used to filter geometry
  65070. */
  65071. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65072. /**
  65073. * Create a navigation mesh debug mesh
  65074. * @param scene is where the mesh will be added
  65075. * @returns debug display mesh
  65076. */
  65077. createDebugNavMesh(scene: Scene): Mesh;
  65078. /**
  65079. * Get a navigation mesh constrained position, closest to the parameter position
  65080. * @param position world position
  65081. * @returns the closest point to position constrained by the navigation mesh
  65082. */
  65083. getClosestPoint(position: Vector3): Vector3;
  65084. /**
  65085. * Get a navigation mesh constrained position, within a particular radius
  65086. * @param position world position
  65087. * @param maxRadius the maximum distance to the constrained world position
  65088. * @returns the closest point to position constrained by the navigation mesh
  65089. */
  65090. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65091. /**
  65092. * Compute the final position from a segment made of destination-position
  65093. * @param position world position
  65094. * @param destination world position
  65095. * @returns the resulting point along the navmesh
  65096. */
  65097. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65098. /**
  65099. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65100. * @param start world position
  65101. * @param end world position
  65102. * @returns array containing world position composing the path
  65103. */
  65104. computePath(start: Vector3, end: Vector3): Vector3[];
  65105. /**
  65106. * If this plugin is supported
  65107. * @returns true if plugin is supported
  65108. */
  65109. isSupported(): boolean;
  65110. /**
  65111. * Create a new Crowd so you can add agents
  65112. * @param maxAgents the maximum agent count in the crowd
  65113. * @param maxAgentRadius the maximum radius an agent can have
  65114. * @param scene to attach the crowd to
  65115. * @returns the crowd you can add agents to
  65116. */
  65117. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65118. /**
  65119. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65120. * The queries will try to find a solution within those bounds
  65121. * default is (1,1,1)
  65122. * @param extent x,y,z value that define the extent around the queries point of reference
  65123. */
  65124. setDefaultQueryExtent(extent: Vector3): void;
  65125. /**
  65126. * Get the Bounding box extent specified by setDefaultQueryExtent
  65127. * @returns the box extent values
  65128. */
  65129. getDefaultQueryExtent(): Vector3;
  65130. /**
  65131. * Release all resources
  65132. */
  65133. dispose(): void;
  65134. }
  65135. /**
  65136. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  65137. */
  65138. export interface ICrowd {
  65139. /**
  65140. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65141. * You can attach anything to that node. The node position is updated in the scene update tick.
  65142. * @param pos world position that will be constrained by the navigation mesh
  65143. * @param parameters agent parameters
  65144. * @param transform hooked to the agent that will be update by the scene
  65145. * @returns agent index
  65146. */
  65147. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65148. /**
  65149. * Returns the agent position in world space
  65150. * @param index agent index returned by addAgent
  65151. * @returns world space position
  65152. */
  65153. getAgentPosition(index: number): Vector3;
  65154. /**
  65155. * Gets the agent velocity in world space
  65156. * @param index agent index returned by addAgent
  65157. * @returns world space velocity
  65158. */
  65159. getAgentVelocity(index: number): Vector3;
  65160. /**
  65161. * remove a particular agent previously created
  65162. * @param index agent index returned by addAgent
  65163. */
  65164. removeAgent(index: number): void;
  65165. /**
  65166. * get the list of all agents attached to this crowd
  65167. * @returns list of agent indices
  65168. */
  65169. getAgents(): number[];
  65170. /**
  65171. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65172. * @param deltaTime in seconds
  65173. */
  65174. update(deltaTime: number): void;
  65175. /**
  65176. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65177. * @param index agent index returned by addAgent
  65178. * @param destination targeted world position
  65179. */
  65180. agentGoto(index: number, destination: Vector3): void;
  65181. /**
  65182. * Teleport the agent to a new position
  65183. * @param index agent index returned by addAgent
  65184. * @param destination targeted world position
  65185. */
  65186. agentTeleport(index: number, destination: Vector3): void;
  65187. /**
  65188. * Update agent parameters
  65189. * @param index agent index returned by addAgent
  65190. * @param parameters agent parameters
  65191. */
  65192. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65193. /**
  65194. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65195. * The queries will try to find a solution within those bounds
  65196. * default is (1,1,1)
  65197. * @param extent x,y,z value that define the extent around the queries point of reference
  65198. */
  65199. setDefaultQueryExtent(extent: Vector3): void;
  65200. /**
  65201. * Get the Bounding box extent specified by setDefaultQueryExtent
  65202. * @returns the box extent values
  65203. */
  65204. getDefaultQueryExtent(): Vector3;
  65205. /**
  65206. * Release all resources
  65207. */
  65208. dispose(): void;
  65209. }
  65210. /**
  65211. * Configures an agent
  65212. */
  65213. export interface IAgentParameters {
  65214. /**
  65215. * Agent radius. [Limit: >= 0]
  65216. */
  65217. radius: number;
  65218. /**
  65219. * Agent height. [Limit: > 0]
  65220. */
  65221. height: number;
  65222. /**
  65223. * Maximum allowed acceleration. [Limit: >= 0]
  65224. */
  65225. maxAcceleration: number;
  65226. /**
  65227. * Maximum allowed speed. [Limit: >= 0]
  65228. */
  65229. maxSpeed: number;
  65230. /**
  65231. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65232. */
  65233. collisionQueryRange: number;
  65234. /**
  65235. * The path visibility optimization range. [Limit: > 0]
  65236. */
  65237. pathOptimizationRange: number;
  65238. /**
  65239. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65240. */
  65241. separationWeight: number;
  65242. }
  65243. /**
  65244. * Configures the navigation mesh creation
  65245. */
  65246. export interface INavMeshParameters {
  65247. /**
  65248. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65249. */
  65250. cs: number;
  65251. /**
  65252. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65253. */
  65254. ch: number;
  65255. /**
  65256. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65257. */
  65258. walkableSlopeAngle: number;
  65259. /**
  65260. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65261. * be considered walkable. [Limit: >= 3] [Units: vx]
  65262. */
  65263. walkableHeight: number;
  65264. /**
  65265. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65266. */
  65267. walkableClimb: number;
  65268. /**
  65269. * The distance to erode/shrink the walkable area of the heightfield away from
  65270. * obstructions. [Limit: >=0] [Units: vx]
  65271. */
  65272. walkableRadius: number;
  65273. /**
  65274. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  65275. */
  65276. maxEdgeLen: number;
  65277. /**
  65278. * The maximum distance a simplfied contour's border edges should deviate
  65279. * the original raw contour. [Limit: >=0] [Units: vx]
  65280. */
  65281. maxSimplificationError: number;
  65282. /**
  65283. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  65284. */
  65285. minRegionArea: number;
  65286. /**
  65287. * Any regions with a span count smaller than this value will, if possible,
  65288. * be merged with larger regions. [Limit: >=0] [Units: vx]
  65289. */
  65290. mergeRegionArea: number;
  65291. /**
  65292. * The maximum number of vertices allowed for polygons generated during the
  65293. * contour to polygon conversion process. [Limit: >= 3]
  65294. */
  65295. maxVertsPerPoly: number;
  65296. /**
  65297. * Sets the sampling distance to use when generating the detail mesh.
  65298. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  65299. */
  65300. detailSampleDist: number;
  65301. /**
  65302. * The maximum distance the detail mesh surface should deviate from heightfield
  65303. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  65304. */
  65305. detailSampleMaxError: number;
  65306. }
  65307. }
  65308. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  65309. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  65310. import { Mesh } from "babylonjs/Meshes/mesh";
  65311. import { Scene } from "babylonjs/scene";
  65312. import { Vector3 } from "babylonjs/Maths/math";
  65313. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65314. /**
  65315. * RecastJS navigation plugin
  65316. */
  65317. export class RecastJSPlugin implements INavigationEnginePlugin {
  65318. /**
  65319. * Reference to the Recast library
  65320. */
  65321. bjsRECAST: any;
  65322. /**
  65323. * plugin name
  65324. */
  65325. name: string;
  65326. /**
  65327. * the first navmesh created. We might extend this to support multiple navmeshes
  65328. */
  65329. navMesh: any;
  65330. /**
  65331. * Initializes the recastJS plugin
  65332. * @param recastInjection can be used to inject your own recast reference
  65333. */
  65334. constructor(recastInjection?: any);
  65335. /**
  65336. * Creates a navigation mesh
  65337. * @param meshes array of all the geometry used to compute the navigatio mesh
  65338. * @param parameters bunch of parameters used to filter geometry
  65339. */
  65340. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65341. /**
  65342. * Create a navigation mesh debug mesh
  65343. * @param scene is where the mesh will be added
  65344. * @returns debug display mesh
  65345. */
  65346. createDebugNavMesh(scene: Scene): Mesh;
  65347. /**
  65348. * Get a navigation mesh constrained position, closest to the parameter position
  65349. * @param position world position
  65350. * @returns the closest point to position constrained by the navigation mesh
  65351. */
  65352. getClosestPoint(position: Vector3): Vector3;
  65353. /**
  65354. * Get a navigation mesh constrained position, within a particular radius
  65355. * @param position world position
  65356. * @param maxRadius the maximum distance to the constrained world position
  65357. * @returns the closest point to position constrained by the navigation mesh
  65358. */
  65359. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65360. /**
  65361. * Compute the final position from a segment made of destination-position
  65362. * @param position world position
  65363. * @param destination world position
  65364. * @returns the resulting point along the navmesh
  65365. */
  65366. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65367. /**
  65368. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65369. * @param start world position
  65370. * @param end world position
  65371. * @returns array containing world position composing the path
  65372. */
  65373. computePath(start: Vector3, end: Vector3): Vector3[];
  65374. /**
  65375. * Create a new Crowd so you can add agents
  65376. * @param maxAgents the maximum agent count in the crowd
  65377. * @param maxAgentRadius the maximum radius an agent can have
  65378. * @param scene to attach the crowd to
  65379. * @returns the crowd you can add agents to
  65380. */
  65381. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65382. /**
  65383. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65384. * The queries will try to find a solution within those bounds
  65385. * default is (1,1,1)
  65386. * @param extent x,y,z value that define the extent around the queries point of reference
  65387. */
  65388. setDefaultQueryExtent(extent: Vector3): void;
  65389. /**
  65390. * Get the Bounding box extent specified by setDefaultQueryExtent
  65391. * @returns the box extent values
  65392. */
  65393. getDefaultQueryExtent(): Vector3;
  65394. /**
  65395. * Disposes
  65396. */
  65397. dispose(): void;
  65398. /**
  65399. * If this plugin is supported
  65400. * @returns true if plugin is supported
  65401. */
  65402. isSupported(): boolean;
  65403. }
  65404. /**
  65405. * Recast detour crowd implementation
  65406. */
  65407. export class RecastJSCrowd implements ICrowd {
  65408. /**
  65409. * Recast/detour plugin
  65410. */
  65411. bjsRECASTPlugin: RecastJSPlugin;
  65412. /**
  65413. * Link to the detour crowd
  65414. */
  65415. recastCrowd: any;
  65416. /**
  65417. * One transform per agent
  65418. */
  65419. transforms: TransformNode[];
  65420. /**
  65421. * All agents created
  65422. */
  65423. agents: number[];
  65424. /**
  65425. * Link to the scene is kept to unregister the crowd from the scene
  65426. */
  65427. private _scene;
  65428. /**
  65429. * Observer for crowd updates
  65430. */
  65431. private _onBeforeAnimationsObserver;
  65432. /**
  65433. * Constructor
  65434. * @param plugin recastJS plugin
  65435. * @param maxAgents the maximum agent count in the crowd
  65436. * @param maxAgentRadius the maximum radius an agent can have
  65437. * @param scene to attach the crowd to
  65438. * @returns the crowd you can add agents to
  65439. */
  65440. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  65441. /**
  65442. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65443. * You can attach anything to that node. The node position is updated in the scene update tick.
  65444. * @param pos world position that will be constrained by the navigation mesh
  65445. * @param parameters agent parameters
  65446. * @param transform hooked to the agent that will be update by the scene
  65447. * @returns agent index
  65448. */
  65449. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65450. /**
  65451. * Returns the agent position in world space
  65452. * @param index agent index returned by addAgent
  65453. * @returns world space position
  65454. */
  65455. getAgentPosition(index: number): Vector3;
  65456. /**
  65457. * Returns the agent velocity in world space
  65458. * @param index agent index returned by addAgent
  65459. * @returns world space velocity
  65460. */
  65461. getAgentVelocity(index: number): Vector3;
  65462. /**
  65463. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65464. * @param index agent index returned by addAgent
  65465. * @param destination targeted world position
  65466. */
  65467. agentGoto(index: number, destination: Vector3): void;
  65468. /**
  65469. * Teleport the agent to a new position
  65470. * @param index agent index returned by addAgent
  65471. * @param destination targeted world position
  65472. */
  65473. agentTeleport(index: number, destination: Vector3): void;
  65474. /**
  65475. * Update agent parameters
  65476. * @param index agent index returned by addAgent
  65477. * @param parameters agent parameters
  65478. */
  65479. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65480. /**
  65481. * remove a particular agent previously created
  65482. * @param index agent index returned by addAgent
  65483. */
  65484. removeAgent(index: number): void;
  65485. /**
  65486. * get the list of all agents attached to this crowd
  65487. * @returns list of agent indices
  65488. */
  65489. getAgents(): number[];
  65490. /**
  65491. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65492. * @param deltaTime in seconds
  65493. */
  65494. update(deltaTime: number): void;
  65495. /**
  65496. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65497. * The queries will try to find a solution within those bounds
  65498. * default is (1,1,1)
  65499. * @param extent x,y,z value that define the extent around the queries point of reference
  65500. */
  65501. setDefaultQueryExtent(extent: Vector3): void;
  65502. /**
  65503. * Get the Bounding box extent specified by setDefaultQueryExtent
  65504. * @returns the box extent values
  65505. */
  65506. getDefaultQueryExtent(): Vector3;
  65507. /**
  65508. * Release all resources
  65509. */
  65510. dispose(): void;
  65511. }
  65512. }
  65513. declare module "babylonjs/Navigation/Plugins/index" {
  65514. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  65515. }
  65516. declare module "babylonjs/Navigation/index" {
  65517. export * from "babylonjs/Navigation/INavigationEngine";
  65518. export * from "babylonjs/Navigation/Plugins/index";
  65519. }
  65520. declare module "babylonjs/Offline/database" {
  65521. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  65522. /**
  65523. * Class used to enable access to IndexedDB
  65524. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  65525. */
  65526. export class Database implements IOfflineProvider {
  65527. private _callbackManifestChecked;
  65528. private _currentSceneUrl;
  65529. private _db;
  65530. private _enableSceneOffline;
  65531. private _enableTexturesOffline;
  65532. private _manifestVersionFound;
  65533. private _mustUpdateRessources;
  65534. private _hasReachedQuota;
  65535. private _isSupported;
  65536. private _idbFactory;
  65537. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  65538. private static IsUASupportingBlobStorage;
  65539. /**
  65540. * Gets a boolean indicating if Database storate is enabled (off by default)
  65541. */
  65542. static IDBStorageEnabled: boolean;
  65543. /**
  65544. * Gets a boolean indicating if scene must be saved in the database
  65545. */
  65546. get enableSceneOffline(): boolean;
  65547. /**
  65548. * Gets a boolean indicating if textures must be saved in the database
  65549. */
  65550. get enableTexturesOffline(): boolean;
  65551. /**
  65552. * Creates a new Database
  65553. * @param urlToScene defines the url to load the scene
  65554. * @param callbackManifestChecked defines the callback to use when manifest is checked
  65555. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  65556. */
  65557. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  65558. private static _ParseURL;
  65559. private static _ReturnFullUrlLocation;
  65560. private _checkManifestFile;
  65561. /**
  65562. * Open the database and make it available
  65563. * @param successCallback defines the callback to call on success
  65564. * @param errorCallback defines the callback to call on error
  65565. */
  65566. open(successCallback: () => void, errorCallback: () => void): void;
  65567. /**
  65568. * Loads an image from the database
  65569. * @param url defines the url to load from
  65570. * @param image defines the target DOM image
  65571. */
  65572. loadImage(url: string, image: HTMLImageElement): void;
  65573. private _loadImageFromDBAsync;
  65574. private _saveImageIntoDBAsync;
  65575. private _checkVersionFromDB;
  65576. private _loadVersionFromDBAsync;
  65577. private _saveVersionIntoDBAsync;
  65578. /**
  65579. * Loads a file from database
  65580. * @param url defines the URL to load from
  65581. * @param sceneLoaded defines a callback to call on success
  65582. * @param progressCallBack defines a callback to call when progress changed
  65583. * @param errorCallback defines a callback to call on error
  65584. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  65585. */
  65586. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  65587. private _loadFileAsync;
  65588. private _saveFileAsync;
  65589. /**
  65590. * Validates if xhr data is correct
  65591. * @param xhr defines the request to validate
  65592. * @param dataType defines the expected data type
  65593. * @returns true if data is correct
  65594. */
  65595. private static _ValidateXHRData;
  65596. }
  65597. }
  65598. declare module "babylonjs/Offline/index" {
  65599. export * from "babylonjs/Offline/database";
  65600. export * from "babylonjs/Offline/IOfflineProvider";
  65601. }
  65602. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  65603. /** @hidden */
  65604. export var gpuUpdateParticlesPixelShader: {
  65605. name: string;
  65606. shader: string;
  65607. };
  65608. }
  65609. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  65610. /** @hidden */
  65611. export var gpuUpdateParticlesVertexShader: {
  65612. name: string;
  65613. shader: string;
  65614. };
  65615. }
  65616. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  65617. /** @hidden */
  65618. export var clipPlaneFragmentDeclaration2: {
  65619. name: string;
  65620. shader: string;
  65621. };
  65622. }
  65623. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  65624. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  65625. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  65626. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65627. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  65628. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  65629. /** @hidden */
  65630. export var gpuRenderParticlesPixelShader: {
  65631. name: string;
  65632. shader: string;
  65633. };
  65634. }
  65635. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  65636. /** @hidden */
  65637. export var clipPlaneVertexDeclaration2: {
  65638. name: string;
  65639. shader: string;
  65640. };
  65641. }
  65642. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  65643. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  65644. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  65645. /** @hidden */
  65646. export var gpuRenderParticlesVertexShader: {
  65647. name: string;
  65648. shader: string;
  65649. };
  65650. }
  65651. declare module "babylonjs/Particles/gpuParticleSystem" {
  65652. import { Nullable } from "babylonjs/types";
  65653. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  65654. import { Observable } from "babylonjs/Misc/observable";
  65655. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  65656. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65657. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  65658. import { Scene, IDisposable } from "babylonjs/scene";
  65659. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  65660. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  65661. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  65662. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  65663. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  65664. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  65665. /**
  65666. * This represents a GPU particle system in Babylon
  65667. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  65668. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  65669. */
  65670. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  65671. /**
  65672. * The layer mask we are rendering the particles through.
  65673. */
  65674. layerMask: number;
  65675. private _capacity;
  65676. private _activeCount;
  65677. private _currentActiveCount;
  65678. private _accumulatedCount;
  65679. private _renderEffect;
  65680. private _updateEffect;
  65681. private _buffer0;
  65682. private _buffer1;
  65683. private _spriteBuffer;
  65684. private _updateVAO;
  65685. private _renderVAO;
  65686. private _targetIndex;
  65687. private _sourceBuffer;
  65688. private _targetBuffer;
  65689. private _engine;
  65690. private _currentRenderId;
  65691. private _started;
  65692. private _stopped;
  65693. private _timeDelta;
  65694. private _randomTexture;
  65695. private _randomTexture2;
  65696. private _attributesStrideSize;
  65697. private _updateEffectOptions;
  65698. private _randomTextureSize;
  65699. private _actualFrame;
  65700. private readonly _rawTextureWidth;
  65701. /**
  65702. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  65703. */
  65704. static get IsSupported(): boolean;
  65705. /**
  65706. * An event triggered when the system is disposed.
  65707. */
  65708. onDisposeObservable: Observable<GPUParticleSystem>;
  65709. /**
  65710. * Gets the maximum number of particles active at the same time.
  65711. * @returns The max number of active particles.
  65712. */
  65713. getCapacity(): number;
  65714. /**
  65715. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  65716. * to override the particles.
  65717. */
  65718. forceDepthWrite: boolean;
  65719. /**
  65720. * Gets or set the number of active particles
  65721. */
  65722. get activeParticleCount(): number;
  65723. set activeParticleCount(value: number);
  65724. private _preWarmDone;
  65725. /**
  65726. * Is this system ready to be used/rendered
  65727. * @return true if the system is ready
  65728. */
  65729. isReady(): boolean;
  65730. /**
  65731. * Gets if the system has been started. (Note: this will still be true after stop is called)
  65732. * @returns True if it has been started, otherwise false.
  65733. */
  65734. isStarted(): boolean;
  65735. /**
  65736. * Starts the particle system and begins to emit
  65737. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  65738. */
  65739. start(delay?: number): void;
  65740. /**
  65741. * Stops the particle system.
  65742. */
  65743. stop(): void;
  65744. /**
  65745. * Remove all active particles
  65746. */
  65747. reset(): void;
  65748. /**
  65749. * Returns the string "GPUParticleSystem"
  65750. * @returns a string containing the class name
  65751. */
  65752. getClassName(): string;
  65753. private _colorGradientsTexture;
  65754. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  65755. /**
  65756. * Adds a new color gradient
  65757. * @param gradient defines the gradient to use (between 0 and 1)
  65758. * @param color1 defines the color to affect to the specified gradient
  65759. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  65760. * @returns the current particle system
  65761. */
  65762. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  65763. /**
  65764. * Remove a specific color gradient
  65765. * @param gradient defines the gradient to remove
  65766. * @returns the current particle system
  65767. */
  65768. removeColorGradient(gradient: number): GPUParticleSystem;
  65769. private _angularSpeedGradientsTexture;
  65770. private _sizeGradientsTexture;
  65771. private _velocityGradientsTexture;
  65772. private _limitVelocityGradientsTexture;
  65773. private _dragGradientsTexture;
  65774. private _addFactorGradient;
  65775. /**
  65776. * Adds a new size gradient
  65777. * @param gradient defines the gradient to use (between 0 and 1)
  65778. * @param factor defines the size factor to affect to the specified gradient
  65779. * @returns the current particle system
  65780. */
  65781. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  65782. /**
  65783. * Remove a specific size gradient
  65784. * @param gradient defines the gradient to remove
  65785. * @returns the current particle system
  65786. */
  65787. removeSizeGradient(gradient: number): GPUParticleSystem;
  65788. /**
  65789. * Adds a new angular speed gradient
  65790. * @param gradient defines the gradient to use (between 0 and 1)
  65791. * @param factor defines the angular speed to affect to the specified gradient
  65792. * @returns the current particle system
  65793. */
  65794. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  65795. /**
  65796. * Remove a specific angular speed gradient
  65797. * @param gradient defines the gradient to remove
  65798. * @returns the current particle system
  65799. */
  65800. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  65801. /**
  65802. * Adds a new velocity gradient
  65803. * @param gradient defines the gradient to use (between 0 and 1)
  65804. * @param factor defines the velocity to affect to the specified gradient
  65805. * @returns the current particle system
  65806. */
  65807. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65808. /**
  65809. * Remove a specific velocity gradient
  65810. * @param gradient defines the gradient to remove
  65811. * @returns the current particle system
  65812. */
  65813. removeVelocityGradient(gradient: number): GPUParticleSystem;
  65814. /**
  65815. * Adds a new limit velocity gradient
  65816. * @param gradient defines the gradient to use (between 0 and 1)
  65817. * @param factor defines the limit velocity value to affect to the specified gradient
  65818. * @returns the current particle system
  65819. */
  65820. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65821. /**
  65822. * Remove a specific limit velocity gradient
  65823. * @param gradient defines the gradient to remove
  65824. * @returns the current particle system
  65825. */
  65826. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  65827. /**
  65828. * Adds a new drag gradient
  65829. * @param gradient defines the gradient to use (between 0 and 1)
  65830. * @param factor defines the drag value to affect to the specified gradient
  65831. * @returns the current particle system
  65832. */
  65833. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  65834. /**
  65835. * Remove a specific drag gradient
  65836. * @param gradient defines the gradient to remove
  65837. * @returns the current particle system
  65838. */
  65839. removeDragGradient(gradient: number): GPUParticleSystem;
  65840. /**
  65841. * Not supported by GPUParticleSystem
  65842. * @param gradient defines the gradient to use (between 0 and 1)
  65843. * @param factor defines the emit rate value to affect to the specified gradient
  65844. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65845. * @returns the current particle system
  65846. */
  65847. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65848. /**
  65849. * Not supported by GPUParticleSystem
  65850. * @param gradient defines the gradient to remove
  65851. * @returns the current particle system
  65852. */
  65853. removeEmitRateGradient(gradient: number): IParticleSystem;
  65854. /**
  65855. * Not supported by GPUParticleSystem
  65856. * @param gradient defines the gradient to use (between 0 and 1)
  65857. * @param factor defines the start size value to affect to the specified gradient
  65858. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65859. * @returns the current particle system
  65860. */
  65861. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65862. /**
  65863. * Not supported by GPUParticleSystem
  65864. * @param gradient defines the gradient to remove
  65865. * @returns the current particle system
  65866. */
  65867. removeStartSizeGradient(gradient: number): IParticleSystem;
  65868. /**
  65869. * Not supported by GPUParticleSystem
  65870. * @param gradient defines the gradient to use (between 0 and 1)
  65871. * @param min defines the color remap minimal range
  65872. * @param max defines the color remap maximal range
  65873. * @returns the current particle system
  65874. */
  65875. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65876. /**
  65877. * Not supported by GPUParticleSystem
  65878. * @param gradient defines the gradient to remove
  65879. * @returns the current particle system
  65880. */
  65881. removeColorRemapGradient(): IParticleSystem;
  65882. /**
  65883. * Not supported by GPUParticleSystem
  65884. * @param gradient defines the gradient to use (between 0 and 1)
  65885. * @param min defines the alpha remap minimal range
  65886. * @param max defines the alpha remap maximal range
  65887. * @returns the current particle system
  65888. */
  65889. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65890. /**
  65891. * Not supported by GPUParticleSystem
  65892. * @param gradient defines the gradient to remove
  65893. * @returns the current particle system
  65894. */
  65895. removeAlphaRemapGradient(): IParticleSystem;
  65896. /**
  65897. * Not supported by GPUParticleSystem
  65898. * @param gradient defines the gradient to use (between 0 and 1)
  65899. * @param color defines the color to affect to the specified gradient
  65900. * @returns the current particle system
  65901. */
  65902. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  65903. /**
  65904. * Not supported by GPUParticleSystem
  65905. * @param gradient defines the gradient to remove
  65906. * @returns the current particle system
  65907. */
  65908. removeRampGradient(): IParticleSystem;
  65909. /**
  65910. * Not supported by GPUParticleSystem
  65911. * @returns the list of ramp gradients
  65912. */
  65913. getRampGradients(): Nullable<Array<Color3Gradient>>;
  65914. /**
  65915. * Not supported by GPUParticleSystem
  65916. * Gets or sets a boolean indicating that ramp gradients must be used
  65917. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  65918. */
  65919. get useRampGradients(): boolean;
  65920. set useRampGradients(value: boolean);
  65921. /**
  65922. * Not supported by GPUParticleSystem
  65923. * @param gradient defines the gradient to use (between 0 and 1)
  65924. * @param factor defines the life time factor to affect to the specified gradient
  65925. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65926. * @returns the current particle system
  65927. */
  65928. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65929. /**
  65930. * Not supported by GPUParticleSystem
  65931. * @param gradient defines the gradient to remove
  65932. * @returns the current particle system
  65933. */
  65934. removeLifeTimeGradient(gradient: number): IParticleSystem;
  65935. /**
  65936. * Instantiates a GPU particle system.
  65937. * 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.
  65938. * @param name The name of the particle system
  65939. * @param options The options used to create the system
  65940. * @param scene The scene the particle system belongs to
  65941. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  65942. */
  65943. constructor(name: string, options: Partial<{
  65944. capacity: number;
  65945. randomTextureSize: number;
  65946. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  65947. protected _reset(): void;
  65948. private _createUpdateVAO;
  65949. private _createRenderVAO;
  65950. private _initialize;
  65951. /** @hidden */
  65952. _recreateUpdateEffect(): void;
  65953. /** @hidden */
  65954. _recreateRenderEffect(): void;
  65955. /**
  65956. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  65957. * @param preWarm defines if we are in the pre-warmimg phase
  65958. */
  65959. animate(preWarm?: boolean): void;
  65960. private _createFactorGradientTexture;
  65961. private _createSizeGradientTexture;
  65962. private _createAngularSpeedGradientTexture;
  65963. private _createVelocityGradientTexture;
  65964. private _createLimitVelocityGradientTexture;
  65965. private _createDragGradientTexture;
  65966. private _createColorGradientTexture;
  65967. /**
  65968. * Renders the particle system in its current state
  65969. * @param preWarm defines if the system should only update the particles but not render them
  65970. * @returns the current number of particles
  65971. */
  65972. render(preWarm?: boolean): number;
  65973. /**
  65974. * Rebuilds the particle system
  65975. */
  65976. rebuild(): void;
  65977. private _releaseBuffers;
  65978. private _releaseVAOs;
  65979. /**
  65980. * Disposes the particle system and free the associated resources
  65981. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  65982. */
  65983. dispose(disposeTexture?: boolean): void;
  65984. /**
  65985. * Clones the particle system.
  65986. * @param name The name of the cloned object
  65987. * @param newEmitter The new emitter to use
  65988. * @returns the cloned particle system
  65989. */
  65990. clone(name: string, newEmitter: any): GPUParticleSystem;
  65991. /**
  65992. * Serializes the particle system to a JSON object.
  65993. * @returns the JSON object
  65994. */
  65995. serialize(): any;
  65996. /**
  65997. * Parses a JSON object to create a GPU particle system.
  65998. * @param parsedParticleSystem The JSON object to parse
  65999. * @param scene The scene to create the particle system in
  66000. * @param rootUrl The root url to use to load external dependencies like texture
  66001. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  66002. * @returns the parsed GPU particle system
  66003. */
  66004. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  66005. }
  66006. }
  66007. declare module "babylonjs/Particles/particleSystemSet" {
  66008. import { Nullable } from "babylonjs/types";
  66009. import { Color3 } from "babylonjs/Maths/math.color";
  66010. import { TransformNode } from "babylonjs/Meshes/transformNode";
  66011. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66012. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66013. import { Scene, IDisposable } from "babylonjs/scene";
  66014. /**
  66015. * Represents a set of particle systems working together to create a specific effect
  66016. */
  66017. export class ParticleSystemSet implements IDisposable {
  66018. /**
  66019. * Gets or sets base Assets URL
  66020. */
  66021. static BaseAssetsUrl: string;
  66022. private _emitterCreationOptions;
  66023. private _emitterNode;
  66024. /**
  66025. * Gets the particle system list
  66026. */
  66027. systems: IParticleSystem[];
  66028. /**
  66029. * Gets the emitter node used with this set
  66030. */
  66031. get emitterNode(): Nullable<TransformNode>;
  66032. /**
  66033. * Creates a new emitter mesh as a sphere
  66034. * @param options defines the options used to create the sphere
  66035. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  66036. * @param scene defines the hosting scene
  66037. */
  66038. setEmitterAsSphere(options: {
  66039. diameter: number;
  66040. segments: number;
  66041. color: Color3;
  66042. }, renderingGroupId: number, scene: Scene): void;
  66043. /**
  66044. * Starts all particle systems of the set
  66045. * @param emitter defines an optional mesh to use as emitter for the particle systems
  66046. */
  66047. start(emitter?: AbstractMesh): void;
  66048. /**
  66049. * Release all associated resources
  66050. */
  66051. dispose(): void;
  66052. /**
  66053. * Serialize the set into a JSON compatible object
  66054. * @returns a JSON compatible representation of the set
  66055. */
  66056. serialize(): any;
  66057. /**
  66058. * Parse a new ParticleSystemSet from a serialized source
  66059. * @param data defines a JSON compatible representation of the set
  66060. * @param scene defines the hosting scene
  66061. * @param gpu defines if we want GPU particles or CPU particles
  66062. * @returns a new ParticleSystemSet
  66063. */
  66064. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  66065. }
  66066. }
  66067. declare module "babylonjs/Particles/particleHelper" {
  66068. import { Nullable } from "babylonjs/types";
  66069. import { Scene } from "babylonjs/scene";
  66070. import { Vector3 } from "babylonjs/Maths/math.vector";
  66071. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66072. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66073. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  66074. /**
  66075. * This class is made for on one-liner static method to help creating particle system set.
  66076. */
  66077. export class ParticleHelper {
  66078. /**
  66079. * Gets or sets base Assets URL
  66080. */
  66081. static BaseAssetsUrl: string;
  66082. /**
  66083. * Create a default particle system that you can tweak
  66084. * @param emitter defines the emitter to use
  66085. * @param capacity defines the system capacity (default is 500 particles)
  66086. * @param scene defines the hosting scene
  66087. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  66088. * @returns the new Particle system
  66089. */
  66090. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  66091. /**
  66092. * This is the main static method (one-liner) of this helper to create different particle systems
  66093. * @param type This string represents the type to the particle system to create
  66094. * @param scene The scene where the particle system should live
  66095. * @param gpu If the system will use gpu
  66096. * @returns the ParticleSystemSet created
  66097. */
  66098. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  66099. /**
  66100. * Static function used to export a particle system to a ParticleSystemSet variable.
  66101. * Please note that the emitter shape is not exported
  66102. * @param systems defines the particle systems to export
  66103. * @returns the created particle system set
  66104. */
  66105. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  66106. }
  66107. }
  66108. declare module "babylonjs/Particles/particleSystemComponent" {
  66109. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66110. import { Effect } from "babylonjs/Materials/effect";
  66111. import "babylonjs/Shaders/particles.vertex";
  66112. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  66113. module "babylonjs/Engines/engine" {
  66114. interface Engine {
  66115. /**
  66116. * Create an effect to use with particle systems.
  66117. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  66118. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  66119. * @param uniformsNames defines a list of attribute names
  66120. * @param samplers defines an array of string used to represent textures
  66121. * @param defines defines the string containing the defines to use to compile the shaders
  66122. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  66123. * @param onCompiled defines a function to call when the effect creation is successful
  66124. * @param onError defines a function to call when the effect creation has failed
  66125. * @returns the new Effect
  66126. */
  66127. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  66128. }
  66129. }
  66130. module "babylonjs/Meshes/mesh" {
  66131. interface Mesh {
  66132. /**
  66133. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66134. * @returns an array of IParticleSystem
  66135. */
  66136. getEmittedParticleSystems(): IParticleSystem[];
  66137. /**
  66138. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66139. * @returns an array of IParticleSystem
  66140. */
  66141. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66142. }
  66143. }
  66144. /**
  66145. * @hidden
  66146. */
  66147. export var _IDoNeedToBeInTheBuild: number;
  66148. }
  66149. declare module "babylonjs/Particles/pointsCloudSystem" {
  66150. import { Color4 } from "babylonjs/Maths/math";
  66151. import { Mesh } from "babylonjs/Meshes/mesh";
  66152. import { Scene, IDisposable } from "babylonjs/scene";
  66153. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  66154. /** Defines the 4 color options */
  66155. export enum PointColor {
  66156. /** color value */
  66157. Color = 2,
  66158. /** uv value */
  66159. UV = 1,
  66160. /** random value */
  66161. Random = 0,
  66162. /** stated value */
  66163. Stated = 3
  66164. }
  66165. /**
  66166. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66167. * 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.
  66168. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66169. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66170. *
  66171. * Full documentation here : TO BE ENTERED
  66172. */
  66173. export class PointsCloudSystem implements IDisposable {
  66174. /**
  66175. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66176. * Example : var p = SPS.particles[i];
  66177. */
  66178. particles: CloudPoint[];
  66179. /**
  66180. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66181. */
  66182. nbParticles: number;
  66183. /**
  66184. * This a counter for your own usage. It's not set by any SPS functions.
  66185. */
  66186. counter: number;
  66187. /**
  66188. * The PCS name. This name is also given to the underlying mesh.
  66189. */
  66190. name: string;
  66191. /**
  66192. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66193. */
  66194. mesh: Mesh;
  66195. /**
  66196. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66197. * Please read :
  66198. */
  66199. vars: any;
  66200. /**
  66201. * @hidden
  66202. */
  66203. _size: number;
  66204. private _scene;
  66205. private _promises;
  66206. private _positions;
  66207. private _indices;
  66208. private _normals;
  66209. private _colors;
  66210. private _uvs;
  66211. private _indices32;
  66212. private _positions32;
  66213. private _colors32;
  66214. private _uvs32;
  66215. private _updatable;
  66216. private _isVisibilityBoxLocked;
  66217. private _alwaysVisible;
  66218. private _groups;
  66219. private _groupCounter;
  66220. private _computeParticleColor;
  66221. private _computeParticleTexture;
  66222. private _computeParticleRotation;
  66223. private _computeBoundingBox;
  66224. private _isReady;
  66225. /**
  66226. * Creates a PCS (Points Cloud System) object
  66227. * @param name (String) is the PCS name, this will be the underlying mesh name
  66228. * @param pointSize (number) is the size for each point
  66229. * @param scene (Scene) is the scene in which the PCS is added
  66230. * @param options defines the options of the PCS e.g.
  66231. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  66232. */
  66233. constructor(name: string, pointSize: number, scene: Scene, options?: {
  66234. updatable?: boolean;
  66235. });
  66236. /**
  66237. * Builds the PCS underlying mesh. Returns a standard Mesh.
  66238. * If no points were added to the PCS, the returned mesh is just a single point.
  66239. * @returns a promise for the created mesh
  66240. */
  66241. buildMeshAsync(): Promise<Mesh>;
  66242. /**
  66243. * @hidden
  66244. */
  66245. private _buildMesh;
  66246. private _addParticle;
  66247. private _randomUnitVector;
  66248. private _getColorIndicesForCoord;
  66249. private _setPointsColorOrUV;
  66250. private _colorFromTexture;
  66251. private _calculateDensity;
  66252. /**
  66253. * Adds points to the PCS in random positions within a unit sphere
  66254. * @param nb (positive integer) the number of particles to be created from this model
  66255. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  66256. * @returns the number of groups in the system
  66257. */
  66258. addPoints(nb: number, pointFunction?: any): number;
  66259. /**
  66260. * Adds points to the PCS from the surface of the model shape
  66261. * @param mesh is any Mesh object that will be used as a surface model for the points
  66262. * @param nb (positive integer) the number of particles to be created from this model
  66263. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66264. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66265. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66266. * @returns the number of groups in the system
  66267. */
  66268. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66269. /**
  66270. * Adds points to the PCS inside the model shape
  66271. * @param mesh is any Mesh object that will be used as a surface model for the points
  66272. * @param nb (positive integer) the number of particles to be created from this model
  66273. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66274. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66275. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66276. * @returns the number of groups in the system
  66277. */
  66278. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66279. /**
  66280. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  66281. * This method calls `updateParticle()` for each particle of the SPS.
  66282. * For an animated SPS, it is usually called within the render loop.
  66283. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  66284. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  66285. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  66286. * @returns the PCS.
  66287. */
  66288. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  66289. /**
  66290. * Disposes the PCS.
  66291. */
  66292. dispose(): void;
  66293. /**
  66294. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  66295. * doc :
  66296. * @returns the PCS.
  66297. */
  66298. refreshVisibleSize(): PointsCloudSystem;
  66299. /**
  66300. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  66301. * @param size the size (float) of the visibility box
  66302. * note : this doesn't lock the PCS mesh bounding box.
  66303. * doc :
  66304. */
  66305. setVisibilityBox(size: number): void;
  66306. /**
  66307. * Gets whether the PCS is always visible or not
  66308. * doc :
  66309. */
  66310. get isAlwaysVisible(): boolean;
  66311. /**
  66312. * Sets the PCS as always visible or not
  66313. * doc :
  66314. */
  66315. set isAlwaysVisible(val: boolean);
  66316. /**
  66317. * Tells to `setParticles()` to compute the particle rotations or not
  66318. * Default value : false. The PCS is faster when it's set to false
  66319. * Note : particle rotations are only applied to parent particles
  66320. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  66321. */
  66322. set computeParticleRotation(val: boolean);
  66323. /**
  66324. * Tells to `setParticles()` to compute the particle colors or not.
  66325. * Default value : true. The PCS is faster when it's set to false.
  66326. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66327. */
  66328. set computeParticleColor(val: boolean);
  66329. set computeParticleTexture(val: boolean);
  66330. /**
  66331. * Gets if `setParticles()` computes the particle colors or not.
  66332. * Default value : false. The PCS is faster when it's set to false.
  66333. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66334. */
  66335. get computeParticleColor(): boolean;
  66336. /**
  66337. * Gets if `setParticles()` computes the particle textures or not.
  66338. * Default value : false. The PCS is faster when it's set to false.
  66339. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  66340. */
  66341. get computeParticleTexture(): boolean;
  66342. /**
  66343. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  66344. */
  66345. set computeBoundingBox(val: boolean);
  66346. /**
  66347. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  66348. */
  66349. get computeBoundingBox(): boolean;
  66350. /**
  66351. * This function does nothing. It may be overwritten to set all the particle first values.
  66352. * The PCS doesn't call this function, you may have to call it by your own.
  66353. * doc :
  66354. */
  66355. initParticles(): void;
  66356. /**
  66357. * This function does nothing. It may be overwritten to recycle a particle
  66358. * The PCS doesn't call this function, you can to call it
  66359. * doc :
  66360. * @param particle The particle to recycle
  66361. * @returns the recycled particle
  66362. */
  66363. recycleParticle(particle: CloudPoint): CloudPoint;
  66364. /**
  66365. * Updates a particle : this function should be overwritten by the user.
  66366. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  66367. * doc :
  66368. * @example : just set a particle position or velocity and recycle conditions
  66369. * @param particle The particle to update
  66370. * @returns the updated particle
  66371. */
  66372. updateParticle(particle: CloudPoint): CloudPoint;
  66373. /**
  66374. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  66375. * This does nothing and may be overwritten by the user.
  66376. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66377. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66378. * @param update the boolean update value actually passed to setParticles()
  66379. */
  66380. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66381. /**
  66382. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  66383. * This will be passed three parameters.
  66384. * This does nothing and may be overwritten by the user.
  66385. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66386. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66387. * @param update the boolean update value actually passed to setParticles()
  66388. */
  66389. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66390. }
  66391. }
  66392. declare module "babylonjs/Particles/cloudPoint" {
  66393. import { Nullable } from "babylonjs/types";
  66394. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  66395. import { Mesh } from "babylonjs/Meshes/mesh";
  66396. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  66397. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  66398. /**
  66399. * Represents one particle of a points cloud system.
  66400. */
  66401. export class CloudPoint {
  66402. /**
  66403. * particle global index
  66404. */
  66405. idx: number;
  66406. /**
  66407. * The color of the particle
  66408. */
  66409. color: Nullable<Color4>;
  66410. /**
  66411. * The world space position of the particle.
  66412. */
  66413. position: Vector3;
  66414. /**
  66415. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  66416. */
  66417. rotation: Vector3;
  66418. /**
  66419. * The world space rotation quaternion of the particle.
  66420. */
  66421. rotationQuaternion: Nullable<Quaternion>;
  66422. /**
  66423. * The uv of the particle.
  66424. */
  66425. uv: Nullable<Vector2>;
  66426. /**
  66427. * The current speed of the particle.
  66428. */
  66429. velocity: Vector3;
  66430. /**
  66431. * The pivot point in the particle local space.
  66432. */
  66433. pivot: Vector3;
  66434. /**
  66435. * Must the particle be translated from its pivot point in its local space ?
  66436. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  66437. * Default : false
  66438. */
  66439. translateFromPivot: boolean;
  66440. /**
  66441. * Index of this particle in the global "positions" array (Internal use)
  66442. * @hidden
  66443. */
  66444. _pos: number;
  66445. /**
  66446. * @hidden Index of this particle in the global "indices" array (Internal use)
  66447. */
  66448. _ind: number;
  66449. /**
  66450. * Group this particle belongs to
  66451. */
  66452. _group: PointsGroup;
  66453. /**
  66454. * Group id of this particle
  66455. */
  66456. groupId: number;
  66457. /**
  66458. * Index of the particle in its group id (Internal use)
  66459. */
  66460. idxInGroup: number;
  66461. /**
  66462. * @hidden Particle BoundingInfo object (Internal use)
  66463. */
  66464. _boundingInfo: BoundingInfo;
  66465. /**
  66466. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  66467. */
  66468. _pcs: PointsCloudSystem;
  66469. /**
  66470. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  66471. */
  66472. _stillInvisible: boolean;
  66473. /**
  66474. * @hidden Last computed particle rotation matrix
  66475. */
  66476. _rotationMatrix: number[];
  66477. /**
  66478. * Parent particle Id, if any.
  66479. * Default null.
  66480. */
  66481. parentId: Nullable<number>;
  66482. /**
  66483. * @hidden Internal global position in the PCS.
  66484. */
  66485. _globalPosition: Vector3;
  66486. /**
  66487. * Creates a Point Cloud object.
  66488. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  66489. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  66490. * @param group (PointsGroup) is the group the particle belongs to
  66491. * @param groupId (integer) is the group identifier in the PCS.
  66492. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  66493. * @param pcs defines the PCS it is associated to
  66494. */
  66495. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  66496. /**
  66497. * get point size
  66498. */
  66499. get size(): Vector3;
  66500. /**
  66501. * Set point size
  66502. */
  66503. set size(scale: Vector3);
  66504. /**
  66505. * Legacy support, changed quaternion to rotationQuaternion
  66506. */
  66507. get quaternion(): Nullable<Quaternion>;
  66508. /**
  66509. * Legacy support, changed quaternion to rotationQuaternion
  66510. */
  66511. set quaternion(q: Nullable<Quaternion>);
  66512. /**
  66513. * Returns a boolean. True if the particle intersects a mesh, else false
  66514. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  66515. * @param target is the object (point or mesh) what the intersection is computed against
  66516. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  66517. * @returns true if it intersects
  66518. */
  66519. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  66520. /**
  66521. * get the rotation matrix of the particle
  66522. * @hidden
  66523. */
  66524. getRotationMatrix(m: Matrix): void;
  66525. }
  66526. /**
  66527. * Represents a group of points in a points cloud system
  66528. * * PCS internal tool, don't use it manually.
  66529. */
  66530. export class PointsGroup {
  66531. /**
  66532. * The group id
  66533. * @hidden
  66534. */
  66535. groupID: number;
  66536. /**
  66537. * image data for group (internal use)
  66538. * @hidden
  66539. */
  66540. _groupImageData: Nullable<ArrayBufferView>;
  66541. /**
  66542. * Image Width (internal use)
  66543. * @hidden
  66544. */
  66545. _groupImgWidth: number;
  66546. /**
  66547. * Image Height (internal use)
  66548. * @hidden
  66549. */
  66550. _groupImgHeight: number;
  66551. /**
  66552. * Custom position function (internal use)
  66553. * @hidden
  66554. */
  66555. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  66556. /**
  66557. * density per facet for surface points
  66558. * @hidden
  66559. */
  66560. _groupDensity: number[];
  66561. /**
  66562. * Only when points are colored by texture carries pointer to texture list array
  66563. * @hidden
  66564. */
  66565. _textureNb: number;
  66566. /**
  66567. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  66568. * PCS internal tool, don't use it manually.
  66569. * @hidden
  66570. */
  66571. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  66572. }
  66573. }
  66574. declare module "babylonjs/Particles/index" {
  66575. export * from "babylonjs/Particles/baseParticleSystem";
  66576. export * from "babylonjs/Particles/EmitterTypes/index";
  66577. export * from "babylonjs/Particles/gpuParticleSystem";
  66578. export * from "babylonjs/Particles/IParticleSystem";
  66579. export * from "babylonjs/Particles/particle";
  66580. export * from "babylonjs/Particles/particleHelper";
  66581. export * from "babylonjs/Particles/particleSystem";
  66582. export * from "babylonjs/Particles/particleSystemComponent";
  66583. export * from "babylonjs/Particles/particleSystemSet";
  66584. export * from "babylonjs/Particles/solidParticle";
  66585. export * from "babylonjs/Particles/solidParticleSystem";
  66586. export * from "babylonjs/Particles/cloudPoint";
  66587. export * from "babylonjs/Particles/pointsCloudSystem";
  66588. export * from "babylonjs/Particles/subEmitter";
  66589. }
  66590. declare module "babylonjs/Physics/physicsEngineComponent" {
  66591. import { Nullable } from "babylonjs/types";
  66592. import { Observable, Observer } from "babylonjs/Misc/observable";
  66593. import { Vector3 } from "babylonjs/Maths/math.vector";
  66594. import { Mesh } from "babylonjs/Meshes/mesh";
  66595. import { ISceneComponent } from "babylonjs/sceneComponent";
  66596. import { Scene } from "babylonjs/scene";
  66597. import { Node } from "babylonjs/node";
  66598. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  66599. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  66600. module "babylonjs/scene" {
  66601. interface Scene {
  66602. /** @hidden (Backing field) */
  66603. _physicsEngine: Nullable<IPhysicsEngine>;
  66604. /** @hidden */
  66605. _physicsTimeAccumulator: number;
  66606. /**
  66607. * Gets the current physics engine
  66608. * @returns a IPhysicsEngine or null if none attached
  66609. */
  66610. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  66611. /**
  66612. * Enables physics to the current scene
  66613. * @param gravity defines the scene's gravity for the physics engine
  66614. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  66615. * @return a boolean indicating if the physics engine was initialized
  66616. */
  66617. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  66618. /**
  66619. * Disables and disposes the physics engine associated with the scene
  66620. */
  66621. disablePhysicsEngine(): void;
  66622. /**
  66623. * Gets a boolean indicating if there is an active physics engine
  66624. * @returns a boolean indicating if there is an active physics engine
  66625. */
  66626. isPhysicsEnabled(): boolean;
  66627. /**
  66628. * Deletes a physics compound impostor
  66629. * @param compound defines the compound to delete
  66630. */
  66631. deleteCompoundImpostor(compound: any): void;
  66632. /**
  66633. * An event triggered when physic simulation is about to be run
  66634. */
  66635. onBeforePhysicsObservable: Observable<Scene>;
  66636. /**
  66637. * An event triggered when physic simulation has been done
  66638. */
  66639. onAfterPhysicsObservable: Observable<Scene>;
  66640. }
  66641. }
  66642. module "babylonjs/Meshes/abstractMesh" {
  66643. interface AbstractMesh {
  66644. /** @hidden */
  66645. _physicsImpostor: Nullable<PhysicsImpostor>;
  66646. /**
  66647. * Gets or sets impostor used for physic simulation
  66648. * @see http://doc.babylonjs.com/features/physics_engine
  66649. */
  66650. physicsImpostor: Nullable<PhysicsImpostor>;
  66651. /**
  66652. * Gets the current physics impostor
  66653. * @see http://doc.babylonjs.com/features/physics_engine
  66654. * @returns a physics impostor or null
  66655. */
  66656. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  66657. /** Apply a physic impulse to the mesh
  66658. * @param force defines the force to apply
  66659. * @param contactPoint defines where to apply the force
  66660. * @returns the current mesh
  66661. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  66662. */
  66663. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  66664. /**
  66665. * Creates a physic joint between two meshes
  66666. * @param otherMesh defines the other mesh to use
  66667. * @param pivot1 defines the pivot to use on this mesh
  66668. * @param pivot2 defines the pivot to use on the other mesh
  66669. * @param options defines additional options (can be plugin dependent)
  66670. * @returns the current mesh
  66671. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  66672. */
  66673. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  66674. /** @hidden */
  66675. _disposePhysicsObserver: Nullable<Observer<Node>>;
  66676. }
  66677. }
  66678. /**
  66679. * Defines the physics engine scene component responsible to manage a physics engine
  66680. */
  66681. export class PhysicsEngineSceneComponent implements ISceneComponent {
  66682. /**
  66683. * The component name helpful to identify the component in the list of scene components.
  66684. */
  66685. readonly name: string;
  66686. /**
  66687. * The scene the component belongs to.
  66688. */
  66689. scene: Scene;
  66690. /**
  66691. * Creates a new instance of the component for the given scene
  66692. * @param scene Defines the scene to register the component in
  66693. */
  66694. constructor(scene: Scene);
  66695. /**
  66696. * Registers the component in a given scene
  66697. */
  66698. register(): void;
  66699. /**
  66700. * Rebuilds the elements related to this component in case of
  66701. * context lost for instance.
  66702. */
  66703. rebuild(): void;
  66704. /**
  66705. * Disposes the component and the associated ressources
  66706. */
  66707. dispose(): void;
  66708. }
  66709. }
  66710. declare module "babylonjs/Physics/physicsHelper" {
  66711. import { Nullable } from "babylonjs/types";
  66712. import { Vector3 } from "babylonjs/Maths/math.vector";
  66713. import { Mesh } from "babylonjs/Meshes/mesh";
  66714. import { Scene } from "babylonjs/scene";
  66715. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  66716. /**
  66717. * A helper for physics simulations
  66718. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66719. */
  66720. export class PhysicsHelper {
  66721. private _scene;
  66722. private _physicsEngine;
  66723. /**
  66724. * Initializes the Physics helper
  66725. * @param scene Babylon.js scene
  66726. */
  66727. constructor(scene: Scene);
  66728. /**
  66729. * Applies a radial explosion impulse
  66730. * @param origin the origin of the explosion
  66731. * @param radiusOrEventOptions the radius or the options of radial explosion
  66732. * @param strength the explosion strength
  66733. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66734. * @returns A physics radial explosion event, or null
  66735. */
  66736. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66737. /**
  66738. * Applies a radial explosion force
  66739. * @param origin the origin of the explosion
  66740. * @param radiusOrEventOptions the radius or the options of radial explosion
  66741. * @param strength the explosion strength
  66742. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66743. * @returns A physics radial explosion event, or null
  66744. */
  66745. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66746. /**
  66747. * Creates a gravitational field
  66748. * @param origin the origin of the explosion
  66749. * @param radiusOrEventOptions the radius or the options of radial explosion
  66750. * @param strength the explosion strength
  66751. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66752. * @returns A physics gravitational field event, or null
  66753. */
  66754. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  66755. /**
  66756. * Creates a physics updraft event
  66757. * @param origin the origin of the updraft
  66758. * @param radiusOrEventOptions the radius or the options of the updraft
  66759. * @param strength the strength of the updraft
  66760. * @param height the height of the updraft
  66761. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  66762. * @returns A physics updraft event, or null
  66763. */
  66764. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  66765. /**
  66766. * Creates a physics vortex event
  66767. * @param origin the of the vortex
  66768. * @param radiusOrEventOptions the radius or the options of the vortex
  66769. * @param strength the strength of the vortex
  66770. * @param height the height of the vortex
  66771. * @returns a Physics vortex event, or null
  66772. * A physics vortex event or null
  66773. */
  66774. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  66775. }
  66776. /**
  66777. * Represents a physics radial explosion event
  66778. */
  66779. class PhysicsRadialExplosionEvent {
  66780. private _scene;
  66781. private _options;
  66782. private _sphere;
  66783. private _dataFetched;
  66784. /**
  66785. * Initializes a radial explosioin event
  66786. * @param _scene BabylonJS scene
  66787. * @param _options The options for the vortex event
  66788. */
  66789. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  66790. /**
  66791. * Returns the data related to the radial explosion event (sphere).
  66792. * @returns The radial explosion event data
  66793. */
  66794. getData(): PhysicsRadialExplosionEventData;
  66795. /**
  66796. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  66797. * @param impostor A physics imposter
  66798. * @param origin the origin of the explosion
  66799. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  66800. */
  66801. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  66802. /**
  66803. * Triggers affecterd impostors callbacks
  66804. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  66805. */
  66806. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  66807. /**
  66808. * Disposes the sphere.
  66809. * @param force Specifies if the sphere should be disposed by force
  66810. */
  66811. dispose(force?: boolean): void;
  66812. /*** Helpers ***/
  66813. private _prepareSphere;
  66814. private _intersectsWithSphere;
  66815. }
  66816. /**
  66817. * Represents a gravitational field event
  66818. */
  66819. class PhysicsGravitationalFieldEvent {
  66820. private _physicsHelper;
  66821. private _scene;
  66822. private _origin;
  66823. private _options;
  66824. private _tickCallback;
  66825. private _sphere;
  66826. private _dataFetched;
  66827. /**
  66828. * Initializes the physics gravitational field event
  66829. * @param _physicsHelper A physics helper
  66830. * @param _scene BabylonJS scene
  66831. * @param _origin The origin position of the gravitational field event
  66832. * @param _options The options for the vortex event
  66833. */
  66834. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  66835. /**
  66836. * Returns the data related to the gravitational field event (sphere).
  66837. * @returns A gravitational field event
  66838. */
  66839. getData(): PhysicsGravitationalFieldEventData;
  66840. /**
  66841. * Enables the gravitational field.
  66842. */
  66843. enable(): void;
  66844. /**
  66845. * Disables the gravitational field.
  66846. */
  66847. disable(): void;
  66848. /**
  66849. * Disposes the sphere.
  66850. * @param force The force to dispose from the gravitational field event
  66851. */
  66852. dispose(force?: boolean): void;
  66853. private _tick;
  66854. }
  66855. /**
  66856. * Represents a physics updraft event
  66857. */
  66858. class PhysicsUpdraftEvent {
  66859. private _scene;
  66860. private _origin;
  66861. private _options;
  66862. private _physicsEngine;
  66863. private _originTop;
  66864. private _originDirection;
  66865. private _tickCallback;
  66866. private _cylinder;
  66867. private _cylinderPosition;
  66868. private _dataFetched;
  66869. /**
  66870. * Initializes the physics updraft event
  66871. * @param _scene BabylonJS scene
  66872. * @param _origin The origin position of the updraft
  66873. * @param _options The options for the updraft event
  66874. */
  66875. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  66876. /**
  66877. * Returns the data related to the updraft event (cylinder).
  66878. * @returns A physics updraft event
  66879. */
  66880. getData(): PhysicsUpdraftEventData;
  66881. /**
  66882. * Enables the updraft.
  66883. */
  66884. enable(): void;
  66885. /**
  66886. * Disables the updraft.
  66887. */
  66888. disable(): void;
  66889. /**
  66890. * Disposes the cylinder.
  66891. * @param force Specifies if the updraft should be disposed by force
  66892. */
  66893. dispose(force?: boolean): void;
  66894. private getImpostorHitData;
  66895. private _tick;
  66896. /*** Helpers ***/
  66897. private _prepareCylinder;
  66898. private _intersectsWithCylinder;
  66899. }
  66900. /**
  66901. * Represents a physics vortex event
  66902. */
  66903. class PhysicsVortexEvent {
  66904. private _scene;
  66905. private _origin;
  66906. private _options;
  66907. private _physicsEngine;
  66908. private _originTop;
  66909. private _tickCallback;
  66910. private _cylinder;
  66911. private _cylinderPosition;
  66912. private _dataFetched;
  66913. /**
  66914. * Initializes the physics vortex event
  66915. * @param _scene The BabylonJS scene
  66916. * @param _origin The origin position of the vortex
  66917. * @param _options The options for the vortex event
  66918. */
  66919. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  66920. /**
  66921. * Returns the data related to the vortex event (cylinder).
  66922. * @returns The physics vortex event data
  66923. */
  66924. getData(): PhysicsVortexEventData;
  66925. /**
  66926. * Enables the vortex.
  66927. */
  66928. enable(): void;
  66929. /**
  66930. * Disables the cortex.
  66931. */
  66932. disable(): void;
  66933. /**
  66934. * Disposes the sphere.
  66935. * @param force
  66936. */
  66937. dispose(force?: boolean): void;
  66938. private getImpostorHitData;
  66939. private _tick;
  66940. /*** Helpers ***/
  66941. private _prepareCylinder;
  66942. private _intersectsWithCylinder;
  66943. }
  66944. /**
  66945. * Options fot the radial explosion event
  66946. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66947. */
  66948. export class PhysicsRadialExplosionEventOptions {
  66949. /**
  66950. * The radius of the sphere for the radial explosion.
  66951. */
  66952. radius: number;
  66953. /**
  66954. * The strenth of the explosion.
  66955. */
  66956. strength: number;
  66957. /**
  66958. * The strenght of the force in correspondence to the distance of the affected object
  66959. */
  66960. falloff: PhysicsRadialImpulseFalloff;
  66961. /**
  66962. * Sphere options for the radial explosion.
  66963. */
  66964. sphere: {
  66965. segments: number;
  66966. diameter: number;
  66967. };
  66968. /**
  66969. * Sphere options for the radial explosion.
  66970. */
  66971. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  66972. }
  66973. /**
  66974. * Options fot the updraft event
  66975. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66976. */
  66977. export class PhysicsUpdraftEventOptions {
  66978. /**
  66979. * The radius of the cylinder for the vortex
  66980. */
  66981. radius: number;
  66982. /**
  66983. * The strenth of the updraft.
  66984. */
  66985. strength: number;
  66986. /**
  66987. * The height of the cylinder for the updraft.
  66988. */
  66989. height: number;
  66990. /**
  66991. * The mode for the the updraft.
  66992. */
  66993. updraftMode: PhysicsUpdraftMode;
  66994. }
  66995. /**
  66996. * Options fot the vortex event
  66997. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66998. */
  66999. export class PhysicsVortexEventOptions {
  67000. /**
  67001. * The radius of the cylinder for the vortex
  67002. */
  67003. radius: number;
  67004. /**
  67005. * The strenth of the vortex.
  67006. */
  67007. strength: number;
  67008. /**
  67009. * The height of the cylinder for the vortex.
  67010. */
  67011. height: number;
  67012. /**
  67013. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  67014. */
  67015. centripetalForceThreshold: number;
  67016. /**
  67017. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  67018. */
  67019. centripetalForceMultiplier: number;
  67020. /**
  67021. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  67022. */
  67023. centrifugalForceMultiplier: number;
  67024. /**
  67025. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  67026. */
  67027. updraftForceMultiplier: number;
  67028. }
  67029. /**
  67030. * The strenght of the force in correspondence to the distance of the affected object
  67031. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67032. */
  67033. export enum PhysicsRadialImpulseFalloff {
  67034. /** Defines that impulse is constant in strength across it's whole radius */
  67035. Constant = 0,
  67036. /** Defines that impulse gets weaker if it's further from the origin */
  67037. Linear = 1
  67038. }
  67039. /**
  67040. * The strength of the force in correspondence to the distance of the affected object
  67041. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67042. */
  67043. export enum PhysicsUpdraftMode {
  67044. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  67045. Center = 0,
  67046. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  67047. Perpendicular = 1
  67048. }
  67049. /**
  67050. * Interface for a physics hit data
  67051. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67052. */
  67053. export interface PhysicsHitData {
  67054. /**
  67055. * The force applied at the contact point
  67056. */
  67057. force: Vector3;
  67058. /**
  67059. * The contact point
  67060. */
  67061. contactPoint: Vector3;
  67062. /**
  67063. * The distance from the origin to the contact point
  67064. */
  67065. distanceFromOrigin: number;
  67066. }
  67067. /**
  67068. * Interface for radial explosion event data
  67069. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67070. */
  67071. export interface PhysicsRadialExplosionEventData {
  67072. /**
  67073. * A sphere used for the radial explosion event
  67074. */
  67075. sphere: Mesh;
  67076. }
  67077. /**
  67078. * Interface for gravitational field event data
  67079. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67080. */
  67081. export interface PhysicsGravitationalFieldEventData {
  67082. /**
  67083. * A sphere mesh used for the gravitational field event
  67084. */
  67085. sphere: Mesh;
  67086. }
  67087. /**
  67088. * Interface for updraft event data
  67089. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67090. */
  67091. export interface PhysicsUpdraftEventData {
  67092. /**
  67093. * A cylinder used for the updraft event
  67094. */
  67095. cylinder: Mesh;
  67096. }
  67097. /**
  67098. * Interface for vortex event data
  67099. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67100. */
  67101. export interface PhysicsVortexEventData {
  67102. /**
  67103. * A cylinder used for the vortex event
  67104. */
  67105. cylinder: Mesh;
  67106. }
  67107. /**
  67108. * Interface for an affected physics impostor
  67109. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67110. */
  67111. export interface PhysicsAffectedImpostorWithData {
  67112. /**
  67113. * The impostor affected by the effect
  67114. */
  67115. impostor: PhysicsImpostor;
  67116. /**
  67117. * The data about the hit/horce from the explosion
  67118. */
  67119. hitData: PhysicsHitData;
  67120. }
  67121. }
  67122. declare module "babylonjs/Physics/Plugins/index" {
  67123. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  67124. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  67125. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  67126. }
  67127. declare module "babylonjs/Physics/index" {
  67128. export * from "babylonjs/Physics/IPhysicsEngine";
  67129. export * from "babylonjs/Physics/physicsEngine";
  67130. export * from "babylonjs/Physics/physicsEngineComponent";
  67131. export * from "babylonjs/Physics/physicsHelper";
  67132. export * from "babylonjs/Physics/physicsImpostor";
  67133. export * from "babylonjs/Physics/physicsJoint";
  67134. export * from "babylonjs/Physics/Plugins/index";
  67135. }
  67136. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  67137. /** @hidden */
  67138. export var blackAndWhitePixelShader: {
  67139. name: string;
  67140. shader: string;
  67141. };
  67142. }
  67143. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  67144. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67145. import { Camera } from "babylonjs/Cameras/camera";
  67146. import { Engine } from "babylonjs/Engines/engine";
  67147. import "babylonjs/Shaders/blackAndWhite.fragment";
  67148. /**
  67149. * Post process used to render in black and white
  67150. */
  67151. export class BlackAndWhitePostProcess extends PostProcess {
  67152. /**
  67153. * Linear about to convert he result to black and white (default: 1)
  67154. */
  67155. degree: number;
  67156. /**
  67157. * Creates a black and white post process
  67158. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67159. * @param name The name of the effect.
  67160. * @param options The required width/height ratio to downsize to before computing the render pass.
  67161. * @param camera The camera to apply the render pass to.
  67162. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67163. * @param engine The engine which the post process will be applied. (default: current engine)
  67164. * @param reusable If the post process can be reused on the same frame. (default: false)
  67165. */
  67166. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67167. }
  67168. }
  67169. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  67170. import { Nullable } from "babylonjs/types";
  67171. import { Camera } from "babylonjs/Cameras/camera";
  67172. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67173. import { Engine } from "babylonjs/Engines/engine";
  67174. /**
  67175. * This represents a set of one or more post processes in Babylon.
  67176. * A post process can be used to apply a shader to a texture after it is rendered.
  67177. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67178. */
  67179. export class PostProcessRenderEffect {
  67180. private _postProcesses;
  67181. private _getPostProcesses;
  67182. private _singleInstance;
  67183. private _cameras;
  67184. private _indicesForCamera;
  67185. /**
  67186. * Name of the effect
  67187. * @hidden
  67188. */
  67189. _name: string;
  67190. /**
  67191. * Instantiates a post process render effect.
  67192. * A post process can be used to apply a shader to a texture after it is rendered.
  67193. * @param engine The engine the effect is tied to
  67194. * @param name The name of the effect
  67195. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  67196. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  67197. */
  67198. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67199. /**
  67200. * Checks if all the post processes in the effect are supported.
  67201. */
  67202. get isSupported(): boolean;
  67203. /**
  67204. * Updates the current state of the effect
  67205. * @hidden
  67206. */
  67207. _update(): void;
  67208. /**
  67209. * Attaches the effect on cameras
  67210. * @param cameras The camera to attach to.
  67211. * @hidden
  67212. */
  67213. _attachCameras(cameras: Camera): void;
  67214. /**
  67215. * Attaches the effect on cameras
  67216. * @param cameras The camera to attach to.
  67217. * @hidden
  67218. */
  67219. _attachCameras(cameras: Camera[]): void;
  67220. /**
  67221. * Detaches the effect on cameras
  67222. * @param cameras The camera to detatch from.
  67223. * @hidden
  67224. */
  67225. _detachCameras(cameras: Camera): void;
  67226. /**
  67227. * Detatches the effect on cameras
  67228. * @param cameras The camera to detatch from.
  67229. * @hidden
  67230. */
  67231. _detachCameras(cameras: Camera[]): void;
  67232. /**
  67233. * Enables the effect on given cameras
  67234. * @param cameras The camera to enable.
  67235. * @hidden
  67236. */
  67237. _enable(cameras: Camera): void;
  67238. /**
  67239. * Enables the effect on given cameras
  67240. * @param cameras The camera to enable.
  67241. * @hidden
  67242. */
  67243. _enable(cameras: Nullable<Camera[]>): void;
  67244. /**
  67245. * Disables the effect on the given cameras
  67246. * @param cameras The camera to disable.
  67247. * @hidden
  67248. */
  67249. _disable(cameras: Camera): void;
  67250. /**
  67251. * Disables the effect on the given cameras
  67252. * @param cameras The camera to disable.
  67253. * @hidden
  67254. */
  67255. _disable(cameras: Nullable<Camera[]>): void;
  67256. /**
  67257. * Gets a list of the post processes contained in the effect.
  67258. * @param camera The camera to get the post processes on.
  67259. * @returns The list of the post processes in the effect.
  67260. */
  67261. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  67262. }
  67263. }
  67264. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  67265. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67266. /** @hidden */
  67267. export var extractHighlightsPixelShader: {
  67268. name: string;
  67269. shader: string;
  67270. };
  67271. }
  67272. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  67273. import { Nullable } from "babylonjs/types";
  67274. import { Camera } from "babylonjs/Cameras/camera";
  67275. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67276. import { Engine } from "babylonjs/Engines/engine";
  67277. import "babylonjs/Shaders/extractHighlights.fragment";
  67278. /**
  67279. * 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.
  67280. */
  67281. export class ExtractHighlightsPostProcess extends PostProcess {
  67282. /**
  67283. * The luminance threshold, pixels below this value will be set to black.
  67284. */
  67285. threshold: number;
  67286. /** @hidden */
  67287. _exposure: number;
  67288. /**
  67289. * Post process which has the input texture to be used when performing highlight extraction
  67290. * @hidden
  67291. */
  67292. _inputPostProcess: Nullable<PostProcess>;
  67293. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67294. }
  67295. }
  67296. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  67297. /** @hidden */
  67298. export var bloomMergePixelShader: {
  67299. name: string;
  67300. shader: string;
  67301. };
  67302. }
  67303. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  67304. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67305. import { Nullable } from "babylonjs/types";
  67306. import { Engine } from "babylonjs/Engines/engine";
  67307. import { Camera } from "babylonjs/Cameras/camera";
  67308. import "babylonjs/Shaders/bloomMerge.fragment";
  67309. /**
  67310. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67311. */
  67312. export class BloomMergePostProcess extends PostProcess {
  67313. /** Weight of the bloom to be added to the original input. */
  67314. weight: number;
  67315. /**
  67316. * Creates a new instance of @see BloomMergePostProcess
  67317. * @param name The name of the effect.
  67318. * @param originalFromInput Post process which's input will be used for the merge.
  67319. * @param blurred Blurred highlights post process which's output will be used.
  67320. * @param weight Weight of the bloom to be added to the original input.
  67321. * @param options The required width/height ratio to downsize to before computing the render pass.
  67322. * @param camera The camera to apply the render pass to.
  67323. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67324. * @param engine The engine which the post process will be applied. (default: current engine)
  67325. * @param reusable If the post process can be reused on the same frame. (default: false)
  67326. * @param textureType Type of textures used when performing the post process. (default: 0)
  67327. * @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)
  67328. */
  67329. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  67330. /** Weight of the bloom to be added to the original input. */
  67331. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67332. }
  67333. }
  67334. declare module "babylonjs/PostProcesses/bloomEffect" {
  67335. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67336. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67337. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  67338. import { Camera } from "babylonjs/Cameras/camera";
  67339. import { Scene } from "babylonjs/scene";
  67340. /**
  67341. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  67342. */
  67343. export class BloomEffect extends PostProcessRenderEffect {
  67344. private bloomScale;
  67345. /**
  67346. * @hidden Internal
  67347. */
  67348. _effects: Array<PostProcess>;
  67349. /**
  67350. * @hidden Internal
  67351. */
  67352. _downscale: ExtractHighlightsPostProcess;
  67353. private _blurX;
  67354. private _blurY;
  67355. private _merge;
  67356. /**
  67357. * The luminance threshold to find bright areas of the image to bloom.
  67358. */
  67359. get threshold(): number;
  67360. set threshold(value: number);
  67361. /**
  67362. * The strength of the bloom.
  67363. */
  67364. get weight(): number;
  67365. set weight(value: number);
  67366. /**
  67367. * Specifies the size of the bloom blur kernel, relative to the final output size
  67368. */
  67369. get kernel(): number;
  67370. set kernel(value: number);
  67371. /**
  67372. * Creates a new instance of @see BloomEffect
  67373. * @param scene The scene the effect belongs to.
  67374. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  67375. * @param bloomKernel The size of the kernel to be used when applying the blur.
  67376. * @param bloomWeight The the strength of bloom.
  67377. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67378. * @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)
  67379. */
  67380. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  67381. /**
  67382. * Disposes each of the internal effects for a given camera.
  67383. * @param camera The camera to dispose the effect on.
  67384. */
  67385. disposeEffects(camera: Camera): void;
  67386. /**
  67387. * @hidden Internal
  67388. */
  67389. _updateEffects(): void;
  67390. /**
  67391. * Internal
  67392. * @returns if all the contained post processes are ready.
  67393. * @hidden
  67394. */
  67395. _isReady(): boolean;
  67396. }
  67397. }
  67398. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  67399. /** @hidden */
  67400. export var chromaticAberrationPixelShader: {
  67401. name: string;
  67402. shader: string;
  67403. };
  67404. }
  67405. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  67406. import { Vector2 } from "babylonjs/Maths/math.vector";
  67407. import { Nullable } from "babylonjs/types";
  67408. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67409. import { Camera } from "babylonjs/Cameras/camera";
  67410. import { Engine } from "babylonjs/Engines/engine";
  67411. import "babylonjs/Shaders/chromaticAberration.fragment";
  67412. /**
  67413. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  67414. */
  67415. export class ChromaticAberrationPostProcess extends PostProcess {
  67416. /**
  67417. * The amount of seperation of rgb channels (default: 30)
  67418. */
  67419. aberrationAmount: number;
  67420. /**
  67421. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  67422. */
  67423. radialIntensity: number;
  67424. /**
  67425. * 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))
  67426. */
  67427. direction: Vector2;
  67428. /**
  67429. * 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))
  67430. */
  67431. centerPosition: Vector2;
  67432. /**
  67433. * Creates a new instance ChromaticAberrationPostProcess
  67434. * @param name The name of the effect.
  67435. * @param screenWidth The width of the screen to apply the effect on.
  67436. * @param screenHeight The height of the screen to apply the effect on.
  67437. * @param options The required width/height ratio to downsize to before computing the render pass.
  67438. * @param camera The camera to apply the render pass to.
  67439. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67440. * @param engine The engine which the post process will be applied. (default: current engine)
  67441. * @param reusable If the post process can be reused on the same frame. (default: false)
  67442. * @param textureType Type of textures used when performing the post process. (default: 0)
  67443. * @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)
  67444. */
  67445. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67446. }
  67447. }
  67448. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  67449. /** @hidden */
  67450. export var circleOfConfusionPixelShader: {
  67451. name: string;
  67452. shader: string;
  67453. };
  67454. }
  67455. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  67456. import { Nullable } from "babylonjs/types";
  67457. import { Engine } from "babylonjs/Engines/engine";
  67458. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67459. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67460. import { Camera } from "babylonjs/Cameras/camera";
  67461. import "babylonjs/Shaders/circleOfConfusion.fragment";
  67462. /**
  67463. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  67464. */
  67465. export class CircleOfConfusionPostProcess extends PostProcess {
  67466. /**
  67467. * 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.
  67468. */
  67469. lensSize: number;
  67470. /**
  67471. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67472. */
  67473. fStop: number;
  67474. /**
  67475. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67476. */
  67477. focusDistance: number;
  67478. /**
  67479. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  67480. */
  67481. focalLength: number;
  67482. private _depthTexture;
  67483. /**
  67484. * Creates a new instance CircleOfConfusionPostProcess
  67485. * @param name The name of the effect.
  67486. * @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.
  67487. * @param options The required width/height ratio to downsize to before computing the render pass.
  67488. * @param camera The camera to apply the render pass to.
  67489. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67490. * @param engine The engine which the post process will be applied. (default: current engine)
  67491. * @param reusable If the post process can be reused on the same frame. (default: false)
  67492. * @param textureType Type of textures used when performing the post process. (default: 0)
  67493. * @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)
  67494. */
  67495. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67496. /**
  67497. * 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.
  67498. */
  67499. set depthTexture(value: RenderTargetTexture);
  67500. }
  67501. }
  67502. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  67503. /** @hidden */
  67504. export var colorCorrectionPixelShader: {
  67505. name: string;
  67506. shader: string;
  67507. };
  67508. }
  67509. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  67510. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67511. import { Engine } from "babylonjs/Engines/engine";
  67512. import { Camera } from "babylonjs/Cameras/camera";
  67513. import "babylonjs/Shaders/colorCorrection.fragment";
  67514. /**
  67515. *
  67516. * This post-process allows the modification of rendered colors by using
  67517. * a 'look-up table' (LUT). This effect is also called Color Grading.
  67518. *
  67519. * The object needs to be provided an url to a texture containing the color
  67520. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  67521. * Use an image editing software to tweak the LUT to match your needs.
  67522. *
  67523. * For an example of a color LUT, see here:
  67524. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  67525. * For explanations on color grading, see here:
  67526. * @see http://udn.epicgames.com/Three/ColorGrading.html
  67527. *
  67528. */
  67529. export class ColorCorrectionPostProcess extends PostProcess {
  67530. private _colorTableTexture;
  67531. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67532. }
  67533. }
  67534. declare module "babylonjs/Shaders/convolution.fragment" {
  67535. /** @hidden */
  67536. export var convolutionPixelShader: {
  67537. name: string;
  67538. shader: string;
  67539. };
  67540. }
  67541. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  67542. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67543. import { Nullable } from "babylonjs/types";
  67544. import { Camera } from "babylonjs/Cameras/camera";
  67545. import { Engine } from "babylonjs/Engines/engine";
  67546. import "babylonjs/Shaders/convolution.fragment";
  67547. /**
  67548. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  67549. * input texture to perform effects such as edge detection or sharpening
  67550. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  67551. */
  67552. export class ConvolutionPostProcess extends PostProcess {
  67553. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67554. kernel: number[];
  67555. /**
  67556. * Creates a new instance ConvolutionPostProcess
  67557. * @param name The name of the effect.
  67558. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  67559. * @param options The required width/height ratio to downsize to before computing the render pass.
  67560. * @param camera The camera to apply the render pass to.
  67561. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67562. * @param engine The engine which the post process will be applied. (default: current engine)
  67563. * @param reusable If the post process can be reused on the same frame. (default: false)
  67564. * @param textureType Type of textures used when performing the post process. (default: 0)
  67565. */
  67566. constructor(name: string,
  67567. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67568. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67569. /**
  67570. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67571. */
  67572. static EdgeDetect0Kernel: number[];
  67573. /**
  67574. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67575. */
  67576. static EdgeDetect1Kernel: number[];
  67577. /**
  67578. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67579. */
  67580. static EdgeDetect2Kernel: number[];
  67581. /**
  67582. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67583. */
  67584. static SharpenKernel: number[];
  67585. /**
  67586. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67587. */
  67588. static EmbossKernel: number[];
  67589. /**
  67590. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67591. */
  67592. static GaussianKernel: number[];
  67593. }
  67594. }
  67595. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  67596. import { Nullable } from "babylonjs/types";
  67597. import { Vector2 } from "babylonjs/Maths/math.vector";
  67598. import { Camera } from "babylonjs/Cameras/camera";
  67599. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67600. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  67601. import { Engine } from "babylonjs/Engines/engine";
  67602. import { Scene } from "babylonjs/scene";
  67603. /**
  67604. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  67605. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  67606. * based on samples that have a large difference in distance than the center pixel.
  67607. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  67608. */
  67609. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  67610. direction: Vector2;
  67611. /**
  67612. * Creates a new instance CircleOfConfusionPostProcess
  67613. * @param name The name of the effect.
  67614. * @param scene The scene the effect belongs to.
  67615. * @param direction The direction the blur should be applied.
  67616. * @param kernel The size of the kernel used to blur.
  67617. * @param options The required width/height ratio to downsize to before computing the render pass.
  67618. * @param camera The camera to apply the render pass to.
  67619. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  67620. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  67621. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67622. * @param engine The engine which the post process will be applied. (default: current engine)
  67623. * @param reusable If the post process can be reused on the same frame. (default: false)
  67624. * @param textureType Type of textures used when performing the post process. (default: 0)
  67625. * @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)
  67626. */
  67627. 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);
  67628. }
  67629. }
  67630. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  67631. /** @hidden */
  67632. export var depthOfFieldMergePixelShader: {
  67633. name: string;
  67634. shader: string;
  67635. };
  67636. }
  67637. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  67638. import { Nullable } from "babylonjs/types";
  67639. import { Camera } from "babylonjs/Cameras/camera";
  67640. import { Effect } from "babylonjs/Materials/effect";
  67641. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67642. import { Engine } from "babylonjs/Engines/engine";
  67643. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  67644. /**
  67645. * Options to be set when merging outputs from the default pipeline.
  67646. */
  67647. export class DepthOfFieldMergePostProcessOptions {
  67648. /**
  67649. * The original image to merge on top of
  67650. */
  67651. originalFromInput: PostProcess;
  67652. /**
  67653. * Parameters to perform the merge of the depth of field effect
  67654. */
  67655. depthOfField?: {
  67656. circleOfConfusion: PostProcess;
  67657. blurSteps: Array<PostProcess>;
  67658. };
  67659. /**
  67660. * Parameters to perform the merge of bloom effect
  67661. */
  67662. bloom?: {
  67663. blurred: PostProcess;
  67664. weight: number;
  67665. };
  67666. }
  67667. /**
  67668. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67669. */
  67670. export class DepthOfFieldMergePostProcess extends PostProcess {
  67671. private blurSteps;
  67672. /**
  67673. * Creates a new instance of DepthOfFieldMergePostProcess
  67674. * @param name The name of the effect.
  67675. * @param originalFromInput Post process which's input will be used for the merge.
  67676. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  67677. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  67678. * @param options The required width/height ratio to downsize to before computing the render pass.
  67679. * @param camera The camera to apply the render pass to.
  67680. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67681. * @param engine The engine which the post process will be applied. (default: current engine)
  67682. * @param reusable If the post process can be reused on the same frame. (default: false)
  67683. * @param textureType Type of textures used when performing the post process. (default: 0)
  67684. * @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)
  67685. */
  67686. 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);
  67687. /**
  67688. * Updates the effect with the current post process compile time values and recompiles the shader.
  67689. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  67690. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  67691. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  67692. * @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
  67693. * @param onCompiled Called when the shader has been compiled.
  67694. * @param onError Called if there is an error when compiling a shader.
  67695. */
  67696. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67697. }
  67698. }
  67699. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  67700. import { Nullable } from "babylonjs/types";
  67701. import { Camera } from "babylonjs/Cameras/camera";
  67702. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67703. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67704. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67705. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  67706. import { Scene } from "babylonjs/scene";
  67707. /**
  67708. * Specifies the level of max blur that should be applied when using the depth of field effect
  67709. */
  67710. export enum DepthOfFieldEffectBlurLevel {
  67711. /**
  67712. * Subtle blur
  67713. */
  67714. Low = 0,
  67715. /**
  67716. * Medium blur
  67717. */
  67718. Medium = 1,
  67719. /**
  67720. * Large blur
  67721. */
  67722. High = 2
  67723. }
  67724. /**
  67725. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  67726. */
  67727. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  67728. private _circleOfConfusion;
  67729. /**
  67730. * @hidden Internal, blurs from high to low
  67731. */
  67732. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  67733. private _depthOfFieldBlurY;
  67734. private _dofMerge;
  67735. /**
  67736. * @hidden Internal post processes in depth of field effect
  67737. */
  67738. _effects: Array<PostProcess>;
  67739. /**
  67740. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  67741. */
  67742. set focalLength(value: number);
  67743. get focalLength(): number;
  67744. /**
  67745. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67746. */
  67747. set fStop(value: number);
  67748. get fStop(): number;
  67749. /**
  67750. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67751. */
  67752. set focusDistance(value: number);
  67753. get focusDistance(): number;
  67754. /**
  67755. * 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.
  67756. */
  67757. set lensSize(value: number);
  67758. get lensSize(): number;
  67759. /**
  67760. * Creates a new instance DepthOfFieldEffect
  67761. * @param scene The scene the effect belongs to.
  67762. * @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.
  67763. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67764. * @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)
  67765. */
  67766. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  67767. /**
  67768. * Get the current class name of the current effet
  67769. * @returns "DepthOfFieldEffect"
  67770. */
  67771. getClassName(): string;
  67772. /**
  67773. * 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.
  67774. */
  67775. set depthTexture(value: RenderTargetTexture);
  67776. /**
  67777. * Disposes each of the internal effects for a given camera.
  67778. * @param camera The camera to dispose the effect on.
  67779. */
  67780. disposeEffects(camera: Camera): void;
  67781. /**
  67782. * @hidden Internal
  67783. */
  67784. _updateEffects(): void;
  67785. /**
  67786. * Internal
  67787. * @returns if all the contained post processes are ready.
  67788. * @hidden
  67789. */
  67790. _isReady(): boolean;
  67791. }
  67792. }
  67793. declare module "babylonjs/Shaders/displayPass.fragment" {
  67794. /** @hidden */
  67795. export var displayPassPixelShader: {
  67796. name: string;
  67797. shader: string;
  67798. };
  67799. }
  67800. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  67801. import { Nullable } from "babylonjs/types";
  67802. import { Camera } from "babylonjs/Cameras/camera";
  67803. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67804. import { Engine } from "babylonjs/Engines/engine";
  67805. import "babylonjs/Shaders/displayPass.fragment";
  67806. /**
  67807. * DisplayPassPostProcess which produces an output the same as it's input
  67808. */
  67809. export class DisplayPassPostProcess extends PostProcess {
  67810. /**
  67811. * Creates the DisplayPassPostProcess
  67812. * @param name The name of the effect.
  67813. * @param options The required width/height ratio to downsize to before computing the render pass.
  67814. * @param camera The camera to apply the render pass to.
  67815. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67816. * @param engine The engine which the post process will be applied. (default: current engine)
  67817. * @param reusable If the post process can be reused on the same frame. (default: false)
  67818. */
  67819. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67820. }
  67821. }
  67822. declare module "babylonjs/Shaders/filter.fragment" {
  67823. /** @hidden */
  67824. export var filterPixelShader: {
  67825. name: string;
  67826. shader: string;
  67827. };
  67828. }
  67829. declare module "babylonjs/PostProcesses/filterPostProcess" {
  67830. import { Nullable } from "babylonjs/types";
  67831. import { Matrix } from "babylonjs/Maths/math.vector";
  67832. import { Camera } from "babylonjs/Cameras/camera";
  67833. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67834. import { Engine } from "babylonjs/Engines/engine";
  67835. import "babylonjs/Shaders/filter.fragment";
  67836. /**
  67837. * Applies a kernel filter to the image
  67838. */
  67839. export class FilterPostProcess extends PostProcess {
  67840. /** The matrix to be applied to the image */
  67841. kernelMatrix: Matrix;
  67842. /**
  67843. *
  67844. * @param name The name of the effect.
  67845. * @param kernelMatrix The matrix to be applied to the image
  67846. * @param options The required width/height ratio to downsize to before computing the render pass.
  67847. * @param camera The camera to apply the render pass to.
  67848. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67849. * @param engine The engine which the post process will be applied. (default: current engine)
  67850. * @param reusable If the post process can be reused on the same frame. (default: false)
  67851. */
  67852. constructor(name: string,
  67853. /** The matrix to be applied to the image */
  67854. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67855. }
  67856. }
  67857. declare module "babylonjs/Shaders/fxaa.fragment" {
  67858. /** @hidden */
  67859. export var fxaaPixelShader: {
  67860. name: string;
  67861. shader: string;
  67862. };
  67863. }
  67864. declare module "babylonjs/Shaders/fxaa.vertex" {
  67865. /** @hidden */
  67866. export var fxaaVertexShader: {
  67867. name: string;
  67868. shader: string;
  67869. };
  67870. }
  67871. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  67872. import { Nullable } from "babylonjs/types";
  67873. import { Camera } from "babylonjs/Cameras/camera";
  67874. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67875. import { Engine } from "babylonjs/Engines/engine";
  67876. import "babylonjs/Shaders/fxaa.fragment";
  67877. import "babylonjs/Shaders/fxaa.vertex";
  67878. /**
  67879. * Fxaa post process
  67880. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  67881. */
  67882. export class FxaaPostProcess extends PostProcess {
  67883. /** @hidden */
  67884. texelWidth: number;
  67885. /** @hidden */
  67886. texelHeight: number;
  67887. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67888. private _getDefines;
  67889. }
  67890. }
  67891. declare module "babylonjs/Shaders/grain.fragment" {
  67892. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67893. /** @hidden */
  67894. export var grainPixelShader: {
  67895. name: string;
  67896. shader: string;
  67897. };
  67898. }
  67899. declare module "babylonjs/PostProcesses/grainPostProcess" {
  67900. import { Nullable } from "babylonjs/types";
  67901. import { Camera } from "babylonjs/Cameras/camera";
  67902. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67903. import { Engine } from "babylonjs/Engines/engine";
  67904. import "babylonjs/Shaders/grain.fragment";
  67905. /**
  67906. * The GrainPostProcess adds noise to the image at mid luminance levels
  67907. */
  67908. export class GrainPostProcess extends PostProcess {
  67909. /**
  67910. * The intensity of the grain added (default: 30)
  67911. */
  67912. intensity: number;
  67913. /**
  67914. * If the grain should be randomized on every frame
  67915. */
  67916. animated: boolean;
  67917. /**
  67918. * Creates a new instance of @see GrainPostProcess
  67919. * @param name The name of the effect.
  67920. * @param options The required width/height ratio to downsize to before computing the render pass.
  67921. * @param camera The camera to apply the render pass to.
  67922. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67923. * @param engine The engine which the post process will be applied. (default: current engine)
  67924. * @param reusable If the post process can be reused on the same frame. (default: false)
  67925. * @param textureType Type of textures used when performing the post process. (default: 0)
  67926. * @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)
  67927. */
  67928. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67929. }
  67930. }
  67931. declare module "babylonjs/Shaders/highlights.fragment" {
  67932. /** @hidden */
  67933. export var highlightsPixelShader: {
  67934. name: string;
  67935. shader: string;
  67936. };
  67937. }
  67938. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  67939. import { Nullable } from "babylonjs/types";
  67940. import { Camera } from "babylonjs/Cameras/camera";
  67941. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67942. import { Engine } from "babylonjs/Engines/engine";
  67943. import "babylonjs/Shaders/highlights.fragment";
  67944. /**
  67945. * Extracts highlights from the image
  67946. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67947. */
  67948. export class HighlightsPostProcess extends PostProcess {
  67949. /**
  67950. * Extracts highlights from the image
  67951. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67952. * @param name The name of the effect.
  67953. * @param options The required width/height ratio to downsize to before computing the render pass.
  67954. * @param camera The camera to apply the render pass to.
  67955. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67956. * @param engine The engine which the post process will be applied. (default: current engine)
  67957. * @param reusable If the post process can be reused on the same frame. (default: false)
  67958. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  67959. */
  67960. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67961. }
  67962. }
  67963. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  67964. /** @hidden */
  67965. export var mrtFragmentDeclaration: {
  67966. name: string;
  67967. shader: string;
  67968. };
  67969. }
  67970. declare module "babylonjs/Shaders/geometry.fragment" {
  67971. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  67972. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  67973. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  67974. /** @hidden */
  67975. export var geometryPixelShader: {
  67976. name: string;
  67977. shader: string;
  67978. };
  67979. }
  67980. declare module "babylonjs/Shaders/geometry.vertex" {
  67981. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  67982. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  67983. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  67984. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  67985. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  67986. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  67987. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  67988. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  67989. /** @hidden */
  67990. export var geometryVertexShader: {
  67991. name: string;
  67992. shader: string;
  67993. };
  67994. }
  67995. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  67996. import { Matrix } from "babylonjs/Maths/math.vector";
  67997. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67998. import { Mesh } from "babylonjs/Meshes/mesh";
  67999. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  68000. import { Effect } from "babylonjs/Materials/effect";
  68001. import { Scene } from "babylonjs/scene";
  68002. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68003. import "babylonjs/Shaders/geometry.fragment";
  68004. import "babylonjs/Shaders/geometry.vertex";
  68005. /** @hidden */
  68006. interface ISavedTransformationMatrix {
  68007. world: Matrix;
  68008. viewProjection: Matrix;
  68009. }
  68010. /**
  68011. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  68012. */
  68013. export class GeometryBufferRenderer {
  68014. /**
  68015. * Constant used to retrieve the position texture index in the G-Buffer textures array
  68016. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  68017. */
  68018. static readonly POSITION_TEXTURE_TYPE: number;
  68019. /**
  68020. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  68021. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  68022. */
  68023. static readonly VELOCITY_TEXTURE_TYPE: number;
  68024. /**
  68025. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  68026. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  68027. */
  68028. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  68029. /**
  68030. * Dictionary used to store the previous transformation matrices of each rendered mesh
  68031. * in order to compute objects velocities when enableVelocity is set to "true"
  68032. * @hidden
  68033. */
  68034. _previousTransformationMatrices: {
  68035. [index: number]: ISavedTransformationMatrix;
  68036. };
  68037. /**
  68038. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  68039. * in order to compute objects velocities when enableVelocity is set to "true"
  68040. * @hidden
  68041. */
  68042. _previousBonesTransformationMatrices: {
  68043. [index: number]: Float32Array;
  68044. };
  68045. /**
  68046. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  68047. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  68048. */
  68049. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  68050. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  68051. renderTransparentMeshes: boolean;
  68052. private _scene;
  68053. private _multiRenderTarget;
  68054. private _ratio;
  68055. private _enablePosition;
  68056. private _enableVelocity;
  68057. private _enableReflectivity;
  68058. private _positionIndex;
  68059. private _velocityIndex;
  68060. private _reflectivityIndex;
  68061. protected _effect: Effect;
  68062. protected _cachedDefines: string;
  68063. /**
  68064. * Set the render list (meshes to be rendered) used in the G buffer.
  68065. */
  68066. set renderList(meshes: Mesh[]);
  68067. /**
  68068. * Gets wether or not G buffer are supported by the running hardware.
  68069. * This requires draw buffer supports
  68070. */
  68071. get isSupported(): boolean;
  68072. /**
  68073. * Returns the index of the given texture type in the G-Buffer textures array
  68074. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  68075. * @returns the index of the given texture type in the G-Buffer textures array
  68076. */
  68077. getTextureIndex(textureType: number): number;
  68078. /**
  68079. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  68080. */
  68081. get enablePosition(): boolean;
  68082. /**
  68083. * Sets whether or not objects positions are enabled for the G buffer.
  68084. */
  68085. set enablePosition(enable: boolean);
  68086. /**
  68087. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  68088. */
  68089. get enableVelocity(): boolean;
  68090. /**
  68091. * Sets wether or not objects velocities are enabled for the G buffer.
  68092. */
  68093. set enableVelocity(enable: boolean);
  68094. /**
  68095. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  68096. */
  68097. get enableReflectivity(): boolean;
  68098. /**
  68099. * Sets wether or not objects roughness are enabled for the G buffer.
  68100. */
  68101. set enableReflectivity(enable: boolean);
  68102. /**
  68103. * Gets the scene associated with the buffer.
  68104. */
  68105. get scene(): Scene;
  68106. /**
  68107. * Gets the ratio used by the buffer during its creation.
  68108. * How big is the buffer related to the main canvas.
  68109. */
  68110. get ratio(): number;
  68111. /** @hidden */
  68112. static _SceneComponentInitialization: (scene: Scene) => void;
  68113. /**
  68114. * Creates a new G Buffer for the scene
  68115. * @param scene The scene the buffer belongs to
  68116. * @param ratio How big is the buffer related to the main canvas.
  68117. */
  68118. constructor(scene: Scene, ratio?: number);
  68119. /**
  68120. * Checks wether everything is ready to render a submesh to the G buffer.
  68121. * @param subMesh the submesh to check readiness for
  68122. * @param useInstances is the mesh drawn using instance or not
  68123. * @returns true if ready otherwise false
  68124. */
  68125. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68126. /**
  68127. * Gets the current underlying G Buffer.
  68128. * @returns the buffer
  68129. */
  68130. getGBuffer(): MultiRenderTarget;
  68131. /**
  68132. * Gets the number of samples used to render the buffer (anti aliasing).
  68133. */
  68134. get samples(): number;
  68135. /**
  68136. * Sets the number of samples used to render the buffer (anti aliasing).
  68137. */
  68138. set samples(value: number);
  68139. /**
  68140. * Disposes the renderer and frees up associated resources.
  68141. */
  68142. dispose(): void;
  68143. protected _createRenderTargets(): void;
  68144. private _copyBonesTransformationMatrices;
  68145. }
  68146. }
  68147. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  68148. import { Nullable } from "babylonjs/types";
  68149. import { Scene } from "babylonjs/scene";
  68150. import { ISceneComponent } from "babylonjs/sceneComponent";
  68151. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  68152. module "babylonjs/scene" {
  68153. interface Scene {
  68154. /** @hidden (Backing field) */
  68155. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68156. /**
  68157. * Gets or Sets the current geometry buffer associated to the scene.
  68158. */
  68159. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68160. /**
  68161. * Enables a GeometryBufferRender and associates it with the scene
  68162. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  68163. * @returns the GeometryBufferRenderer
  68164. */
  68165. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  68166. /**
  68167. * Disables the GeometryBufferRender associated with the scene
  68168. */
  68169. disableGeometryBufferRenderer(): void;
  68170. }
  68171. }
  68172. /**
  68173. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  68174. * in several rendering techniques.
  68175. */
  68176. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  68177. /**
  68178. * The component name helpful to identify the component in the list of scene components.
  68179. */
  68180. readonly name: string;
  68181. /**
  68182. * The scene the component belongs to.
  68183. */
  68184. scene: Scene;
  68185. /**
  68186. * Creates a new instance of the component for the given scene
  68187. * @param scene Defines the scene to register the component in
  68188. */
  68189. constructor(scene: Scene);
  68190. /**
  68191. * Registers the component in a given scene
  68192. */
  68193. register(): void;
  68194. /**
  68195. * Rebuilds the elements related to this component in case of
  68196. * context lost for instance.
  68197. */
  68198. rebuild(): void;
  68199. /**
  68200. * Disposes the component and the associated ressources
  68201. */
  68202. dispose(): void;
  68203. private _gatherRenderTargets;
  68204. }
  68205. }
  68206. declare module "babylonjs/Shaders/motionBlur.fragment" {
  68207. /** @hidden */
  68208. export var motionBlurPixelShader: {
  68209. name: string;
  68210. shader: string;
  68211. };
  68212. }
  68213. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  68214. import { Nullable } from "babylonjs/types";
  68215. import { Camera } from "babylonjs/Cameras/camera";
  68216. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68217. import { Scene } from "babylonjs/scene";
  68218. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68219. import "babylonjs/Animations/animatable";
  68220. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  68221. import "babylonjs/Shaders/motionBlur.fragment";
  68222. import { Engine } from "babylonjs/Engines/engine";
  68223. /**
  68224. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  68225. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  68226. * As an example, all you have to do is to create the post-process:
  68227. * var mb = new BABYLON.MotionBlurPostProcess(
  68228. * 'mb', // The name of the effect.
  68229. * scene, // The scene containing the objects to blur according to their velocity.
  68230. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  68231. * camera // The camera to apply the render pass to.
  68232. * );
  68233. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  68234. */
  68235. export class MotionBlurPostProcess extends PostProcess {
  68236. /**
  68237. * Defines how much the image is blurred by the movement. Default value is equal to 1
  68238. */
  68239. motionStrength: number;
  68240. /**
  68241. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  68242. */
  68243. get motionBlurSamples(): number;
  68244. /**
  68245. * Sets the number of iterations to be used for motion blur quality
  68246. */
  68247. set motionBlurSamples(samples: number);
  68248. private _motionBlurSamples;
  68249. private _geometryBufferRenderer;
  68250. /**
  68251. * Creates a new instance MotionBlurPostProcess
  68252. * @param name The name of the effect.
  68253. * @param scene The scene containing the objects to blur according to their velocity.
  68254. * @param options The required width/height ratio to downsize to before computing the render pass.
  68255. * @param camera The camera to apply the render pass to.
  68256. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68257. * @param engine The engine which the post process will be applied. (default: current engine)
  68258. * @param reusable If the post process can be reused on the same frame. (default: false)
  68259. * @param textureType Type of textures used when performing the post process. (default: 0)
  68260. * @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)
  68261. */
  68262. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68263. /**
  68264. * Excludes the given skinned mesh from computing bones velocities.
  68265. * 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.
  68266. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  68267. */
  68268. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68269. /**
  68270. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  68271. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  68272. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  68273. */
  68274. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68275. /**
  68276. * Disposes the post process.
  68277. * @param camera The camera to dispose the post process on.
  68278. */
  68279. dispose(camera?: Camera): void;
  68280. }
  68281. }
  68282. declare module "babylonjs/Shaders/refraction.fragment" {
  68283. /** @hidden */
  68284. export var refractionPixelShader: {
  68285. name: string;
  68286. shader: string;
  68287. };
  68288. }
  68289. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  68290. import { Color3 } from "babylonjs/Maths/math.color";
  68291. import { Camera } from "babylonjs/Cameras/camera";
  68292. import { Texture } from "babylonjs/Materials/Textures/texture";
  68293. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68294. import { Engine } from "babylonjs/Engines/engine";
  68295. import "babylonjs/Shaders/refraction.fragment";
  68296. /**
  68297. * Post process which applies a refractin texture
  68298. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68299. */
  68300. export class RefractionPostProcess extends PostProcess {
  68301. /** the base color of the refraction (used to taint the rendering) */
  68302. color: Color3;
  68303. /** simulated refraction depth */
  68304. depth: number;
  68305. /** the coefficient of the base color (0 to remove base color tainting) */
  68306. colorLevel: number;
  68307. private _refTexture;
  68308. private _ownRefractionTexture;
  68309. /**
  68310. * Gets or sets the refraction texture
  68311. * Please note that you are responsible for disposing the texture if you set it manually
  68312. */
  68313. get refractionTexture(): Texture;
  68314. set refractionTexture(value: Texture);
  68315. /**
  68316. * Initializes the RefractionPostProcess
  68317. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68318. * @param name The name of the effect.
  68319. * @param refractionTextureUrl Url of the refraction texture to use
  68320. * @param color the base color of the refraction (used to taint the rendering)
  68321. * @param depth simulated refraction depth
  68322. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  68323. * @param camera The camera to apply the render pass to.
  68324. * @param options The required width/height ratio to downsize to before computing the render pass.
  68325. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68326. * @param engine The engine which the post process will be applied. (default: current engine)
  68327. * @param reusable If the post process can be reused on the same frame. (default: false)
  68328. */
  68329. constructor(name: string, refractionTextureUrl: string,
  68330. /** the base color of the refraction (used to taint the rendering) */
  68331. color: Color3,
  68332. /** simulated refraction depth */
  68333. depth: number,
  68334. /** the coefficient of the base color (0 to remove base color tainting) */
  68335. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68336. /**
  68337. * Disposes of the post process
  68338. * @param camera Camera to dispose post process on
  68339. */
  68340. dispose(camera: Camera): void;
  68341. }
  68342. }
  68343. declare module "babylonjs/Shaders/sharpen.fragment" {
  68344. /** @hidden */
  68345. export var sharpenPixelShader: {
  68346. name: string;
  68347. shader: string;
  68348. };
  68349. }
  68350. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  68351. import { Nullable } from "babylonjs/types";
  68352. import { Camera } from "babylonjs/Cameras/camera";
  68353. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68354. import "babylonjs/Shaders/sharpen.fragment";
  68355. import { Engine } from "babylonjs/Engines/engine";
  68356. /**
  68357. * The SharpenPostProcess applies a sharpen kernel to every pixel
  68358. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68359. */
  68360. export class SharpenPostProcess extends PostProcess {
  68361. /**
  68362. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  68363. */
  68364. colorAmount: number;
  68365. /**
  68366. * How much sharpness should be applied (default: 0.3)
  68367. */
  68368. edgeAmount: number;
  68369. /**
  68370. * Creates a new instance ConvolutionPostProcess
  68371. * @param name The name of the effect.
  68372. * @param options The required width/height ratio to downsize to before computing the render pass.
  68373. * @param camera The camera to apply the render pass to.
  68374. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68375. * @param engine The engine which the post process will be applied. (default: current engine)
  68376. * @param reusable If the post process can be reused on the same frame. (default: false)
  68377. * @param textureType Type of textures used when performing the post process. (default: 0)
  68378. * @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)
  68379. */
  68380. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68381. }
  68382. }
  68383. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  68384. import { Nullable } from "babylonjs/types";
  68385. import { Camera } from "babylonjs/Cameras/camera";
  68386. import { Engine } from "babylonjs/Engines/engine";
  68387. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  68388. import { IInspectable } from "babylonjs/Misc/iInspectable";
  68389. /**
  68390. * PostProcessRenderPipeline
  68391. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68392. */
  68393. export class PostProcessRenderPipeline {
  68394. private engine;
  68395. private _renderEffects;
  68396. private _renderEffectsForIsolatedPass;
  68397. /**
  68398. * List of inspectable custom properties (used by the Inspector)
  68399. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68400. */
  68401. inspectableCustomProperties: IInspectable[];
  68402. /**
  68403. * @hidden
  68404. */
  68405. protected _cameras: Camera[];
  68406. /** @hidden */
  68407. _name: string;
  68408. /**
  68409. * Gets pipeline name
  68410. */
  68411. get name(): string;
  68412. /** Gets the list of attached cameras */
  68413. get cameras(): Camera[];
  68414. /**
  68415. * Initializes a PostProcessRenderPipeline
  68416. * @param engine engine to add the pipeline to
  68417. * @param name name of the pipeline
  68418. */
  68419. constructor(engine: Engine, name: string);
  68420. /**
  68421. * Gets the class name
  68422. * @returns "PostProcessRenderPipeline"
  68423. */
  68424. getClassName(): string;
  68425. /**
  68426. * If all the render effects in the pipeline are supported
  68427. */
  68428. get isSupported(): boolean;
  68429. /**
  68430. * Adds an effect to the pipeline
  68431. * @param renderEffect the effect to add
  68432. */
  68433. addEffect(renderEffect: PostProcessRenderEffect): void;
  68434. /** @hidden */
  68435. _rebuild(): void;
  68436. /** @hidden */
  68437. _enableEffect(renderEffectName: string, cameras: Camera): void;
  68438. /** @hidden */
  68439. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  68440. /** @hidden */
  68441. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68442. /** @hidden */
  68443. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68444. /** @hidden */
  68445. _attachCameras(cameras: Camera, unique: boolean): void;
  68446. /** @hidden */
  68447. _attachCameras(cameras: Camera[], unique: boolean): void;
  68448. /** @hidden */
  68449. _detachCameras(cameras: Camera): void;
  68450. /** @hidden */
  68451. _detachCameras(cameras: Nullable<Camera[]>): void;
  68452. /** @hidden */
  68453. _update(): void;
  68454. /** @hidden */
  68455. _reset(): void;
  68456. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  68457. /**
  68458. * Disposes of the pipeline
  68459. */
  68460. dispose(): void;
  68461. }
  68462. }
  68463. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  68464. import { Camera } from "babylonjs/Cameras/camera";
  68465. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68466. /**
  68467. * PostProcessRenderPipelineManager class
  68468. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68469. */
  68470. export class PostProcessRenderPipelineManager {
  68471. private _renderPipelines;
  68472. /**
  68473. * Initializes a PostProcessRenderPipelineManager
  68474. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68475. */
  68476. constructor();
  68477. /**
  68478. * Gets the list of supported render pipelines
  68479. */
  68480. get supportedPipelines(): PostProcessRenderPipeline[];
  68481. /**
  68482. * Adds a pipeline to the manager
  68483. * @param renderPipeline The pipeline to add
  68484. */
  68485. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  68486. /**
  68487. * Attaches a camera to the pipeline
  68488. * @param renderPipelineName The name of the pipeline to attach to
  68489. * @param cameras the camera to attach
  68490. * @param unique if the camera can be attached multiple times to the pipeline
  68491. */
  68492. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  68493. /**
  68494. * Detaches a camera from the pipeline
  68495. * @param renderPipelineName The name of the pipeline to detach from
  68496. * @param cameras the camera to detach
  68497. */
  68498. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  68499. /**
  68500. * Enables an effect by name on a pipeline
  68501. * @param renderPipelineName the name of the pipeline to enable the effect in
  68502. * @param renderEffectName the name of the effect to enable
  68503. * @param cameras the cameras that the effect should be enabled on
  68504. */
  68505. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68506. /**
  68507. * Disables an effect by name on a pipeline
  68508. * @param renderPipelineName the name of the pipeline to disable the effect in
  68509. * @param renderEffectName the name of the effect to disable
  68510. * @param cameras the cameras that the effect should be disabled on
  68511. */
  68512. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68513. /**
  68514. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  68515. */
  68516. update(): void;
  68517. /** @hidden */
  68518. _rebuild(): void;
  68519. /**
  68520. * Disposes of the manager and pipelines
  68521. */
  68522. dispose(): void;
  68523. }
  68524. }
  68525. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  68526. import { ISceneComponent } from "babylonjs/sceneComponent";
  68527. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  68528. import { Scene } from "babylonjs/scene";
  68529. module "babylonjs/scene" {
  68530. interface Scene {
  68531. /** @hidden (Backing field) */
  68532. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68533. /**
  68534. * Gets the postprocess render pipeline manager
  68535. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68536. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68537. */
  68538. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68539. }
  68540. }
  68541. /**
  68542. * Defines the Render Pipeline scene component responsible to rendering pipelines
  68543. */
  68544. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  68545. /**
  68546. * The component name helpfull to identify the component in the list of scene components.
  68547. */
  68548. readonly name: string;
  68549. /**
  68550. * The scene the component belongs to.
  68551. */
  68552. scene: Scene;
  68553. /**
  68554. * Creates a new instance of the component for the given scene
  68555. * @param scene Defines the scene to register the component in
  68556. */
  68557. constructor(scene: Scene);
  68558. /**
  68559. * Registers the component in a given scene
  68560. */
  68561. register(): void;
  68562. /**
  68563. * Rebuilds the elements related to this component in case of
  68564. * context lost for instance.
  68565. */
  68566. rebuild(): void;
  68567. /**
  68568. * Disposes the component and the associated ressources
  68569. */
  68570. dispose(): void;
  68571. private _gatherRenderTargets;
  68572. }
  68573. }
  68574. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  68575. import { Nullable } from "babylonjs/types";
  68576. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  68577. import { Camera } from "babylonjs/Cameras/camera";
  68578. import { IDisposable } from "babylonjs/scene";
  68579. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  68580. import { Scene } from "babylonjs/scene";
  68581. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  68582. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  68583. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  68584. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  68585. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  68586. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68587. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  68588. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68589. import { Animation } from "babylonjs/Animations/animation";
  68590. /**
  68591. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  68592. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68593. */
  68594. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68595. private _scene;
  68596. private _camerasToBeAttached;
  68597. /**
  68598. * ID of the sharpen post process,
  68599. */
  68600. private readonly SharpenPostProcessId;
  68601. /**
  68602. * @ignore
  68603. * ID of the image processing post process;
  68604. */
  68605. readonly ImageProcessingPostProcessId: string;
  68606. /**
  68607. * @ignore
  68608. * ID of the Fast Approximate Anti-Aliasing post process;
  68609. */
  68610. readonly FxaaPostProcessId: string;
  68611. /**
  68612. * ID of the chromatic aberration post process,
  68613. */
  68614. private readonly ChromaticAberrationPostProcessId;
  68615. /**
  68616. * ID of the grain post process
  68617. */
  68618. private readonly GrainPostProcessId;
  68619. /**
  68620. * Sharpen post process which will apply a sharpen convolution to enhance edges
  68621. */
  68622. sharpen: SharpenPostProcess;
  68623. private _sharpenEffect;
  68624. private bloom;
  68625. /**
  68626. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  68627. */
  68628. depthOfField: DepthOfFieldEffect;
  68629. /**
  68630. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  68631. */
  68632. fxaa: FxaaPostProcess;
  68633. /**
  68634. * Image post processing pass used to perform operations such as tone mapping or color grading.
  68635. */
  68636. imageProcessing: ImageProcessingPostProcess;
  68637. /**
  68638. * Chromatic aberration post process which will shift rgb colors in the image
  68639. */
  68640. chromaticAberration: ChromaticAberrationPostProcess;
  68641. private _chromaticAberrationEffect;
  68642. /**
  68643. * Grain post process which add noise to the image
  68644. */
  68645. grain: GrainPostProcess;
  68646. private _grainEffect;
  68647. /**
  68648. * Glow post process which adds a glow to emissive areas of the image
  68649. */
  68650. private _glowLayer;
  68651. /**
  68652. * Animations which can be used to tweak settings over a period of time
  68653. */
  68654. animations: Animation[];
  68655. private _imageProcessingConfigurationObserver;
  68656. private _sharpenEnabled;
  68657. private _bloomEnabled;
  68658. private _depthOfFieldEnabled;
  68659. private _depthOfFieldBlurLevel;
  68660. private _fxaaEnabled;
  68661. private _imageProcessingEnabled;
  68662. private _defaultPipelineTextureType;
  68663. private _bloomScale;
  68664. private _chromaticAberrationEnabled;
  68665. private _grainEnabled;
  68666. private _buildAllowed;
  68667. /**
  68668. * Gets active scene
  68669. */
  68670. get scene(): Scene;
  68671. /**
  68672. * Enable or disable the sharpen process from the pipeline
  68673. */
  68674. set sharpenEnabled(enabled: boolean);
  68675. get sharpenEnabled(): boolean;
  68676. private _resizeObserver;
  68677. private _hardwareScaleLevel;
  68678. private _bloomKernel;
  68679. /**
  68680. * Specifies the size of the bloom blur kernel, relative to the final output size
  68681. */
  68682. get bloomKernel(): number;
  68683. set bloomKernel(value: number);
  68684. /**
  68685. * Specifies the weight of the bloom in the final rendering
  68686. */
  68687. private _bloomWeight;
  68688. /**
  68689. * Specifies the luma threshold for the area that will be blurred by the bloom
  68690. */
  68691. private _bloomThreshold;
  68692. private _hdr;
  68693. /**
  68694. * The strength of the bloom.
  68695. */
  68696. set bloomWeight(value: number);
  68697. get bloomWeight(): number;
  68698. /**
  68699. * The strength of the bloom.
  68700. */
  68701. set bloomThreshold(value: number);
  68702. get bloomThreshold(): number;
  68703. /**
  68704. * The scale of the bloom, lower value will provide better performance.
  68705. */
  68706. set bloomScale(value: number);
  68707. get bloomScale(): number;
  68708. /**
  68709. * Enable or disable the bloom from the pipeline
  68710. */
  68711. set bloomEnabled(enabled: boolean);
  68712. get bloomEnabled(): boolean;
  68713. private _rebuildBloom;
  68714. /**
  68715. * If the depth of field is enabled.
  68716. */
  68717. get depthOfFieldEnabled(): boolean;
  68718. set depthOfFieldEnabled(enabled: boolean);
  68719. /**
  68720. * Blur level of the depth of field effect. (Higher blur will effect performance)
  68721. */
  68722. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  68723. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  68724. /**
  68725. * If the anti aliasing is enabled.
  68726. */
  68727. set fxaaEnabled(enabled: boolean);
  68728. get fxaaEnabled(): boolean;
  68729. private _samples;
  68730. /**
  68731. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  68732. */
  68733. set samples(sampleCount: number);
  68734. get samples(): number;
  68735. /**
  68736. * If image processing is enabled.
  68737. */
  68738. set imageProcessingEnabled(enabled: boolean);
  68739. get imageProcessingEnabled(): boolean;
  68740. /**
  68741. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  68742. */
  68743. set glowLayerEnabled(enabled: boolean);
  68744. get glowLayerEnabled(): boolean;
  68745. /**
  68746. * Gets the glow layer (or null if not defined)
  68747. */
  68748. get glowLayer(): Nullable<GlowLayer>;
  68749. /**
  68750. * Enable or disable the chromaticAberration process from the pipeline
  68751. */
  68752. set chromaticAberrationEnabled(enabled: boolean);
  68753. get chromaticAberrationEnabled(): boolean;
  68754. /**
  68755. * Enable or disable the grain process from the pipeline
  68756. */
  68757. set grainEnabled(enabled: boolean);
  68758. get grainEnabled(): boolean;
  68759. /**
  68760. * @constructor
  68761. * @param name - The rendering pipeline name (default: "")
  68762. * @param hdr - If high dynamic range textures should be used (default: true)
  68763. * @param scene - The scene linked to this pipeline (default: the last created scene)
  68764. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  68765. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  68766. */
  68767. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  68768. /**
  68769. * Get the class name
  68770. * @returns "DefaultRenderingPipeline"
  68771. */
  68772. getClassName(): string;
  68773. /**
  68774. * Force the compilation of the entire pipeline.
  68775. */
  68776. prepare(): void;
  68777. private _hasCleared;
  68778. private _prevPostProcess;
  68779. private _prevPrevPostProcess;
  68780. private _setAutoClearAndTextureSharing;
  68781. private _depthOfFieldSceneObserver;
  68782. private _buildPipeline;
  68783. private _disposePostProcesses;
  68784. /**
  68785. * Adds a camera to the pipeline
  68786. * @param camera the camera to be added
  68787. */
  68788. addCamera(camera: Camera): void;
  68789. /**
  68790. * Removes a camera from the pipeline
  68791. * @param camera the camera to remove
  68792. */
  68793. removeCamera(camera: Camera): void;
  68794. /**
  68795. * Dispose of the pipeline and stop all post processes
  68796. */
  68797. dispose(): void;
  68798. /**
  68799. * Serialize the rendering pipeline (Used when exporting)
  68800. * @returns the serialized object
  68801. */
  68802. serialize(): any;
  68803. /**
  68804. * Parse the serialized pipeline
  68805. * @param source Source pipeline.
  68806. * @param scene The scene to load the pipeline to.
  68807. * @param rootUrl The URL of the serialized pipeline.
  68808. * @returns An instantiated pipeline from the serialized object.
  68809. */
  68810. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  68811. }
  68812. }
  68813. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  68814. /** @hidden */
  68815. export var lensHighlightsPixelShader: {
  68816. name: string;
  68817. shader: string;
  68818. };
  68819. }
  68820. declare module "babylonjs/Shaders/depthOfField.fragment" {
  68821. /** @hidden */
  68822. export var depthOfFieldPixelShader: {
  68823. name: string;
  68824. shader: string;
  68825. };
  68826. }
  68827. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  68828. import { Camera } from "babylonjs/Cameras/camera";
  68829. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68830. import { Scene } from "babylonjs/scene";
  68831. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68832. import "babylonjs/Shaders/chromaticAberration.fragment";
  68833. import "babylonjs/Shaders/lensHighlights.fragment";
  68834. import "babylonjs/Shaders/depthOfField.fragment";
  68835. /**
  68836. * BABYLON.JS Chromatic Aberration GLSL Shader
  68837. * Author: Olivier Guyot
  68838. * Separates very slightly R, G and B colors on the edges of the screen
  68839. * Inspired by Francois Tarlier & Martins Upitis
  68840. */
  68841. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  68842. /**
  68843. * @ignore
  68844. * The chromatic aberration PostProcess id in the pipeline
  68845. */
  68846. LensChromaticAberrationEffect: string;
  68847. /**
  68848. * @ignore
  68849. * The highlights enhancing PostProcess id in the pipeline
  68850. */
  68851. HighlightsEnhancingEffect: string;
  68852. /**
  68853. * @ignore
  68854. * The depth-of-field PostProcess id in the pipeline
  68855. */
  68856. LensDepthOfFieldEffect: string;
  68857. private _scene;
  68858. private _depthTexture;
  68859. private _grainTexture;
  68860. private _chromaticAberrationPostProcess;
  68861. private _highlightsPostProcess;
  68862. private _depthOfFieldPostProcess;
  68863. private _edgeBlur;
  68864. private _grainAmount;
  68865. private _chromaticAberration;
  68866. private _distortion;
  68867. private _highlightsGain;
  68868. private _highlightsThreshold;
  68869. private _dofDistance;
  68870. private _dofAperture;
  68871. private _dofDarken;
  68872. private _dofPentagon;
  68873. private _blurNoise;
  68874. /**
  68875. * @constructor
  68876. *
  68877. * Effect parameters are as follow:
  68878. * {
  68879. * chromatic_aberration: number; // from 0 to x (1 for realism)
  68880. * edge_blur: number; // from 0 to x (1 for realism)
  68881. * distortion: number; // from 0 to x (1 for realism)
  68882. * grain_amount: number; // from 0 to 1
  68883. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  68884. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  68885. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  68886. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  68887. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  68888. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  68889. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  68890. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  68891. * }
  68892. * Note: if an effect parameter is unset, effect is disabled
  68893. *
  68894. * @param name The rendering pipeline name
  68895. * @param parameters - An object containing all parameters (see above)
  68896. * @param scene The scene linked to this pipeline
  68897. * @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)
  68898. * @param cameras The array of cameras that the rendering pipeline will be attached to
  68899. */
  68900. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  68901. /**
  68902. * Get the class name
  68903. * @returns "LensRenderingPipeline"
  68904. */
  68905. getClassName(): string;
  68906. /**
  68907. * Gets associated scene
  68908. */
  68909. get scene(): Scene;
  68910. /**
  68911. * Gets or sets the edge blur
  68912. */
  68913. get edgeBlur(): number;
  68914. set edgeBlur(value: number);
  68915. /**
  68916. * Gets or sets the grain amount
  68917. */
  68918. get grainAmount(): number;
  68919. set grainAmount(value: number);
  68920. /**
  68921. * Gets or sets the chromatic aberration amount
  68922. */
  68923. get chromaticAberration(): number;
  68924. set chromaticAberration(value: number);
  68925. /**
  68926. * Gets or sets the depth of field aperture
  68927. */
  68928. get dofAperture(): number;
  68929. set dofAperture(value: number);
  68930. /**
  68931. * Gets or sets the edge distortion
  68932. */
  68933. get edgeDistortion(): number;
  68934. set edgeDistortion(value: number);
  68935. /**
  68936. * Gets or sets the depth of field distortion
  68937. */
  68938. get dofDistortion(): number;
  68939. set dofDistortion(value: number);
  68940. /**
  68941. * Gets or sets the darken out of focus amount
  68942. */
  68943. get darkenOutOfFocus(): number;
  68944. set darkenOutOfFocus(value: number);
  68945. /**
  68946. * Gets or sets a boolean indicating if blur noise is enabled
  68947. */
  68948. get blurNoise(): boolean;
  68949. set blurNoise(value: boolean);
  68950. /**
  68951. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  68952. */
  68953. get pentagonBokeh(): boolean;
  68954. set pentagonBokeh(value: boolean);
  68955. /**
  68956. * Gets or sets the highlight grain amount
  68957. */
  68958. get highlightsGain(): number;
  68959. set highlightsGain(value: number);
  68960. /**
  68961. * Gets or sets the highlight threshold
  68962. */
  68963. get highlightsThreshold(): number;
  68964. set highlightsThreshold(value: number);
  68965. /**
  68966. * Sets the amount of blur at the edges
  68967. * @param amount blur amount
  68968. */
  68969. setEdgeBlur(amount: number): void;
  68970. /**
  68971. * Sets edge blur to 0
  68972. */
  68973. disableEdgeBlur(): void;
  68974. /**
  68975. * Sets the amout of grain
  68976. * @param amount Amount of grain
  68977. */
  68978. setGrainAmount(amount: number): void;
  68979. /**
  68980. * Set grain amount to 0
  68981. */
  68982. disableGrain(): void;
  68983. /**
  68984. * Sets the chromatic aberration amount
  68985. * @param amount amount of chromatic aberration
  68986. */
  68987. setChromaticAberration(amount: number): void;
  68988. /**
  68989. * Sets chromatic aberration amount to 0
  68990. */
  68991. disableChromaticAberration(): void;
  68992. /**
  68993. * Sets the EdgeDistortion amount
  68994. * @param amount amount of EdgeDistortion
  68995. */
  68996. setEdgeDistortion(amount: number): void;
  68997. /**
  68998. * Sets edge distortion to 0
  68999. */
  69000. disableEdgeDistortion(): void;
  69001. /**
  69002. * Sets the FocusDistance amount
  69003. * @param amount amount of FocusDistance
  69004. */
  69005. setFocusDistance(amount: number): void;
  69006. /**
  69007. * Disables depth of field
  69008. */
  69009. disableDepthOfField(): void;
  69010. /**
  69011. * Sets the Aperture amount
  69012. * @param amount amount of Aperture
  69013. */
  69014. setAperture(amount: number): void;
  69015. /**
  69016. * Sets the DarkenOutOfFocus amount
  69017. * @param amount amount of DarkenOutOfFocus
  69018. */
  69019. setDarkenOutOfFocus(amount: number): void;
  69020. private _pentagonBokehIsEnabled;
  69021. /**
  69022. * Creates a pentagon bokeh effect
  69023. */
  69024. enablePentagonBokeh(): void;
  69025. /**
  69026. * Disables the pentagon bokeh effect
  69027. */
  69028. disablePentagonBokeh(): void;
  69029. /**
  69030. * Enables noise blur
  69031. */
  69032. enableNoiseBlur(): void;
  69033. /**
  69034. * Disables noise blur
  69035. */
  69036. disableNoiseBlur(): void;
  69037. /**
  69038. * Sets the HighlightsGain amount
  69039. * @param amount amount of HighlightsGain
  69040. */
  69041. setHighlightsGain(amount: number): void;
  69042. /**
  69043. * Sets the HighlightsThreshold amount
  69044. * @param amount amount of HighlightsThreshold
  69045. */
  69046. setHighlightsThreshold(amount: number): void;
  69047. /**
  69048. * Disables highlights
  69049. */
  69050. disableHighlights(): void;
  69051. /**
  69052. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  69053. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  69054. */
  69055. dispose(disableDepthRender?: boolean): void;
  69056. private _createChromaticAberrationPostProcess;
  69057. private _createHighlightsPostProcess;
  69058. private _createDepthOfFieldPostProcess;
  69059. private _createGrainTexture;
  69060. }
  69061. }
  69062. declare module "babylonjs/Shaders/ssao2.fragment" {
  69063. /** @hidden */
  69064. export var ssao2PixelShader: {
  69065. name: string;
  69066. shader: string;
  69067. };
  69068. }
  69069. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  69070. /** @hidden */
  69071. export var ssaoCombinePixelShader: {
  69072. name: string;
  69073. shader: string;
  69074. };
  69075. }
  69076. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  69077. import { Camera } from "babylonjs/Cameras/camera";
  69078. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69079. import { Scene } from "babylonjs/scene";
  69080. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69081. import "babylonjs/Shaders/ssao2.fragment";
  69082. import "babylonjs/Shaders/ssaoCombine.fragment";
  69083. /**
  69084. * Render pipeline to produce ssao effect
  69085. */
  69086. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  69087. /**
  69088. * @ignore
  69089. * The PassPostProcess id in the pipeline that contains the original scene color
  69090. */
  69091. SSAOOriginalSceneColorEffect: string;
  69092. /**
  69093. * @ignore
  69094. * The SSAO PostProcess id in the pipeline
  69095. */
  69096. SSAORenderEffect: string;
  69097. /**
  69098. * @ignore
  69099. * The horizontal blur PostProcess id in the pipeline
  69100. */
  69101. SSAOBlurHRenderEffect: string;
  69102. /**
  69103. * @ignore
  69104. * The vertical blur PostProcess id in the pipeline
  69105. */
  69106. SSAOBlurVRenderEffect: string;
  69107. /**
  69108. * @ignore
  69109. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69110. */
  69111. SSAOCombineRenderEffect: string;
  69112. /**
  69113. * The output strength of the SSAO post-process. Default value is 1.0.
  69114. */
  69115. totalStrength: number;
  69116. /**
  69117. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  69118. */
  69119. maxZ: number;
  69120. /**
  69121. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  69122. */
  69123. minZAspect: number;
  69124. private _samples;
  69125. /**
  69126. * Number of samples used for the SSAO calculations. Default value is 8
  69127. */
  69128. set samples(n: number);
  69129. get samples(): number;
  69130. private _textureSamples;
  69131. /**
  69132. * Number of samples to use for antialiasing
  69133. */
  69134. set textureSamples(n: number);
  69135. get textureSamples(): number;
  69136. /**
  69137. * Ratio object used for SSAO ratio and blur ratio
  69138. */
  69139. private _ratio;
  69140. /**
  69141. * Dynamically generated sphere sampler.
  69142. */
  69143. private _sampleSphere;
  69144. /**
  69145. * Blur filter offsets
  69146. */
  69147. private _samplerOffsets;
  69148. private _expensiveBlur;
  69149. /**
  69150. * If bilateral blur should be used
  69151. */
  69152. set expensiveBlur(b: boolean);
  69153. get expensiveBlur(): boolean;
  69154. /**
  69155. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  69156. */
  69157. radius: number;
  69158. /**
  69159. * The base color of the SSAO post-process
  69160. * The final result is "base + ssao" between [0, 1]
  69161. */
  69162. base: number;
  69163. /**
  69164. * Support test.
  69165. */
  69166. static get IsSupported(): boolean;
  69167. private _scene;
  69168. private _depthTexture;
  69169. private _normalTexture;
  69170. private _randomTexture;
  69171. private _originalColorPostProcess;
  69172. private _ssaoPostProcess;
  69173. private _blurHPostProcess;
  69174. private _blurVPostProcess;
  69175. private _ssaoCombinePostProcess;
  69176. /**
  69177. * Gets active scene
  69178. */
  69179. get scene(): Scene;
  69180. /**
  69181. * @constructor
  69182. * @param name The rendering pipeline name
  69183. * @param scene The scene linked to this pipeline
  69184. * @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 }
  69185. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69186. */
  69187. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69188. /**
  69189. * Get the class name
  69190. * @returns "SSAO2RenderingPipeline"
  69191. */
  69192. getClassName(): string;
  69193. /**
  69194. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69195. */
  69196. dispose(disableGeometryBufferRenderer?: boolean): void;
  69197. private _createBlurPostProcess;
  69198. /** @hidden */
  69199. _rebuild(): void;
  69200. private _bits;
  69201. private _radicalInverse_VdC;
  69202. private _hammersley;
  69203. private _hemisphereSample_uniform;
  69204. private _generateHemisphere;
  69205. private _createSSAOPostProcess;
  69206. private _createSSAOCombinePostProcess;
  69207. private _createRandomTexture;
  69208. /**
  69209. * Serialize the rendering pipeline (Used when exporting)
  69210. * @returns the serialized object
  69211. */
  69212. serialize(): any;
  69213. /**
  69214. * Parse the serialized pipeline
  69215. * @param source Source pipeline.
  69216. * @param scene The scene to load the pipeline to.
  69217. * @param rootUrl The URL of the serialized pipeline.
  69218. * @returns An instantiated pipeline from the serialized object.
  69219. */
  69220. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  69221. }
  69222. }
  69223. declare module "babylonjs/Shaders/ssao.fragment" {
  69224. /** @hidden */
  69225. export var ssaoPixelShader: {
  69226. name: string;
  69227. shader: string;
  69228. };
  69229. }
  69230. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  69231. import { Camera } from "babylonjs/Cameras/camera";
  69232. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69233. import { Scene } from "babylonjs/scene";
  69234. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69235. import "babylonjs/Shaders/ssao.fragment";
  69236. import "babylonjs/Shaders/ssaoCombine.fragment";
  69237. /**
  69238. * Render pipeline to produce ssao effect
  69239. */
  69240. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  69241. /**
  69242. * @ignore
  69243. * The PassPostProcess id in the pipeline that contains the original scene color
  69244. */
  69245. SSAOOriginalSceneColorEffect: string;
  69246. /**
  69247. * @ignore
  69248. * The SSAO PostProcess id in the pipeline
  69249. */
  69250. SSAORenderEffect: string;
  69251. /**
  69252. * @ignore
  69253. * The horizontal blur PostProcess id in the pipeline
  69254. */
  69255. SSAOBlurHRenderEffect: string;
  69256. /**
  69257. * @ignore
  69258. * The vertical blur PostProcess id in the pipeline
  69259. */
  69260. SSAOBlurVRenderEffect: string;
  69261. /**
  69262. * @ignore
  69263. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69264. */
  69265. SSAOCombineRenderEffect: string;
  69266. /**
  69267. * The output strength of the SSAO post-process. Default value is 1.0.
  69268. */
  69269. totalStrength: number;
  69270. /**
  69271. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  69272. */
  69273. radius: number;
  69274. /**
  69275. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  69276. * Must not be equal to fallOff and superior to fallOff.
  69277. * Default value is 0.0075
  69278. */
  69279. area: number;
  69280. /**
  69281. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  69282. * Must not be equal to area and inferior to area.
  69283. * Default value is 0.000001
  69284. */
  69285. fallOff: number;
  69286. /**
  69287. * The base color of the SSAO post-process
  69288. * The final result is "base + ssao" between [0, 1]
  69289. */
  69290. base: number;
  69291. private _scene;
  69292. private _depthTexture;
  69293. private _randomTexture;
  69294. private _originalColorPostProcess;
  69295. private _ssaoPostProcess;
  69296. private _blurHPostProcess;
  69297. private _blurVPostProcess;
  69298. private _ssaoCombinePostProcess;
  69299. private _firstUpdate;
  69300. /**
  69301. * Gets active scene
  69302. */
  69303. get scene(): Scene;
  69304. /**
  69305. * @constructor
  69306. * @param name - The rendering pipeline name
  69307. * @param scene - The scene linked to this pipeline
  69308. * @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 }
  69309. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  69310. */
  69311. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69312. /**
  69313. * Get the class name
  69314. * @returns "SSAORenderingPipeline"
  69315. */
  69316. getClassName(): string;
  69317. /**
  69318. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69319. */
  69320. dispose(disableDepthRender?: boolean): void;
  69321. private _createBlurPostProcess;
  69322. /** @hidden */
  69323. _rebuild(): void;
  69324. private _createSSAOPostProcess;
  69325. private _createSSAOCombinePostProcess;
  69326. private _createRandomTexture;
  69327. }
  69328. }
  69329. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  69330. /** @hidden */
  69331. export var screenSpaceReflectionPixelShader: {
  69332. name: string;
  69333. shader: string;
  69334. };
  69335. }
  69336. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  69337. import { Nullable } from "babylonjs/types";
  69338. import { Camera } from "babylonjs/Cameras/camera";
  69339. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69340. import { Scene } from "babylonjs/scene";
  69341. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  69342. import { Engine } from "babylonjs/Engines/engine";
  69343. /**
  69344. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  69345. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  69346. */
  69347. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  69348. /**
  69349. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  69350. */
  69351. threshold: number;
  69352. /**
  69353. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  69354. */
  69355. strength: number;
  69356. /**
  69357. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  69358. */
  69359. reflectionSpecularFalloffExponent: number;
  69360. /**
  69361. * 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]
  69362. */
  69363. step: number;
  69364. /**
  69365. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  69366. */
  69367. roughnessFactor: number;
  69368. private _geometryBufferRenderer;
  69369. private _enableSmoothReflections;
  69370. private _reflectionSamples;
  69371. private _smoothSteps;
  69372. /**
  69373. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  69374. * @param name The name of the effect.
  69375. * @param scene The scene containing the objects to calculate reflections.
  69376. * @param options The required width/height ratio to downsize to before computing the render pass.
  69377. * @param camera The camera to apply the render pass to.
  69378. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69379. * @param engine The engine which the post process will be applied. (default: current engine)
  69380. * @param reusable If the post process can be reused on the same frame. (default: false)
  69381. * @param textureType Type of textures used when performing the post process. (default: 0)
  69382. * @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)
  69383. */
  69384. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69385. /**
  69386. * Gets wether or not smoothing reflections is enabled.
  69387. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69388. */
  69389. get enableSmoothReflections(): boolean;
  69390. /**
  69391. * Sets wether or not smoothing reflections is enabled.
  69392. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69393. */
  69394. set enableSmoothReflections(enabled: boolean);
  69395. /**
  69396. * Gets the number of samples taken while computing reflections. More samples count is high,
  69397. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69398. */
  69399. get reflectionSamples(): number;
  69400. /**
  69401. * Sets the number of samples taken while computing reflections. More samples count is high,
  69402. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69403. */
  69404. set reflectionSamples(samples: number);
  69405. /**
  69406. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  69407. * more the post-process will require GPU power and can generate a drop in FPS.
  69408. * Default value (5.0) work pretty well in all cases but can be adjusted.
  69409. */
  69410. get smoothSteps(): number;
  69411. set smoothSteps(steps: number);
  69412. private _updateEffectDefines;
  69413. }
  69414. }
  69415. declare module "babylonjs/Shaders/standard.fragment" {
  69416. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  69417. /** @hidden */
  69418. export var standardPixelShader: {
  69419. name: string;
  69420. shader: string;
  69421. };
  69422. }
  69423. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  69424. import { Nullable } from "babylonjs/types";
  69425. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  69426. import { Camera } from "babylonjs/Cameras/camera";
  69427. import { Texture } from "babylonjs/Materials/Textures/texture";
  69428. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69429. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69430. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  69431. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  69432. import { IDisposable } from "babylonjs/scene";
  69433. import { SpotLight } from "babylonjs/Lights/spotLight";
  69434. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  69435. import { Scene } from "babylonjs/scene";
  69436. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  69437. import { Animation } from "babylonjs/Animations/animation";
  69438. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69439. import "babylonjs/Shaders/standard.fragment";
  69440. /**
  69441. * Standard rendering pipeline
  69442. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69443. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  69444. */
  69445. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69446. /**
  69447. * Public members
  69448. */
  69449. /**
  69450. * Post-process which contains the original scene color before the pipeline applies all the effects
  69451. */
  69452. originalPostProcess: Nullable<PostProcess>;
  69453. /**
  69454. * Post-process used to down scale an image x4
  69455. */
  69456. downSampleX4PostProcess: Nullable<PostProcess>;
  69457. /**
  69458. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  69459. */
  69460. brightPassPostProcess: Nullable<PostProcess>;
  69461. /**
  69462. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  69463. */
  69464. blurHPostProcesses: PostProcess[];
  69465. /**
  69466. * Post-process array storing all the vertical blur post-processes used by the pipeline
  69467. */
  69468. blurVPostProcesses: PostProcess[];
  69469. /**
  69470. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  69471. */
  69472. textureAdderPostProcess: Nullable<PostProcess>;
  69473. /**
  69474. * Post-process used to create volumetric lighting effect
  69475. */
  69476. volumetricLightPostProcess: Nullable<PostProcess>;
  69477. /**
  69478. * Post-process used to smooth the previous volumetric light post-process on the X axis
  69479. */
  69480. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  69481. /**
  69482. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  69483. */
  69484. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  69485. /**
  69486. * Post-process used to merge the volumetric light effect and the real scene color
  69487. */
  69488. volumetricLightMergePostProces: Nullable<PostProcess>;
  69489. /**
  69490. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  69491. */
  69492. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  69493. /**
  69494. * Base post-process used to calculate the average luminance of the final image for HDR
  69495. */
  69496. luminancePostProcess: Nullable<PostProcess>;
  69497. /**
  69498. * Post-processes used to create down sample post-processes in order to get
  69499. * the average luminance of the final image for HDR
  69500. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  69501. */
  69502. luminanceDownSamplePostProcesses: PostProcess[];
  69503. /**
  69504. * Post-process used to create a HDR effect (light adaptation)
  69505. */
  69506. hdrPostProcess: Nullable<PostProcess>;
  69507. /**
  69508. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  69509. */
  69510. textureAdderFinalPostProcess: Nullable<PostProcess>;
  69511. /**
  69512. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  69513. */
  69514. lensFlareFinalPostProcess: Nullable<PostProcess>;
  69515. /**
  69516. * Post-process used to merge the final HDR post-process and the real scene color
  69517. */
  69518. hdrFinalPostProcess: Nullable<PostProcess>;
  69519. /**
  69520. * Post-process used to create a lens flare effect
  69521. */
  69522. lensFlarePostProcess: Nullable<PostProcess>;
  69523. /**
  69524. * Post-process that merges the result of the lens flare post-process and the real scene color
  69525. */
  69526. lensFlareComposePostProcess: Nullable<PostProcess>;
  69527. /**
  69528. * Post-process used to create a motion blur effect
  69529. */
  69530. motionBlurPostProcess: Nullable<PostProcess>;
  69531. /**
  69532. * Post-process used to create a depth of field effect
  69533. */
  69534. depthOfFieldPostProcess: Nullable<PostProcess>;
  69535. /**
  69536. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69537. */
  69538. fxaaPostProcess: Nullable<FxaaPostProcess>;
  69539. /**
  69540. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  69541. */
  69542. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  69543. /**
  69544. * Represents the brightness threshold in order to configure the illuminated surfaces
  69545. */
  69546. brightThreshold: number;
  69547. /**
  69548. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  69549. */
  69550. blurWidth: number;
  69551. /**
  69552. * Sets if the blur for highlighted surfaces must be only horizontal
  69553. */
  69554. horizontalBlur: boolean;
  69555. /**
  69556. * Gets the overall exposure used by the pipeline
  69557. */
  69558. get exposure(): number;
  69559. /**
  69560. * Sets the overall exposure used by the pipeline
  69561. */
  69562. set exposure(value: number);
  69563. /**
  69564. * Texture used typically to simulate "dirty" on camera lens
  69565. */
  69566. lensTexture: Nullable<Texture>;
  69567. /**
  69568. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  69569. */
  69570. volumetricLightCoefficient: number;
  69571. /**
  69572. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  69573. */
  69574. volumetricLightPower: number;
  69575. /**
  69576. * Used the set the blur intensity to smooth the volumetric lights
  69577. */
  69578. volumetricLightBlurScale: number;
  69579. /**
  69580. * Light (spot or directional) used to generate the volumetric lights rays
  69581. * The source light must have a shadow generate so the pipeline can get its
  69582. * depth map
  69583. */
  69584. sourceLight: Nullable<SpotLight | DirectionalLight>;
  69585. /**
  69586. * For eye adaptation, represents the minimum luminance the eye can see
  69587. */
  69588. hdrMinimumLuminance: number;
  69589. /**
  69590. * For eye adaptation, represents the decrease luminance speed
  69591. */
  69592. hdrDecreaseRate: number;
  69593. /**
  69594. * For eye adaptation, represents the increase luminance speed
  69595. */
  69596. hdrIncreaseRate: number;
  69597. /**
  69598. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69599. */
  69600. get hdrAutoExposure(): boolean;
  69601. /**
  69602. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69603. */
  69604. set hdrAutoExposure(value: boolean);
  69605. /**
  69606. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  69607. */
  69608. lensColorTexture: Nullable<Texture>;
  69609. /**
  69610. * The overall strengh for the lens flare effect
  69611. */
  69612. lensFlareStrength: number;
  69613. /**
  69614. * Dispersion coefficient for lens flare ghosts
  69615. */
  69616. lensFlareGhostDispersal: number;
  69617. /**
  69618. * Main lens flare halo width
  69619. */
  69620. lensFlareHaloWidth: number;
  69621. /**
  69622. * Based on the lens distortion effect, defines how much the lens flare result
  69623. * is distorted
  69624. */
  69625. lensFlareDistortionStrength: number;
  69626. /**
  69627. * Configures the blur intensity used for for lens flare (halo)
  69628. */
  69629. lensFlareBlurWidth: number;
  69630. /**
  69631. * Lens star texture must be used to simulate rays on the flares and is available
  69632. * in the documentation
  69633. */
  69634. lensStarTexture: Nullable<Texture>;
  69635. /**
  69636. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  69637. * flare effect by taking account of the dirt texture
  69638. */
  69639. lensFlareDirtTexture: Nullable<Texture>;
  69640. /**
  69641. * Represents the focal length for the depth of field effect
  69642. */
  69643. depthOfFieldDistance: number;
  69644. /**
  69645. * Represents the blur intensity for the blurred part of the depth of field effect
  69646. */
  69647. depthOfFieldBlurWidth: number;
  69648. /**
  69649. * Gets how much the image is blurred by the movement while using the motion blur post-process
  69650. */
  69651. get motionStrength(): number;
  69652. /**
  69653. * Sets how much the image is blurred by the movement while using the motion blur post-process
  69654. */
  69655. set motionStrength(strength: number);
  69656. /**
  69657. * Gets wether or not the motion blur post-process is object based or screen based.
  69658. */
  69659. get objectBasedMotionBlur(): boolean;
  69660. /**
  69661. * Sets wether or not the motion blur post-process should be object based or screen based
  69662. */
  69663. set objectBasedMotionBlur(value: boolean);
  69664. /**
  69665. * List of animations for the pipeline (IAnimatable implementation)
  69666. */
  69667. animations: Animation[];
  69668. /**
  69669. * Private members
  69670. */
  69671. private _scene;
  69672. private _currentDepthOfFieldSource;
  69673. private _basePostProcess;
  69674. private _fixedExposure;
  69675. private _currentExposure;
  69676. private _hdrAutoExposure;
  69677. private _hdrCurrentLuminance;
  69678. private _motionStrength;
  69679. private _isObjectBasedMotionBlur;
  69680. private _floatTextureType;
  69681. private _camerasToBeAttached;
  69682. private _ratio;
  69683. private _bloomEnabled;
  69684. private _depthOfFieldEnabled;
  69685. private _vlsEnabled;
  69686. private _lensFlareEnabled;
  69687. private _hdrEnabled;
  69688. private _motionBlurEnabled;
  69689. private _fxaaEnabled;
  69690. private _screenSpaceReflectionsEnabled;
  69691. private _motionBlurSamples;
  69692. private _volumetricLightStepsCount;
  69693. private _samples;
  69694. /**
  69695. * @ignore
  69696. * Specifies if the bloom pipeline is enabled
  69697. */
  69698. get BloomEnabled(): boolean;
  69699. set BloomEnabled(enabled: boolean);
  69700. /**
  69701. * @ignore
  69702. * Specifies if the depth of field pipeline is enabed
  69703. */
  69704. get DepthOfFieldEnabled(): boolean;
  69705. set DepthOfFieldEnabled(enabled: boolean);
  69706. /**
  69707. * @ignore
  69708. * Specifies if the lens flare pipeline is enabed
  69709. */
  69710. get LensFlareEnabled(): boolean;
  69711. set LensFlareEnabled(enabled: boolean);
  69712. /**
  69713. * @ignore
  69714. * Specifies if the HDR pipeline is enabled
  69715. */
  69716. get HDREnabled(): boolean;
  69717. set HDREnabled(enabled: boolean);
  69718. /**
  69719. * @ignore
  69720. * Specifies if the volumetric lights scattering effect is enabled
  69721. */
  69722. get VLSEnabled(): boolean;
  69723. set VLSEnabled(enabled: boolean);
  69724. /**
  69725. * @ignore
  69726. * Specifies if the motion blur effect is enabled
  69727. */
  69728. get MotionBlurEnabled(): boolean;
  69729. set MotionBlurEnabled(enabled: boolean);
  69730. /**
  69731. * Specifies if anti-aliasing is enabled
  69732. */
  69733. get fxaaEnabled(): boolean;
  69734. set fxaaEnabled(enabled: boolean);
  69735. /**
  69736. * Specifies if screen space reflections are enabled.
  69737. */
  69738. get screenSpaceReflectionsEnabled(): boolean;
  69739. set screenSpaceReflectionsEnabled(enabled: boolean);
  69740. /**
  69741. * Specifies the number of steps used to calculate the volumetric lights
  69742. * Typically in interval [50, 200]
  69743. */
  69744. get volumetricLightStepsCount(): number;
  69745. set volumetricLightStepsCount(count: number);
  69746. /**
  69747. * Specifies the number of samples used for the motion blur effect
  69748. * Typically in interval [16, 64]
  69749. */
  69750. get motionBlurSamples(): number;
  69751. set motionBlurSamples(samples: number);
  69752. /**
  69753. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69754. */
  69755. get samples(): number;
  69756. set samples(sampleCount: number);
  69757. /**
  69758. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69759. * @constructor
  69760. * @param name The rendering pipeline name
  69761. * @param scene The scene linked to this pipeline
  69762. * @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)
  69763. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  69764. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69765. */
  69766. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  69767. private _buildPipeline;
  69768. private _createDownSampleX4PostProcess;
  69769. private _createBrightPassPostProcess;
  69770. private _createBlurPostProcesses;
  69771. private _createTextureAdderPostProcess;
  69772. private _createVolumetricLightPostProcess;
  69773. private _createLuminancePostProcesses;
  69774. private _createHdrPostProcess;
  69775. private _createLensFlarePostProcess;
  69776. private _createDepthOfFieldPostProcess;
  69777. private _createMotionBlurPostProcess;
  69778. private _getDepthTexture;
  69779. private _disposePostProcesses;
  69780. /**
  69781. * Dispose of the pipeline and stop all post processes
  69782. */
  69783. dispose(): void;
  69784. /**
  69785. * Serialize the rendering pipeline (Used when exporting)
  69786. * @returns the serialized object
  69787. */
  69788. serialize(): any;
  69789. /**
  69790. * Parse the serialized pipeline
  69791. * @param source Source pipeline.
  69792. * @param scene The scene to load the pipeline to.
  69793. * @param rootUrl The URL of the serialized pipeline.
  69794. * @returns An instantiated pipeline from the serialized object.
  69795. */
  69796. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  69797. /**
  69798. * Luminance steps
  69799. */
  69800. static LuminanceSteps: number;
  69801. }
  69802. }
  69803. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  69804. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  69805. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  69806. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  69807. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  69808. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  69809. }
  69810. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  69811. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  69812. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  69813. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69814. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  69815. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69816. }
  69817. declare module "babylonjs/Shaders/tonemap.fragment" {
  69818. /** @hidden */
  69819. export var tonemapPixelShader: {
  69820. name: string;
  69821. shader: string;
  69822. };
  69823. }
  69824. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  69825. import { Camera } from "babylonjs/Cameras/camera";
  69826. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69827. import "babylonjs/Shaders/tonemap.fragment";
  69828. import { Engine } from "babylonjs/Engines/engine";
  69829. /** Defines operator used for tonemapping */
  69830. export enum TonemappingOperator {
  69831. /** Hable */
  69832. Hable = 0,
  69833. /** Reinhard */
  69834. Reinhard = 1,
  69835. /** HejiDawson */
  69836. HejiDawson = 2,
  69837. /** Photographic */
  69838. Photographic = 3
  69839. }
  69840. /**
  69841. * Defines a post process to apply tone mapping
  69842. */
  69843. export class TonemapPostProcess extends PostProcess {
  69844. private _operator;
  69845. /** Defines the required exposure adjustement */
  69846. exposureAdjustment: number;
  69847. /**
  69848. * Creates a new TonemapPostProcess
  69849. * @param name defines the name of the postprocess
  69850. * @param _operator defines the operator to use
  69851. * @param exposureAdjustment defines the required exposure adjustement
  69852. * @param camera defines the camera to use (can be null)
  69853. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  69854. * @param engine defines the hosting engine (can be ignore if camera is set)
  69855. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  69856. */
  69857. constructor(name: string, _operator: TonemappingOperator,
  69858. /** Defines the required exposure adjustement */
  69859. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  69860. }
  69861. }
  69862. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  69863. /** @hidden */
  69864. export var volumetricLightScatteringPixelShader: {
  69865. name: string;
  69866. shader: string;
  69867. };
  69868. }
  69869. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  69870. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  69871. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  69872. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  69873. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  69874. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  69875. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  69876. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  69877. /** @hidden */
  69878. export var volumetricLightScatteringPassVertexShader: {
  69879. name: string;
  69880. shader: string;
  69881. };
  69882. }
  69883. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  69884. /** @hidden */
  69885. export var volumetricLightScatteringPassPixelShader: {
  69886. name: string;
  69887. shader: string;
  69888. };
  69889. }
  69890. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  69891. import { Vector3 } from "babylonjs/Maths/math.vector";
  69892. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69893. import { Mesh } from "babylonjs/Meshes/mesh";
  69894. import { Camera } from "babylonjs/Cameras/camera";
  69895. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  69896. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69897. import { Scene } from "babylonjs/scene";
  69898. import "babylonjs/Meshes/Builders/planeBuilder";
  69899. import "babylonjs/Shaders/depth.vertex";
  69900. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  69901. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  69902. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  69903. import { Engine } from "babylonjs/Engines/engine";
  69904. /**
  69905. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  69906. */
  69907. export class VolumetricLightScatteringPostProcess extends PostProcess {
  69908. private _volumetricLightScatteringPass;
  69909. private _volumetricLightScatteringRTT;
  69910. private _viewPort;
  69911. private _screenCoordinates;
  69912. private _cachedDefines;
  69913. /**
  69914. * If not undefined, the mesh position is computed from the attached node position
  69915. */
  69916. attachedNode: {
  69917. position: Vector3;
  69918. };
  69919. /**
  69920. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  69921. */
  69922. customMeshPosition: Vector3;
  69923. /**
  69924. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  69925. */
  69926. useCustomMeshPosition: boolean;
  69927. /**
  69928. * If the post-process should inverse the light scattering direction
  69929. */
  69930. invert: boolean;
  69931. /**
  69932. * The internal mesh used by the post-process
  69933. */
  69934. mesh: Mesh;
  69935. /**
  69936. * @hidden
  69937. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  69938. */
  69939. get useDiffuseColor(): boolean;
  69940. set useDiffuseColor(useDiffuseColor: boolean);
  69941. /**
  69942. * Array containing the excluded meshes not rendered in the internal pass
  69943. */
  69944. excludedMeshes: AbstractMesh[];
  69945. /**
  69946. * Controls the overall intensity of the post-process
  69947. */
  69948. exposure: number;
  69949. /**
  69950. * Dissipates each sample's contribution in range [0, 1]
  69951. */
  69952. decay: number;
  69953. /**
  69954. * Controls the overall intensity of each sample
  69955. */
  69956. weight: number;
  69957. /**
  69958. * Controls the density of each sample
  69959. */
  69960. density: number;
  69961. /**
  69962. * @constructor
  69963. * @param name The post-process name
  69964. * @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)
  69965. * @param camera The camera that the post-process will be attached to
  69966. * @param mesh The mesh used to create the light scattering
  69967. * @param samples The post-process quality, default 100
  69968. * @param samplingModeThe post-process filtering mode
  69969. * @param engine The babylon engine
  69970. * @param reusable If the post-process is reusable
  69971. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  69972. */
  69973. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  69974. /**
  69975. * Returns the string "VolumetricLightScatteringPostProcess"
  69976. * @returns "VolumetricLightScatteringPostProcess"
  69977. */
  69978. getClassName(): string;
  69979. private _isReady;
  69980. /**
  69981. * Sets the new light position for light scattering effect
  69982. * @param position The new custom light position
  69983. */
  69984. setCustomMeshPosition(position: Vector3): void;
  69985. /**
  69986. * Returns the light position for light scattering effect
  69987. * @return Vector3 The custom light position
  69988. */
  69989. getCustomMeshPosition(): Vector3;
  69990. /**
  69991. * Disposes the internal assets and detaches the post-process from the camera
  69992. */
  69993. dispose(camera: Camera): void;
  69994. /**
  69995. * Returns the render target texture used by the post-process
  69996. * @return the render target texture used by the post-process
  69997. */
  69998. getPass(): RenderTargetTexture;
  69999. private _meshExcluded;
  70000. private _createPass;
  70001. private _updateMeshScreenCoordinates;
  70002. /**
  70003. * Creates a default mesh for the Volumeric Light Scattering post-process
  70004. * @param name The mesh name
  70005. * @param scene The scene where to create the mesh
  70006. * @return the default mesh
  70007. */
  70008. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  70009. }
  70010. }
  70011. declare module "babylonjs/PostProcesses/index" {
  70012. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  70013. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  70014. export * from "babylonjs/PostProcesses/bloomEffect";
  70015. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  70016. export * from "babylonjs/PostProcesses/blurPostProcess";
  70017. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  70018. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  70019. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  70020. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  70021. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  70022. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  70023. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  70024. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  70025. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  70026. export * from "babylonjs/PostProcesses/filterPostProcess";
  70027. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  70028. export * from "babylonjs/PostProcesses/grainPostProcess";
  70029. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  70030. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  70031. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  70032. export * from "babylonjs/PostProcesses/passPostProcess";
  70033. export * from "babylonjs/PostProcesses/postProcess";
  70034. export * from "babylonjs/PostProcesses/postProcessManager";
  70035. export * from "babylonjs/PostProcesses/refractionPostProcess";
  70036. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  70037. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  70038. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  70039. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  70040. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  70041. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  70042. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  70043. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  70044. }
  70045. declare module "babylonjs/Probes/index" {
  70046. export * from "babylonjs/Probes/reflectionProbe";
  70047. }
  70048. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  70049. import { Scene } from "babylonjs/scene";
  70050. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70051. import { SmartArray } from "babylonjs/Misc/smartArray";
  70052. import { ISceneComponent } from "babylonjs/sceneComponent";
  70053. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  70054. import "babylonjs/Meshes/Builders/boxBuilder";
  70055. import "babylonjs/Shaders/color.fragment";
  70056. import "babylonjs/Shaders/color.vertex";
  70057. import { Color3 } from "babylonjs/Maths/math.color";
  70058. module "babylonjs/scene" {
  70059. interface Scene {
  70060. /** @hidden (Backing field) */
  70061. _boundingBoxRenderer: BoundingBoxRenderer;
  70062. /** @hidden (Backing field) */
  70063. _forceShowBoundingBoxes: boolean;
  70064. /**
  70065. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  70066. */
  70067. forceShowBoundingBoxes: boolean;
  70068. /**
  70069. * Gets the bounding box renderer associated with the scene
  70070. * @returns a BoundingBoxRenderer
  70071. */
  70072. getBoundingBoxRenderer(): BoundingBoxRenderer;
  70073. }
  70074. }
  70075. module "babylonjs/Meshes/abstractMesh" {
  70076. interface AbstractMesh {
  70077. /** @hidden (Backing field) */
  70078. _showBoundingBox: boolean;
  70079. /**
  70080. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  70081. */
  70082. showBoundingBox: boolean;
  70083. }
  70084. }
  70085. /**
  70086. * Component responsible of rendering the bounding box of the meshes in a scene.
  70087. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  70088. */
  70089. export class BoundingBoxRenderer implements ISceneComponent {
  70090. /**
  70091. * The component name helpfull to identify the component in the list of scene components.
  70092. */
  70093. readonly name: string;
  70094. /**
  70095. * The scene the component belongs to.
  70096. */
  70097. scene: Scene;
  70098. /**
  70099. * Color of the bounding box lines placed in front of an object
  70100. */
  70101. frontColor: Color3;
  70102. /**
  70103. * Color of the bounding box lines placed behind an object
  70104. */
  70105. backColor: Color3;
  70106. /**
  70107. * Defines if the renderer should show the back lines or not
  70108. */
  70109. showBackLines: boolean;
  70110. /**
  70111. * @hidden
  70112. */
  70113. renderList: SmartArray<BoundingBox>;
  70114. private _colorShader;
  70115. private _vertexBuffers;
  70116. private _indexBuffer;
  70117. private _fillIndexBuffer;
  70118. private _fillIndexData;
  70119. /**
  70120. * Instantiates a new bounding box renderer in a scene.
  70121. * @param scene the scene the renderer renders in
  70122. */
  70123. constructor(scene: Scene);
  70124. /**
  70125. * Registers the component in a given scene
  70126. */
  70127. register(): void;
  70128. private _evaluateSubMesh;
  70129. private _activeMesh;
  70130. private _prepareRessources;
  70131. private _createIndexBuffer;
  70132. /**
  70133. * Rebuilds the elements related to this component in case of
  70134. * context lost for instance.
  70135. */
  70136. rebuild(): void;
  70137. /**
  70138. * @hidden
  70139. */
  70140. reset(): void;
  70141. /**
  70142. * Render the bounding boxes of a specific rendering group
  70143. * @param renderingGroupId defines the rendering group to render
  70144. */
  70145. render(renderingGroupId: number): void;
  70146. /**
  70147. * In case of occlusion queries, we can render the occlusion bounding box through this method
  70148. * @param mesh Define the mesh to render the occlusion bounding box for
  70149. */
  70150. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  70151. /**
  70152. * Dispose and release the resources attached to this renderer.
  70153. */
  70154. dispose(): void;
  70155. }
  70156. }
  70157. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  70158. import { Nullable } from "babylonjs/types";
  70159. import { Scene } from "babylonjs/scene";
  70160. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  70161. import { Camera } from "babylonjs/Cameras/camera";
  70162. import { ISceneComponent } from "babylonjs/sceneComponent";
  70163. module "babylonjs/scene" {
  70164. interface Scene {
  70165. /** @hidden (Backing field) */
  70166. _depthRenderer: {
  70167. [id: string]: DepthRenderer;
  70168. };
  70169. /**
  70170. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  70171. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  70172. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  70173. * @returns the created depth renderer
  70174. */
  70175. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  70176. /**
  70177. * Disables a depth renderer for a given camera
  70178. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  70179. */
  70180. disableDepthRenderer(camera?: Nullable<Camera>): void;
  70181. }
  70182. }
  70183. /**
  70184. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  70185. * in several rendering techniques.
  70186. */
  70187. export class DepthRendererSceneComponent implements ISceneComponent {
  70188. /**
  70189. * The component name helpfull to identify the component in the list of scene components.
  70190. */
  70191. readonly name: string;
  70192. /**
  70193. * The scene the component belongs to.
  70194. */
  70195. scene: Scene;
  70196. /**
  70197. * Creates a new instance of the component for the given scene
  70198. * @param scene Defines the scene to register the component in
  70199. */
  70200. constructor(scene: Scene);
  70201. /**
  70202. * Registers the component in a given scene
  70203. */
  70204. register(): void;
  70205. /**
  70206. * Rebuilds the elements related to this component in case of
  70207. * context lost for instance.
  70208. */
  70209. rebuild(): void;
  70210. /**
  70211. * Disposes the component and the associated ressources
  70212. */
  70213. dispose(): void;
  70214. private _gatherRenderTargets;
  70215. private _gatherActiveCameraRenderTargets;
  70216. }
  70217. }
  70218. declare module "babylonjs/Shaders/outline.fragment" {
  70219. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70220. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  70221. /** @hidden */
  70222. export var outlinePixelShader: {
  70223. name: string;
  70224. shader: string;
  70225. };
  70226. }
  70227. declare module "babylonjs/Shaders/outline.vertex" {
  70228. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  70229. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  70230. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  70231. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  70232. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70233. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  70234. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  70235. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  70236. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  70237. /** @hidden */
  70238. export var outlineVertexShader: {
  70239. name: string;
  70240. shader: string;
  70241. };
  70242. }
  70243. declare module "babylonjs/Rendering/outlineRenderer" {
  70244. import { SubMesh } from "babylonjs/Meshes/subMesh";
  70245. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  70246. import { Scene } from "babylonjs/scene";
  70247. import { ISceneComponent } from "babylonjs/sceneComponent";
  70248. import "babylonjs/Shaders/outline.fragment";
  70249. import "babylonjs/Shaders/outline.vertex";
  70250. module "babylonjs/scene" {
  70251. interface Scene {
  70252. /** @hidden */
  70253. _outlineRenderer: OutlineRenderer;
  70254. /**
  70255. * Gets the outline renderer associated with the scene
  70256. * @returns a OutlineRenderer
  70257. */
  70258. getOutlineRenderer(): OutlineRenderer;
  70259. }
  70260. }
  70261. module "babylonjs/Meshes/abstractMesh" {
  70262. interface AbstractMesh {
  70263. /** @hidden (Backing field) */
  70264. _renderOutline: boolean;
  70265. /**
  70266. * Gets or sets a boolean indicating if the outline must be rendered as well
  70267. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  70268. */
  70269. renderOutline: boolean;
  70270. /** @hidden (Backing field) */
  70271. _renderOverlay: boolean;
  70272. /**
  70273. * Gets or sets a boolean indicating if the overlay must be rendered as well
  70274. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  70275. */
  70276. renderOverlay: boolean;
  70277. }
  70278. }
  70279. /**
  70280. * This class is responsible to draw bothe outline/overlay of meshes.
  70281. * It should not be used directly but through the available method on mesh.
  70282. */
  70283. export class OutlineRenderer implements ISceneComponent {
  70284. /**
  70285. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  70286. */
  70287. private static _StencilReference;
  70288. /**
  70289. * The name of the component. Each component must have a unique name.
  70290. */
  70291. name: string;
  70292. /**
  70293. * The scene the component belongs to.
  70294. */
  70295. scene: Scene;
  70296. /**
  70297. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  70298. */
  70299. zOffset: number;
  70300. private _engine;
  70301. private _effect;
  70302. private _cachedDefines;
  70303. private _savedDepthWrite;
  70304. /**
  70305. * Instantiates a new outline renderer. (There could be only one per scene).
  70306. * @param scene Defines the scene it belongs to
  70307. */
  70308. constructor(scene: Scene);
  70309. /**
  70310. * Register the component to one instance of a scene.
  70311. */
  70312. register(): void;
  70313. /**
  70314. * Rebuilds the elements related to this component in case of
  70315. * context lost for instance.
  70316. */
  70317. rebuild(): void;
  70318. /**
  70319. * Disposes the component and the associated ressources.
  70320. */
  70321. dispose(): void;
  70322. /**
  70323. * Renders the outline in the canvas.
  70324. * @param subMesh Defines the sumesh to render
  70325. * @param batch Defines the batch of meshes in case of instances
  70326. * @param useOverlay Defines if the rendering is for the overlay or the outline
  70327. */
  70328. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  70329. /**
  70330. * Returns whether or not the outline renderer is ready for a given submesh.
  70331. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  70332. * @param subMesh Defines the submesh to check readyness for
  70333. * @param useInstances Defines wheter wee are trying to render instances or not
  70334. * @returns true if ready otherwise false
  70335. */
  70336. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70337. private _beforeRenderingMesh;
  70338. private _afterRenderingMesh;
  70339. }
  70340. }
  70341. declare module "babylonjs/Rendering/index" {
  70342. export * from "babylonjs/Rendering/boundingBoxRenderer";
  70343. export * from "babylonjs/Rendering/depthRenderer";
  70344. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  70345. export * from "babylonjs/Rendering/edgesRenderer";
  70346. export * from "babylonjs/Rendering/geometryBufferRenderer";
  70347. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  70348. export * from "babylonjs/Rendering/outlineRenderer";
  70349. export * from "babylonjs/Rendering/renderingGroup";
  70350. export * from "babylonjs/Rendering/renderingManager";
  70351. export * from "babylonjs/Rendering/utilityLayerRenderer";
  70352. }
  70353. declare module "babylonjs/Sprites/ISprites" {
  70354. /**
  70355. * Defines the basic options interface of a Sprite Frame Source Size.
  70356. */
  70357. export interface ISpriteJSONSpriteSourceSize {
  70358. /**
  70359. * number of the original width of the Frame
  70360. */
  70361. w: number;
  70362. /**
  70363. * number of the original height of the Frame
  70364. */
  70365. h: number;
  70366. }
  70367. /**
  70368. * Defines the basic options interface of a Sprite Frame Data.
  70369. */
  70370. export interface ISpriteJSONSpriteFrameData {
  70371. /**
  70372. * number of the x offset of the Frame
  70373. */
  70374. x: number;
  70375. /**
  70376. * number of the y offset of the Frame
  70377. */
  70378. y: number;
  70379. /**
  70380. * number of the width of the Frame
  70381. */
  70382. w: number;
  70383. /**
  70384. * number of the height of the Frame
  70385. */
  70386. h: number;
  70387. }
  70388. /**
  70389. * Defines the basic options interface of a JSON Sprite.
  70390. */
  70391. export interface ISpriteJSONSprite {
  70392. /**
  70393. * string name of the Frame
  70394. */
  70395. filename: string;
  70396. /**
  70397. * ISpriteJSONSpriteFrame basic object of the frame data
  70398. */
  70399. frame: ISpriteJSONSpriteFrameData;
  70400. /**
  70401. * boolean to flag is the frame was rotated.
  70402. */
  70403. rotated: boolean;
  70404. /**
  70405. * boolean to flag is the frame was trimmed.
  70406. */
  70407. trimmed: boolean;
  70408. /**
  70409. * ISpriteJSONSpriteFrame basic object of the source data
  70410. */
  70411. spriteSourceSize: ISpriteJSONSpriteFrameData;
  70412. /**
  70413. * ISpriteJSONSpriteFrame basic object of the source data
  70414. */
  70415. sourceSize: ISpriteJSONSpriteSourceSize;
  70416. }
  70417. /**
  70418. * Defines the basic options interface of a JSON atlas.
  70419. */
  70420. export interface ISpriteJSONAtlas {
  70421. /**
  70422. * Array of objects that contain the frame data.
  70423. */
  70424. frames: Array<ISpriteJSONSprite>;
  70425. /**
  70426. * object basic object containing the sprite meta data.
  70427. */
  70428. meta?: object;
  70429. }
  70430. }
  70431. declare module "babylonjs/Shaders/spriteMap.fragment" {
  70432. /** @hidden */
  70433. export var spriteMapPixelShader: {
  70434. name: string;
  70435. shader: string;
  70436. };
  70437. }
  70438. declare module "babylonjs/Shaders/spriteMap.vertex" {
  70439. /** @hidden */
  70440. export var spriteMapVertexShader: {
  70441. name: string;
  70442. shader: string;
  70443. };
  70444. }
  70445. declare module "babylonjs/Sprites/spriteMap" {
  70446. import { IDisposable, Scene } from "babylonjs/scene";
  70447. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  70448. import { Texture } from "babylonjs/Materials/Textures/texture";
  70449. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  70450. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  70451. import "babylonjs/Meshes/Builders/planeBuilder";
  70452. import "babylonjs/Shaders/spriteMap.fragment";
  70453. import "babylonjs/Shaders/spriteMap.vertex";
  70454. /**
  70455. * Defines the basic options interface of a SpriteMap
  70456. */
  70457. export interface ISpriteMapOptions {
  70458. /**
  70459. * Vector2 of the number of cells in the grid.
  70460. */
  70461. stageSize?: Vector2;
  70462. /**
  70463. * Vector2 of the size of the output plane in World Units.
  70464. */
  70465. outputSize?: Vector2;
  70466. /**
  70467. * Vector3 of the position of the output plane in World Units.
  70468. */
  70469. outputPosition?: Vector3;
  70470. /**
  70471. * Vector3 of the rotation of the output plane.
  70472. */
  70473. outputRotation?: Vector3;
  70474. /**
  70475. * number of layers that the system will reserve in resources.
  70476. */
  70477. layerCount?: number;
  70478. /**
  70479. * number of max animation frames a single cell will reserve in resources.
  70480. */
  70481. maxAnimationFrames?: number;
  70482. /**
  70483. * number cell index of the base tile when the system compiles.
  70484. */
  70485. baseTile?: number;
  70486. /**
  70487. * boolean flip the sprite after its been repositioned by the framing data.
  70488. */
  70489. flipU?: boolean;
  70490. /**
  70491. * Vector3 scalar of the global RGB values of the SpriteMap.
  70492. */
  70493. colorMultiply?: Vector3;
  70494. }
  70495. /**
  70496. * Defines the IDisposable interface in order to be cleanable from resources.
  70497. */
  70498. export interface ISpriteMap extends IDisposable {
  70499. /**
  70500. * String name of the SpriteMap.
  70501. */
  70502. name: string;
  70503. /**
  70504. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  70505. */
  70506. atlasJSON: ISpriteJSONAtlas;
  70507. /**
  70508. * Texture of the SpriteMap.
  70509. */
  70510. spriteSheet: Texture;
  70511. /**
  70512. * The parameters to initialize the SpriteMap with.
  70513. */
  70514. options: ISpriteMapOptions;
  70515. }
  70516. /**
  70517. * Class used to manage a grid restricted sprite deployment on an Output plane.
  70518. */
  70519. export class SpriteMap implements ISpriteMap {
  70520. /** The Name of the spriteMap */
  70521. name: string;
  70522. /** The JSON file with the frame and meta data */
  70523. atlasJSON: ISpriteJSONAtlas;
  70524. /** The systems Sprite Sheet Texture */
  70525. spriteSheet: Texture;
  70526. /** Arguments passed with the Constructor */
  70527. options: ISpriteMapOptions;
  70528. /** Public Sprite Storage array, parsed from atlasJSON */
  70529. sprites: Array<ISpriteJSONSprite>;
  70530. /** Returns the Number of Sprites in the System */
  70531. get spriteCount(): number;
  70532. /** Returns the Position of Output Plane*/
  70533. get position(): Vector3;
  70534. /** Returns the Position of Output Plane*/
  70535. set position(v: Vector3);
  70536. /** Returns the Rotation of Output Plane*/
  70537. get rotation(): Vector3;
  70538. /** Returns the Rotation of Output Plane*/
  70539. set rotation(v: Vector3);
  70540. /** Sets the AnimationMap*/
  70541. get animationMap(): RawTexture;
  70542. /** Sets the AnimationMap*/
  70543. set animationMap(v: RawTexture);
  70544. /** Scene that the SpriteMap was created in */
  70545. private _scene;
  70546. /** Texture Buffer of Float32 that holds tile frame data*/
  70547. private _frameMap;
  70548. /** Texture Buffers of Float32 that holds tileMap data*/
  70549. private _tileMaps;
  70550. /** Texture Buffer of Float32 that holds Animation Data*/
  70551. private _animationMap;
  70552. /** Custom ShaderMaterial Central to the System*/
  70553. private _material;
  70554. /** Custom ShaderMaterial Central to the System*/
  70555. private _output;
  70556. /** Systems Time Ticker*/
  70557. private _time;
  70558. /**
  70559. * Creates a new SpriteMap
  70560. * @param name defines the SpriteMaps Name
  70561. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  70562. * @param spriteSheet is the Texture that the Sprites are on.
  70563. * @param options a basic deployment configuration
  70564. * @param scene The Scene that the map is deployed on
  70565. */
  70566. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  70567. /**
  70568. * Returns tileID location
  70569. * @returns Vector2 the cell position ID
  70570. */
  70571. getTileID(): Vector2;
  70572. /**
  70573. * Gets the UV location of the mouse over the SpriteMap.
  70574. * @returns Vector2 the UV position of the mouse interaction
  70575. */
  70576. getMousePosition(): Vector2;
  70577. /**
  70578. * Creates the "frame" texture Buffer
  70579. * -------------------------------------
  70580. * Structure of frames
  70581. * "filename": "Falling-Water-2.png",
  70582. * "frame": {"x":69,"y":103,"w":24,"h":32},
  70583. * "rotated": true,
  70584. * "trimmed": true,
  70585. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  70586. * "sourceSize": {"w":32,"h":32}
  70587. * @returns RawTexture of the frameMap
  70588. */
  70589. private _createFrameBuffer;
  70590. /**
  70591. * Creates the tileMap texture Buffer
  70592. * @param buffer normally and array of numbers, or a false to generate from scratch
  70593. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  70594. * @returns RawTexture of the tileMap
  70595. */
  70596. private _createTileBuffer;
  70597. /**
  70598. * Modifies the data of the tileMaps
  70599. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  70600. * @param pos is the iVector2 Coordinates of the Tile
  70601. * @param tile The SpriteIndex of the new Tile
  70602. */
  70603. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  70604. /**
  70605. * Creates the animationMap texture Buffer
  70606. * @param buffer normally and array of numbers, or a false to generate from scratch
  70607. * @returns RawTexture of the animationMap
  70608. */
  70609. private _createTileAnimationBuffer;
  70610. /**
  70611. * Modifies the data of the animationMap
  70612. * @param cellID is the Index of the Sprite
  70613. * @param _frame is the target Animation frame
  70614. * @param toCell is the Target Index of the next frame of the animation
  70615. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  70616. * @param speed is a global scalar of the time variable on the map.
  70617. */
  70618. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  70619. /**
  70620. * Exports the .tilemaps file
  70621. */
  70622. saveTileMaps(): void;
  70623. /**
  70624. * Imports the .tilemaps file
  70625. * @param url of the .tilemaps file
  70626. */
  70627. loadTileMaps(url: string): void;
  70628. /**
  70629. * Release associated resources
  70630. */
  70631. dispose(): void;
  70632. }
  70633. }
  70634. declare module "babylonjs/Sprites/spritePackedManager" {
  70635. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  70636. import { Scene } from "babylonjs/scene";
  70637. /**
  70638. * Class used to manage multiple sprites of different sizes on the same spritesheet
  70639. * @see http://doc.babylonjs.com/babylon101/sprites
  70640. */
  70641. export class SpritePackedManager extends SpriteManager {
  70642. /** defines the packed manager's name */
  70643. name: string;
  70644. /**
  70645. * Creates a new sprite manager from a packed sprite sheet
  70646. * @param name defines the manager's name
  70647. * @param imgUrl defines the sprite sheet url
  70648. * @param capacity defines the maximum allowed number of sprites
  70649. * @param scene defines the hosting scene
  70650. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  70651. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70652. * @param samplingMode defines the smapling mode to use with spritesheet
  70653. * @param fromPacked set to true; do not alter
  70654. */
  70655. constructor(
  70656. /** defines the packed manager's name */
  70657. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  70658. }
  70659. }
  70660. declare module "babylonjs/Sprites/index" {
  70661. export * from "babylonjs/Sprites/sprite";
  70662. export * from "babylonjs/Sprites/ISprites";
  70663. export * from "babylonjs/Sprites/spriteManager";
  70664. export * from "babylonjs/Sprites/spriteMap";
  70665. export * from "babylonjs/Sprites/spritePackedManager";
  70666. export * from "babylonjs/Sprites/spriteSceneComponent";
  70667. }
  70668. declare module "babylonjs/States/index" {
  70669. export * from "babylonjs/States/alphaCullingState";
  70670. export * from "babylonjs/States/depthCullingState";
  70671. export * from "babylonjs/States/stencilState";
  70672. }
  70673. declare module "babylonjs/Misc/assetsManager" {
  70674. import { Scene } from "babylonjs/scene";
  70675. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70676. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70677. import { Skeleton } from "babylonjs/Bones/skeleton";
  70678. import { Observable } from "babylonjs/Misc/observable";
  70679. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  70680. import { Texture } from "babylonjs/Materials/Textures/texture";
  70681. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  70682. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  70683. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  70684. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  70685. /**
  70686. * Defines the list of states available for a task inside a AssetsManager
  70687. */
  70688. export enum AssetTaskState {
  70689. /**
  70690. * Initialization
  70691. */
  70692. INIT = 0,
  70693. /**
  70694. * Running
  70695. */
  70696. RUNNING = 1,
  70697. /**
  70698. * Done
  70699. */
  70700. DONE = 2,
  70701. /**
  70702. * Error
  70703. */
  70704. ERROR = 3
  70705. }
  70706. /**
  70707. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  70708. */
  70709. export abstract class AbstractAssetTask {
  70710. /**
  70711. * Task name
  70712. */ name: string;
  70713. /**
  70714. * Callback called when the task is successful
  70715. */
  70716. onSuccess: (task: any) => void;
  70717. /**
  70718. * Callback called when the task is not successful
  70719. */
  70720. onError: (task: any, message?: string, exception?: any) => void;
  70721. /**
  70722. * Creates a new AssetsManager
  70723. * @param name defines the name of the task
  70724. */
  70725. constructor(
  70726. /**
  70727. * Task name
  70728. */ name: string);
  70729. private _isCompleted;
  70730. private _taskState;
  70731. private _errorObject;
  70732. /**
  70733. * Get if the task is completed
  70734. */
  70735. get isCompleted(): boolean;
  70736. /**
  70737. * Gets the current state of the task
  70738. */
  70739. get taskState(): AssetTaskState;
  70740. /**
  70741. * Gets the current error object (if task is in error)
  70742. */
  70743. get errorObject(): {
  70744. message?: string;
  70745. exception?: any;
  70746. };
  70747. /**
  70748. * Internal only
  70749. * @hidden
  70750. */
  70751. _setErrorObject(message?: string, exception?: any): void;
  70752. /**
  70753. * Execute the current task
  70754. * @param scene defines the scene where you want your assets to be loaded
  70755. * @param onSuccess is a callback called when the task is successfully executed
  70756. * @param onError is a callback called if an error occurs
  70757. */
  70758. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70759. /**
  70760. * Execute the current task
  70761. * @param scene defines the scene where you want your assets to be loaded
  70762. * @param onSuccess is a callback called when the task is successfully executed
  70763. * @param onError is a callback called if an error occurs
  70764. */
  70765. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70766. /**
  70767. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  70768. * This can be used with failed tasks that have the reason for failure fixed.
  70769. */
  70770. reset(): void;
  70771. private onErrorCallback;
  70772. private onDoneCallback;
  70773. }
  70774. /**
  70775. * Define the interface used by progress events raised during assets loading
  70776. */
  70777. export interface IAssetsProgressEvent {
  70778. /**
  70779. * Defines the number of remaining tasks to process
  70780. */
  70781. remainingCount: number;
  70782. /**
  70783. * Defines the total number of tasks
  70784. */
  70785. totalCount: number;
  70786. /**
  70787. * Defines the task that was just processed
  70788. */
  70789. task: AbstractAssetTask;
  70790. }
  70791. /**
  70792. * Class used to share progress information about assets loading
  70793. */
  70794. export class AssetsProgressEvent implements IAssetsProgressEvent {
  70795. /**
  70796. * Defines the number of remaining tasks to process
  70797. */
  70798. remainingCount: number;
  70799. /**
  70800. * Defines the total number of tasks
  70801. */
  70802. totalCount: number;
  70803. /**
  70804. * Defines the task that was just processed
  70805. */
  70806. task: AbstractAssetTask;
  70807. /**
  70808. * Creates a AssetsProgressEvent
  70809. * @param remainingCount defines the number of remaining tasks to process
  70810. * @param totalCount defines the total number of tasks
  70811. * @param task defines the task that was just processed
  70812. */
  70813. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  70814. }
  70815. /**
  70816. * Define a task used by AssetsManager to load meshes
  70817. */
  70818. export class MeshAssetTask extends AbstractAssetTask {
  70819. /**
  70820. * Defines the name of the task
  70821. */
  70822. name: string;
  70823. /**
  70824. * Defines the list of mesh's names you want to load
  70825. */
  70826. meshesNames: any;
  70827. /**
  70828. * Defines the root url to use as a base to load your meshes and associated resources
  70829. */
  70830. rootUrl: string;
  70831. /**
  70832. * Defines the filename of the scene to load from
  70833. */
  70834. sceneFilename: string;
  70835. /**
  70836. * Gets the list of loaded meshes
  70837. */
  70838. loadedMeshes: Array<AbstractMesh>;
  70839. /**
  70840. * Gets the list of loaded particle systems
  70841. */
  70842. loadedParticleSystems: Array<IParticleSystem>;
  70843. /**
  70844. * Gets the list of loaded skeletons
  70845. */
  70846. loadedSkeletons: Array<Skeleton>;
  70847. /**
  70848. * Gets the list of loaded animation groups
  70849. */
  70850. loadedAnimationGroups: Array<AnimationGroup>;
  70851. /**
  70852. * Callback called when the task is successful
  70853. */
  70854. onSuccess: (task: MeshAssetTask) => void;
  70855. /**
  70856. * Callback called when the task is successful
  70857. */
  70858. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  70859. /**
  70860. * Creates a new MeshAssetTask
  70861. * @param name defines the name of the task
  70862. * @param meshesNames defines the list of mesh's names you want to load
  70863. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  70864. * @param sceneFilename defines the filename of the scene to load from
  70865. */
  70866. constructor(
  70867. /**
  70868. * Defines the name of the task
  70869. */
  70870. name: string,
  70871. /**
  70872. * Defines the list of mesh's names you want to load
  70873. */
  70874. meshesNames: any,
  70875. /**
  70876. * Defines the root url to use as a base to load your meshes and associated resources
  70877. */
  70878. rootUrl: string,
  70879. /**
  70880. * Defines the filename of the scene to load from
  70881. */
  70882. sceneFilename: string);
  70883. /**
  70884. * Execute the current task
  70885. * @param scene defines the scene where you want your assets to be loaded
  70886. * @param onSuccess is a callback called when the task is successfully executed
  70887. * @param onError is a callback called if an error occurs
  70888. */
  70889. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70890. }
  70891. /**
  70892. * Define a task used by AssetsManager to load text content
  70893. */
  70894. export class TextFileAssetTask extends AbstractAssetTask {
  70895. /**
  70896. * Defines the name of the task
  70897. */
  70898. name: string;
  70899. /**
  70900. * Defines the location of the file to load
  70901. */
  70902. url: string;
  70903. /**
  70904. * Gets the loaded text string
  70905. */
  70906. text: string;
  70907. /**
  70908. * Callback called when the task is successful
  70909. */
  70910. onSuccess: (task: TextFileAssetTask) => void;
  70911. /**
  70912. * Callback called when the task is successful
  70913. */
  70914. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  70915. /**
  70916. * Creates a new TextFileAssetTask object
  70917. * @param name defines the name of the task
  70918. * @param url defines the location of the file to load
  70919. */
  70920. constructor(
  70921. /**
  70922. * Defines the name of the task
  70923. */
  70924. name: string,
  70925. /**
  70926. * Defines the location of the file to load
  70927. */
  70928. url: string);
  70929. /**
  70930. * Execute the current task
  70931. * @param scene defines the scene where you want your assets to be loaded
  70932. * @param onSuccess is a callback called when the task is successfully executed
  70933. * @param onError is a callback called if an error occurs
  70934. */
  70935. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70936. }
  70937. /**
  70938. * Define a task used by AssetsManager to load binary data
  70939. */
  70940. export class BinaryFileAssetTask extends AbstractAssetTask {
  70941. /**
  70942. * Defines the name of the task
  70943. */
  70944. name: string;
  70945. /**
  70946. * Defines the location of the file to load
  70947. */
  70948. url: string;
  70949. /**
  70950. * Gets the lodaded data (as an array buffer)
  70951. */
  70952. data: ArrayBuffer;
  70953. /**
  70954. * Callback called when the task is successful
  70955. */
  70956. onSuccess: (task: BinaryFileAssetTask) => void;
  70957. /**
  70958. * Callback called when the task is successful
  70959. */
  70960. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  70961. /**
  70962. * Creates a new BinaryFileAssetTask object
  70963. * @param name defines the name of the new task
  70964. * @param url defines the location of the file to load
  70965. */
  70966. constructor(
  70967. /**
  70968. * Defines the name of the task
  70969. */
  70970. name: string,
  70971. /**
  70972. * Defines the location of the file to load
  70973. */
  70974. url: string);
  70975. /**
  70976. * Execute the current task
  70977. * @param scene defines the scene where you want your assets to be loaded
  70978. * @param onSuccess is a callback called when the task is successfully executed
  70979. * @param onError is a callback called if an error occurs
  70980. */
  70981. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70982. }
  70983. /**
  70984. * Define a task used by AssetsManager to load images
  70985. */
  70986. export class ImageAssetTask extends AbstractAssetTask {
  70987. /**
  70988. * Defines the name of the task
  70989. */
  70990. name: string;
  70991. /**
  70992. * Defines the location of the image to load
  70993. */
  70994. url: string;
  70995. /**
  70996. * Gets the loaded images
  70997. */
  70998. image: HTMLImageElement;
  70999. /**
  71000. * Callback called when the task is successful
  71001. */
  71002. onSuccess: (task: ImageAssetTask) => void;
  71003. /**
  71004. * Callback called when the task is successful
  71005. */
  71006. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  71007. /**
  71008. * Creates a new ImageAssetTask
  71009. * @param name defines the name of the task
  71010. * @param url defines the location of the image to load
  71011. */
  71012. constructor(
  71013. /**
  71014. * Defines the name of the task
  71015. */
  71016. name: string,
  71017. /**
  71018. * Defines the location of the image to load
  71019. */
  71020. url: string);
  71021. /**
  71022. * Execute the current task
  71023. * @param scene defines the scene where you want your assets to be loaded
  71024. * @param onSuccess is a callback called when the task is successfully executed
  71025. * @param onError is a callback called if an error occurs
  71026. */
  71027. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71028. }
  71029. /**
  71030. * Defines the interface used by texture loading tasks
  71031. */
  71032. export interface ITextureAssetTask<TEX extends BaseTexture> {
  71033. /**
  71034. * Gets the loaded texture
  71035. */
  71036. texture: TEX;
  71037. }
  71038. /**
  71039. * Define a task used by AssetsManager to load 2D textures
  71040. */
  71041. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  71042. /**
  71043. * Defines the name of the task
  71044. */
  71045. name: string;
  71046. /**
  71047. * Defines the location of the file to load
  71048. */
  71049. url: string;
  71050. /**
  71051. * Defines if mipmap should not be generated (default is false)
  71052. */
  71053. noMipmap?: boolean | undefined;
  71054. /**
  71055. * Defines if texture must be inverted on Y axis (default is false)
  71056. */
  71057. invertY?: boolean | undefined;
  71058. /**
  71059. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71060. */
  71061. samplingMode: number;
  71062. /**
  71063. * Gets the loaded texture
  71064. */
  71065. texture: Texture;
  71066. /**
  71067. * Callback called when the task is successful
  71068. */
  71069. onSuccess: (task: TextureAssetTask) => void;
  71070. /**
  71071. * Callback called when the task is successful
  71072. */
  71073. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  71074. /**
  71075. * Creates a new TextureAssetTask object
  71076. * @param name defines the name of the task
  71077. * @param url defines the location of the file to load
  71078. * @param noMipmap defines if mipmap should not be generated (default is false)
  71079. * @param invertY defines if texture must be inverted on Y axis (default is false)
  71080. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71081. */
  71082. constructor(
  71083. /**
  71084. * Defines the name of the task
  71085. */
  71086. name: string,
  71087. /**
  71088. * Defines the location of the file to load
  71089. */
  71090. url: string,
  71091. /**
  71092. * Defines if mipmap should not be generated (default is false)
  71093. */
  71094. noMipmap?: boolean | undefined,
  71095. /**
  71096. * Defines if texture must be inverted on Y axis (default is false)
  71097. */
  71098. invertY?: boolean | undefined,
  71099. /**
  71100. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71101. */
  71102. samplingMode?: number);
  71103. /**
  71104. * Execute the current task
  71105. * @param scene defines the scene where you want your assets to be loaded
  71106. * @param onSuccess is a callback called when the task is successfully executed
  71107. * @param onError is a callback called if an error occurs
  71108. */
  71109. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71110. }
  71111. /**
  71112. * Define a task used by AssetsManager to load cube textures
  71113. */
  71114. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  71115. /**
  71116. * Defines the name of the task
  71117. */
  71118. name: string;
  71119. /**
  71120. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71121. */
  71122. url: string;
  71123. /**
  71124. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71125. */
  71126. extensions?: string[] | undefined;
  71127. /**
  71128. * Defines if mipmaps should not be generated (default is false)
  71129. */
  71130. noMipmap?: boolean | undefined;
  71131. /**
  71132. * Defines the explicit list of files (undefined by default)
  71133. */
  71134. files?: string[] | undefined;
  71135. /**
  71136. * Gets the loaded texture
  71137. */
  71138. texture: CubeTexture;
  71139. /**
  71140. * Callback called when the task is successful
  71141. */
  71142. onSuccess: (task: CubeTextureAssetTask) => void;
  71143. /**
  71144. * Callback called when the task is successful
  71145. */
  71146. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  71147. /**
  71148. * Creates a new CubeTextureAssetTask
  71149. * @param name defines the name of the task
  71150. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71151. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71152. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71153. * @param files defines the explicit list of files (undefined by default)
  71154. */
  71155. constructor(
  71156. /**
  71157. * Defines the name of the task
  71158. */
  71159. name: string,
  71160. /**
  71161. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71162. */
  71163. url: string,
  71164. /**
  71165. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71166. */
  71167. extensions?: string[] | undefined,
  71168. /**
  71169. * Defines if mipmaps should not be generated (default is false)
  71170. */
  71171. noMipmap?: boolean | undefined,
  71172. /**
  71173. * Defines the explicit list of files (undefined by default)
  71174. */
  71175. files?: string[] | undefined);
  71176. /**
  71177. * Execute the current task
  71178. * @param scene defines the scene where you want your assets to be loaded
  71179. * @param onSuccess is a callback called when the task is successfully executed
  71180. * @param onError is a callback called if an error occurs
  71181. */
  71182. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71183. }
  71184. /**
  71185. * Define a task used by AssetsManager to load HDR cube textures
  71186. */
  71187. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  71188. /**
  71189. * Defines the name of the task
  71190. */
  71191. name: string;
  71192. /**
  71193. * Defines the location of the file to load
  71194. */
  71195. url: string;
  71196. /**
  71197. * Defines the desired size (the more it increases the longer the generation will be)
  71198. */
  71199. size: number;
  71200. /**
  71201. * Defines if mipmaps should not be generated (default is false)
  71202. */
  71203. noMipmap: boolean;
  71204. /**
  71205. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71206. */
  71207. generateHarmonics: boolean;
  71208. /**
  71209. * 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)
  71210. */
  71211. gammaSpace: boolean;
  71212. /**
  71213. * Internal Use Only
  71214. */
  71215. reserved: boolean;
  71216. /**
  71217. * Gets the loaded texture
  71218. */
  71219. texture: HDRCubeTexture;
  71220. /**
  71221. * Callback called when the task is successful
  71222. */
  71223. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  71224. /**
  71225. * Callback called when the task is successful
  71226. */
  71227. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  71228. /**
  71229. * Creates a new HDRCubeTextureAssetTask object
  71230. * @param name defines the name of the task
  71231. * @param url defines the location of the file to load
  71232. * @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.
  71233. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71234. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71235. * @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)
  71236. * @param reserved Internal use only
  71237. */
  71238. constructor(
  71239. /**
  71240. * Defines the name of the task
  71241. */
  71242. name: string,
  71243. /**
  71244. * Defines the location of the file to load
  71245. */
  71246. url: string,
  71247. /**
  71248. * Defines the desired size (the more it increases the longer the generation will be)
  71249. */
  71250. size: number,
  71251. /**
  71252. * Defines if mipmaps should not be generated (default is false)
  71253. */
  71254. noMipmap?: boolean,
  71255. /**
  71256. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71257. */
  71258. generateHarmonics?: boolean,
  71259. /**
  71260. * 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)
  71261. */
  71262. gammaSpace?: boolean,
  71263. /**
  71264. * Internal Use Only
  71265. */
  71266. reserved?: boolean);
  71267. /**
  71268. * Execute the current task
  71269. * @param scene defines the scene where you want your assets to be loaded
  71270. * @param onSuccess is a callback called when the task is successfully executed
  71271. * @param onError is a callback called if an error occurs
  71272. */
  71273. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71274. }
  71275. /**
  71276. * Define a task used by AssetsManager to load Equirectangular cube textures
  71277. */
  71278. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  71279. /**
  71280. * Defines the name of the task
  71281. */
  71282. name: string;
  71283. /**
  71284. * Defines the location of the file to load
  71285. */
  71286. url: string;
  71287. /**
  71288. * Defines the desired size (the more it increases the longer the generation will be)
  71289. */
  71290. size: number;
  71291. /**
  71292. * Defines if mipmaps should not be generated (default is false)
  71293. */
  71294. noMipmap: boolean;
  71295. /**
  71296. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71297. * but the standard material would require them in Gamma space) (default is true)
  71298. */
  71299. gammaSpace: boolean;
  71300. /**
  71301. * Gets the loaded texture
  71302. */
  71303. texture: EquiRectangularCubeTexture;
  71304. /**
  71305. * Callback called when the task is successful
  71306. */
  71307. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  71308. /**
  71309. * Callback called when the task is successful
  71310. */
  71311. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  71312. /**
  71313. * Creates a new EquiRectangularCubeTextureAssetTask object
  71314. * @param name defines the name of the task
  71315. * @param url defines the location of the file to load
  71316. * @param size defines the desired size (the more it increases the longer the generation will be)
  71317. * If the size is omitted this implies you are using a preprocessed cubemap.
  71318. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71319. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  71320. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  71321. * (default is true)
  71322. */
  71323. constructor(
  71324. /**
  71325. * Defines the name of the task
  71326. */
  71327. name: string,
  71328. /**
  71329. * Defines the location of the file to load
  71330. */
  71331. url: string,
  71332. /**
  71333. * Defines the desired size (the more it increases the longer the generation will be)
  71334. */
  71335. size: number,
  71336. /**
  71337. * Defines if mipmaps should not be generated (default is false)
  71338. */
  71339. noMipmap?: boolean,
  71340. /**
  71341. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71342. * but the standard material would require them in Gamma space) (default is true)
  71343. */
  71344. gammaSpace?: boolean);
  71345. /**
  71346. * Execute the current task
  71347. * @param scene defines the scene where you want your assets to be loaded
  71348. * @param onSuccess is a callback called when the task is successfully executed
  71349. * @param onError is a callback called if an error occurs
  71350. */
  71351. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71352. }
  71353. /**
  71354. * This class can be used to easily import assets into a scene
  71355. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  71356. */
  71357. export class AssetsManager {
  71358. private _scene;
  71359. private _isLoading;
  71360. protected _tasks: AbstractAssetTask[];
  71361. protected _waitingTasksCount: number;
  71362. protected _totalTasksCount: number;
  71363. /**
  71364. * Callback called when all tasks are processed
  71365. */
  71366. onFinish: (tasks: AbstractAssetTask[]) => void;
  71367. /**
  71368. * Callback called when a task is successful
  71369. */
  71370. onTaskSuccess: (task: AbstractAssetTask) => void;
  71371. /**
  71372. * Callback called when a task had an error
  71373. */
  71374. onTaskError: (task: AbstractAssetTask) => void;
  71375. /**
  71376. * Callback called when a task is done (whatever the result is)
  71377. */
  71378. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  71379. /**
  71380. * Observable called when all tasks are processed
  71381. */
  71382. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  71383. /**
  71384. * Observable called when a task had an error
  71385. */
  71386. onTaskErrorObservable: Observable<AbstractAssetTask>;
  71387. /**
  71388. * Observable called when all tasks were executed
  71389. */
  71390. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  71391. /**
  71392. * Observable called when a task is done (whatever the result is)
  71393. */
  71394. onProgressObservable: Observable<IAssetsProgressEvent>;
  71395. /**
  71396. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  71397. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  71398. */
  71399. useDefaultLoadingScreen: boolean;
  71400. /**
  71401. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  71402. * when all assets have been downloaded.
  71403. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  71404. */
  71405. autoHideLoadingUI: boolean;
  71406. /**
  71407. * Creates a new AssetsManager
  71408. * @param scene defines the scene to work on
  71409. */
  71410. constructor(scene: Scene);
  71411. /**
  71412. * Add a MeshAssetTask to the list of active tasks
  71413. * @param taskName defines the name of the new task
  71414. * @param meshesNames defines the name of meshes to load
  71415. * @param rootUrl defines the root url to use to locate files
  71416. * @param sceneFilename defines the filename of the scene file
  71417. * @returns a new MeshAssetTask object
  71418. */
  71419. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  71420. /**
  71421. * Add a TextFileAssetTask to the list of active tasks
  71422. * @param taskName defines the name of the new task
  71423. * @param url defines the url of the file to load
  71424. * @returns a new TextFileAssetTask object
  71425. */
  71426. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  71427. /**
  71428. * Add a BinaryFileAssetTask to the list of active tasks
  71429. * @param taskName defines the name of the new task
  71430. * @param url defines the url of the file to load
  71431. * @returns a new BinaryFileAssetTask object
  71432. */
  71433. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  71434. /**
  71435. * Add a ImageAssetTask to the list of active tasks
  71436. * @param taskName defines the name of the new task
  71437. * @param url defines the url of the file to load
  71438. * @returns a new ImageAssetTask object
  71439. */
  71440. addImageTask(taskName: string, url: string): ImageAssetTask;
  71441. /**
  71442. * Add a TextureAssetTask to the list of active tasks
  71443. * @param taskName defines the name of the new task
  71444. * @param url defines the url of the file to load
  71445. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71446. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  71447. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  71448. * @returns a new TextureAssetTask object
  71449. */
  71450. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  71451. /**
  71452. * Add a CubeTextureAssetTask 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 extensions defines the extension to use to load the cube map (can be null)
  71456. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71457. * @param files defines the list of files to load (can be null)
  71458. * @returns a new CubeTextureAssetTask object
  71459. */
  71460. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  71461. /**
  71462. *
  71463. * Add a HDRCubeTextureAssetTask to the list of active tasks
  71464. * @param taskName defines the name of the new task
  71465. * @param url defines the url of the file to load
  71466. * @param size defines the size you want for the cubemap (can be null)
  71467. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71468. * @param generateHarmonics defines if you want to automatically generate (true by default)
  71469. * @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)
  71470. * @param reserved Internal use only
  71471. * @returns a new HDRCubeTextureAssetTask object
  71472. */
  71473. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  71474. /**
  71475. *
  71476. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  71477. * @param taskName defines the name of the new task
  71478. * @param url defines the url of the file to load
  71479. * @param size defines the size you want for the cubemap (can be null)
  71480. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71481. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  71482. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  71483. * @returns a new EquiRectangularCubeTextureAssetTask object
  71484. */
  71485. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  71486. /**
  71487. * Remove a task from the assets manager.
  71488. * @param task the task to remove
  71489. */
  71490. removeTask(task: AbstractAssetTask): void;
  71491. private _decreaseWaitingTasksCount;
  71492. private _runTask;
  71493. /**
  71494. * Reset the AssetsManager and remove all tasks
  71495. * @return the current instance of the AssetsManager
  71496. */
  71497. reset(): AssetsManager;
  71498. /**
  71499. * Start the loading process
  71500. * @return the current instance of the AssetsManager
  71501. */
  71502. load(): AssetsManager;
  71503. /**
  71504. * Start the loading process as an async operation
  71505. * @return a promise returning the list of failed tasks
  71506. */
  71507. loadAsync(): Promise<void>;
  71508. }
  71509. }
  71510. declare module "babylonjs/Misc/deferred" {
  71511. /**
  71512. * Wrapper class for promise with external resolve and reject.
  71513. */
  71514. export class Deferred<T> {
  71515. /**
  71516. * The promise associated with this deferred object.
  71517. */
  71518. readonly promise: Promise<T>;
  71519. private _resolve;
  71520. private _reject;
  71521. /**
  71522. * The resolve method of the promise associated with this deferred object.
  71523. */
  71524. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  71525. /**
  71526. * The reject method of the promise associated with this deferred object.
  71527. */
  71528. get reject(): (reason?: any) => void;
  71529. /**
  71530. * Constructor for this deferred object.
  71531. */
  71532. constructor();
  71533. }
  71534. }
  71535. declare module "babylonjs/Misc/meshExploder" {
  71536. import { Mesh } from "babylonjs/Meshes/mesh";
  71537. /**
  71538. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  71539. */
  71540. export class MeshExploder {
  71541. private _centerMesh;
  71542. private _meshes;
  71543. private _meshesOrigins;
  71544. private _toCenterVectors;
  71545. private _scaledDirection;
  71546. private _newPosition;
  71547. private _centerPosition;
  71548. /**
  71549. * Explodes meshes from a center mesh.
  71550. * @param meshes The meshes to explode.
  71551. * @param centerMesh The mesh to be center of explosion.
  71552. */
  71553. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  71554. private _setCenterMesh;
  71555. /**
  71556. * Get class name
  71557. * @returns "MeshExploder"
  71558. */
  71559. getClassName(): string;
  71560. /**
  71561. * "Exploded meshes"
  71562. * @returns Array of meshes with the centerMesh at index 0.
  71563. */
  71564. getMeshes(): Array<Mesh>;
  71565. /**
  71566. * Explodes meshes giving a specific direction
  71567. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  71568. */
  71569. explode(direction?: number): void;
  71570. }
  71571. }
  71572. declare module "babylonjs/Misc/filesInput" {
  71573. import { Engine } from "babylonjs/Engines/engine";
  71574. import { Scene } from "babylonjs/scene";
  71575. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  71576. /**
  71577. * Class used to help managing file picking and drag'n'drop
  71578. */
  71579. export class FilesInput {
  71580. /**
  71581. * List of files ready to be loaded
  71582. */
  71583. static get FilesToLoad(): {
  71584. [key: string]: File;
  71585. };
  71586. /**
  71587. * Callback called when a file is processed
  71588. */
  71589. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  71590. private _engine;
  71591. private _currentScene;
  71592. private _sceneLoadedCallback;
  71593. private _progressCallback;
  71594. private _additionalRenderLoopLogicCallback;
  71595. private _textureLoadingCallback;
  71596. private _startingProcessingFilesCallback;
  71597. private _onReloadCallback;
  71598. private _errorCallback;
  71599. private _elementToMonitor;
  71600. private _sceneFileToLoad;
  71601. private _filesToLoad;
  71602. /**
  71603. * Creates a new FilesInput
  71604. * @param engine defines the rendering engine
  71605. * @param scene defines the hosting scene
  71606. * @param sceneLoadedCallback callback called when scene is loaded
  71607. * @param progressCallback callback called to track progress
  71608. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  71609. * @param textureLoadingCallback callback called when a texture is loading
  71610. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  71611. * @param onReloadCallback callback called when a reload is requested
  71612. * @param errorCallback callback call if an error occurs
  71613. */
  71614. 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);
  71615. private _dragEnterHandler;
  71616. private _dragOverHandler;
  71617. private _dropHandler;
  71618. /**
  71619. * Calls this function to listen to drag'n'drop events on a specific DOM element
  71620. * @param elementToMonitor defines the DOM element to track
  71621. */
  71622. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  71623. /**
  71624. * Release all associated resources
  71625. */
  71626. dispose(): void;
  71627. private renderFunction;
  71628. private drag;
  71629. private drop;
  71630. private _traverseFolder;
  71631. private _processFiles;
  71632. /**
  71633. * Load files from a drop event
  71634. * @param event defines the drop event to use as source
  71635. */
  71636. loadFiles(event: any): void;
  71637. private _processReload;
  71638. /**
  71639. * Reload the current scene from the loaded files
  71640. */
  71641. reload(): void;
  71642. }
  71643. }
  71644. declare module "babylonjs/Misc/HighDynamicRange/index" {
  71645. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  71646. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  71647. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  71648. }
  71649. declare module "babylonjs/Misc/sceneOptimizer" {
  71650. import { Scene, IDisposable } from "babylonjs/scene";
  71651. import { Observable } from "babylonjs/Misc/observable";
  71652. /**
  71653. * Defines the root class used to create scene optimization to use with SceneOptimizer
  71654. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71655. */
  71656. export class SceneOptimization {
  71657. /**
  71658. * Defines the priority of this optimization (0 by default which means first in the list)
  71659. */
  71660. priority: number;
  71661. /**
  71662. * Gets a string describing the action executed by the current optimization
  71663. * @returns description string
  71664. */
  71665. getDescription(): string;
  71666. /**
  71667. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71668. * @param scene defines the current scene where to apply this optimization
  71669. * @param optimizer defines the current optimizer
  71670. * @returns true if everything that can be done was applied
  71671. */
  71672. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71673. /**
  71674. * Creates the SceneOptimization object
  71675. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71676. * @param desc defines the description associated with the optimization
  71677. */
  71678. constructor(
  71679. /**
  71680. * Defines the priority of this optimization (0 by default which means first in the list)
  71681. */
  71682. priority?: number);
  71683. }
  71684. /**
  71685. * Defines an optimization used to reduce the size of render target textures
  71686. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71687. */
  71688. export class TextureOptimization extends SceneOptimization {
  71689. /**
  71690. * Defines the priority of this optimization (0 by default which means first in the list)
  71691. */
  71692. priority: number;
  71693. /**
  71694. * 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
  71695. */
  71696. maximumSize: number;
  71697. /**
  71698. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71699. */
  71700. step: number;
  71701. /**
  71702. * Gets a string describing the action executed by the current optimization
  71703. * @returns description string
  71704. */
  71705. getDescription(): string;
  71706. /**
  71707. * Creates the TextureOptimization object
  71708. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71709. * @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
  71710. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71711. */
  71712. constructor(
  71713. /**
  71714. * Defines the priority of this optimization (0 by default which means first in the list)
  71715. */
  71716. priority?: number,
  71717. /**
  71718. * 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
  71719. */
  71720. maximumSize?: number,
  71721. /**
  71722. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71723. */
  71724. step?: number);
  71725. /**
  71726. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71727. * @param scene defines the current scene where to apply this optimization
  71728. * @param optimizer defines the current optimizer
  71729. * @returns true if everything that can be done was applied
  71730. */
  71731. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71732. }
  71733. /**
  71734. * Defines an optimization used to increase or decrease the rendering resolution
  71735. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71736. */
  71737. export class HardwareScalingOptimization extends SceneOptimization {
  71738. /**
  71739. * Defines the priority of this optimization (0 by default which means first in the list)
  71740. */
  71741. priority: number;
  71742. /**
  71743. * Defines the maximum scale to use (2 by default)
  71744. */
  71745. maximumScale: number;
  71746. /**
  71747. * Defines the step to use between two passes (0.5 by default)
  71748. */
  71749. step: number;
  71750. private _currentScale;
  71751. private _directionOffset;
  71752. /**
  71753. * Gets a string describing the action executed by the current optimization
  71754. * @return description string
  71755. */
  71756. getDescription(): string;
  71757. /**
  71758. * Creates the HardwareScalingOptimization object
  71759. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71760. * @param maximumScale defines the maximum scale to use (2 by default)
  71761. * @param step defines the step to use between two passes (0.5 by default)
  71762. */
  71763. constructor(
  71764. /**
  71765. * Defines the priority of this optimization (0 by default which means first in the list)
  71766. */
  71767. priority?: number,
  71768. /**
  71769. * Defines the maximum scale to use (2 by default)
  71770. */
  71771. maximumScale?: number,
  71772. /**
  71773. * Defines the step to use between two passes (0.5 by default)
  71774. */
  71775. step?: number);
  71776. /**
  71777. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71778. * @param scene defines the current scene where to apply this optimization
  71779. * @param optimizer defines the current optimizer
  71780. * @returns true if everything that can be done was applied
  71781. */
  71782. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71783. }
  71784. /**
  71785. * Defines an optimization used to remove shadows
  71786. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71787. */
  71788. export class ShadowsOptimization extends SceneOptimization {
  71789. /**
  71790. * Gets a string describing the action executed by the current optimization
  71791. * @return description string
  71792. */
  71793. getDescription(): string;
  71794. /**
  71795. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71796. * @param scene defines the current scene where to apply this optimization
  71797. * @param optimizer defines the current optimizer
  71798. * @returns true if everything that can be done was applied
  71799. */
  71800. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71801. }
  71802. /**
  71803. * Defines an optimization used to turn post-processes off
  71804. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71805. */
  71806. export class PostProcessesOptimization extends SceneOptimization {
  71807. /**
  71808. * Gets a string describing the action executed by the current optimization
  71809. * @return description string
  71810. */
  71811. getDescription(): string;
  71812. /**
  71813. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71814. * @param scene defines the current scene where to apply this optimization
  71815. * @param optimizer defines the current optimizer
  71816. * @returns true if everything that can be done was applied
  71817. */
  71818. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71819. }
  71820. /**
  71821. * Defines an optimization used to turn lens flares off
  71822. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71823. */
  71824. export class LensFlaresOptimization extends SceneOptimization {
  71825. /**
  71826. * Gets a string describing the action executed by the current optimization
  71827. * @return description string
  71828. */
  71829. getDescription(): string;
  71830. /**
  71831. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71832. * @param scene defines the current scene where to apply this optimization
  71833. * @param optimizer defines the current optimizer
  71834. * @returns true if everything that can be done was applied
  71835. */
  71836. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71837. }
  71838. /**
  71839. * Defines an optimization based on user defined callback.
  71840. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71841. */
  71842. export class CustomOptimization extends SceneOptimization {
  71843. /**
  71844. * Callback called to apply the custom optimization.
  71845. */
  71846. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  71847. /**
  71848. * Callback called to get custom description
  71849. */
  71850. onGetDescription: () => string;
  71851. /**
  71852. * Gets a string describing the action executed by the current optimization
  71853. * @returns description string
  71854. */
  71855. getDescription(): string;
  71856. /**
  71857. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71858. * @param scene defines the current scene where to apply this optimization
  71859. * @param optimizer defines the current optimizer
  71860. * @returns true if everything that can be done was applied
  71861. */
  71862. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71863. }
  71864. /**
  71865. * Defines an optimization used to turn particles off
  71866. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71867. */
  71868. export class ParticlesOptimization extends SceneOptimization {
  71869. /**
  71870. * Gets a string describing the action executed by the current optimization
  71871. * @return description string
  71872. */
  71873. getDescription(): string;
  71874. /**
  71875. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71876. * @param scene defines the current scene where to apply this optimization
  71877. * @param optimizer defines the current optimizer
  71878. * @returns true if everything that can be done was applied
  71879. */
  71880. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71881. }
  71882. /**
  71883. * Defines an optimization used to turn render targets off
  71884. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71885. */
  71886. export class RenderTargetsOptimization extends SceneOptimization {
  71887. /**
  71888. * Gets a string describing the action executed by the current optimization
  71889. * @return description string
  71890. */
  71891. getDescription(): string;
  71892. /**
  71893. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71894. * @param scene defines the current scene where to apply this optimization
  71895. * @param optimizer defines the current optimizer
  71896. * @returns true if everything that can be done was applied
  71897. */
  71898. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71899. }
  71900. /**
  71901. * Defines an optimization used to merge meshes with compatible materials
  71902. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71903. */
  71904. export class MergeMeshesOptimization extends SceneOptimization {
  71905. private static _UpdateSelectionTree;
  71906. /**
  71907. * Gets or sets a boolean which defines if optimization octree has to be updated
  71908. */
  71909. static get UpdateSelectionTree(): boolean;
  71910. /**
  71911. * Gets or sets a boolean which defines if optimization octree has to be updated
  71912. */
  71913. static set UpdateSelectionTree(value: boolean);
  71914. /**
  71915. * Gets a string describing the action executed by the current optimization
  71916. * @return description string
  71917. */
  71918. getDescription(): string;
  71919. private _canBeMerged;
  71920. /**
  71921. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71922. * @param scene defines the current scene where to apply this optimization
  71923. * @param optimizer defines the current optimizer
  71924. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  71925. * @returns true if everything that can be done was applied
  71926. */
  71927. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  71928. }
  71929. /**
  71930. * Defines a list of options used by SceneOptimizer
  71931. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71932. */
  71933. export class SceneOptimizerOptions {
  71934. /**
  71935. * Defines the target frame rate to reach (60 by default)
  71936. */
  71937. targetFrameRate: number;
  71938. /**
  71939. * Defines the interval between two checkes (2000ms by default)
  71940. */
  71941. trackerDuration: number;
  71942. /**
  71943. * Gets the list of optimizations to apply
  71944. */
  71945. optimizations: SceneOptimization[];
  71946. /**
  71947. * Creates a new list of options used by SceneOptimizer
  71948. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  71949. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  71950. */
  71951. constructor(
  71952. /**
  71953. * Defines the target frame rate to reach (60 by default)
  71954. */
  71955. targetFrameRate?: number,
  71956. /**
  71957. * Defines the interval between two checkes (2000ms by default)
  71958. */
  71959. trackerDuration?: number);
  71960. /**
  71961. * Add a new optimization
  71962. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  71963. * @returns the current SceneOptimizerOptions
  71964. */
  71965. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  71966. /**
  71967. * Add a new custom optimization
  71968. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  71969. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  71970. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71971. * @returns the current SceneOptimizerOptions
  71972. */
  71973. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  71974. /**
  71975. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  71976. * @param targetFrameRate defines the target frame rate (60 by default)
  71977. * @returns a SceneOptimizerOptions object
  71978. */
  71979. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71980. /**
  71981. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  71982. * @param targetFrameRate defines the target frame rate (60 by default)
  71983. * @returns a SceneOptimizerOptions object
  71984. */
  71985. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71986. /**
  71987. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  71988. * @param targetFrameRate defines the target frame rate (60 by default)
  71989. * @returns a SceneOptimizerOptions object
  71990. */
  71991. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71992. }
  71993. /**
  71994. * Class used to run optimizations in order to reach a target frame rate
  71995. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71996. */
  71997. export class SceneOptimizer implements IDisposable {
  71998. private _isRunning;
  71999. private _options;
  72000. private _scene;
  72001. private _currentPriorityLevel;
  72002. private _targetFrameRate;
  72003. private _trackerDuration;
  72004. private _currentFrameRate;
  72005. private _sceneDisposeObserver;
  72006. private _improvementMode;
  72007. /**
  72008. * Defines an observable called when the optimizer reaches the target frame rate
  72009. */
  72010. onSuccessObservable: Observable<SceneOptimizer>;
  72011. /**
  72012. * Defines an observable called when the optimizer enables an optimization
  72013. */
  72014. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  72015. /**
  72016. * Defines an observable called when the optimizer is not able to reach the target frame rate
  72017. */
  72018. onFailureObservable: Observable<SceneOptimizer>;
  72019. /**
  72020. * Gets a boolean indicating if the optimizer is in improvement mode
  72021. */
  72022. get isInImprovementMode(): boolean;
  72023. /**
  72024. * Gets the current priority level (0 at start)
  72025. */
  72026. get currentPriorityLevel(): number;
  72027. /**
  72028. * Gets the current frame rate checked by the SceneOptimizer
  72029. */
  72030. get currentFrameRate(): number;
  72031. /**
  72032. * Gets or sets the current target frame rate (60 by default)
  72033. */
  72034. get targetFrameRate(): number;
  72035. /**
  72036. * Gets or sets the current target frame rate (60 by default)
  72037. */
  72038. set targetFrameRate(value: number);
  72039. /**
  72040. * Gets or sets the current interval between two checks (every 2000ms by default)
  72041. */
  72042. get trackerDuration(): number;
  72043. /**
  72044. * Gets or sets the current interval between two checks (every 2000ms by default)
  72045. */
  72046. set trackerDuration(value: number);
  72047. /**
  72048. * Gets the list of active optimizations
  72049. */
  72050. get optimizations(): SceneOptimization[];
  72051. /**
  72052. * Creates a new SceneOptimizer
  72053. * @param scene defines the scene to work on
  72054. * @param options defines the options to use with the SceneOptimizer
  72055. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  72056. * @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)
  72057. */
  72058. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  72059. /**
  72060. * Stops the current optimizer
  72061. */
  72062. stop(): void;
  72063. /**
  72064. * Reset the optimizer to initial step (current priority level = 0)
  72065. */
  72066. reset(): void;
  72067. /**
  72068. * Start the optimizer. By default it will try to reach a specific framerate
  72069. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  72070. */
  72071. start(): void;
  72072. private _checkCurrentState;
  72073. /**
  72074. * Release all resources
  72075. */
  72076. dispose(): void;
  72077. /**
  72078. * Helper function to create a SceneOptimizer with one single line of code
  72079. * @param scene defines the scene to work on
  72080. * @param options defines the options to use with the SceneOptimizer
  72081. * @param onSuccess defines a callback to call on success
  72082. * @param onFailure defines a callback to call on failure
  72083. * @returns the new SceneOptimizer object
  72084. */
  72085. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  72086. }
  72087. }
  72088. declare module "babylonjs/Misc/sceneSerializer" {
  72089. import { Scene } from "babylonjs/scene";
  72090. /**
  72091. * Class used to serialize a scene into a string
  72092. */
  72093. export class SceneSerializer {
  72094. /**
  72095. * Clear cache used by a previous serialization
  72096. */
  72097. static ClearCache(): void;
  72098. /**
  72099. * Serialize a scene into a JSON compatible object
  72100. * @param scene defines the scene to serialize
  72101. * @returns a JSON compatible object
  72102. */
  72103. static Serialize(scene: Scene): any;
  72104. /**
  72105. * Serialize a mesh into a JSON compatible object
  72106. * @param toSerialize defines the mesh to serialize
  72107. * @param withParents defines if parents must be serialized as well
  72108. * @param withChildren defines if children must be serialized as well
  72109. * @returns a JSON compatible object
  72110. */
  72111. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  72112. }
  72113. }
  72114. declare module "babylonjs/Misc/textureTools" {
  72115. import { Texture } from "babylonjs/Materials/Textures/texture";
  72116. /**
  72117. * Class used to host texture specific utilities
  72118. */
  72119. export class TextureTools {
  72120. /**
  72121. * Uses the GPU to create a copy texture rescaled at a given size
  72122. * @param texture Texture to copy from
  72123. * @param width defines the desired width
  72124. * @param height defines the desired height
  72125. * @param useBilinearMode defines if bilinear mode has to be used
  72126. * @return the generated texture
  72127. */
  72128. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  72129. }
  72130. }
  72131. declare module "babylonjs/Misc/videoRecorder" {
  72132. import { Nullable } from "babylonjs/types";
  72133. import { Engine } from "babylonjs/Engines/engine";
  72134. /**
  72135. * This represents the different options available for the video capture.
  72136. */
  72137. export interface VideoRecorderOptions {
  72138. /** Defines the mime type of the video. */
  72139. mimeType: string;
  72140. /** Defines the FPS the video should be recorded at. */
  72141. fps: number;
  72142. /** Defines the chunk size for the recording data. */
  72143. recordChunckSize: number;
  72144. /** The audio tracks to attach to the recording. */
  72145. audioTracks?: MediaStreamTrack[];
  72146. }
  72147. /**
  72148. * This can help with recording videos from BabylonJS.
  72149. * This is based on the available WebRTC functionalities of the browser.
  72150. *
  72151. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  72152. */
  72153. export class VideoRecorder {
  72154. private static readonly _defaultOptions;
  72155. /**
  72156. * Returns whether or not the VideoRecorder is available in your browser.
  72157. * @param engine Defines the Babylon Engine.
  72158. * @returns true if supported otherwise false.
  72159. */
  72160. static IsSupported(engine: Engine): boolean;
  72161. private readonly _options;
  72162. private _canvas;
  72163. private _mediaRecorder;
  72164. private _recordedChunks;
  72165. private _fileName;
  72166. private _resolve;
  72167. private _reject;
  72168. /**
  72169. * True when a recording is already in progress.
  72170. */
  72171. get isRecording(): boolean;
  72172. /**
  72173. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  72174. * @param engine Defines the BabylonJS Engine you wish to record.
  72175. * @param options Defines options that can be used to customize the capture.
  72176. */
  72177. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  72178. /**
  72179. * Stops the current recording before the default capture timeout passed in the startRecording function.
  72180. */
  72181. stopRecording(): void;
  72182. /**
  72183. * Starts recording the canvas for a max duration specified in parameters.
  72184. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  72185. * If null no automatic download will start and you can rely on the promise to get the data back.
  72186. * @param maxDuration Defines the maximum recording time in seconds.
  72187. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  72188. * @return A promise callback at the end of the recording with the video data in Blob.
  72189. */
  72190. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  72191. /**
  72192. * Releases internal resources used during the recording.
  72193. */
  72194. dispose(): void;
  72195. private _handleDataAvailable;
  72196. private _handleError;
  72197. private _handleStop;
  72198. }
  72199. }
  72200. declare module "babylonjs/Misc/screenshotTools" {
  72201. import { Camera } from "babylonjs/Cameras/camera";
  72202. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  72203. import { Engine } from "babylonjs/Engines/engine";
  72204. /**
  72205. * Class containing a set of static utilities functions for screenshots
  72206. */
  72207. export class ScreenshotTools {
  72208. /**
  72209. * Captures a screenshot of the current rendering
  72210. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72211. * @param engine defines the rendering engine
  72212. * @param camera defines the source camera
  72213. * @param size This parameter can be set to a single number or to an object with the
  72214. * following (optional) properties: precision, width, height. If a single number is passed,
  72215. * it will be used for both width and height. If an object is passed, the screenshot size
  72216. * will be derived from the parameters. The precision property is a multiplier allowing
  72217. * rendering at a higher or lower resolution
  72218. * @param successCallback defines the callback receives a single parameter which contains the
  72219. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72220. * src parameter of an <img> to display it
  72221. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72222. * Check your browser for supported MIME types
  72223. */
  72224. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  72225. /**
  72226. * Captures a screenshot of the current rendering
  72227. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72228. * @param engine defines the rendering engine
  72229. * @param camera defines the source camera
  72230. * @param size This parameter can be set to a single number or to an object with the
  72231. * following (optional) properties: precision, width, height. If a single number is passed,
  72232. * it will be used for both width and height. If an object is passed, the screenshot size
  72233. * will be derived from the parameters. The precision property is a multiplier allowing
  72234. * rendering at a higher or lower resolution
  72235. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72236. * Check your browser for supported MIME types
  72237. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72238. * to the src parameter of an <img> to display it
  72239. */
  72240. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  72241. /**
  72242. * Generates an image screenshot from the specified camera.
  72243. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72244. * @param engine The engine to use for rendering
  72245. * @param camera The camera to use for rendering
  72246. * @param size This parameter can be set to a single number or to an object with the
  72247. * following (optional) properties: precision, width, height. If a single number is passed,
  72248. * it will be used for both width and height. If an object is passed, the screenshot size
  72249. * will be derived from the parameters. The precision property is a multiplier allowing
  72250. * rendering at a higher or lower resolution
  72251. * @param successCallback The callback receives a single parameter which contains the
  72252. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72253. * src parameter of an <img> to display it
  72254. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72255. * Check your browser for supported MIME types
  72256. * @param samples Texture samples (default: 1)
  72257. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72258. * @param fileName A name for for the downloaded file.
  72259. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72260. */
  72261. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  72262. /**
  72263. * Generates an image screenshot from the specified camera.
  72264. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72265. * @param engine The engine to use for rendering
  72266. * @param camera The camera to use for rendering
  72267. * @param size This parameter can be set to a single number or to an object with the
  72268. * following (optional) properties: precision, width, height. If a single number is passed,
  72269. * it will be used for both width and height. If an object is passed, the screenshot size
  72270. * will be derived from the parameters. The precision property is a multiplier allowing
  72271. * rendering at a higher or lower resolution
  72272. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72273. * Check your browser for supported MIME types
  72274. * @param samples Texture samples (default: 1)
  72275. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72276. * @param fileName A name for for the downloaded file.
  72277. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72278. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72279. * to the src parameter of an <img> to display it
  72280. */
  72281. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  72282. /**
  72283. * Gets height and width for screenshot size
  72284. * @private
  72285. */
  72286. private static _getScreenshotSize;
  72287. }
  72288. }
  72289. declare module "babylonjs/Misc/dataReader" {
  72290. /**
  72291. * Interface for a data buffer
  72292. */
  72293. export interface IDataBuffer {
  72294. /**
  72295. * Reads bytes from the data buffer.
  72296. * @param byteOffset The byte offset to read
  72297. * @param byteLength The byte length to read
  72298. * @returns A promise that resolves when the bytes are read
  72299. */
  72300. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  72301. /**
  72302. * The byte length of the buffer.
  72303. */
  72304. readonly byteLength: number;
  72305. }
  72306. /**
  72307. * Utility class for reading from a data buffer
  72308. */
  72309. export class DataReader {
  72310. /**
  72311. * The data buffer associated with this data reader.
  72312. */
  72313. readonly buffer: IDataBuffer;
  72314. /**
  72315. * The current byte offset from the beginning of the data buffer.
  72316. */
  72317. byteOffset: number;
  72318. private _dataView;
  72319. private _dataByteOffset;
  72320. /**
  72321. * Constructor
  72322. * @param buffer The buffer to read
  72323. */
  72324. constructor(buffer: IDataBuffer);
  72325. /**
  72326. * Loads the given byte length.
  72327. * @param byteLength The byte length to load
  72328. * @returns A promise that resolves when the load is complete
  72329. */
  72330. loadAsync(byteLength: number): Promise<void>;
  72331. /**
  72332. * Read a unsigned 32-bit integer from the currently loaded data range.
  72333. * @returns The 32-bit integer read
  72334. */
  72335. readUint32(): number;
  72336. /**
  72337. * Read a byte array from the currently loaded data range.
  72338. * @param byteLength The byte length to read
  72339. * @returns The byte array read
  72340. */
  72341. readUint8Array(byteLength: number): Uint8Array;
  72342. /**
  72343. * Read a string from the currently loaded data range.
  72344. * @param byteLength The byte length to read
  72345. * @returns The string read
  72346. */
  72347. readString(byteLength: number): string;
  72348. /**
  72349. * Skips the given byte length the currently loaded data range.
  72350. * @param byteLength The byte length to skip
  72351. */
  72352. skipBytes(byteLength: number): void;
  72353. }
  72354. }
  72355. declare module "babylonjs/Misc/index" {
  72356. export * from "babylonjs/Misc/andOrNotEvaluator";
  72357. export * from "babylonjs/Misc/assetsManager";
  72358. export * from "babylonjs/Misc/basis";
  72359. export * from "babylonjs/Misc/dds";
  72360. export * from "babylonjs/Misc/decorators";
  72361. export * from "babylonjs/Misc/deferred";
  72362. export * from "babylonjs/Misc/environmentTextureTools";
  72363. export * from "babylonjs/Misc/meshExploder";
  72364. export * from "babylonjs/Misc/filesInput";
  72365. export * from "babylonjs/Misc/HighDynamicRange/index";
  72366. export * from "babylonjs/Misc/khronosTextureContainer";
  72367. export * from "babylonjs/Misc/observable";
  72368. export * from "babylonjs/Misc/performanceMonitor";
  72369. export * from "babylonjs/Misc/promise";
  72370. export * from "babylonjs/Misc/sceneOptimizer";
  72371. export * from "babylonjs/Misc/sceneSerializer";
  72372. export * from "babylonjs/Misc/smartArray";
  72373. export * from "babylonjs/Misc/stringDictionary";
  72374. export * from "babylonjs/Misc/tags";
  72375. export * from "babylonjs/Misc/textureTools";
  72376. export * from "babylonjs/Misc/tga";
  72377. export * from "babylonjs/Misc/tools";
  72378. export * from "babylonjs/Misc/videoRecorder";
  72379. export * from "babylonjs/Misc/virtualJoystick";
  72380. export * from "babylonjs/Misc/workerPool";
  72381. export * from "babylonjs/Misc/logger";
  72382. export * from "babylonjs/Misc/typeStore";
  72383. export * from "babylonjs/Misc/filesInputStore";
  72384. export * from "babylonjs/Misc/deepCopier";
  72385. export * from "babylonjs/Misc/pivotTools";
  72386. export * from "babylonjs/Misc/precisionDate";
  72387. export * from "babylonjs/Misc/screenshotTools";
  72388. export * from "babylonjs/Misc/typeStore";
  72389. export * from "babylonjs/Misc/webRequest";
  72390. export * from "babylonjs/Misc/iInspectable";
  72391. export * from "babylonjs/Misc/brdfTextureTools";
  72392. export * from "babylonjs/Misc/rgbdTextureTools";
  72393. export * from "babylonjs/Misc/gradients";
  72394. export * from "babylonjs/Misc/perfCounter";
  72395. export * from "babylonjs/Misc/fileRequest";
  72396. export * from "babylonjs/Misc/customAnimationFrameRequester";
  72397. export * from "babylonjs/Misc/retryStrategy";
  72398. export * from "babylonjs/Misc/interfaces/screenshotSize";
  72399. export * from "babylonjs/Misc/canvasGenerator";
  72400. export * from "babylonjs/Misc/fileTools";
  72401. export * from "babylonjs/Misc/stringTools";
  72402. export * from "babylonjs/Misc/dataReader";
  72403. export * from "babylonjs/Misc/minMaxReducer";
  72404. export * from "babylonjs/Misc/depthReducer";
  72405. }
  72406. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  72407. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72408. import { Observable } from "babylonjs/Misc/observable";
  72409. import { Matrix } from "babylonjs/Maths/math.vector";
  72410. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72411. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72412. /**
  72413. * Options used for hit testing
  72414. */
  72415. export interface IWebXRHitTestOptions {
  72416. /**
  72417. * Only test when user interacted with the scene. Default - hit test every frame
  72418. */
  72419. testOnPointerDownOnly?: boolean;
  72420. /**
  72421. * The node to use to transform the local results to world coordinates
  72422. */
  72423. worldParentNode?: TransformNode;
  72424. }
  72425. /**
  72426. * Interface defining the babylon result of raycasting/hit-test
  72427. */
  72428. export interface IWebXRHitResult {
  72429. /**
  72430. * The native hit test result
  72431. */
  72432. xrHitResult: XRHitResult;
  72433. /**
  72434. * Transformation matrix that can be applied to a node that will put it in the hit point location
  72435. */
  72436. transformationMatrix: Matrix;
  72437. }
  72438. /**
  72439. * The currently-working hit-test module.
  72440. * Hit test (or raycasting) is used to interact with the real world.
  72441. * For further information read here - https://github.com/immersive-web/hit-test
  72442. */
  72443. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  72444. /**
  72445. * options to use when constructing this feature
  72446. */
  72447. readonly options: IWebXRHitTestOptions;
  72448. /**
  72449. * The module's name
  72450. */
  72451. static readonly Name: string;
  72452. /**
  72453. * The (Babylon) version of this module.
  72454. * This is an integer representing the implementation version.
  72455. * This number does not correspond to the webxr specs version
  72456. */
  72457. static readonly Version: number;
  72458. /**
  72459. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  72460. * @param event the (select) event to use to select with
  72461. * @param referenceSpace the reference space to use for this hit test
  72462. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72463. */
  72464. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  72465. /**
  72466. * execute a hit test with an XR Ray
  72467. *
  72468. * @param xrSession a native xrSession that will execute this hit test
  72469. * @param xrRay the ray (position and direction) to use for raycasting
  72470. * @param referenceSpace native XR reference space to use for the hit-test
  72471. * @param filter filter function that will filter the results
  72472. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72473. */
  72474. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  72475. /**
  72476. * Triggered when new babylon (transformed) hit test results are available
  72477. */
  72478. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  72479. private _onSelectEnabled;
  72480. /**
  72481. * Creates a new instance of the (legacy version) hit test feature
  72482. * @param _xrSessionManager an instance of WebXRSessionManager
  72483. * @param options options to use when constructing this feature
  72484. */
  72485. constructor(_xrSessionManager: WebXRSessionManager,
  72486. /**
  72487. * options to use when constructing this feature
  72488. */
  72489. options?: IWebXRHitTestOptions);
  72490. /**
  72491. * Populated with the last native XR Hit Results
  72492. */
  72493. lastNativeXRHitResults: XRHitResult[];
  72494. /**
  72495. * attach this feature
  72496. * Will usually be called by the features manager
  72497. *
  72498. * @returns true if successful.
  72499. */
  72500. attach(): boolean;
  72501. /**
  72502. * detach this feature.
  72503. * Will usually be called by the features manager
  72504. *
  72505. * @returns true if successful.
  72506. */
  72507. detach(): boolean;
  72508. private _onHitTestResults;
  72509. private _origin;
  72510. private _direction;
  72511. private _mat;
  72512. protected _onXRFrame(frame: XRFrame): void;
  72513. private _onSelect;
  72514. /**
  72515. * Dispose this feature and all of the resources attached
  72516. */
  72517. dispose(): void;
  72518. }
  72519. }
  72520. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  72521. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72522. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72523. import { Observable } from "babylonjs/Misc/observable";
  72524. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  72525. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72526. /**
  72527. * Options used in the plane detector module
  72528. */
  72529. export interface IWebXRPlaneDetectorOptions {
  72530. /**
  72531. * The node to use to transform the local results to world coordinates
  72532. */
  72533. worldParentNode?: TransformNode;
  72534. }
  72535. /**
  72536. * A babylon interface for a webxr plane.
  72537. * A Plane is actually a polygon, built from N points in space
  72538. *
  72539. * Supported in chrome 79, not supported in canary 81 ATM
  72540. */
  72541. export interface IWebXRPlane {
  72542. /**
  72543. * a babylon-assigned ID for this polygon
  72544. */
  72545. id: number;
  72546. /**
  72547. * the native xr-plane object
  72548. */
  72549. xrPlane: XRPlane;
  72550. /**
  72551. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  72552. */
  72553. polygonDefinition: Array<Vector3>;
  72554. /**
  72555. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  72556. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  72557. */
  72558. transformationMatrix: Matrix;
  72559. }
  72560. /**
  72561. * The plane detector is used to detect planes in the real world when in AR
  72562. * For more information see https://github.com/immersive-web/real-world-geometry/
  72563. */
  72564. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  72565. private _options;
  72566. /**
  72567. * The module's name
  72568. */
  72569. static readonly Name: string;
  72570. /**
  72571. * The (Babylon) version of this module.
  72572. * This is an integer representing the implementation version.
  72573. * This number does not correspond to the webxr specs version
  72574. */
  72575. static readonly Version: number;
  72576. /**
  72577. * Observers registered here will be executed when a new plane was added to the session
  72578. */
  72579. onPlaneAddedObservable: Observable<IWebXRPlane>;
  72580. /**
  72581. * Observers registered here will be executed when a plane is no longer detected in the session
  72582. */
  72583. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  72584. /**
  72585. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  72586. * This can execute N times every frame
  72587. */
  72588. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  72589. private _enabled;
  72590. private _detectedPlanes;
  72591. private _lastFrameDetected;
  72592. /**
  72593. * construct a new Plane Detector
  72594. * @param _xrSessionManager an instance of xr Session manager
  72595. * @param _options configuration to use when constructing this feature
  72596. */
  72597. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  72598. private _init;
  72599. protected _onXRFrame(frame: XRFrame): void;
  72600. /**
  72601. * Dispose this feature and all of the resources attached
  72602. */
  72603. dispose(): void;
  72604. private _updatePlaneWithXRPlane;
  72605. /**
  72606. * avoiding using Array.find for global support.
  72607. * @param xrPlane the plane to find in the array
  72608. */
  72609. private findIndexInPlaneArray;
  72610. }
  72611. }
  72612. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  72613. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72614. import { Observable } from "babylonjs/Misc/observable";
  72615. import { Matrix } from "babylonjs/Maths/math.vector";
  72616. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72617. import { WebXRPlaneDetector } from "babylonjs/XR/features/WebXRPlaneDetector";
  72618. import { WebXRHitTestLegacy } from "babylonjs/XR/features/WebXRHitTestLegacy";
  72619. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72620. /**
  72621. * Configuration options of the anchor system
  72622. */
  72623. export interface IWebXRAnchorSystemOptions {
  72624. /**
  72625. * a node that will be used to convert local to world coordinates
  72626. */
  72627. worldParentNode?: TransformNode;
  72628. /**
  72629. * should the anchor system use plane detection.
  72630. * If set to true, the plane-detection feature should be set using setPlaneDetector
  72631. */
  72632. usePlaneDetection?: boolean;
  72633. /**
  72634. * Should a new anchor be added every time a select event is triggered
  72635. */
  72636. addAnchorOnSelect?: boolean;
  72637. }
  72638. /**
  72639. * A babylon container for an XR Anchor
  72640. */
  72641. export interface IWebXRAnchor {
  72642. /**
  72643. * A babylon-assigned ID for this anchor
  72644. */
  72645. id: number;
  72646. /**
  72647. * The native anchor object
  72648. */
  72649. xrAnchor: XRAnchor;
  72650. /**
  72651. * Transformation matrix to apply to an object attached to this anchor
  72652. */
  72653. transformationMatrix: Matrix;
  72654. }
  72655. /**
  72656. * An implementation of the anchor system of WebXR.
  72657. * Note that the current documented implementation is not available in any browser. Future implementations
  72658. * will use the frame to create an anchor and not the session or a detected plane
  72659. * For further information see https://github.com/immersive-web/anchors/
  72660. */
  72661. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  72662. private _options;
  72663. /**
  72664. * The module's name
  72665. */
  72666. static readonly Name: string;
  72667. /**
  72668. * The (Babylon) version of this module.
  72669. * This is an integer representing the implementation version.
  72670. * This number does not correspond to the webxr specs version
  72671. */
  72672. static readonly Version: number;
  72673. /**
  72674. * Observers registered here will be executed when a new anchor was added to the session
  72675. */
  72676. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  72677. /**
  72678. * Observers registered here will be executed when an existing anchor updates
  72679. * This can execute N times every frame
  72680. */
  72681. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  72682. /**
  72683. * Observers registered here will be executed when an anchor was removed from the session
  72684. */
  72685. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  72686. private _planeDetector;
  72687. private _hitTestModule;
  72688. private _enabled;
  72689. private _trackedAnchors;
  72690. private _lastFrameDetected;
  72691. /**
  72692. * constructs a new anchor system
  72693. * @param _xrSessionManager an instance of WebXRSessionManager
  72694. * @param _options configuration object for this feature
  72695. */
  72696. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  72697. /**
  72698. * set the plane detector to use in order to create anchors from frames
  72699. * @param planeDetector the plane-detector module to use
  72700. * @param enable enable plane-anchors. default is true
  72701. */
  72702. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  72703. /**
  72704. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  72705. * @param hitTestModule the hit-test module to use.
  72706. */
  72707. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  72708. /**
  72709. * attach this feature
  72710. * Will usually be called by the features manager
  72711. *
  72712. * @returns true if successful.
  72713. */
  72714. attach(): boolean;
  72715. /**
  72716. * detach this feature.
  72717. * Will usually be called by the features manager
  72718. *
  72719. * @returns true if successful.
  72720. */
  72721. detach(): boolean;
  72722. /**
  72723. * Dispose this feature and all of the resources attached
  72724. */
  72725. dispose(): void;
  72726. protected _onXRFrame(frame: XRFrame): void;
  72727. private _onSelect;
  72728. /**
  72729. * Add anchor at a specific XR point.
  72730. *
  72731. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  72732. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  72733. * @returns a promise the fulfills when the anchor was created
  72734. */
  72735. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  72736. private _updateAnchorWithXRFrame;
  72737. /**
  72738. * avoiding using Array.find for global support.
  72739. * @param xrAnchor the plane to find in the array
  72740. */
  72741. private _findIndexInAnchorArray;
  72742. }
  72743. }
  72744. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  72745. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72746. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72747. import { Observable } from "babylonjs/Misc/observable";
  72748. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72749. /**
  72750. * Options interface for the background remover plugin
  72751. */
  72752. export interface IWebXRBackgroundRemoverOptions {
  72753. /**
  72754. * don't disable the environment helper
  72755. */
  72756. ignoreEnvironmentHelper?: boolean;
  72757. /**
  72758. * flags to configure the removal of the environment helper.
  72759. * If not set, the entire background will be removed. If set, flags should be set as well.
  72760. */
  72761. environmentHelperRemovalFlags?: {
  72762. /**
  72763. * Should the skybox be removed (default false)
  72764. */
  72765. skyBox?: boolean;
  72766. /**
  72767. * Should the ground be removed (default false)
  72768. */
  72769. ground?: boolean;
  72770. };
  72771. /**
  72772. * Further background meshes to disable when entering AR
  72773. */
  72774. backgroundMeshes?: AbstractMesh[];
  72775. }
  72776. /**
  72777. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  72778. */
  72779. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  72780. /**
  72781. * read-only options to be used in this module
  72782. */
  72783. readonly options: IWebXRBackgroundRemoverOptions;
  72784. /**
  72785. * The module's name
  72786. */
  72787. static readonly Name: string;
  72788. /**
  72789. * The (Babylon) version of this module.
  72790. * This is an integer representing the implementation version.
  72791. * This number does not correspond to the webxr specs version
  72792. */
  72793. static readonly Version: number;
  72794. /**
  72795. * registered observers will be triggered when the background state changes
  72796. */
  72797. onBackgroundStateChangedObservable: Observable<boolean>;
  72798. /**
  72799. * constructs a new background remover module
  72800. * @param _xrSessionManager the session manager for this module
  72801. * @param options read-only options to be used in this module
  72802. */
  72803. constructor(_xrSessionManager: WebXRSessionManager,
  72804. /**
  72805. * read-only options to be used in this module
  72806. */
  72807. options?: IWebXRBackgroundRemoverOptions);
  72808. /**
  72809. * attach this feature
  72810. * Will usually be called by the features manager
  72811. *
  72812. * @returns true if successful.
  72813. */
  72814. attach(): boolean;
  72815. /**
  72816. * detach this feature.
  72817. * Will usually be called by the features manager
  72818. *
  72819. * @returns true if successful.
  72820. */
  72821. detach(): boolean;
  72822. private _setBackgroundState;
  72823. /**
  72824. * Dispose this feature and all of the resources attached
  72825. */
  72826. dispose(): void;
  72827. protected _onXRFrame(_xrFrame: XRFrame): void;
  72828. }
  72829. }
  72830. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  72831. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72832. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  72833. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72834. import { WebXRInput } from "babylonjs/XR/webXRInput";
  72835. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72836. import { Nullable } from "babylonjs/types";
  72837. /**
  72838. * Options for the controller physics feature
  72839. */
  72840. export class IWebXRControllerPhysicsOptions {
  72841. /**
  72842. * the xr input to use with this pointer selection
  72843. */
  72844. xrInput: WebXRInput;
  72845. /**
  72846. * The physics properties of the future impostors
  72847. */
  72848. physicsProperties?: {
  72849. /**
  72850. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  72851. * Note that this requires a physics engine that supports mesh impostors!
  72852. */
  72853. useControllerMesh?: boolean;
  72854. /**
  72855. * The type of impostor to create. Default is sphere
  72856. */
  72857. impostorType?: number;
  72858. /**
  72859. * the size of the impostor. Defaults to 10cm
  72860. */
  72861. impostorSize?: number | {
  72862. width: number;
  72863. height: number;
  72864. depth: number;
  72865. };
  72866. /**
  72867. * Friction definitions
  72868. */
  72869. friction?: number;
  72870. /**
  72871. * Restitution
  72872. */
  72873. restitution?: number;
  72874. };
  72875. /**
  72876. * Should the headset get its own impostor
  72877. */
  72878. enableHeadsetImpostor?: boolean;
  72879. /**
  72880. * Optional parameters for the headset impostor
  72881. */
  72882. headsetImpostorParams?: {
  72883. /**
  72884. * The type of impostor to create. Default is sphere
  72885. */
  72886. impostorType: number;
  72887. /**
  72888. * the size of the impostor. Defaults to 10cm
  72889. */
  72890. impostorSize?: number | {
  72891. width: number;
  72892. height: number;
  72893. depth: number;
  72894. };
  72895. /**
  72896. * Friction definitions
  72897. */
  72898. friction?: number;
  72899. /**
  72900. * Restitution
  72901. */
  72902. restitution?: number;
  72903. };
  72904. }
  72905. /**
  72906. * Add physics impostor to your webxr controllers,
  72907. * including naive calculation of their linear and angular velocity
  72908. */
  72909. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  72910. private readonly _options;
  72911. /**
  72912. * The module's name
  72913. */
  72914. static readonly Name: string;
  72915. /**
  72916. * The (Babylon) version of this module.
  72917. * This is an integer representing the implementation version.
  72918. * This number does not correspond to the webxr specs version
  72919. */
  72920. static readonly Version: number;
  72921. private _lastTimestamp;
  72922. private _delta;
  72923. private _controllers;
  72924. private _headsetImpostor?;
  72925. private _headsetMesh?;
  72926. private _tmpVector;
  72927. private _tmpQuaternion;
  72928. /**
  72929. * Construct a new Controller Physics Feature
  72930. * @param _xrSessionManager the corresponding xr session manager
  72931. * @param _options options to create this feature with
  72932. */
  72933. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  72934. /**
  72935. * Update the physics properties provided in the constructor
  72936. * @param newProperties the new properties object
  72937. */
  72938. setPhysicsProperties(newProperties: {
  72939. impostorType?: number;
  72940. impostorSize?: number | {
  72941. width: number;
  72942. height: number;
  72943. depth: number;
  72944. };
  72945. friction?: number;
  72946. restitution?: number;
  72947. }): void;
  72948. /**
  72949. * Get the physics impostor of a specific controller.
  72950. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  72951. * @param controller the controller or the controller id of which to get the impostor
  72952. * @returns the impostor or null
  72953. */
  72954. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  72955. /**
  72956. * Get the headset impostor, if enabled
  72957. * @returns the impostor
  72958. */
  72959. getHeadsetImpostor(): PhysicsImpostor | undefined;
  72960. /**
  72961. * attach this feature
  72962. * Will usually be called by the features manager
  72963. *
  72964. * @returns true if successful.
  72965. */
  72966. attach(): boolean;
  72967. /**
  72968. * detach this feature.
  72969. * Will usually be called by the features manager
  72970. *
  72971. * @returns true if successful.
  72972. */
  72973. detach(): boolean;
  72974. /**
  72975. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  72976. * @param xrController the controller to add
  72977. */
  72978. addController(xrController: WebXRInputSource): void;
  72979. private _debugMode;
  72980. /**
  72981. * @hidden
  72982. * enable debugging - will show console outputs and the impostor mesh
  72983. */
  72984. _enablePhysicsDebug(): void;
  72985. private _attachController;
  72986. private _detachController;
  72987. protected _onXRFrame(_xrFrame: any): void;
  72988. }
  72989. }
  72990. declare module "babylonjs/XR/features/index" {
  72991. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  72992. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  72993. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  72994. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  72995. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  72996. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  72997. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  72998. }
  72999. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  73000. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73001. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73002. import { Scene } from "babylonjs/scene";
  73003. /**
  73004. * The motion controller class for all microsoft mixed reality controllers
  73005. */
  73006. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  73007. /**
  73008. * The base url used to load the left and right controller models
  73009. */
  73010. static MODEL_BASE_URL: string;
  73011. /**
  73012. * The name of the left controller model file
  73013. */
  73014. static MODEL_LEFT_FILENAME: string;
  73015. /**
  73016. * The name of the right controller model file
  73017. */
  73018. static MODEL_RIGHT_FILENAME: string;
  73019. profileId: string;
  73020. protected readonly _mapping: {
  73021. defaultButton: {
  73022. "valueNodeName": string;
  73023. "unpressedNodeName": string;
  73024. "pressedNodeName": string;
  73025. };
  73026. defaultAxis: {
  73027. "valueNodeName": string;
  73028. "minNodeName": string;
  73029. "maxNodeName": string;
  73030. };
  73031. buttons: {
  73032. "xr-standard-trigger": {
  73033. "rootNodeName": string;
  73034. "componentProperty": string;
  73035. "states": string[];
  73036. };
  73037. "xr-standard-squeeze": {
  73038. "rootNodeName": string;
  73039. "componentProperty": string;
  73040. "states": string[];
  73041. };
  73042. "xr-standard-touchpad": {
  73043. "rootNodeName": string;
  73044. "labelAnchorNodeName": string;
  73045. "touchPointNodeName": string;
  73046. };
  73047. "xr-standard-thumbstick": {
  73048. "rootNodeName": string;
  73049. "componentProperty": string;
  73050. "states": string[];
  73051. };
  73052. };
  73053. axes: {
  73054. "xr-standard-touchpad": {
  73055. "x-axis": {
  73056. "rootNodeName": string;
  73057. };
  73058. "y-axis": {
  73059. "rootNodeName": string;
  73060. };
  73061. };
  73062. "xr-standard-thumbstick": {
  73063. "x-axis": {
  73064. "rootNodeName": string;
  73065. };
  73066. "y-axis": {
  73067. "rootNodeName": string;
  73068. };
  73069. };
  73070. };
  73071. };
  73072. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  73073. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73074. protected _getFilenameAndPath(): {
  73075. filename: string;
  73076. path: string;
  73077. };
  73078. protected _updateModel(): void;
  73079. protected _getModelLoadingConstraints(): boolean;
  73080. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73081. }
  73082. }
  73083. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  73084. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73085. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73086. import { Scene } from "babylonjs/scene";
  73087. /**
  73088. * The motion controller class for oculus touch (quest, rift).
  73089. * This class supports legacy mapping as well the standard xr mapping
  73090. */
  73091. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  73092. private _forceLegacyControllers;
  73093. /**
  73094. * The base url used to load the left and right controller models
  73095. */
  73096. static MODEL_BASE_URL: string;
  73097. /**
  73098. * The name of the left controller model file
  73099. */
  73100. static MODEL_LEFT_FILENAME: string;
  73101. /**
  73102. * The name of the right controller model file
  73103. */
  73104. static MODEL_RIGHT_FILENAME: string;
  73105. /**
  73106. * Base Url for the Quest controller model.
  73107. */
  73108. static QUEST_MODEL_BASE_URL: string;
  73109. profileId: string;
  73110. private _modelRootNode;
  73111. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  73112. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73113. protected _getFilenameAndPath(): {
  73114. filename: string;
  73115. path: string;
  73116. };
  73117. /**
  73118. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  73119. * between the touch and touch 2.
  73120. */
  73121. private _isQuest;
  73122. protected _updateModel(): void;
  73123. protected _getModelLoadingConstraints(): boolean;
  73124. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73125. }
  73126. }
  73127. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  73128. import { IMinimalMotionControllerObject, MotionControllerHandness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73129. import { Scene } from "babylonjs/scene";
  73130. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73131. /**
  73132. * The motion controller class for the standard HTC-Vive controllers
  73133. */
  73134. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  73135. /**
  73136. * The base url used to load the left and right controller models
  73137. */
  73138. static MODEL_BASE_URL: string;
  73139. /**
  73140. * File name for the controller model.
  73141. */
  73142. static MODEL_FILENAME: string;
  73143. profileId: string;
  73144. private _modelRootNode;
  73145. /**
  73146. * Create a new Vive motion controller object
  73147. * @param scene the scene to use to create this controller
  73148. * @param gamepadObject the corresponding gamepad object
  73149. * @param handness the handness of the controller
  73150. */
  73151. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  73152. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73153. protected _getFilenameAndPath(): {
  73154. filename: string;
  73155. path: string;
  73156. };
  73157. protected _updateModel(): void;
  73158. protected _getModelLoadingConstraints(): boolean;
  73159. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73160. }
  73161. }
  73162. declare module "babylonjs/XR/motionController/index" {
  73163. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73164. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  73165. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  73166. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  73167. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  73168. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  73169. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  73170. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  73171. }
  73172. declare module "babylonjs/XR/index" {
  73173. export * from "babylonjs/XR/webXRCamera";
  73174. export * from "babylonjs/XR/webXREnterExitUI";
  73175. export * from "babylonjs/XR/webXRExperienceHelper";
  73176. export * from "babylonjs/XR/webXRInput";
  73177. export * from "babylonjs/XR/webXRInputSource";
  73178. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  73179. export * from "babylonjs/XR/webXRTypes";
  73180. export * from "babylonjs/XR/webXRSessionManager";
  73181. export * from "babylonjs/XR/webXRDefaultExperience";
  73182. export * from "babylonjs/XR/webXRFeaturesManager";
  73183. export * from "babylonjs/XR/features/index";
  73184. export * from "babylonjs/XR/motionController/index";
  73185. }
  73186. declare module "babylonjs/index" {
  73187. export * from "babylonjs/abstractScene";
  73188. export * from "babylonjs/Actions/index";
  73189. export * from "babylonjs/Animations/index";
  73190. export * from "babylonjs/assetContainer";
  73191. export * from "babylonjs/Audio/index";
  73192. export * from "babylonjs/Behaviors/index";
  73193. export * from "babylonjs/Bones/index";
  73194. export * from "babylonjs/Cameras/index";
  73195. export * from "babylonjs/Collisions/index";
  73196. export * from "babylonjs/Culling/index";
  73197. export * from "babylonjs/Debug/index";
  73198. export * from "babylonjs/Engines/index";
  73199. export * from "babylonjs/Events/index";
  73200. export * from "babylonjs/Gamepads/index";
  73201. export * from "babylonjs/Gizmos/index";
  73202. export * from "babylonjs/Helpers/index";
  73203. export * from "babylonjs/Instrumentation/index";
  73204. export * from "babylonjs/Layers/index";
  73205. export * from "babylonjs/LensFlares/index";
  73206. export * from "babylonjs/Lights/index";
  73207. export * from "babylonjs/Loading/index";
  73208. export * from "babylonjs/Materials/index";
  73209. export * from "babylonjs/Maths/index";
  73210. export * from "babylonjs/Meshes/index";
  73211. export * from "babylonjs/Morph/index";
  73212. export * from "babylonjs/Navigation/index";
  73213. export * from "babylonjs/node";
  73214. export * from "babylonjs/Offline/index";
  73215. export * from "babylonjs/Particles/index";
  73216. export * from "babylonjs/Physics/index";
  73217. export * from "babylonjs/PostProcesses/index";
  73218. export * from "babylonjs/Probes/index";
  73219. export * from "babylonjs/Rendering/index";
  73220. export * from "babylonjs/scene";
  73221. export * from "babylonjs/sceneComponent";
  73222. export * from "babylonjs/Sprites/index";
  73223. export * from "babylonjs/States/index";
  73224. export * from "babylonjs/Misc/index";
  73225. export * from "babylonjs/XR/index";
  73226. export * from "babylonjs/types";
  73227. }
  73228. declare module "babylonjs/Animations/pathCursor" {
  73229. import { Vector3 } from "babylonjs/Maths/math.vector";
  73230. import { Path2 } from "babylonjs/Maths/math.path";
  73231. /**
  73232. * A cursor which tracks a point on a path
  73233. */
  73234. export class PathCursor {
  73235. private path;
  73236. /**
  73237. * Stores path cursor callbacks for when an onchange event is triggered
  73238. */
  73239. private _onchange;
  73240. /**
  73241. * The value of the path cursor
  73242. */
  73243. value: number;
  73244. /**
  73245. * The animation array of the path cursor
  73246. */
  73247. animations: Animation[];
  73248. /**
  73249. * Initializes the path cursor
  73250. * @param path The path to track
  73251. */
  73252. constructor(path: Path2);
  73253. /**
  73254. * Gets the cursor point on the path
  73255. * @returns A point on the path cursor at the cursor location
  73256. */
  73257. getPoint(): Vector3;
  73258. /**
  73259. * Moves the cursor ahead by the step amount
  73260. * @param step The amount to move the cursor forward
  73261. * @returns This path cursor
  73262. */
  73263. moveAhead(step?: number): PathCursor;
  73264. /**
  73265. * Moves the cursor behind by the step amount
  73266. * @param step The amount to move the cursor back
  73267. * @returns This path cursor
  73268. */
  73269. moveBack(step?: number): PathCursor;
  73270. /**
  73271. * Moves the cursor by the step amount
  73272. * If the step amount is greater than one, an exception is thrown
  73273. * @param step The amount to move the cursor
  73274. * @returns This path cursor
  73275. */
  73276. move(step: number): PathCursor;
  73277. /**
  73278. * Ensures that the value is limited between zero and one
  73279. * @returns This path cursor
  73280. */
  73281. private ensureLimits;
  73282. /**
  73283. * Runs onchange callbacks on change (used by the animation engine)
  73284. * @returns This path cursor
  73285. */
  73286. private raiseOnChange;
  73287. /**
  73288. * Executes a function on change
  73289. * @param f A path cursor onchange callback
  73290. * @returns This path cursor
  73291. */
  73292. onchange(f: (cursor: PathCursor) => void): PathCursor;
  73293. }
  73294. }
  73295. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  73296. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  73297. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  73298. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  73299. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  73300. }
  73301. declare module "babylonjs/Engines/Processors/Expressions/index" {
  73302. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  73303. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  73304. }
  73305. declare module "babylonjs/Engines/Processors/index" {
  73306. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  73307. export * from "babylonjs/Engines/Processors/Expressions/index";
  73308. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  73309. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  73310. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  73311. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  73312. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  73313. export * from "babylonjs/Engines/Processors/shaderProcessor";
  73314. }
  73315. declare module "babylonjs/Legacy/legacy" {
  73316. import * as Babylon from "babylonjs/index";
  73317. export * from "babylonjs/index";
  73318. }
  73319. declare module "babylonjs/Shaders/blur.fragment" {
  73320. /** @hidden */
  73321. export var blurPixelShader: {
  73322. name: string;
  73323. shader: string;
  73324. };
  73325. }
  73326. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  73327. /** @hidden */
  73328. export var pointCloudVertexDeclaration: {
  73329. name: string;
  73330. shader: string;
  73331. };
  73332. }
  73333. declare module "babylonjs" {
  73334. export * from "babylonjs/Legacy/legacy";
  73335. }
  73336. declare module BABYLON {
  73337. /** Alias type for value that can be null */
  73338. export type Nullable<T> = T | null;
  73339. /**
  73340. * Alias type for number that are floats
  73341. * @ignorenaming
  73342. */
  73343. export type float = number;
  73344. /**
  73345. * Alias type for number that are doubles.
  73346. * @ignorenaming
  73347. */
  73348. export type double = number;
  73349. /**
  73350. * Alias type for number that are integer
  73351. * @ignorenaming
  73352. */
  73353. export type int = number;
  73354. /** Alias type for number array or Float32Array */
  73355. export type FloatArray = number[] | Float32Array;
  73356. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  73357. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  73358. /**
  73359. * Alias for types that can be used by a Buffer or VertexBuffer.
  73360. */
  73361. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  73362. /**
  73363. * Alias type for primitive types
  73364. * @ignorenaming
  73365. */
  73366. type Primitive = undefined | null | boolean | string | number | Function;
  73367. /**
  73368. * Type modifier to make all the properties of an object Readonly
  73369. */
  73370. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  73371. /**
  73372. * Type modifier to make all the properties of an object Readonly recursively
  73373. */
  73374. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  73375. /**
  73376. * Type modifier to make object properties readonly.
  73377. */
  73378. export type DeepImmutableObject<T> = {
  73379. readonly [K in keyof T]: DeepImmutable<T[K]>;
  73380. };
  73381. /** @hidden */
  73382. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  73383. }
  73384. }
  73385. declare module BABYLON {
  73386. /**
  73387. * A class serves as a medium between the observable and its observers
  73388. */
  73389. export class EventState {
  73390. /**
  73391. * Create a new EventState
  73392. * @param mask defines the mask associated with this state
  73393. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  73394. * @param target defines the original target of the state
  73395. * @param currentTarget defines the current target of the state
  73396. */
  73397. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  73398. /**
  73399. * Initialize the current event state
  73400. * @param mask defines the mask associated with this state
  73401. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  73402. * @param target defines the original target of the state
  73403. * @param currentTarget defines the current target of the state
  73404. * @returns the current event state
  73405. */
  73406. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73407. /**
  73408. * An Observer can set this property to true to prevent subsequent observers of being notified
  73409. */
  73410. skipNextObservers: boolean;
  73411. /**
  73412. * Get the mask value that were used to trigger the event corresponding to this EventState object
  73413. */
  73414. mask: number;
  73415. /**
  73416. * The object that originally notified the event
  73417. */
  73418. target?: any;
  73419. /**
  73420. * The current object in the bubbling phase
  73421. */
  73422. currentTarget?: any;
  73423. /**
  73424. * This will be populated with the return value of the last function that was executed.
  73425. * If it is the first function in the callback chain it will be the event data.
  73426. */
  73427. lastReturnValue?: any;
  73428. }
  73429. /**
  73430. * Represent an Observer registered to a given Observable object.
  73431. */
  73432. export class Observer<T> {
  73433. /**
  73434. * Defines the callback to call when the observer is notified
  73435. */
  73436. callback: (eventData: T, eventState: EventState) => void;
  73437. /**
  73438. * Defines the mask of the observer (used to filter notifications)
  73439. */
  73440. mask: number;
  73441. /**
  73442. * Defines the current scope used to restore the JS context
  73443. */
  73444. scope: any;
  73445. /** @hidden */
  73446. _willBeUnregistered: boolean;
  73447. /**
  73448. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  73449. */
  73450. unregisterOnNextCall: boolean;
  73451. /**
  73452. * Creates a new observer
  73453. * @param callback defines the callback to call when the observer is notified
  73454. * @param mask defines the mask of the observer (used to filter notifications)
  73455. * @param scope defines the current scope used to restore the JS context
  73456. */
  73457. constructor(
  73458. /**
  73459. * Defines the callback to call when the observer is notified
  73460. */
  73461. callback: (eventData: T, eventState: EventState) => void,
  73462. /**
  73463. * Defines the mask of the observer (used to filter notifications)
  73464. */
  73465. mask: number,
  73466. /**
  73467. * Defines the current scope used to restore the JS context
  73468. */
  73469. scope?: any);
  73470. }
  73471. /**
  73472. * Represent a list of observers registered to multiple Observables object.
  73473. */
  73474. export class MultiObserver<T> {
  73475. private _observers;
  73476. private _observables;
  73477. /**
  73478. * Release associated resources
  73479. */
  73480. dispose(): void;
  73481. /**
  73482. * Raise a callback when one of the observable will notify
  73483. * @param observables defines a list of observables to watch
  73484. * @param callback defines the callback to call on notification
  73485. * @param mask defines the mask used to filter notifications
  73486. * @param scope defines the current scope used to restore the JS context
  73487. * @returns the new MultiObserver
  73488. */
  73489. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  73490. }
  73491. /**
  73492. * The Observable class is a simple implementation of the Observable pattern.
  73493. *
  73494. * 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.
  73495. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  73496. * 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).
  73497. * 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.
  73498. */
  73499. export class Observable<T> {
  73500. private _observers;
  73501. private _eventState;
  73502. private _onObserverAdded;
  73503. /**
  73504. * Gets the list of observers
  73505. */
  73506. get observers(): Array<Observer<T>>;
  73507. /**
  73508. * Creates a new observable
  73509. * @param onObserverAdded defines a callback to call when a new observer is added
  73510. */
  73511. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  73512. /**
  73513. * Create a new Observer with the specified callback
  73514. * @param callback the callback that will be executed for that Observer
  73515. * @param mask the mask used to filter observers
  73516. * @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.
  73517. * @param scope optional scope for the callback to be called from
  73518. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  73519. * @returns the new observer created for the callback
  73520. */
  73521. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  73522. /**
  73523. * Create a new Observer with the specified callback and unregisters after the next notification
  73524. * @param callback the callback that will be executed for that Observer
  73525. * @returns the new observer created for the callback
  73526. */
  73527. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  73528. /**
  73529. * Remove an Observer from the Observable object
  73530. * @param observer the instance of the Observer to remove
  73531. * @returns false if it doesn't belong to this Observable
  73532. */
  73533. remove(observer: Nullable<Observer<T>>): boolean;
  73534. /**
  73535. * Remove a callback from the Observable object
  73536. * @param callback the callback to remove
  73537. * @param scope optional scope. If used only the callbacks with this scope will be removed
  73538. * @returns false if it doesn't belong to this Observable
  73539. */
  73540. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  73541. private _deferUnregister;
  73542. private _remove;
  73543. /**
  73544. * Moves the observable to the top of the observer list making it get called first when notified
  73545. * @param observer the observer to move
  73546. */
  73547. makeObserverTopPriority(observer: Observer<T>): void;
  73548. /**
  73549. * Moves the observable to the bottom of the observer list making it get called last when notified
  73550. * @param observer the observer to move
  73551. */
  73552. makeObserverBottomPriority(observer: Observer<T>): void;
  73553. /**
  73554. * Notify all Observers by calling their respective callback with the given data
  73555. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  73556. * @param eventData defines the data to send to all observers
  73557. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  73558. * @param target defines the original target of the state
  73559. * @param currentTarget defines the current target of the state
  73560. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  73561. */
  73562. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  73563. /**
  73564. * Calling this will execute each callback, expecting it to be a promise or return a value.
  73565. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  73566. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  73567. * and it is crucial that all callbacks will be executed.
  73568. * The order of the callbacks is kept, callbacks are not executed parallel.
  73569. *
  73570. * @param eventData The data to be sent to each callback
  73571. * @param mask is used to filter observers defaults to -1
  73572. * @param target defines the callback target (see EventState)
  73573. * @param currentTarget defines he current object in the bubbling phase
  73574. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  73575. */
  73576. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  73577. /**
  73578. * Notify a specific observer
  73579. * @param observer defines the observer to notify
  73580. * @param eventData defines the data to be sent to each callback
  73581. * @param mask is used to filter observers defaults to -1
  73582. */
  73583. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  73584. /**
  73585. * Gets a boolean indicating if the observable has at least one observer
  73586. * @returns true is the Observable has at least one Observer registered
  73587. */
  73588. hasObservers(): boolean;
  73589. /**
  73590. * Clear the list of observers
  73591. */
  73592. clear(): void;
  73593. /**
  73594. * Clone the current observable
  73595. * @returns a new observable
  73596. */
  73597. clone(): Observable<T>;
  73598. /**
  73599. * Does this observable handles observer registered with a given mask
  73600. * @param mask defines the mask to be tested
  73601. * @return whether or not one observer registered with the given mask is handeled
  73602. **/
  73603. hasSpecificMask(mask?: number): boolean;
  73604. }
  73605. }
  73606. declare module BABYLON {
  73607. /**
  73608. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  73609. * Babylon.js
  73610. */
  73611. export class DomManagement {
  73612. /**
  73613. * Checks if the window object exists
  73614. * @returns true if the window object exists
  73615. */
  73616. static IsWindowObjectExist(): boolean;
  73617. /**
  73618. * Checks if the navigator object exists
  73619. * @returns true if the navigator object exists
  73620. */
  73621. static IsNavigatorAvailable(): boolean;
  73622. /**
  73623. * Extracts text content from a DOM element hierarchy
  73624. * @param element defines the root element
  73625. * @returns a string
  73626. */
  73627. static GetDOMTextContent(element: HTMLElement): string;
  73628. }
  73629. }
  73630. declare module BABYLON {
  73631. /**
  73632. * Logger used througouht the application to allow configuration of
  73633. * the log level required for the messages.
  73634. */
  73635. export class Logger {
  73636. /**
  73637. * No log
  73638. */
  73639. static readonly NoneLogLevel: number;
  73640. /**
  73641. * Only message logs
  73642. */
  73643. static readonly MessageLogLevel: number;
  73644. /**
  73645. * Only warning logs
  73646. */
  73647. static readonly WarningLogLevel: number;
  73648. /**
  73649. * Only error logs
  73650. */
  73651. static readonly ErrorLogLevel: number;
  73652. /**
  73653. * All logs
  73654. */
  73655. static readonly AllLogLevel: number;
  73656. private static _LogCache;
  73657. /**
  73658. * Gets a value indicating the number of loading errors
  73659. * @ignorenaming
  73660. */
  73661. static errorsCount: number;
  73662. /**
  73663. * Callback called when a new log is added
  73664. */
  73665. static OnNewCacheEntry: (entry: string) => void;
  73666. private static _AddLogEntry;
  73667. private static _FormatMessage;
  73668. private static _LogDisabled;
  73669. private static _LogEnabled;
  73670. private static _WarnDisabled;
  73671. private static _WarnEnabled;
  73672. private static _ErrorDisabled;
  73673. private static _ErrorEnabled;
  73674. /**
  73675. * Log a message to the console
  73676. */
  73677. static Log: (message: string) => void;
  73678. /**
  73679. * Write a warning message to the console
  73680. */
  73681. static Warn: (message: string) => void;
  73682. /**
  73683. * Write an error message to the console
  73684. */
  73685. static Error: (message: string) => void;
  73686. /**
  73687. * Gets current log cache (list of logs)
  73688. */
  73689. static get LogCache(): string;
  73690. /**
  73691. * Clears the log cache
  73692. */
  73693. static ClearLogCache(): void;
  73694. /**
  73695. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  73696. */
  73697. static set LogLevels(level: number);
  73698. }
  73699. }
  73700. declare module BABYLON {
  73701. /** @hidden */
  73702. export class _TypeStore {
  73703. /** @hidden */
  73704. static RegisteredTypes: {
  73705. [key: string]: Object;
  73706. };
  73707. /** @hidden */
  73708. static GetClass(fqdn: string): any;
  73709. }
  73710. }
  73711. declare module BABYLON {
  73712. /**
  73713. * Helper to manipulate strings
  73714. */
  73715. export class StringTools {
  73716. /**
  73717. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  73718. * @param str Source string
  73719. * @param suffix Suffix to search for in the source string
  73720. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  73721. */
  73722. static EndsWith(str: string, suffix: string): boolean;
  73723. /**
  73724. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  73725. * @param str Source string
  73726. * @param suffix Suffix to search for in the source string
  73727. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  73728. */
  73729. static StartsWith(str: string, suffix: string): boolean;
  73730. /**
  73731. * Decodes a buffer into a string
  73732. * @param buffer The buffer to decode
  73733. * @returns The decoded string
  73734. */
  73735. static Decode(buffer: Uint8Array | Uint16Array): string;
  73736. /**
  73737. * Encode a buffer to a base64 string
  73738. * @param buffer defines the buffer to encode
  73739. * @returns the encoded string
  73740. */
  73741. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  73742. }
  73743. }
  73744. declare module BABYLON {
  73745. /**
  73746. * Class containing a set of static utilities functions for deep copy.
  73747. */
  73748. export class DeepCopier {
  73749. /**
  73750. * Tries to copy an object by duplicating every property
  73751. * @param source defines the source object
  73752. * @param destination defines the target object
  73753. * @param doNotCopyList defines a list of properties to avoid
  73754. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  73755. */
  73756. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  73757. }
  73758. }
  73759. declare module BABYLON {
  73760. /**
  73761. * Class containing a set of static utilities functions for precision date
  73762. */
  73763. export class PrecisionDate {
  73764. /**
  73765. * Gets either window.performance.now() if supported or Date.now() else
  73766. */
  73767. static get Now(): number;
  73768. }
  73769. }
  73770. declare module BABYLON {
  73771. /** @hidden */
  73772. export class _DevTools {
  73773. static WarnImport(name: string): string;
  73774. }
  73775. }
  73776. declare module BABYLON {
  73777. /**
  73778. * Interface used to define the mechanism to get data from the network
  73779. */
  73780. export interface IWebRequest {
  73781. /**
  73782. * Returns client's response url
  73783. */
  73784. responseURL: string;
  73785. /**
  73786. * Returns client's status
  73787. */
  73788. status: number;
  73789. /**
  73790. * Returns client's status as a text
  73791. */
  73792. statusText: string;
  73793. }
  73794. }
  73795. declare module BABYLON {
  73796. /**
  73797. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  73798. */
  73799. export class WebRequest implements IWebRequest {
  73800. private _xhr;
  73801. /**
  73802. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  73803. * i.e. when loading files, where the server/service expects an Authorization header
  73804. */
  73805. static CustomRequestHeaders: {
  73806. [key: string]: string;
  73807. };
  73808. /**
  73809. * Add callback functions in this array to update all the requests before they get sent to the network
  73810. */
  73811. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  73812. private _injectCustomRequestHeaders;
  73813. /**
  73814. * Gets or sets a function to be called when loading progress changes
  73815. */
  73816. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  73817. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  73818. /**
  73819. * Returns client's state
  73820. */
  73821. get readyState(): number;
  73822. /**
  73823. * Returns client's status
  73824. */
  73825. get status(): number;
  73826. /**
  73827. * Returns client's status as a text
  73828. */
  73829. get statusText(): string;
  73830. /**
  73831. * Returns client's response
  73832. */
  73833. get response(): any;
  73834. /**
  73835. * Returns client's response url
  73836. */
  73837. get responseURL(): string;
  73838. /**
  73839. * Returns client's response as text
  73840. */
  73841. get responseText(): string;
  73842. /**
  73843. * Gets or sets the expected response type
  73844. */
  73845. get responseType(): XMLHttpRequestResponseType;
  73846. set responseType(value: XMLHttpRequestResponseType);
  73847. /** @hidden */
  73848. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  73849. /** @hidden */
  73850. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  73851. /**
  73852. * Cancels any network activity
  73853. */
  73854. abort(): void;
  73855. /**
  73856. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  73857. * @param body defines an optional request body
  73858. */
  73859. send(body?: Document | BodyInit | null): void;
  73860. /**
  73861. * Sets the request method, request URL
  73862. * @param method defines the method to use (GET, POST, etc..)
  73863. * @param url defines the url to connect with
  73864. */
  73865. open(method: string, url: string): void;
  73866. /**
  73867. * Sets the value of a request header.
  73868. * @param name The name of the header whose value is to be set
  73869. * @param value The value to set as the body of the header
  73870. */
  73871. setRequestHeader(name: string, value: string): void;
  73872. /**
  73873. * Get the string containing the text of a particular header's value.
  73874. * @param name The name of the header
  73875. * @returns The string containing the text of the given header name
  73876. */
  73877. getResponseHeader(name: string): Nullable<string>;
  73878. }
  73879. }
  73880. declare module BABYLON {
  73881. /**
  73882. * File request interface
  73883. */
  73884. export interface IFileRequest {
  73885. /**
  73886. * Raised when the request is complete (success or error).
  73887. */
  73888. onCompleteObservable: Observable<IFileRequest>;
  73889. /**
  73890. * Aborts the request for a file.
  73891. */
  73892. abort: () => void;
  73893. }
  73894. }
  73895. declare module BABYLON {
  73896. /**
  73897. * Define options used to create a render target texture
  73898. */
  73899. export class RenderTargetCreationOptions {
  73900. /**
  73901. * Specifies is mipmaps must be generated
  73902. */
  73903. generateMipMaps?: boolean;
  73904. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  73905. generateDepthBuffer?: boolean;
  73906. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  73907. generateStencilBuffer?: boolean;
  73908. /** Defines texture type (int by default) */
  73909. type?: number;
  73910. /** Defines sampling mode (trilinear by default) */
  73911. samplingMode?: number;
  73912. /** Defines format (RGBA by default) */
  73913. format?: number;
  73914. }
  73915. }
  73916. declare module BABYLON {
  73917. /** Defines the cross module used constants to avoid circular dependncies */
  73918. export class Constants {
  73919. /** Defines that alpha blending is disabled */
  73920. static readonly ALPHA_DISABLE: number;
  73921. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  73922. static readonly ALPHA_ADD: number;
  73923. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  73924. static readonly ALPHA_COMBINE: number;
  73925. /** Defines that alpha blending is DEST - SRC * DEST */
  73926. static readonly ALPHA_SUBTRACT: number;
  73927. /** Defines that alpha blending is SRC * DEST */
  73928. static readonly ALPHA_MULTIPLY: number;
  73929. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  73930. static readonly ALPHA_MAXIMIZED: number;
  73931. /** Defines that alpha blending is SRC + DEST */
  73932. static readonly ALPHA_ONEONE: number;
  73933. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  73934. static readonly ALPHA_PREMULTIPLIED: number;
  73935. /**
  73936. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  73937. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  73938. */
  73939. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  73940. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  73941. static readonly ALPHA_INTERPOLATE: number;
  73942. /**
  73943. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  73944. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  73945. */
  73946. static readonly ALPHA_SCREENMODE: number;
  73947. /**
  73948. * Defines that alpha blending is SRC + DST
  73949. * Alpha will be set to SRC ALPHA + DST ALPHA
  73950. */
  73951. static readonly ALPHA_ONEONE_ONEONE: number;
  73952. /**
  73953. * Defines that alpha blending is SRC * DST ALPHA + DST
  73954. * Alpha will be set to 0
  73955. */
  73956. static readonly ALPHA_ALPHATOCOLOR: number;
  73957. /**
  73958. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  73959. */
  73960. static readonly ALPHA_REVERSEONEMINUS: number;
  73961. /**
  73962. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  73963. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  73964. */
  73965. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  73966. /**
  73967. * Defines that alpha blending is SRC + DST
  73968. * Alpha will be set to SRC ALPHA
  73969. */
  73970. static readonly ALPHA_ONEONE_ONEZERO: number;
  73971. /**
  73972. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  73973. * Alpha will be set to DST ALPHA
  73974. */
  73975. static readonly ALPHA_EXCLUSION: number;
  73976. /** Defines that alpha blending equation a SUM */
  73977. static readonly ALPHA_EQUATION_ADD: number;
  73978. /** Defines that alpha blending equation a SUBSTRACTION */
  73979. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  73980. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  73981. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  73982. /** Defines that alpha blending equation a MAX operation */
  73983. static readonly ALPHA_EQUATION_MAX: number;
  73984. /** Defines that alpha blending equation a MIN operation */
  73985. static readonly ALPHA_EQUATION_MIN: number;
  73986. /**
  73987. * Defines that alpha blending equation a DARKEN operation:
  73988. * It takes the min of the src and sums the alpha channels.
  73989. */
  73990. static readonly ALPHA_EQUATION_DARKEN: number;
  73991. /** Defines that the ressource is not delayed*/
  73992. static readonly DELAYLOADSTATE_NONE: number;
  73993. /** Defines that the ressource was successfully delay loaded */
  73994. static readonly DELAYLOADSTATE_LOADED: number;
  73995. /** Defines that the ressource is currently delay loading */
  73996. static readonly DELAYLOADSTATE_LOADING: number;
  73997. /** Defines that the ressource is delayed and has not started loading */
  73998. static readonly DELAYLOADSTATE_NOTLOADED: number;
  73999. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  74000. static readonly NEVER: number;
  74001. /** 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 */
  74002. static readonly ALWAYS: number;
  74003. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  74004. static readonly LESS: number;
  74005. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  74006. static readonly EQUAL: number;
  74007. /** 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 */
  74008. static readonly LEQUAL: number;
  74009. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  74010. static readonly GREATER: number;
  74011. /** 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 */
  74012. static readonly GEQUAL: number;
  74013. /** 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 */
  74014. static readonly NOTEQUAL: number;
  74015. /** Passed to stencilOperation to specify that stencil value must be kept */
  74016. static readonly KEEP: number;
  74017. /** Passed to stencilOperation to specify that stencil value must be replaced */
  74018. static readonly REPLACE: number;
  74019. /** Passed to stencilOperation to specify that stencil value must be incremented */
  74020. static readonly INCR: number;
  74021. /** Passed to stencilOperation to specify that stencil value must be decremented */
  74022. static readonly DECR: number;
  74023. /** Passed to stencilOperation to specify that stencil value must be inverted */
  74024. static readonly INVERT: number;
  74025. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  74026. static readonly INCR_WRAP: number;
  74027. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  74028. static readonly DECR_WRAP: number;
  74029. /** Texture is not repeating outside of 0..1 UVs */
  74030. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  74031. /** Texture is repeating outside of 0..1 UVs */
  74032. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  74033. /** Texture is repeating and mirrored */
  74034. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  74035. /** ALPHA */
  74036. static readonly TEXTUREFORMAT_ALPHA: number;
  74037. /** LUMINANCE */
  74038. static readonly TEXTUREFORMAT_LUMINANCE: number;
  74039. /** LUMINANCE_ALPHA */
  74040. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  74041. /** RGB */
  74042. static readonly TEXTUREFORMAT_RGB: number;
  74043. /** RGBA */
  74044. static readonly TEXTUREFORMAT_RGBA: number;
  74045. /** RED */
  74046. static readonly TEXTUREFORMAT_RED: number;
  74047. /** RED (2nd reference) */
  74048. static readonly TEXTUREFORMAT_R: number;
  74049. /** RG */
  74050. static readonly TEXTUREFORMAT_RG: number;
  74051. /** RED_INTEGER */
  74052. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  74053. /** RED_INTEGER (2nd reference) */
  74054. static readonly TEXTUREFORMAT_R_INTEGER: number;
  74055. /** RG_INTEGER */
  74056. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  74057. /** RGB_INTEGER */
  74058. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  74059. /** RGBA_INTEGER */
  74060. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  74061. /** UNSIGNED_BYTE */
  74062. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  74063. /** UNSIGNED_BYTE (2nd reference) */
  74064. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  74065. /** FLOAT */
  74066. static readonly TEXTURETYPE_FLOAT: number;
  74067. /** HALF_FLOAT */
  74068. static readonly TEXTURETYPE_HALF_FLOAT: number;
  74069. /** BYTE */
  74070. static readonly TEXTURETYPE_BYTE: number;
  74071. /** SHORT */
  74072. static readonly TEXTURETYPE_SHORT: number;
  74073. /** UNSIGNED_SHORT */
  74074. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  74075. /** INT */
  74076. static readonly TEXTURETYPE_INT: number;
  74077. /** UNSIGNED_INT */
  74078. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  74079. /** UNSIGNED_SHORT_4_4_4_4 */
  74080. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  74081. /** UNSIGNED_SHORT_5_5_5_1 */
  74082. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  74083. /** UNSIGNED_SHORT_5_6_5 */
  74084. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  74085. /** UNSIGNED_INT_2_10_10_10_REV */
  74086. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  74087. /** UNSIGNED_INT_24_8 */
  74088. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  74089. /** UNSIGNED_INT_10F_11F_11F_REV */
  74090. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  74091. /** UNSIGNED_INT_5_9_9_9_REV */
  74092. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  74093. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  74094. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  74095. /** nearest is mag = nearest and min = nearest and no mip */
  74096. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  74097. /** mag = nearest and min = nearest and mip = none */
  74098. static readonly TEXTURE_NEAREST_NEAREST: number;
  74099. /** Bilinear is mag = linear and min = linear and no mip */
  74100. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  74101. /** mag = linear and min = linear and mip = none */
  74102. static readonly TEXTURE_LINEAR_LINEAR: number;
  74103. /** Trilinear is mag = linear and min = linear and mip = linear */
  74104. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  74105. /** Trilinear is mag = linear and min = linear and mip = linear */
  74106. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  74107. /** mag = nearest and min = nearest and mip = nearest */
  74108. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  74109. /** mag = nearest and min = linear and mip = nearest */
  74110. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  74111. /** mag = nearest and min = linear and mip = linear */
  74112. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  74113. /** mag = nearest and min = linear and mip = none */
  74114. static readonly TEXTURE_NEAREST_LINEAR: number;
  74115. /** nearest is mag = nearest and min = nearest and mip = linear */
  74116. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  74117. /** mag = linear and min = nearest and mip = nearest */
  74118. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  74119. /** mag = linear and min = nearest and mip = linear */
  74120. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  74121. /** Bilinear is mag = linear and min = linear and mip = nearest */
  74122. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  74123. /** mag = linear and min = nearest and mip = none */
  74124. static readonly TEXTURE_LINEAR_NEAREST: number;
  74125. /** Explicit coordinates mode */
  74126. static readonly TEXTURE_EXPLICIT_MODE: number;
  74127. /** Spherical coordinates mode */
  74128. static readonly TEXTURE_SPHERICAL_MODE: number;
  74129. /** Planar coordinates mode */
  74130. static readonly TEXTURE_PLANAR_MODE: number;
  74131. /** Cubic coordinates mode */
  74132. static readonly TEXTURE_CUBIC_MODE: number;
  74133. /** Projection coordinates mode */
  74134. static readonly TEXTURE_PROJECTION_MODE: number;
  74135. /** Skybox coordinates mode */
  74136. static readonly TEXTURE_SKYBOX_MODE: number;
  74137. /** Inverse Cubic coordinates mode */
  74138. static readonly TEXTURE_INVCUBIC_MODE: number;
  74139. /** Equirectangular coordinates mode */
  74140. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  74141. /** Equirectangular Fixed coordinates mode */
  74142. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  74143. /** Equirectangular Fixed Mirrored coordinates mode */
  74144. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  74145. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  74146. static readonly SCALEMODE_FLOOR: number;
  74147. /** Defines that texture rescaling will look for the nearest power of 2 size */
  74148. static readonly SCALEMODE_NEAREST: number;
  74149. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  74150. static readonly SCALEMODE_CEILING: number;
  74151. /**
  74152. * The dirty texture flag value
  74153. */
  74154. static readonly MATERIAL_TextureDirtyFlag: number;
  74155. /**
  74156. * The dirty light flag value
  74157. */
  74158. static readonly MATERIAL_LightDirtyFlag: number;
  74159. /**
  74160. * The dirty fresnel flag value
  74161. */
  74162. static readonly MATERIAL_FresnelDirtyFlag: number;
  74163. /**
  74164. * The dirty attribute flag value
  74165. */
  74166. static readonly MATERIAL_AttributesDirtyFlag: number;
  74167. /**
  74168. * The dirty misc flag value
  74169. */
  74170. static readonly MATERIAL_MiscDirtyFlag: number;
  74171. /**
  74172. * The all dirty flag value
  74173. */
  74174. static readonly MATERIAL_AllDirtyFlag: number;
  74175. /**
  74176. * Returns the triangle fill mode
  74177. */
  74178. static readonly MATERIAL_TriangleFillMode: number;
  74179. /**
  74180. * Returns the wireframe mode
  74181. */
  74182. static readonly MATERIAL_WireFrameFillMode: number;
  74183. /**
  74184. * Returns the point fill mode
  74185. */
  74186. static readonly MATERIAL_PointFillMode: number;
  74187. /**
  74188. * Returns the point list draw mode
  74189. */
  74190. static readonly MATERIAL_PointListDrawMode: number;
  74191. /**
  74192. * Returns the line list draw mode
  74193. */
  74194. static readonly MATERIAL_LineListDrawMode: number;
  74195. /**
  74196. * Returns the line loop draw mode
  74197. */
  74198. static readonly MATERIAL_LineLoopDrawMode: number;
  74199. /**
  74200. * Returns the line strip draw mode
  74201. */
  74202. static readonly MATERIAL_LineStripDrawMode: number;
  74203. /**
  74204. * Returns the triangle strip draw mode
  74205. */
  74206. static readonly MATERIAL_TriangleStripDrawMode: number;
  74207. /**
  74208. * Returns the triangle fan draw mode
  74209. */
  74210. static readonly MATERIAL_TriangleFanDrawMode: number;
  74211. /**
  74212. * Stores the clock-wise side orientation
  74213. */
  74214. static readonly MATERIAL_ClockWiseSideOrientation: number;
  74215. /**
  74216. * Stores the counter clock-wise side orientation
  74217. */
  74218. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  74219. /**
  74220. * Nothing
  74221. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74222. */
  74223. static readonly ACTION_NothingTrigger: number;
  74224. /**
  74225. * On pick
  74226. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74227. */
  74228. static readonly ACTION_OnPickTrigger: number;
  74229. /**
  74230. * On left pick
  74231. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74232. */
  74233. static readonly ACTION_OnLeftPickTrigger: number;
  74234. /**
  74235. * On right pick
  74236. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74237. */
  74238. static readonly ACTION_OnRightPickTrigger: number;
  74239. /**
  74240. * On center pick
  74241. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74242. */
  74243. static readonly ACTION_OnCenterPickTrigger: number;
  74244. /**
  74245. * On pick down
  74246. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74247. */
  74248. static readonly ACTION_OnPickDownTrigger: number;
  74249. /**
  74250. * On double pick
  74251. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74252. */
  74253. static readonly ACTION_OnDoublePickTrigger: number;
  74254. /**
  74255. * On pick up
  74256. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74257. */
  74258. static readonly ACTION_OnPickUpTrigger: number;
  74259. /**
  74260. * On pick out.
  74261. * This trigger will only be raised if you also declared a OnPickDown
  74262. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74263. */
  74264. static readonly ACTION_OnPickOutTrigger: number;
  74265. /**
  74266. * On long press
  74267. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74268. */
  74269. static readonly ACTION_OnLongPressTrigger: number;
  74270. /**
  74271. * On pointer over
  74272. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74273. */
  74274. static readonly ACTION_OnPointerOverTrigger: number;
  74275. /**
  74276. * On pointer out
  74277. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74278. */
  74279. static readonly ACTION_OnPointerOutTrigger: number;
  74280. /**
  74281. * On every frame
  74282. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74283. */
  74284. static readonly ACTION_OnEveryFrameTrigger: number;
  74285. /**
  74286. * On intersection enter
  74287. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74288. */
  74289. static readonly ACTION_OnIntersectionEnterTrigger: number;
  74290. /**
  74291. * On intersection exit
  74292. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74293. */
  74294. static readonly ACTION_OnIntersectionExitTrigger: number;
  74295. /**
  74296. * On key down
  74297. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74298. */
  74299. static readonly ACTION_OnKeyDownTrigger: number;
  74300. /**
  74301. * On key up
  74302. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74303. */
  74304. static readonly ACTION_OnKeyUpTrigger: number;
  74305. /**
  74306. * Billboard mode will only apply to Y axis
  74307. */
  74308. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  74309. /**
  74310. * Billboard mode will apply to all axes
  74311. */
  74312. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  74313. /**
  74314. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  74315. */
  74316. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  74317. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  74318. * Test order :
  74319. * Is the bounding sphere outside the frustum ?
  74320. * If not, are the bounding box vertices outside the frustum ?
  74321. * It not, then the cullable object is in the frustum.
  74322. */
  74323. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  74324. /** Culling strategy : Bounding Sphere Only.
  74325. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  74326. * It's also less accurate than the standard because some not visible objects can still be selected.
  74327. * Test : is the bounding sphere outside the frustum ?
  74328. * If not, then the cullable object is in the frustum.
  74329. */
  74330. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  74331. /** Culling strategy : Optimistic Inclusion.
  74332. * This in an inclusion test first, then the standard exclusion test.
  74333. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  74334. * 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.
  74335. * Anyway, it's as accurate as the standard strategy.
  74336. * Test :
  74337. * Is the cullable object bounding sphere center in the frustum ?
  74338. * If not, apply the default culling strategy.
  74339. */
  74340. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  74341. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  74342. * This in an inclusion test first, then the bounding sphere only exclusion test.
  74343. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  74344. * 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.
  74345. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  74346. * Test :
  74347. * Is the cullable object bounding sphere center in the frustum ?
  74348. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  74349. */
  74350. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  74351. /**
  74352. * No logging while loading
  74353. */
  74354. static readonly SCENELOADER_NO_LOGGING: number;
  74355. /**
  74356. * Minimal logging while loading
  74357. */
  74358. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  74359. /**
  74360. * Summary logging while loading
  74361. */
  74362. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  74363. /**
  74364. * Detailled logging while loading
  74365. */
  74366. static readonly SCENELOADER_DETAILED_LOGGING: number;
  74367. }
  74368. }
  74369. declare module BABYLON {
  74370. /**
  74371. * This represents the required contract to create a new type of texture loader.
  74372. */
  74373. export interface IInternalTextureLoader {
  74374. /**
  74375. * Defines wether the loader supports cascade loading the different faces.
  74376. */
  74377. supportCascades: boolean;
  74378. /**
  74379. * This returns if the loader support the current file information.
  74380. * @param extension defines the file extension of the file being loaded
  74381. * @param textureFormatInUse defines the current compressed format in use iun the engine
  74382. * @param fallback defines the fallback internal texture if any
  74383. * @param isBase64 defines whether the texture is encoded as a base64
  74384. * @param isBuffer defines whether the texture data are stored as a buffer
  74385. * @returns true if the loader can load the specified file
  74386. */
  74387. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  74388. /**
  74389. * Transform the url before loading if required.
  74390. * @param rootUrl the url of the texture
  74391. * @param textureFormatInUse defines the current compressed format in use iun the engine
  74392. * @returns the transformed texture
  74393. */
  74394. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  74395. /**
  74396. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  74397. * @param rootUrl the url of the texture
  74398. * @param textureFormatInUse defines the current compressed format in use iun the engine
  74399. * @returns the fallback texture
  74400. */
  74401. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  74402. /**
  74403. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  74404. * @param data contains the texture data
  74405. * @param texture defines the BabylonJS internal texture
  74406. * @param createPolynomials will be true if polynomials have been requested
  74407. * @param onLoad defines the callback to trigger once the texture is ready
  74408. * @param onError defines the callback to trigger in case of error
  74409. */
  74410. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  74411. /**
  74412. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  74413. * @param data contains the texture data
  74414. * @param texture defines the BabylonJS internal texture
  74415. * @param callback defines the method to call once ready to upload
  74416. */
  74417. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  74418. }
  74419. }
  74420. declare module BABYLON {
  74421. /**
  74422. * Class used to store and describe the pipeline context associated with an effect
  74423. */
  74424. export interface IPipelineContext {
  74425. /**
  74426. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  74427. */
  74428. isAsync: boolean;
  74429. /**
  74430. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  74431. */
  74432. isReady: boolean;
  74433. /** @hidden */
  74434. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  74435. }
  74436. }
  74437. declare module BABYLON {
  74438. /**
  74439. * Class used to store gfx data (like WebGLBuffer)
  74440. */
  74441. export class DataBuffer {
  74442. /**
  74443. * Gets or sets the number of objects referencing this buffer
  74444. */
  74445. references: number;
  74446. /** Gets or sets the size of the underlying buffer */
  74447. capacity: number;
  74448. /**
  74449. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  74450. */
  74451. is32Bits: boolean;
  74452. /**
  74453. * Gets the underlying buffer
  74454. */
  74455. get underlyingResource(): any;
  74456. }
  74457. }
  74458. declare module BABYLON {
  74459. /** @hidden */
  74460. export interface IShaderProcessor {
  74461. attributeProcessor?: (attribute: string) => string;
  74462. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  74463. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  74464. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  74465. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  74466. lineProcessor?: (line: string, isFragment: boolean) => string;
  74467. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  74468. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  74469. }
  74470. }
  74471. declare module BABYLON {
  74472. /** @hidden */
  74473. export interface ProcessingOptions {
  74474. defines: string[];
  74475. indexParameters: any;
  74476. isFragment: boolean;
  74477. shouldUseHighPrecisionShader: boolean;
  74478. supportsUniformBuffers: boolean;
  74479. shadersRepository: string;
  74480. includesShadersStore: {
  74481. [key: string]: string;
  74482. };
  74483. processor?: IShaderProcessor;
  74484. version: string;
  74485. platformName: string;
  74486. lookForClosingBracketForUniformBuffer?: boolean;
  74487. }
  74488. }
  74489. declare module BABYLON {
  74490. /** @hidden */
  74491. export class ShaderCodeNode {
  74492. line: string;
  74493. children: ShaderCodeNode[];
  74494. additionalDefineKey?: string;
  74495. additionalDefineValue?: string;
  74496. isValid(preprocessors: {
  74497. [key: string]: string;
  74498. }): boolean;
  74499. process(preprocessors: {
  74500. [key: string]: string;
  74501. }, options: ProcessingOptions): string;
  74502. }
  74503. }
  74504. declare module BABYLON {
  74505. /** @hidden */
  74506. export class ShaderCodeCursor {
  74507. private _lines;
  74508. lineIndex: number;
  74509. get currentLine(): string;
  74510. get canRead(): boolean;
  74511. set lines(value: string[]);
  74512. }
  74513. }
  74514. declare module BABYLON {
  74515. /** @hidden */
  74516. export class ShaderCodeConditionNode extends ShaderCodeNode {
  74517. process(preprocessors: {
  74518. [key: string]: string;
  74519. }, options: ProcessingOptions): string;
  74520. }
  74521. }
  74522. declare module BABYLON {
  74523. /** @hidden */
  74524. export class ShaderDefineExpression {
  74525. isTrue(preprocessors: {
  74526. [key: string]: string;
  74527. }): boolean;
  74528. }
  74529. }
  74530. declare module BABYLON {
  74531. /** @hidden */
  74532. export class ShaderCodeTestNode extends ShaderCodeNode {
  74533. testExpression: ShaderDefineExpression;
  74534. isValid(preprocessors: {
  74535. [key: string]: string;
  74536. }): boolean;
  74537. }
  74538. }
  74539. declare module BABYLON {
  74540. /** @hidden */
  74541. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  74542. define: string;
  74543. not: boolean;
  74544. constructor(define: string, not?: boolean);
  74545. isTrue(preprocessors: {
  74546. [key: string]: string;
  74547. }): boolean;
  74548. }
  74549. }
  74550. declare module BABYLON {
  74551. /** @hidden */
  74552. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  74553. leftOperand: ShaderDefineExpression;
  74554. rightOperand: ShaderDefineExpression;
  74555. isTrue(preprocessors: {
  74556. [key: string]: string;
  74557. }): boolean;
  74558. }
  74559. }
  74560. declare module BABYLON {
  74561. /** @hidden */
  74562. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  74563. leftOperand: ShaderDefineExpression;
  74564. rightOperand: ShaderDefineExpression;
  74565. isTrue(preprocessors: {
  74566. [key: string]: string;
  74567. }): boolean;
  74568. }
  74569. }
  74570. declare module BABYLON {
  74571. /** @hidden */
  74572. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  74573. define: string;
  74574. operand: string;
  74575. testValue: string;
  74576. constructor(define: string, operand: string, testValue: string);
  74577. isTrue(preprocessors: {
  74578. [key: string]: string;
  74579. }): boolean;
  74580. }
  74581. }
  74582. declare module BABYLON {
  74583. /**
  74584. * Class used to enable access to offline support
  74585. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  74586. */
  74587. export interface IOfflineProvider {
  74588. /**
  74589. * Gets a boolean indicating if scene must be saved in the database
  74590. */
  74591. enableSceneOffline: boolean;
  74592. /**
  74593. * Gets a boolean indicating if textures must be saved in the database
  74594. */
  74595. enableTexturesOffline: boolean;
  74596. /**
  74597. * Open the offline support and make it available
  74598. * @param successCallback defines the callback to call on success
  74599. * @param errorCallback defines the callback to call on error
  74600. */
  74601. open(successCallback: () => void, errorCallback: () => void): void;
  74602. /**
  74603. * Loads an image from the offline support
  74604. * @param url defines the url to load from
  74605. * @param image defines the target DOM image
  74606. */
  74607. loadImage(url: string, image: HTMLImageElement): void;
  74608. /**
  74609. * Loads a file from offline support
  74610. * @param url defines the URL to load from
  74611. * @param sceneLoaded defines a callback to call on success
  74612. * @param progressCallBack defines a callback to call when progress changed
  74613. * @param errorCallback defines a callback to call on error
  74614. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  74615. */
  74616. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  74617. }
  74618. }
  74619. declare module BABYLON {
  74620. /**
  74621. * Class used to help managing file picking and drag'n'drop
  74622. * File Storage
  74623. */
  74624. export class FilesInputStore {
  74625. /**
  74626. * List of files ready to be loaded
  74627. */
  74628. static FilesToLoad: {
  74629. [key: string]: File;
  74630. };
  74631. }
  74632. }
  74633. declare module BABYLON {
  74634. /**
  74635. * Class used to define a retry strategy when error happens while loading assets
  74636. */
  74637. export class RetryStrategy {
  74638. /**
  74639. * Function used to defines an exponential back off strategy
  74640. * @param maxRetries defines the maximum number of retries (3 by default)
  74641. * @param baseInterval defines the interval between retries
  74642. * @returns the strategy function to use
  74643. */
  74644. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  74645. }
  74646. }
  74647. declare module BABYLON {
  74648. /**
  74649. * @ignore
  74650. * Application error to support additional information when loading a file
  74651. */
  74652. export abstract class BaseError extends Error {
  74653. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  74654. }
  74655. }
  74656. declare module BABYLON {
  74657. /** @ignore */
  74658. export class LoadFileError extends BaseError {
  74659. request?: WebRequest;
  74660. file?: File;
  74661. /**
  74662. * Creates a new LoadFileError
  74663. * @param message defines the message of the error
  74664. * @param request defines the optional web request
  74665. * @param file defines the optional file
  74666. */
  74667. constructor(message: string, object?: WebRequest | File);
  74668. }
  74669. /** @ignore */
  74670. export class RequestFileError extends BaseError {
  74671. request: WebRequest;
  74672. /**
  74673. * Creates a new LoadFileError
  74674. * @param message defines the message of the error
  74675. * @param request defines the optional web request
  74676. */
  74677. constructor(message: string, request: WebRequest);
  74678. }
  74679. /** @ignore */
  74680. export class ReadFileError extends BaseError {
  74681. file: File;
  74682. /**
  74683. * Creates a new ReadFileError
  74684. * @param message defines the message of the error
  74685. * @param file defines the optional file
  74686. */
  74687. constructor(message: string, file: File);
  74688. }
  74689. /**
  74690. * @hidden
  74691. */
  74692. export class FileTools {
  74693. /**
  74694. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  74695. */
  74696. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  74697. /**
  74698. * Gets or sets the base URL to use to load assets
  74699. */
  74700. static BaseUrl: string;
  74701. /**
  74702. * Default behaviour for cors in the application.
  74703. * It can be a string if the expected behavior is identical in the entire app.
  74704. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  74705. */
  74706. static CorsBehavior: string | ((url: string | string[]) => string);
  74707. /**
  74708. * Gets or sets a function used to pre-process url before using them to load assets
  74709. */
  74710. static PreprocessUrl: (url: string) => string;
  74711. /**
  74712. * Removes unwanted characters from an url
  74713. * @param url defines the url to clean
  74714. * @returns the cleaned url
  74715. */
  74716. private static _CleanUrl;
  74717. /**
  74718. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  74719. * @param url define the url we are trying
  74720. * @param element define the dom element where to configure the cors policy
  74721. */
  74722. static SetCorsBehavior(url: string | string[], element: {
  74723. crossOrigin: string | null;
  74724. }): void;
  74725. /**
  74726. * Loads an image as an HTMLImageElement.
  74727. * @param input url string, ArrayBuffer, or Blob to load
  74728. * @param onLoad callback called when the image successfully loads
  74729. * @param onError callback called when the image fails to load
  74730. * @param offlineProvider offline provider for caching
  74731. * @param mimeType optional mime type
  74732. * @returns the HTMLImageElement of the loaded image
  74733. */
  74734. 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>;
  74735. /**
  74736. * Reads a file from a File object
  74737. * @param file defines the file to load
  74738. * @param onSuccess defines the callback to call when data is loaded
  74739. * @param onProgress defines the callback to call during loading process
  74740. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  74741. * @param onError defines the callback to call when an error occurs
  74742. * @returns a file request object
  74743. */
  74744. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  74745. /**
  74746. * Loads a file from a url
  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 offlineProvider defines the offline provider for caching
  74751. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74752. * @param onError callback called when the file fails to load
  74753. * @returns a file request object
  74754. */
  74755. 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;
  74756. /**
  74757. * Loads a file
  74758. * @param url url to load
  74759. * @param onSuccess callback called when the file successfully loads
  74760. * @param onProgress callback called while file is loading (if the server supports this mode)
  74761. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74762. * @param onError callback called when the file fails to load
  74763. * @param onOpened callback called when the web request is opened
  74764. * @returns a file request object
  74765. */
  74766. 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;
  74767. /**
  74768. * Checks if the loaded document was accessed via `file:`-Protocol.
  74769. * @returns boolean
  74770. */
  74771. static IsFileURL(): boolean;
  74772. }
  74773. }
  74774. declare module BABYLON {
  74775. /** @hidden */
  74776. export class ShaderProcessor {
  74777. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  74778. private static _ProcessPrecision;
  74779. private static _ExtractOperation;
  74780. private static _BuildSubExpression;
  74781. private static _BuildExpression;
  74782. private static _MoveCursorWithinIf;
  74783. private static _MoveCursor;
  74784. private static _EvaluatePreProcessors;
  74785. private static _PreparePreProcessors;
  74786. private static _ProcessShaderConversion;
  74787. private static _ProcessIncludes;
  74788. /**
  74789. * Loads a file from a url
  74790. * @param url url to load
  74791. * @param onSuccess callback called when the file successfully loads
  74792. * @param onProgress callback called while file is loading (if the server supports this mode)
  74793. * @param offlineProvider defines the offline provider for caching
  74794. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74795. * @param onError callback called when the file fails to load
  74796. * @returns a file request object
  74797. * @hidden
  74798. */
  74799. 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;
  74800. }
  74801. }
  74802. declare module BABYLON {
  74803. /**
  74804. * @hidden
  74805. */
  74806. export interface IColor4Like {
  74807. r: float;
  74808. g: float;
  74809. b: float;
  74810. a: float;
  74811. }
  74812. /**
  74813. * @hidden
  74814. */
  74815. export interface IColor3Like {
  74816. r: float;
  74817. g: float;
  74818. b: float;
  74819. }
  74820. /**
  74821. * @hidden
  74822. */
  74823. export interface IVector4Like {
  74824. x: float;
  74825. y: float;
  74826. z: float;
  74827. w: float;
  74828. }
  74829. /**
  74830. * @hidden
  74831. */
  74832. export interface IVector3Like {
  74833. x: float;
  74834. y: float;
  74835. z: float;
  74836. }
  74837. /**
  74838. * @hidden
  74839. */
  74840. export interface IVector2Like {
  74841. x: float;
  74842. y: float;
  74843. }
  74844. /**
  74845. * @hidden
  74846. */
  74847. export interface IMatrixLike {
  74848. toArray(): DeepImmutable<Float32Array>;
  74849. updateFlag: int;
  74850. }
  74851. /**
  74852. * @hidden
  74853. */
  74854. export interface IViewportLike {
  74855. x: float;
  74856. y: float;
  74857. width: float;
  74858. height: float;
  74859. }
  74860. /**
  74861. * @hidden
  74862. */
  74863. export interface IPlaneLike {
  74864. normal: IVector3Like;
  74865. d: float;
  74866. normalize(): void;
  74867. }
  74868. }
  74869. declare module BABYLON {
  74870. /**
  74871. * Interface used to define common properties for effect fallbacks
  74872. */
  74873. export interface IEffectFallbacks {
  74874. /**
  74875. * Removes the defines that should be removed when falling back.
  74876. * @param currentDefines defines the current define statements for the shader.
  74877. * @param effect defines the current effect we try to compile
  74878. * @returns The resulting defines with defines of the current rank removed.
  74879. */
  74880. reduce(currentDefines: string, effect: Effect): string;
  74881. /**
  74882. * Removes the fallback from the bound mesh.
  74883. */
  74884. unBindMesh(): void;
  74885. /**
  74886. * Checks to see if more fallbacks are still availible.
  74887. */
  74888. hasMoreFallbacks: boolean;
  74889. }
  74890. }
  74891. declare module BABYLON {
  74892. /**
  74893. * Class used to evalaute queries containing `and` and `or` operators
  74894. */
  74895. export class AndOrNotEvaluator {
  74896. /**
  74897. * Evaluate a query
  74898. * @param query defines the query to evaluate
  74899. * @param evaluateCallback defines the callback used to filter result
  74900. * @returns true if the query matches
  74901. */
  74902. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  74903. private static _HandleParenthesisContent;
  74904. private static _SimplifyNegation;
  74905. }
  74906. }
  74907. declare module BABYLON {
  74908. /**
  74909. * Class used to store custom tags
  74910. */
  74911. export class Tags {
  74912. /**
  74913. * Adds support for tags on the given object
  74914. * @param obj defines the object to use
  74915. */
  74916. static EnableFor(obj: any): void;
  74917. /**
  74918. * Removes tags support
  74919. * @param obj defines the object to use
  74920. */
  74921. static DisableFor(obj: any): void;
  74922. /**
  74923. * Gets a boolean indicating if the given object has tags
  74924. * @param obj defines the object to use
  74925. * @returns a boolean
  74926. */
  74927. static HasTags(obj: any): boolean;
  74928. /**
  74929. * Gets the tags available on a given object
  74930. * @param obj defines the object to use
  74931. * @param asString defines if the tags must be returned as a string instead of an array of strings
  74932. * @returns the tags
  74933. */
  74934. static GetTags(obj: any, asString?: boolean): any;
  74935. /**
  74936. * Adds tags to an object
  74937. * @param obj defines the object to use
  74938. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  74939. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  74940. */
  74941. static AddTagsTo(obj: any, tagsString: string): void;
  74942. /**
  74943. * @hidden
  74944. */
  74945. static _AddTagTo(obj: any, tag: string): void;
  74946. /**
  74947. * Removes specific tags from a specific object
  74948. * @param obj defines the object to use
  74949. * @param tagsString defines the tags to remove
  74950. */
  74951. static RemoveTagsFrom(obj: any, tagsString: string): void;
  74952. /**
  74953. * @hidden
  74954. */
  74955. static _RemoveTagFrom(obj: any, tag: string): void;
  74956. /**
  74957. * Defines if tags hosted on an object match a given query
  74958. * @param obj defines the object to use
  74959. * @param tagsQuery defines the tag query
  74960. * @returns a boolean
  74961. */
  74962. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  74963. }
  74964. }
  74965. declare module BABYLON {
  74966. /**
  74967. * Scalar computation library
  74968. */
  74969. export class Scalar {
  74970. /**
  74971. * Two pi constants convenient for computation.
  74972. */
  74973. static TwoPi: number;
  74974. /**
  74975. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74976. * @param a number
  74977. * @param b number
  74978. * @param epsilon (default = 1.401298E-45)
  74979. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74980. */
  74981. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  74982. /**
  74983. * Returns a string : the upper case translation of the number i to hexadecimal.
  74984. * @param i number
  74985. * @returns the upper case translation of the number i to hexadecimal.
  74986. */
  74987. static ToHex(i: number): string;
  74988. /**
  74989. * Returns -1 if value is negative and +1 is value is positive.
  74990. * @param value the value
  74991. * @returns the value itself if it's equal to zero.
  74992. */
  74993. static Sign(value: number): number;
  74994. /**
  74995. * Returns the value itself if it's between min and max.
  74996. * Returns min if the value is lower than min.
  74997. * Returns max if the value is greater than max.
  74998. * @param value the value to clmap
  74999. * @param min the min value to clamp to (default: 0)
  75000. * @param max the max value to clamp to (default: 1)
  75001. * @returns the clamped value
  75002. */
  75003. static Clamp(value: number, min?: number, max?: number): number;
  75004. /**
  75005. * the log2 of value.
  75006. * @param value the value to compute log2 of
  75007. * @returns the log2 of value.
  75008. */
  75009. static Log2(value: number): number;
  75010. /**
  75011. * Loops the value, so that it is never larger than length and never smaller than 0.
  75012. *
  75013. * This is similar to the modulo operator but it works with floating point numbers.
  75014. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  75015. * With t = 5 and length = 2.5, the result would be 0.0.
  75016. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  75017. * @param value the value
  75018. * @param length the length
  75019. * @returns the looped value
  75020. */
  75021. static Repeat(value: number, length: number): number;
  75022. /**
  75023. * Normalize the value between 0.0 and 1.0 using min and max values
  75024. * @param value value to normalize
  75025. * @param min max to normalize between
  75026. * @param max min to normalize between
  75027. * @returns the normalized value
  75028. */
  75029. static Normalize(value: number, min: number, max: number): number;
  75030. /**
  75031. * Denormalize the value from 0.0 and 1.0 using min and max values
  75032. * @param normalized value to denormalize
  75033. * @param min max to denormalize between
  75034. * @param max min to denormalize between
  75035. * @returns the denormalized value
  75036. */
  75037. static Denormalize(normalized: number, min: number, max: number): number;
  75038. /**
  75039. * Calculates the shortest difference between two given angles given in degrees.
  75040. * @param current current angle in degrees
  75041. * @param target target angle in degrees
  75042. * @returns the delta
  75043. */
  75044. static DeltaAngle(current: number, target: number): number;
  75045. /**
  75046. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  75047. * @param tx value
  75048. * @param length length
  75049. * @returns The returned value will move back and forth between 0 and length
  75050. */
  75051. static PingPong(tx: number, length: number): number;
  75052. /**
  75053. * Interpolates between min and max with smoothing at the limits.
  75054. *
  75055. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  75056. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  75057. * @param from from
  75058. * @param to to
  75059. * @param tx value
  75060. * @returns the smooth stepped value
  75061. */
  75062. static SmoothStep(from: number, to: number, tx: number): number;
  75063. /**
  75064. * Moves a value current towards target.
  75065. *
  75066. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  75067. * Negative values of maxDelta pushes the value away from target.
  75068. * @param current current value
  75069. * @param target target value
  75070. * @param maxDelta max distance to move
  75071. * @returns resulting value
  75072. */
  75073. static MoveTowards(current: number, target: number, maxDelta: number): number;
  75074. /**
  75075. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  75076. *
  75077. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  75078. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  75079. * @param current current value
  75080. * @param target target value
  75081. * @param maxDelta max distance to move
  75082. * @returns resulting angle
  75083. */
  75084. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  75085. /**
  75086. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  75087. * @param start start value
  75088. * @param end target value
  75089. * @param amount amount to lerp between
  75090. * @returns the lerped value
  75091. */
  75092. static Lerp(start: number, end: number, amount: number): number;
  75093. /**
  75094. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  75095. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  75096. * @param start start value
  75097. * @param end target value
  75098. * @param amount amount to lerp between
  75099. * @returns the lerped value
  75100. */
  75101. static LerpAngle(start: number, end: number, amount: number): number;
  75102. /**
  75103. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  75104. * @param a start value
  75105. * @param b target value
  75106. * @param value value between a and b
  75107. * @returns the inverseLerp value
  75108. */
  75109. static InverseLerp(a: number, b: number, value: number): number;
  75110. /**
  75111. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  75112. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  75113. * @param value1 spline value
  75114. * @param tangent1 spline value
  75115. * @param value2 spline value
  75116. * @param tangent2 spline value
  75117. * @param amount input value
  75118. * @returns hermite result
  75119. */
  75120. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  75121. /**
  75122. * Returns a random float number between and min and max values
  75123. * @param min min value of random
  75124. * @param max max value of random
  75125. * @returns random value
  75126. */
  75127. static RandomRange(min: number, max: number): number;
  75128. /**
  75129. * This function returns percentage of a number in a given range.
  75130. *
  75131. * RangeToPercent(40,20,60) will return 0.5 (50%)
  75132. * RangeToPercent(34,0,100) will return 0.34 (34%)
  75133. * @param number to convert to percentage
  75134. * @param min min range
  75135. * @param max max range
  75136. * @returns the percentage
  75137. */
  75138. static RangeToPercent(number: number, min: number, max: number): number;
  75139. /**
  75140. * This function returns number that corresponds to the percentage in a given range.
  75141. *
  75142. * PercentToRange(0.34,0,100) will return 34.
  75143. * @param percent to convert to number
  75144. * @param min min range
  75145. * @param max max range
  75146. * @returns the number
  75147. */
  75148. static PercentToRange(percent: number, min: number, max: number): number;
  75149. /**
  75150. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  75151. * @param angle The angle to normalize in radian.
  75152. * @return The converted angle.
  75153. */
  75154. static NormalizeRadians(angle: number): number;
  75155. }
  75156. }
  75157. declare module BABYLON {
  75158. /**
  75159. * Constant used to convert a value to gamma space
  75160. * @ignorenaming
  75161. */
  75162. export const ToGammaSpace: number;
  75163. /**
  75164. * Constant used to convert a value to linear space
  75165. * @ignorenaming
  75166. */
  75167. export const ToLinearSpace = 2.2;
  75168. /**
  75169. * Constant used to define the minimal number value in Babylon.js
  75170. * @ignorenaming
  75171. */
  75172. let Epsilon: number;
  75173. }
  75174. declare module BABYLON {
  75175. /**
  75176. * Class used to represent a viewport on screen
  75177. */
  75178. export class Viewport {
  75179. /** viewport left coordinate */
  75180. x: number;
  75181. /** viewport top coordinate */
  75182. y: number;
  75183. /**viewport width */
  75184. width: number;
  75185. /** viewport height */
  75186. height: number;
  75187. /**
  75188. * Creates a Viewport object located at (x, y) and sized (width, height)
  75189. * @param x defines viewport left coordinate
  75190. * @param y defines viewport top coordinate
  75191. * @param width defines the viewport width
  75192. * @param height defines the viewport height
  75193. */
  75194. constructor(
  75195. /** viewport left coordinate */
  75196. x: number,
  75197. /** viewport top coordinate */
  75198. y: number,
  75199. /**viewport width */
  75200. width: number,
  75201. /** viewport height */
  75202. height: number);
  75203. /**
  75204. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  75205. * @param renderWidth defines the rendering width
  75206. * @param renderHeight defines the rendering height
  75207. * @returns a new Viewport
  75208. */
  75209. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  75210. /**
  75211. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  75212. * @param renderWidth defines the rendering width
  75213. * @param renderHeight defines the rendering height
  75214. * @param ref defines the target viewport
  75215. * @returns the current viewport
  75216. */
  75217. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  75218. /**
  75219. * Returns a new Viewport copied from the current one
  75220. * @returns a new Viewport
  75221. */
  75222. clone(): Viewport;
  75223. }
  75224. }
  75225. declare module BABYLON {
  75226. /**
  75227. * Class containing a set of static utilities functions for arrays.
  75228. */
  75229. export class ArrayTools {
  75230. /**
  75231. * Returns an array of the given size filled with element built from the given constructor and the paramters
  75232. * @param size the number of element to construct and put in the array
  75233. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  75234. * @returns a new array filled with new objects
  75235. */
  75236. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  75237. }
  75238. }
  75239. declare module BABYLON {
  75240. /**
  75241. * Class representing a vector containing 2 coordinates
  75242. */
  75243. export class Vector2 {
  75244. /** defines the first coordinate */
  75245. x: number;
  75246. /** defines the second coordinate */
  75247. y: number;
  75248. /**
  75249. * Creates a new Vector2 from the given x and y coordinates
  75250. * @param x defines the first coordinate
  75251. * @param y defines the second coordinate
  75252. */
  75253. constructor(
  75254. /** defines the first coordinate */
  75255. x?: number,
  75256. /** defines the second coordinate */
  75257. y?: number);
  75258. /**
  75259. * Gets a string with the Vector2 coordinates
  75260. * @returns a string with the Vector2 coordinates
  75261. */
  75262. toString(): string;
  75263. /**
  75264. * Gets class name
  75265. * @returns the string "Vector2"
  75266. */
  75267. getClassName(): string;
  75268. /**
  75269. * Gets current vector hash code
  75270. * @returns the Vector2 hash code as a number
  75271. */
  75272. getHashCode(): number;
  75273. /**
  75274. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  75275. * @param array defines the source array
  75276. * @param index defines the offset in source array
  75277. * @returns the current Vector2
  75278. */
  75279. toArray(array: FloatArray, index?: number): Vector2;
  75280. /**
  75281. * Copy the current vector to an array
  75282. * @returns a new array with 2 elements: the Vector2 coordinates.
  75283. */
  75284. asArray(): number[];
  75285. /**
  75286. * Sets the Vector2 coordinates with the given Vector2 coordinates
  75287. * @param source defines the source Vector2
  75288. * @returns the current updated Vector2
  75289. */
  75290. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  75291. /**
  75292. * Sets the Vector2 coordinates with the given floats
  75293. * @param x defines the first coordinate
  75294. * @param y defines the second coordinate
  75295. * @returns the current updated Vector2
  75296. */
  75297. copyFromFloats(x: number, y: number): Vector2;
  75298. /**
  75299. * Sets the Vector2 coordinates with the given floats
  75300. * @param x defines the first coordinate
  75301. * @param y defines the second coordinate
  75302. * @returns the current updated Vector2
  75303. */
  75304. set(x: number, y: number): Vector2;
  75305. /**
  75306. * Add another vector with the current one
  75307. * @param otherVector defines the other vector
  75308. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  75309. */
  75310. add(otherVector: DeepImmutable<Vector2>): Vector2;
  75311. /**
  75312. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  75313. * @param otherVector defines the other vector
  75314. * @param result defines the target vector
  75315. * @returns the unmodified current Vector2
  75316. */
  75317. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75318. /**
  75319. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  75320. * @param otherVector defines the other vector
  75321. * @returns the current updated Vector2
  75322. */
  75323. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75324. /**
  75325. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  75326. * @param otherVector defines the other vector
  75327. * @returns a new Vector2
  75328. */
  75329. addVector3(otherVector: Vector3): Vector2;
  75330. /**
  75331. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  75332. * @param otherVector defines the other vector
  75333. * @returns a new Vector2
  75334. */
  75335. subtract(otherVector: Vector2): Vector2;
  75336. /**
  75337. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  75338. * @param otherVector defines the other vector
  75339. * @param result defines the target vector
  75340. * @returns the unmodified current Vector2
  75341. */
  75342. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75343. /**
  75344. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  75345. * @param otherVector defines the other vector
  75346. * @returns the current updated Vector2
  75347. */
  75348. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75349. /**
  75350. * Multiplies in place the current Vector2 coordinates by the given ones
  75351. * @param otherVector defines the other vector
  75352. * @returns the current updated Vector2
  75353. */
  75354. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75355. /**
  75356. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  75357. * @param otherVector defines the other vector
  75358. * @returns a new Vector2
  75359. */
  75360. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  75361. /**
  75362. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  75363. * @param otherVector defines the other vector
  75364. * @param result defines the target vector
  75365. * @returns the unmodified current Vector2
  75366. */
  75367. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75368. /**
  75369. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  75370. * @param x defines the first coordinate
  75371. * @param y defines the second coordinate
  75372. * @returns a new Vector2
  75373. */
  75374. multiplyByFloats(x: number, y: number): Vector2;
  75375. /**
  75376. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  75377. * @param otherVector defines the other vector
  75378. * @returns a new Vector2
  75379. */
  75380. divide(otherVector: Vector2): Vector2;
  75381. /**
  75382. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  75383. * @param otherVector defines the other vector
  75384. * @param result defines the target vector
  75385. * @returns the unmodified current Vector2
  75386. */
  75387. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75388. /**
  75389. * Divides the current Vector2 coordinates by the given ones
  75390. * @param otherVector defines the other vector
  75391. * @returns the current updated Vector2
  75392. */
  75393. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75394. /**
  75395. * Gets a new Vector2 with current Vector2 negated coordinates
  75396. * @returns a new Vector2
  75397. */
  75398. negate(): Vector2;
  75399. /**
  75400. * Negate this vector in place
  75401. * @returns this
  75402. */
  75403. negateInPlace(): Vector2;
  75404. /**
  75405. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  75406. * @param result defines the Vector3 object where to store the result
  75407. * @returns the current Vector2
  75408. */
  75409. negateToRef(result: Vector2): Vector2;
  75410. /**
  75411. * Multiply the Vector2 coordinates by scale
  75412. * @param scale defines the scaling factor
  75413. * @returns the current updated Vector2
  75414. */
  75415. scaleInPlace(scale: number): Vector2;
  75416. /**
  75417. * Returns a new Vector2 scaled by "scale" from the current Vector2
  75418. * @param scale defines the scaling factor
  75419. * @returns a new Vector2
  75420. */
  75421. scale(scale: number): Vector2;
  75422. /**
  75423. * Scale the current Vector2 values by a factor to a given Vector2
  75424. * @param scale defines the scale factor
  75425. * @param result defines the Vector2 object where to store the result
  75426. * @returns the unmodified current Vector2
  75427. */
  75428. scaleToRef(scale: number, result: Vector2): Vector2;
  75429. /**
  75430. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  75431. * @param scale defines the scale factor
  75432. * @param result defines the Vector2 object where to store the result
  75433. * @returns the unmodified current Vector2
  75434. */
  75435. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  75436. /**
  75437. * Gets a boolean if two vectors are equals
  75438. * @param otherVector defines the other vector
  75439. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  75440. */
  75441. equals(otherVector: DeepImmutable<Vector2>): boolean;
  75442. /**
  75443. * Gets a boolean if two vectors are equals (using an epsilon value)
  75444. * @param otherVector defines the other vector
  75445. * @param epsilon defines the minimal distance to consider equality
  75446. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  75447. */
  75448. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  75449. /**
  75450. * Gets a new Vector2 from current Vector2 floored values
  75451. * @returns a new Vector2
  75452. */
  75453. floor(): Vector2;
  75454. /**
  75455. * Gets a new Vector2 from current Vector2 floored values
  75456. * @returns a new Vector2
  75457. */
  75458. fract(): Vector2;
  75459. /**
  75460. * Gets the length of the vector
  75461. * @returns the vector length (float)
  75462. */
  75463. length(): number;
  75464. /**
  75465. * Gets the vector squared length
  75466. * @returns the vector squared length (float)
  75467. */
  75468. lengthSquared(): number;
  75469. /**
  75470. * Normalize the vector
  75471. * @returns the current updated Vector2
  75472. */
  75473. normalize(): Vector2;
  75474. /**
  75475. * Gets a new Vector2 copied from the Vector2
  75476. * @returns a new Vector2
  75477. */
  75478. clone(): Vector2;
  75479. /**
  75480. * Gets a new Vector2(0, 0)
  75481. * @returns a new Vector2
  75482. */
  75483. static Zero(): Vector2;
  75484. /**
  75485. * Gets a new Vector2(1, 1)
  75486. * @returns a new Vector2
  75487. */
  75488. static One(): Vector2;
  75489. /**
  75490. * Gets a new Vector2 set from the given index element of the given array
  75491. * @param array defines the data source
  75492. * @param offset defines the offset in the data source
  75493. * @returns a new Vector2
  75494. */
  75495. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  75496. /**
  75497. * Sets "result" from the given index element of the given array
  75498. * @param array defines the data source
  75499. * @param offset defines the offset in the data source
  75500. * @param result defines the target vector
  75501. */
  75502. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  75503. /**
  75504. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  75505. * @param value1 defines 1st point of control
  75506. * @param value2 defines 2nd point of control
  75507. * @param value3 defines 3rd point of control
  75508. * @param value4 defines 4th point of control
  75509. * @param amount defines the interpolation factor
  75510. * @returns a new Vector2
  75511. */
  75512. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  75513. /**
  75514. * 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".
  75515. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  75516. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  75517. * @param value defines the value to clamp
  75518. * @param min defines the lower limit
  75519. * @param max defines the upper limit
  75520. * @returns a new Vector2
  75521. */
  75522. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  75523. /**
  75524. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  75525. * @param value1 defines the 1st control point
  75526. * @param tangent1 defines the outgoing tangent
  75527. * @param value2 defines the 2nd control point
  75528. * @param tangent2 defines the incoming tangent
  75529. * @param amount defines the interpolation factor
  75530. * @returns a new Vector2
  75531. */
  75532. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  75533. /**
  75534. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  75535. * @param start defines the start vector
  75536. * @param end defines the end vector
  75537. * @param amount defines the interpolation factor
  75538. * @returns a new Vector2
  75539. */
  75540. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  75541. /**
  75542. * Gets the dot product of the vector "left" and the vector "right"
  75543. * @param left defines first vector
  75544. * @param right defines second vector
  75545. * @returns the dot product (float)
  75546. */
  75547. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  75548. /**
  75549. * Returns a new Vector2 equal to the normalized given vector
  75550. * @param vector defines the vector to normalize
  75551. * @returns a new Vector2
  75552. */
  75553. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  75554. /**
  75555. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  75556. * @param left defines 1st vector
  75557. * @param right defines 2nd vector
  75558. * @returns a new Vector2
  75559. */
  75560. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  75561. /**
  75562. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  75563. * @param left defines 1st vector
  75564. * @param right defines 2nd vector
  75565. * @returns a new Vector2
  75566. */
  75567. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  75568. /**
  75569. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  75570. * @param vector defines the vector to transform
  75571. * @param transformation defines the matrix to apply
  75572. * @returns a new Vector2
  75573. */
  75574. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  75575. /**
  75576. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  75577. * @param vector defines the vector to transform
  75578. * @param transformation defines the matrix to apply
  75579. * @param result defines the target vector
  75580. */
  75581. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  75582. /**
  75583. * Determines if a given vector is included in a triangle
  75584. * @param p defines the vector to test
  75585. * @param p0 defines 1st triangle point
  75586. * @param p1 defines 2nd triangle point
  75587. * @param p2 defines 3rd triangle point
  75588. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  75589. */
  75590. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  75591. /**
  75592. * Gets the distance between the vectors "value1" and "value2"
  75593. * @param value1 defines first vector
  75594. * @param value2 defines second vector
  75595. * @returns the distance between vectors
  75596. */
  75597. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  75598. /**
  75599. * Returns the squared distance between the vectors "value1" and "value2"
  75600. * @param value1 defines first vector
  75601. * @param value2 defines second vector
  75602. * @returns the squared distance between vectors
  75603. */
  75604. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  75605. /**
  75606. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  75607. * @param value1 defines first vector
  75608. * @param value2 defines second vector
  75609. * @returns a new Vector2
  75610. */
  75611. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  75612. /**
  75613. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  75614. * @param p defines the middle point
  75615. * @param segA defines one point of the segment
  75616. * @param segB defines the other point of the segment
  75617. * @returns the shortest distance
  75618. */
  75619. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  75620. }
  75621. /**
  75622. * Class used to store (x,y,z) vector representation
  75623. * A Vector3 is the main object used in 3D geometry
  75624. * It can represent etiher the coordinates of a point the space, either a direction
  75625. * Reminder: js uses a left handed forward facing system
  75626. */
  75627. export class Vector3 {
  75628. /**
  75629. * Defines the first coordinates (on X axis)
  75630. */
  75631. x: number;
  75632. /**
  75633. * Defines the second coordinates (on Y axis)
  75634. */
  75635. y: number;
  75636. /**
  75637. * Defines the third coordinates (on Z axis)
  75638. */
  75639. z: number;
  75640. private static _UpReadOnly;
  75641. private static _ZeroReadOnly;
  75642. /**
  75643. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  75644. * @param x defines the first coordinates (on X axis)
  75645. * @param y defines the second coordinates (on Y axis)
  75646. * @param z defines the third coordinates (on Z axis)
  75647. */
  75648. constructor(
  75649. /**
  75650. * Defines the first coordinates (on X axis)
  75651. */
  75652. x?: number,
  75653. /**
  75654. * Defines the second coordinates (on Y axis)
  75655. */
  75656. y?: number,
  75657. /**
  75658. * Defines the third coordinates (on Z axis)
  75659. */
  75660. z?: number);
  75661. /**
  75662. * Creates a string representation of the Vector3
  75663. * @returns a string with the Vector3 coordinates.
  75664. */
  75665. toString(): string;
  75666. /**
  75667. * Gets the class name
  75668. * @returns the string "Vector3"
  75669. */
  75670. getClassName(): string;
  75671. /**
  75672. * Creates the Vector3 hash code
  75673. * @returns a number which tends to be unique between Vector3 instances
  75674. */
  75675. getHashCode(): number;
  75676. /**
  75677. * Creates an array containing three elements : the coordinates of the Vector3
  75678. * @returns a new array of numbers
  75679. */
  75680. asArray(): number[];
  75681. /**
  75682. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  75683. * @param array defines the destination array
  75684. * @param index defines the offset in the destination array
  75685. * @returns the current Vector3
  75686. */
  75687. toArray(array: FloatArray, index?: number): Vector3;
  75688. /**
  75689. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  75690. * @returns a new Quaternion object, computed from the Vector3 coordinates
  75691. */
  75692. toQuaternion(): Quaternion;
  75693. /**
  75694. * Adds the given vector to the current Vector3
  75695. * @param otherVector defines the second operand
  75696. * @returns the current updated Vector3
  75697. */
  75698. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75699. /**
  75700. * Adds the given coordinates to the current Vector3
  75701. * @param x defines the x coordinate of the operand
  75702. * @param y defines the y coordinate of the operand
  75703. * @param z defines the z coordinate of the operand
  75704. * @returns the current updated Vector3
  75705. */
  75706. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75707. /**
  75708. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  75709. * @param otherVector defines the second operand
  75710. * @returns the resulting Vector3
  75711. */
  75712. add(otherVector: DeepImmutable<Vector3>): Vector3;
  75713. /**
  75714. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  75715. * @param otherVector defines the second operand
  75716. * @param result defines the Vector3 object where to store the result
  75717. * @returns the current Vector3
  75718. */
  75719. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75720. /**
  75721. * Subtract the given vector from the current Vector3
  75722. * @param otherVector defines the second operand
  75723. * @returns the current updated Vector3
  75724. */
  75725. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75726. /**
  75727. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  75728. * @param otherVector defines the second operand
  75729. * @returns the resulting Vector3
  75730. */
  75731. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  75732. /**
  75733. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  75734. * @param otherVector defines the second operand
  75735. * @param result defines the Vector3 object where to store the result
  75736. * @returns the current Vector3
  75737. */
  75738. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75739. /**
  75740. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  75741. * @param x defines the x coordinate of the operand
  75742. * @param y defines the y coordinate of the operand
  75743. * @param z defines the z coordinate of the operand
  75744. * @returns the resulting Vector3
  75745. */
  75746. subtractFromFloats(x: number, y: number, z: number): Vector3;
  75747. /**
  75748. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  75749. * @param x defines the x coordinate of the operand
  75750. * @param y defines the y coordinate of the operand
  75751. * @param z defines the z coordinate of the operand
  75752. * @param result defines the Vector3 object where to store the result
  75753. * @returns the current Vector3
  75754. */
  75755. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  75756. /**
  75757. * Gets a new Vector3 set with the current Vector3 negated coordinates
  75758. * @returns a new Vector3
  75759. */
  75760. negate(): Vector3;
  75761. /**
  75762. * Negate this vector in place
  75763. * @returns this
  75764. */
  75765. negateInPlace(): Vector3;
  75766. /**
  75767. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  75768. * @param result defines the Vector3 object where to store the result
  75769. * @returns the current Vector3
  75770. */
  75771. negateToRef(result: Vector3): Vector3;
  75772. /**
  75773. * Multiplies the Vector3 coordinates by the float "scale"
  75774. * @param scale defines the multiplier factor
  75775. * @returns the current updated Vector3
  75776. */
  75777. scaleInPlace(scale: number): Vector3;
  75778. /**
  75779. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  75780. * @param scale defines the multiplier factor
  75781. * @returns a new Vector3
  75782. */
  75783. scale(scale: number): Vector3;
  75784. /**
  75785. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  75786. * @param scale defines the multiplier factor
  75787. * @param result defines the Vector3 object where to store the result
  75788. * @returns the current Vector3
  75789. */
  75790. scaleToRef(scale: number, result: Vector3): Vector3;
  75791. /**
  75792. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  75793. * @param scale defines the scale factor
  75794. * @param result defines the Vector3 object where to store the result
  75795. * @returns the unmodified current Vector3
  75796. */
  75797. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  75798. /**
  75799. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  75800. * @param otherVector defines the second operand
  75801. * @returns true if both vectors are equals
  75802. */
  75803. equals(otherVector: DeepImmutable<Vector3>): boolean;
  75804. /**
  75805. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  75806. * @param otherVector defines the second operand
  75807. * @param epsilon defines the minimal distance to define values as equals
  75808. * @returns true if both vectors are distant less than epsilon
  75809. */
  75810. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  75811. /**
  75812. * Returns true if the current Vector3 coordinates equals the given floats
  75813. * @param x defines the x coordinate of the operand
  75814. * @param y defines the y coordinate of the operand
  75815. * @param z defines the z coordinate of the operand
  75816. * @returns true if both vectors are equals
  75817. */
  75818. equalsToFloats(x: number, y: number, z: number): boolean;
  75819. /**
  75820. * Multiplies the current Vector3 coordinates by the given ones
  75821. * @param otherVector defines the second operand
  75822. * @returns the current updated Vector3
  75823. */
  75824. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75825. /**
  75826. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  75827. * @param otherVector defines the second operand
  75828. * @returns the new Vector3
  75829. */
  75830. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  75831. /**
  75832. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  75833. * @param otherVector defines the second operand
  75834. * @param result defines the Vector3 object where to store the result
  75835. * @returns the current Vector3
  75836. */
  75837. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75838. /**
  75839. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  75840. * @param x defines the x coordinate of the operand
  75841. * @param y defines the y coordinate of the operand
  75842. * @param z defines the z coordinate of the operand
  75843. * @returns the new Vector3
  75844. */
  75845. multiplyByFloats(x: number, y: number, z: number): Vector3;
  75846. /**
  75847. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  75848. * @param otherVector defines the second operand
  75849. * @returns the new Vector3
  75850. */
  75851. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  75852. /**
  75853. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  75854. * @param otherVector defines the second operand
  75855. * @param result defines the Vector3 object where to store the result
  75856. * @returns the current Vector3
  75857. */
  75858. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75859. /**
  75860. * Divides the current Vector3 coordinates by the given ones.
  75861. * @param otherVector defines the second operand
  75862. * @returns the current updated Vector3
  75863. */
  75864. divideInPlace(otherVector: Vector3): Vector3;
  75865. /**
  75866. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  75867. * @param other defines the second operand
  75868. * @returns the current updated Vector3
  75869. */
  75870. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  75871. /**
  75872. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  75873. * @param other defines the second operand
  75874. * @returns the current updated Vector3
  75875. */
  75876. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  75877. /**
  75878. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  75879. * @param x defines the x coordinate of the operand
  75880. * @param y defines the y coordinate of the operand
  75881. * @param z defines the z coordinate of the operand
  75882. * @returns the current updated Vector3
  75883. */
  75884. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75885. /**
  75886. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  75887. * @param x defines the x coordinate of the operand
  75888. * @param y defines the y coordinate of the operand
  75889. * @param z defines the z coordinate of the operand
  75890. * @returns the current updated Vector3
  75891. */
  75892. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75893. /**
  75894. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  75895. * Check if is non uniform within a certain amount of decimal places to account for this
  75896. * @param epsilon the amount the values can differ
  75897. * @returns if the the vector is non uniform to a certain number of decimal places
  75898. */
  75899. isNonUniformWithinEpsilon(epsilon: number): boolean;
  75900. /**
  75901. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  75902. */
  75903. get isNonUniform(): boolean;
  75904. /**
  75905. * Gets a new Vector3 from current Vector3 floored values
  75906. * @returns a new Vector3
  75907. */
  75908. floor(): Vector3;
  75909. /**
  75910. * Gets a new Vector3 from current Vector3 floored values
  75911. * @returns a new Vector3
  75912. */
  75913. fract(): Vector3;
  75914. /**
  75915. * Gets the length of the Vector3
  75916. * @returns the length of the Vector3
  75917. */
  75918. length(): number;
  75919. /**
  75920. * Gets the squared length of the Vector3
  75921. * @returns squared length of the Vector3
  75922. */
  75923. lengthSquared(): number;
  75924. /**
  75925. * Normalize the current Vector3.
  75926. * Please note that this is an in place operation.
  75927. * @returns the current updated Vector3
  75928. */
  75929. normalize(): Vector3;
  75930. /**
  75931. * Reorders the x y z properties of the vector in place
  75932. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  75933. * @returns the current updated vector
  75934. */
  75935. reorderInPlace(order: string): this;
  75936. /**
  75937. * Rotates the vector around 0,0,0 by a quaternion
  75938. * @param quaternion the rotation quaternion
  75939. * @param result vector to store the result
  75940. * @returns the resulting vector
  75941. */
  75942. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  75943. /**
  75944. * Rotates a vector around a given point
  75945. * @param quaternion the rotation quaternion
  75946. * @param point the point to rotate around
  75947. * @param result vector to store the result
  75948. * @returns the resulting vector
  75949. */
  75950. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  75951. /**
  75952. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  75953. * The cross product is then orthogonal to both current and "other"
  75954. * @param other defines the right operand
  75955. * @returns the cross product
  75956. */
  75957. cross(other: Vector3): Vector3;
  75958. /**
  75959. * Normalize the current Vector3 with the given input length.
  75960. * Please note that this is an in place operation.
  75961. * @param len the length of the vector
  75962. * @returns the current updated Vector3
  75963. */
  75964. normalizeFromLength(len: number): Vector3;
  75965. /**
  75966. * Normalize the current Vector3 to a new vector
  75967. * @returns the new Vector3
  75968. */
  75969. normalizeToNew(): Vector3;
  75970. /**
  75971. * Normalize the current Vector3 to the reference
  75972. * @param reference define the Vector3 to update
  75973. * @returns the updated Vector3
  75974. */
  75975. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  75976. /**
  75977. * Creates a new Vector3 copied from the current Vector3
  75978. * @returns the new Vector3
  75979. */
  75980. clone(): Vector3;
  75981. /**
  75982. * Copies the given vector coordinates to the current Vector3 ones
  75983. * @param source defines the source Vector3
  75984. * @returns the current updated Vector3
  75985. */
  75986. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  75987. /**
  75988. * Copies the given floats to the current Vector3 coordinates
  75989. * @param x defines the x coordinate of the operand
  75990. * @param y defines the y coordinate of the operand
  75991. * @param z defines the z coordinate of the operand
  75992. * @returns the current updated Vector3
  75993. */
  75994. copyFromFloats(x: number, y: number, z: number): Vector3;
  75995. /**
  75996. * Copies the given floats to the current Vector3 coordinates
  75997. * @param x defines the x coordinate of the operand
  75998. * @param y defines the y coordinate of the operand
  75999. * @param z defines the z coordinate of the operand
  76000. * @returns the current updated Vector3
  76001. */
  76002. set(x: number, y: number, z: number): Vector3;
  76003. /**
  76004. * Copies the given float to the current Vector3 coordinates
  76005. * @param v defines the x, y and z coordinates of the operand
  76006. * @returns the current updated Vector3
  76007. */
  76008. setAll(v: number): Vector3;
  76009. /**
  76010. * Get the clip factor between two vectors
  76011. * @param vector0 defines the first operand
  76012. * @param vector1 defines the second operand
  76013. * @param axis defines the axis to use
  76014. * @param size defines the size along the axis
  76015. * @returns the clip factor
  76016. */
  76017. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  76018. /**
  76019. * Get angle between two vectors
  76020. * @param vector0 angle between vector0 and vector1
  76021. * @param vector1 angle between vector0 and vector1
  76022. * @param normal direction of the normal
  76023. * @return the angle between vector0 and vector1
  76024. */
  76025. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  76026. /**
  76027. * Returns a new Vector3 set from the index "offset" of the given array
  76028. * @param array defines the source array
  76029. * @param offset defines the offset in the source array
  76030. * @returns the new Vector3
  76031. */
  76032. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  76033. /**
  76034. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  76035. * @param array defines the source array
  76036. * @param offset defines the offset in the source array
  76037. * @returns the new Vector3
  76038. * @deprecated Please use FromArray instead.
  76039. */
  76040. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  76041. /**
  76042. * Sets the given vector "result" with the element values from the index "offset" of the given array
  76043. * @param array defines the source array
  76044. * @param offset defines the offset in the source array
  76045. * @param result defines the Vector3 where to store the result
  76046. */
  76047. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  76048. /**
  76049. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  76050. * @param array defines the source array
  76051. * @param offset defines the offset in the source array
  76052. * @param result defines the Vector3 where to store the result
  76053. * @deprecated Please use FromArrayToRef instead.
  76054. */
  76055. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  76056. /**
  76057. * Sets the given vector "result" with the given floats.
  76058. * @param x defines the x coordinate of the source
  76059. * @param y defines the y coordinate of the source
  76060. * @param z defines the z coordinate of the source
  76061. * @param result defines the Vector3 where to store the result
  76062. */
  76063. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  76064. /**
  76065. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  76066. * @returns a new empty Vector3
  76067. */
  76068. static Zero(): Vector3;
  76069. /**
  76070. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  76071. * @returns a new unit Vector3
  76072. */
  76073. static One(): Vector3;
  76074. /**
  76075. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  76076. * @returns a new up Vector3
  76077. */
  76078. static Up(): Vector3;
  76079. /**
  76080. * Gets a up Vector3 that must not be updated
  76081. */
  76082. static get UpReadOnly(): DeepImmutable<Vector3>;
  76083. /**
  76084. * Gets a zero Vector3 that must not be updated
  76085. */
  76086. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  76087. /**
  76088. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  76089. * @returns a new down Vector3
  76090. */
  76091. static Down(): Vector3;
  76092. /**
  76093. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  76094. * @returns a new forward Vector3
  76095. */
  76096. static Forward(): Vector3;
  76097. /**
  76098. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  76099. * @returns a new forward Vector3
  76100. */
  76101. static Backward(): Vector3;
  76102. /**
  76103. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  76104. * @returns a new right Vector3
  76105. */
  76106. static Right(): Vector3;
  76107. /**
  76108. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  76109. * @returns a new left Vector3
  76110. */
  76111. static Left(): Vector3;
  76112. /**
  76113. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  76114. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  76115. * @param vector defines the Vector3 to transform
  76116. * @param transformation defines the transformation matrix
  76117. * @returns the transformed Vector3
  76118. */
  76119. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  76120. /**
  76121. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  76122. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  76123. * @param vector defines the Vector3 to transform
  76124. * @param transformation defines the transformation matrix
  76125. * @param result defines the Vector3 where to store the result
  76126. */
  76127. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76128. /**
  76129. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  76130. * This method computes tranformed coordinates only, not transformed direction vectors
  76131. * @param x define the x coordinate of the source vector
  76132. * @param y define the y coordinate of the source vector
  76133. * @param z define the z coordinate of the source vector
  76134. * @param transformation defines the transformation matrix
  76135. * @param result defines the Vector3 where to store the result
  76136. */
  76137. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76138. /**
  76139. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  76140. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76141. * @param vector defines the Vector3 to transform
  76142. * @param transformation defines the transformation matrix
  76143. * @returns the new Vector3
  76144. */
  76145. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  76146. /**
  76147. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  76148. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76149. * @param vector defines the Vector3 to transform
  76150. * @param transformation defines the transformation matrix
  76151. * @param result defines the Vector3 where to store the result
  76152. */
  76153. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76154. /**
  76155. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  76156. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76157. * @param x define the x coordinate of the source vector
  76158. * @param y define the y coordinate of the source vector
  76159. * @param z define the z coordinate of the source vector
  76160. * @param transformation defines the transformation matrix
  76161. * @param result defines the Vector3 where to store the result
  76162. */
  76163. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76164. /**
  76165. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  76166. * @param value1 defines the first control point
  76167. * @param value2 defines the second control point
  76168. * @param value3 defines the third control point
  76169. * @param value4 defines the fourth control point
  76170. * @param amount defines the amount on the spline to use
  76171. * @returns the new Vector3
  76172. */
  76173. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  76174. /**
  76175. * 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"
  76176. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  76177. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  76178. * @param value defines the current value
  76179. * @param min defines the lower range value
  76180. * @param max defines the upper range value
  76181. * @returns the new Vector3
  76182. */
  76183. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  76184. /**
  76185. * 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"
  76186. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  76187. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  76188. * @param value defines the current value
  76189. * @param min defines the lower range value
  76190. * @param max defines the upper range value
  76191. * @param result defines the Vector3 where to store the result
  76192. */
  76193. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  76194. /**
  76195. * Checks if a given vector is inside a specific range
  76196. * @param v defines the vector to test
  76197. * @param min defines the minimum range
  76198. * @param max defines the maximum range
  76199. */
  76200. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  76201. /**
  76202. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  76203. * @param value1 defines the first control point
  76204. * @param tangent1 defines the first tangent vector
  76205. * @param value2 defines the second control point
  76206. * @param tangent2 defines the second tangent vector
  76207. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  76208. * @returns the new Vector3
  76209. */
  76210. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  76211. /**
  76212. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  76213. * @param start defines the start value
  76214. * @param end defines the end value
  76215. * @param amount max defines amount between both (between 0 and 1)
  76216. * @returns the new Vector3
  76217. */
  76218. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  76219. /**
  76220. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  76221. * @param start defines the start value
  76222. * @param end defines the end value
  76223. * @param amount max defines amount between both (between 0 and 1)
  76224. * @param result defines the Vector3 where to store the result
  76225. */
  76226. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  76227. /**
  76228. * Returns the dot product (float) between the vectors "left" and "right"
  76229. * @param left defines the left operand
  76230. * @param right defines the right operand
  76231. * @returns the dot product
  76232. */
  76233. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  76234. /**
  76235. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  76236. * The cross product is then orthogonal to both "left" and "right"
  76237. * @param left defines the left operand
  76238. * @param right defines the right operand
  76239. * @returns the cross product
  76240. */
  76241. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76242. /**
  76243. * Sets the given vector "result" with the cross product of "left" and "right"
  76244. * The cross product is then orthogonal to both "left" and "right"
  76245. * @param left defines the left operand
  76246. * @param right defines the right operand
  76247. * @param result defines the Vector3 where to store the result
  76248. */
  76249. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  76250. /**
  76251. * Returns a new Vector3 as the normalization of the given vector
  76252. * @param vector defines the Vector3 to normalize
  76253. * @returns the new Vector3
  76254. */
  76255. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  76256. /**
  76257. * Sets the given vector "result" with the normalization of the given first vector
  76258. * @param vector defines the Vector3 to normalize
  76259. * @param result defines the Vector3 where to store the result
  76260. */
  76261. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  76262. /**
  76263. * Project a Vector3 onto screen space
  76264. * @param vector defines the Vector3 to project
  76265. * @param world defines the world matrix to use
  76266. * @param transform defines the transform (view x projection) matrix to use
  76267. * @param viewport defines the screen viewport to use
  76268. * @returns the new Vector3
  76269. */
  76270. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  76271. /** @hidden */
  76272. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  76273. /**
  76274. * Unproject from screen space to object space
  76275. * @param source defines the screen space Vector3 to use
  76276. * @param viewportWidth defines the current width of the viewport
  76277. * @param viewportHeight defines the current height of the viewport
  76278. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76279. * @param transform defines the transform (view x projection) matrix to use
  76280. * @returns the new Vector3
  76281. */
  76282. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: 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. * @returns the new Vector3
  76292. */
  76293. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  76294. /**
  76295. * Unproject from screen space to object space
  76296. * @param source defines the screen space Vector3 to use
  76297. * @param viewportWidth defines the current width of the viewport
  76298. * @param viewportHeight defines the current height of the viewport
  76299. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76300. * @param view defines the view matrix to use
  76301. * @param projection defines the projection matrix to use
  76302. * @param result defines the Vector3 where to store the result
  76303. */
  76304. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  76305. /**
  76306. * Unproject from screen space to object space
  76307. * @param sourceX defines the screen space x coordinate to use
  76308. * @param sourceY defines the screen space y coordinate to use
  76309. * @param sourceZ defines the screen space z coordinate to use
  76310. * @param viewportWidth defines the current width of the viewport
  76311. * @param viewportHeight defines the current height of the viewport
  76312. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76313. * @param view defines the view matrix to use
  76314. * @param projection defines the projection matrix to use
  76315. * @param result defines the Vector3 where to store the result
  76316. */
  76317. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  76318. /**
  76319. * Gets the minimal coordinate values between two Vector3
  76320. * @param left defines the first operand
  76321. * @param right defines the second operand
  76322. * @returns the new Vector3
  76323. */
  76324. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76325. /**
  76326. * Gets the maximal coordinate values between two Vector3
  76327. * @param left defines the first operand
  76328. * @param right defines the second operand
  76329. * @returns the new Vector3
  76330. */
  76331. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76332. /**
  76333. * Returns the distance between the vectors "value1" and "value2"
  76334. * @param value1 defines the first operand
  76335. * @param value2 defines the second operand
  76336. * @returns the distance
  76337. */
  76338. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  76339. /**
  76340. * Returns the squared distance between the vectors "value1" and "value2"
  76341. * @param value1 defines the first operand
  76342. * @param value2 defines the second operand
  76343. * @returns the squared distance
  76344. */
  76345. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  76346. /**
  76347. * Returns a new Vector3 located at the center between "value1" and "value2"
  76348. * @param value1 defines the first operand
  76349. * @param value2 defines the second operand
  76350. * @returns the new Vector3
  76351. */
  76352. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  76353. /**
  76354. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  76355. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  76356. * to something in order to rotate it from its local system to the given target system
  76357. * Note: axis1, axis2 and axis3 are normalized during this operation
  76358. * @param axis1 defines the first axis
  76359. * @param axis2 defines the second axis
  76360. * @param axis3 defines the third axis
  76361. * @returns a new Vector3
  76362. */
  76363. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  76364. /**
  76365. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  76366. * @param axis1 defines the first axis
  76367. * @param axis2 defines the second axis
  76368. * @param axis3 defines the third axis
  76369. * @param ref defines the Vector3 where to store the result
  76370. */
  76371. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  76372. }
  76373. /**
  76374. * Vector4 class created for EulerAngle class conversion to Quaternion
  76375. */
  76376. export class Vector4 {
  76377. /** x value of the vector */
  76378. x: number;
  76379. /** y value of the vector */
  76380. y: number;
  76381. /** z value of the vector */
  76382. z: number;
  76383. /** w value of the vector */
  76384. w: number;
  76385. /**
  76386. * Creates a Vector4 object from the given floats.
  76387. * @param x x value of the vector
  76388. * @param y y value of the vector
  76389. * @param z z value of the vector
  76390. * @param w w value of the vector
  76391. */
  76392. constructor(
  76393. /** x value of the vector */
  76394. x: number,
  76395. /** y value of the vector */
  76396. y: number,
  76397. /** z value of the vector */
  76398. z: number,
  76399. /** w value of the vector */
  76400. w: number);
  76401. /**
  76402. * Returns the string with the Vector4 coordinates.
  76403. * @returns a string containing all the vector values
  76404. */
  76405. toString(): string;
  76406. /**
  76407. * Returns the string "Vector4".
  76408. * @returns "Vector4"
  76409. */
  76410. getClassName(): string;
  76411. /**
  76412. * Returns the Vector4 hash code.
  76413. * @returns a unique hash code
  76414. */
  76415. getHashCode(): number;
  76416. /**
  76417. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  76418. * @returns the resulting array
  76419. */
  76420. asArray(): number[];
  76421. /**
  76422. * Populates the given array from the given index with the Vector4 coordinates.
  76423. * @param array array to populate
  76424. * @param index index of the array to start at (default: 0)
  76425. * @returns the Vector4.
  76426. */
  76427. toArray(array: FloatArray, index?: number): Vector4;
  76428. /**
  76429. * Adds the given vector to the current Vector4.
  76430. * @param otherVector the vector to add
  76431. * @returns the updated Vector4.
  76432. */
  76433. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76434. /**
  76435. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  76436. * @param otherVector the vector to add
  76437. * @returns the resulting vector
  76438. */
  76439. add(otherVector: DeepImmutable<Vector4>): Vector4;
  76440. /**
  76441. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  76442. * @param otherVector the vector to add
  76443. * @param result the vector to store the result
  76444. * @returns the current Vector4.
  76445. */
  76446. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76447. /**
  76448. * Subtract in place the given vector from the current Vector4.
  76449. * @param otherVector the vector to subtract
  76450. * @returns the updated Vector4.
  76451. */
  76452. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76453. /**
  76454. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  76455. * @param otherVector the vector to add
  76456. * @returns the new vector with the result
  76457. */
  76458. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  76459. /**
  76460. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  76461. * @param otherVector the vector to subtract
  76462. * @param result the vector to store the result
  76463. * @returns the current Vector4.
  76464. */
  76465. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76466. /**
  76467. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76468. */
  76469. /**
  76470. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76471. * @param x value to subtract
  76472. * @param y value to subtract
  76473. * @param z value to subtract
  76474. * @param w value to subtract
  76475. * @returns new vector containing the result
  76476. */
  76477. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  76478. /**
  76479. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76480. * @param x value to subtract
  76481. * @param y value to subtract
  76482. * @param z value to subtract
  76483. * @param w value to subtract
  76484. * @param result the vector to store the result in
  76485. * @returns the current Vector4.
  76486. */
  76487. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  76488. /**
  76489. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  76490. * @returns a new vector with the negated values
  76491. */
  76492. negate(): Vector4;
  76493. /**
  76494. * Negate this vector in place
  76495. * @returns this
  76496. */
  76497. negateInPlace(): Vector4;
  76498. /**
  76499. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  76500. * @param result defines the Vector3 object where to store the result
  76501. * @returns the current Vector4
  76502. */
  76503. negateToRef(result: Vector4): Vector4;
  76504. /**
  76505. * Multiplies the current Vector4 coordinates by scale (float).
  76506. * @param scale the number to scale with
  76507. * @returns the updated Vector4.
  76508. */
  76509. scaleInPlace(scale: number): Vector4;
  76510. /**
  76511. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  76512. * @param scale the number to scale with
  76513. * @returns a new vector with the result
  76514. */
  76515. scale(scale: number): Vector4;
  76516. /**
  76517. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  76518. * @param scale the number to scale with
  76519. * @param result a vector to store the result in
  76520. * @returns the current Vector4.
  76521. */
  76522. scaleToRef(scale: number, result: Vector4): Vector4;
  76523. /**
  76524. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  76525. * @param scale defines the scale factor
  76526. * @param result defines the Vector4 object where to store the result
  76527. * @returns the unmodified current Vector4
  76528. */
  76529. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  76530. /**
  76531. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  76532. * @param otherVector the vector to compare against
  76533. * @returns true if they are equal
  76534. */
  76535. equals(otherVector: DeepImmutable<Vector4>): boolean;
  76536. /**
  76537. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  76538. * @param otherVector vector to compare against
  76539. * @param epsilon (Default: very small number)
  76540. * @returns true if they are equal
  76541. */
  76542. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  76543. /**
  76544. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  76545. * @param x x value to compare against
  76546. * @param y y value to compare against
  76547. * @param z z value to compare against
  76548. * @param w w value to compare against
  76549. * @returns true if equal
  76550. */
  76551. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  76552. /**
  76553. * Multiplies in place the current Vector4 by the given one.
  76554. * @param otherVector vector to multiple with
  76555. * @returns the updated Vector4.
  76556. */
  76557. multiplyInPlace(otherVector: Vector4): Vector4;
  76558. /**
  76559. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  76560. * @param otherVector vector to multiple with
  76561. * @returns resulting new vector
  76562. */
  76563. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  76564. /**
  76565. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  76566. * @param otherVector vector to multiple with
  76567. * @param result vector to store the result
  76568. * @returns the current Vector4.
  76569. */
  76570. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76571. /**
  76572. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  76573. * @param x x value multiply with
  76574. * @param y y value multiply with
  76575. * @param z z value multiply with
  76576. * @param w w value multiply with
  76577. * @returns resulting new vector
  76578. */
  76579. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  76580. /**
  76581. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  76582. * @param otherVector vector to devide with
  76583. * @returns resulting new vector
  76584. */
  76585. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  76586. /**
  76587. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  76588. * @param otherVector vector to devide with
  76589. * @param result vector to store the result
  76590. * @returns the current Vector4.
  76591. */
  76592. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76593. /**
  76594. * Divides the current Vector3 coordinates by the given ones.
  76595. * @param otherVector vector to devide with
  76596. * @returns the updated Vector3.
  76597. */
  76598. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76599. /**
  76600. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  76601. * @param other defines the second operand
  76602. * @returns the current updated Vector4
  76603. */
  76604. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  76605. /**
  76606. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  76607. * @param other defines the second operand
  76608. * @returns the current updated Vector4
  76609. */
  76610. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  76611. /**
  76612. * Gets a new Vector4 from current Vector4 floored values
  76613. * @returns a new Vector4
  76614. */
  76615. floor(): Vector4;
  76616. /**
  76617. * Gets a new Vector4 from current Vector3 floored values
  76618. * @returns a new Vector4
  76619. */
  76620. fract(): Vector4;
  76621. /**
  76622. * Returns the Vector4 length (float).
  76623. * @returns the length
  76624. */
  76625. length(): number;
  76626. /**
  76627. * Returns the Vector4 squared length (float).
  76628. * @returns the length squared
  76629. */
  76630. lengthSquared(): number;
  76631. /**
  76632. * Normalizes in place the Vector4.
  76633. * @returns the updated Vector4.
  76634. */
  76635. normalize(): Vector4;
  76636. /**
  76637. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  76638. * @returns this converted to a new vector3
  76639. */
  76640. toVector3(): Vector3;
  76641. /**
  76642. * Returns a new Vector4 copied from the current one.
  76643. * @returns the new cloned vector
  76644. */
  76645. clone(): Vector4;
  76646. /**
  76647. * Updates the current Vector4 with the given one coordinates.
  76648. * @param source the source vector to copy from
  76649. * @returns the updated Vector4.
  76650. */
  76651. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  76652. /**
  76653. * Updates the current Vector4 coordinates with the given floats.
  76654. * @param x float to copy from
  76655. * @param y float to copy from
  76656. * @param z float to copy from
  76657. * @param w float to copy from
  76658. * @returns the updated Vector4.
  76659. */
  76660. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  76661. /**
  76662. * Updates the current Vector4 coordinates with the given floats.
  76663. * @param x float to set from
  76664. * @param y float to set from
  76665. * @param z float to set from
  76666. * @param w float to set from
  76667. * @returns the updated Vector4.
  76668. */
  76669. set(x: number, y: number, z: number, w: number): Vector4;
  76670. /**
  76671. * Copies the given float to the current Vector3 coordinates
  76672. * @param v defines the x, y, z and w coordinates of the operand
  76673. * @returns the current updated Vector3
  76674. */
  76675. setAll(v: number): Vector4;
  76676. /**
  76677. * Returns a new Vector4 set from the starting index of the given array.
  76678. * @param array the array to pull values from
  76679. * @param offset the offset into the array to start at
  76680. * @returns the new vector
  76681. */
  76682. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  76683. /**
  76684. * Updates the given vector "result" from the starting index of the given array.
  76685. * @param array the array to pull values from
  76686. * @param offset the offset into the array to start at
  76687. * @param result the vector to store the result in
  76688. */
  76689. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  76690. /**
  76691. * Updates the given vector "result" from the starting index of the given Float32Array.
  76692. * @param array the array to pull values from
  76693. * @param offset the offset into the array to start at
  76694. * @param result the vector to store the result in
  76695. */
  76696. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  76697. /**
  76698. * Updates the given vector "result" coordinates from the given floats.
  76699. * @param x float to set from
  76700. * @param y float to set from
  76701. * @param z float to set from
  76702. * @param w float to set from
  76703. * @param result the vector to the floats in
  76704. */
  76705. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  76706. /**
  76707. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  76708. * @returns the new vector
  76709. */
  76710. static Zero(): Vector4;
  76711. /**
  76712. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  76713. * @returns the new vector
  76714. */
  76715. static One(): Vector4;
  76716. /**
  76717. * Returns a new normalized Vector4 from the given one.
  76718. * @param vector the vector to normalize
  76719. * @returns the vector
  76720. */
  76721. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  76722. /**
  76723. * Updates the given vector "result" from the normalization of the given one.
  76724. * @param vector the vector to normalize
  76725. * @param result the vector to store the result in
  76726. */
  76727. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  76728. /**
  76729. * Returns a vector with the minimum values from the left and right vectors
  76730. * @param left left vector to minimize
  76731. * @param right right vector to minimize
  76732. * @returns a new vector with the minimum of the left and right vector values
  76733. */
  76734. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  76735. /**
  76736. * Returns a vector with the maximum values from the left and right vectors
  76737. * @param left left vector to maximize
  76738. * @param right right vector to maximize
  76739. * @returns a new vector with the maximum of the left and right vector values
  76740. */
  76741. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  76742. /**
  76743. * Returns the distance (float) between the vectors "value1" and "value2".
  76744. * @param value1 value to calulate the distance between
  76745. * @param value2 value to calulate the distance between
  76746. * @return the distance between the two vectors
  76747. */
  76748. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  76749. /**
  76750. * Returns the squared distance (float) between the vectors "value1" and "value2".
  76751. * @param value1 value to calulate the distance between
  76752. * @param value2 value to calulate the distance between
  76753. * @return the distance between the two vectors squared
  76754. */
  76755. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  76756. /**
  76757. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  76758. * @param value1 value to calulate the center between
  76759. * @param value2 value to calulate the center between
  76760. * @return the center between the two vectors
  76761. */
  76762. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  76763. /**
  76764. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  76765. * This methods computes transformed normalized direction vectors only.
  76766. * @param vector the vector to transform
  76767. * @param transformation the transformation matrix to apply
  76768. * @returns the new vector
  76769. */
  76770. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  76771. /**
  76772. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  76773. * This methods computes transformed normalized direction vectors only.
  76774. * @param vector the vector to transform
  76775. * @param transformation the transformation matrix to apply
  76776. * @param result the vector to store the result in
  76777. */
  76778. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  76779. /**
  76780. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  76781. * This methods computes transformed normalized direction vectors only.
  76782. * @param x value to transform
  76783. * @param y value to transform
  76784. * @param z value to transform
  76785. * @param w value to transform
  76786. * @param transformation the transformation matrix to apply
  76787. * @param result the vector to store the results in
  76788. */
  76789. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  76790. /**
  76791. * Creates a new Vector4 from a Vector3
  76792. * @param source defines the source data
  76793. * @param w defines the 4th component (default is 0)
  76794. * @returns a new Vector4
  76795. */
  76796. static FromVector3(source: Vector3, w?: number): Vector4;
  76797. }
  76798. /**
  76799. * Class used to store quaternion data
  76800. * @see https://en.wikipedia.org/wiki/Quaternion
  76801. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  76802. */
  76803. export class Quaternion {
  76804. /** defines the first component (0 by default) */
  76805. x: number;
  76806. /** defines the second component (0 by default) */
  76807. y: number;
  76808. /** defines the third component (0 by default) */
  76809. z: number;
  76810. /** defines the fourth component (1.0 by default) */
  76811. w: number;
  76812. /**
  76813. * Creates a new Quaternion from the given floats
  76814. * @param x defines the first component (0 by default)
  76815. * @param y defines the second component (0 by default)
  76816. * @param z defines the third component (0 by default)
  76817. * @param w defines the fourth component (1.0 by default)
  76818. */
  76819. constructor(
  76820. /** defines the first component (0 by default) */
  76821. x?: number,
  76822. /** defines the second component (0 by default) */
  76823. y?: number,
  76824. /** defines the third component (0 by default) */
  76825. z?: number,
  76826. /** defines the fourth component (1.0 by default) */
  76827. w?: number);
  76828. /**
  76829. * Gets a string representation for the current quaternion
  76830. * @returns a string with the Quaternion coordinates
  76831. */
  76832. toString(): string;
  76833. /**
  76834. * Gets the class name of the quaternion
  76835. * @returns the string "Quaternion"
  76836. */
  76837. getClassName(): string;
  76838. /**
  76839. * Gets a hash code for this quaternion
  76840. * @returns the quaternion hash code
  76841. */
  76842. getHashCode(): number;
  76843. /**
  76844. * Copy the quaternion to an array
  76845. * @returns a new array populated with 4 elements from the quaternion coordinates
  76846. */
  76847. asArray(): number[];
  76848. /**
  76849. * Check if two quaternions are equals
  76850. * @param otherQuaternion defines the second operand
  76851. * @return true if the current quaternion and the given one coordinates are strictly equals
  76852. */
  76853. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  76854. /**
  76855. * Gets a boolean if two quaternions are equals (using an epsilon value)
  76856. * @param otherQuaternion defines the other quaternion
  76857. * @param epsilon defines the minimal distance to consider equality
  76858. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  76859. */
  76860. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  76861. /**
  76862. * Clone the current quaternion
  76863. * @returns a new quaternion copied from the current one
  76864. */
  76865. clone(): Quaternion;
  76866. /**
  76867. * Copy a quaternion to the current one
  76868. * @param other defines the other quaternion
  76869. * @returns the updated current quaternion
  76870. */
  76871. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  76872. /**
  76873. * Updates the current quaternion with the given float coordinates
  76874. * @param x defines the x coordinate
  76875. * @param y defines the y coordinate
  76876. * @param z defines the z coordinate
  76877. * @param w defines the w coordinate
  76878. * @returns the updated current quaternion
  76879. */
  76880. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  76881. /**
  76882. * Updates the current quaternion from the given float coordinates
  76883. * @param x defines the x coordinate
  76884. * @param y defines the y coordinate
  76885. * @param z defines the z coordinate
  76886. * @param w defines the w coordinate
  76887. * @returns the updated current quaternion
  76888. */
  76889. set(x: number, y: number, z: number, w: number): Quaternion;
  76890. /**
  76891. * Adds two quaternions
  76892. * @param other defines the second operand
  76893. * @returns a new quaternion as the addition result of the given one and the current quaternion
  76894. */
  76895. add(other: DeepImmutable<Quaternion>): Quaternion;
  76896. /**
  76897. * Add a quaternion to the current one
  76898. * @param other defines the quaternion to add
  76899. * @returns the current quaternion
  76900. */
  76901. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  76902. /**
  76903. * Subtract two quaternions
  76904. * @param other defines the second operand
  76905. * @returns a new quaternion as the subtraction result of the given one from the current one
  76906. */
  76907. subtract(other: Quaternion): Quaternion;
  76908. /**
  76909. * Multiplies the current quaternion by a scale factor
  76910. * @param value defines the scale factor
  76911. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  76912. */
  76913. scale(value: number): Quaternion;
  76914. /**
  76915. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  76916. * @param scale defines the scale factor
  76917. * @param result defines the Quaternion object where to store the result
  76918. * @returns the unmodified current quaternion
  76919. */
  76920. scaleToRef(scale: number, result: Quaternion): Quaternion;
  76921. /**
  76922. * Multiplies in place the current quaternion by a scale factor
  76923. * @param value defines the scale factor
  76924. * @returns the current modified quaternion
  76925. */
  76926. scaleInPlace(value: number): Quaternion;
  76927. /**
  76928. * Scale the current quaternion values by a factor and add the result to a given quaternion
  76929. * @param scale defines the scale factor
  76930. * @param result defines the Quaternion object where to store the result
  76931. * @returns the unmodified current quaternion
  76932. */
  76933. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  76934. /**
  76935. * Multiplies two quaternions
  76936. * @param q1 defines the second operand
  76937. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  76938. */
  76939. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  76940. /**
  76941. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  76942. * @param q1 defines the second operand
  76943. * @param result defines the target quaternion
  76944. * @returns the current quaternion
  76945. */
  76946. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  76947. /**
  76948. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  76949. * @param q1 defines the second operand
  76950. * @returns the currentupdated quaternion
  76951. */
  76952. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  76953. /**
  76954. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  76955. * @param ref defines the target quaternion
  76956. * @returns the current quaternion
  76957. */
  76958. conjugateToRef(ref: Quaternion): Quaternion;
  76959. /**
  76960. * Conjugates in place (1-q) the current quaternion
  76961. * @returns the current updated quaternion
  76962. */
  76963. conjugateInPlace(): Quaternion;
  76964. /**
  76965. * Conjugates in place (1-q) the current quaternion
  76966. * @returns a new quaternion
  76967. */
  76968. conjugate(): Quaternion;
  76969. /**
  76970. * Gets length of current quaternion
  76971. * @returns the quaternion length (float)
  76972. */
  76973. length(): number;
  76974. /**
  76975. * Normalize in place the current quaternion
  76976. * @returns the current updated quaternion
  76977. */
  76978. normalize(): Quaternion;
  76979. /**
  76980. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  76981. * @param order is a reserved parameter and is ignore for now
  76982. * @returns a new Vector3 containing the Euler angles
  76983. */
  76984. toEulerAngles(order?: string): Vector3;
  76985. /**
  76986. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  76987. * @param result defines the vector which will be filled with the Euler angles
  76988. * @param order is a reserved parameter and is ignore for now
  76989. * @returns the current unchanged quaternion
  76990. */
  76991. toEulerAnglesToRef(result: Vector3): Quaternion;
  76992. /**
  76993. * Updates the given rotation matrix with the current quaternion values
  76994. * @param result defines the target matrix
  76995. * @returns the current unchanged quaternion
  76996. */
  76997. toRotationMatrix(result: Matrix): Quaternion;
  76998. /**
  76999. * Updates the current quaternion from the given rotation matrix values
  77000. * @param matrix defines the source matrix
  77001. * @returns the current updated quaternion
  77002. */
  77003. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  77004. /**
  77005. * Creates a new quaternion from a rotation matrix
  77006. * @param matrix defines the source matrix
  77007. * @returns a new quaternion created from the given rotation matrix values
  77008. */
  77009. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  77010. /**
  77011. * Updates the given quaternion with the given rotation matrix values
  77012. * @param matrix defines the source matrix
  77013. * @param result defines the target quaternion
  77014. */
  77015. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  77016. /**
  77017. * Returns the dot product (float) between the quaternions "left" and "right"
  77018. * @param left defines the left operand
  77019. * @param right defines the right operand
  77020. * @returns the dot product
  77021. */
  77022. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  77023. /**
  77024. * Checks if the two quaternions are close to each other
  77025. * @param quat0 defines the first quaternion to check
  77026. * @param quat1 defines the second quaternion to check
  77027. * @returns true if the two quaternions are close to each other
  77028. */
  77029. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  77030. /**
  77031. * Creates an empty quaternion
  77032. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  77033. */
  77034. static Zero(): Quaternion;
  77035. /**
  77036. * Inverse a given quaternion
  77037. * @param q defines the source quaternion
  77038. * @returns a new quaternion as the inverted current quaternion
  77039. */
  77040. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  77041. /**
  77042. * Inverse a given quaternion
  77043. * @param q defines the source quaternion
  77044. * @param result the quaternion the result will be stored in
  77045. * @returns the result quaternion
  77046. */
  77047. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  77048. /**
  77049. * Creates an identity quaternion
  77050. * @returns the identity quaternion
  77051. */
  77052. static Identity(): Quaternion;
  77053. /**
  77054. * Gets a boolean indicating if the given quaternion is identity
  77055. * @param quaternion defines the quaternion to check
  77056. * @returns true if the quaternion is identity
  77057. */
  77058. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  77059. /**
  77060. * Creates a quaternion from a rotation around an axis
  77061. * @param axis defines the axis to use
  77062. * @param angle defines the angle to use
  77063. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  77064. */
  77065. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  77066. /**
  77067. * Creates a rotation around an axis and stores it into the given quaternion
  77068. * @param axis defines the axis to use
  77069. * @param angle defines the angle to use
  77070. * @param result defines the target quaternion
  77071. * @returns the target quaternion
  77072. */
  77073. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  77074. /**
  77075. * Creates a new quaternion from data stored into an array
  77076. * @param array defines the data source
  77077. * @param offset defines the offset in the source array where the data starts
  77078. * @returns a new quaternion
  77079. */
  77080. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  77081. /**
  77082. * Create a quaternion from Euler rotation angles
  77083. * @param x Pitch
  77084. * @param y Yaw
  77085. * @param z Roll
  77086. * @returns the new Quaternion
  77087. */
  77088. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  77089. /**
  77090. * Updates a quaternion from Euler rotation angles
  77091. * @param x Pitch
  77092. * @param y Yaw
  77093. * @param z Roll
  77094. * @param result the quaternion to store the result
  77095. * @returns the updated quaternion
  77096. */
  77097. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  77098. /**
  77099. * Create a quaternion from Euler rotation vector
  77100. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  77101. * @returns the new Quaternion
  77102. */
  77103. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  77104. /**
  77105. * Updates a quaternion from Euler rotation vector
  77106. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  77107. * @param result the quaternion to store the result
  77108. * @returns the updated quaternion
  77109. */
  77110. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  77111. /**
  77112. * Creates a new quaternion from the given Euler float angles (y, x, z)
  77113. * @param yaw defines the rotation around Y axis
  77114. * @param pitch defines the rotation around X axis
  77115. * @param roll defines the rotation around Z axis
  77116. * @returns the new quaternion
  77117. */
  77118. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  77119. /**
  77120. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  77121. * @param yaw defines the rotation around Y axis
  77122. * @param pitch defines the rotation around X axis
  77123. * @param roll defines the rotation around Z axis
  77124. * @param result defines the target quaternion
  77125. */
  77126. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  77127. /**
  77128. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  77129. * @param alpha defines the rotation around first axis
  77130. * @param beta defines the rotation around second axis
  77131. * @param gamma defines the rotation around third axis
  77132. * @returns the new quaternion
  77133. */
  77134. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  77135. /**
  77136. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  77137. * @param alpha defines the rotation around first axis
  77138. * @param beta defines the rotation around second axis
  77139. * @param gamma defines the rotation around third axis
  77140. * @param result defines the target quaternion
  77141. */
  77142. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  77143. /**
  77144. * 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)
  77145. * @param axis1 defines the first axis
  77146. * @param axis2 defines the second axis
  77147. * @param axis3 defines the third axis
  77148. * @returns the new quaternion
  77149. */
  77150. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  77151. /**
  77152. * 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
  77153. * @param axis1 defines the first axis
  77154. * @param axis2 defines the second axis
  77155. * @param axis3 defines the third axis
  77156. * @param ref defines the target quaternion
  77157. */
  77158. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  77159. /**
  77160. * Interpolates between two quaternions
  77161. * @param left defines first quaternion
  77162. * @param right defines second quaternion
  77163. * @param amount defines the gradient to use
  77164. * @returns the new interpolated quaternion
  77165. */
  77166. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  77167. /**
  77168. * Interpolates between two quaternions and stores it into a target quaternion
  77169. * @param left defines first quaternion
  77170. * @param right defines second quaternion
  77171. * @param amount defines the gradient to use
  77172. * @param result defines the target quaternion
  77173. */
  77174. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  77175. /**
  77176. * Interpolate between two quaternions using Hermite interpolation
  77177. * @param value1 defines first quaternion
  77178. * @param tangent1 defines the incoming tangent
  77179. * @param value2 defines second quaternion
  77180. * @param tangent2 defines the outgoing tangent
  77181. * @param amount defines the target quaternion
  77182. * @returns the new interpolated quaternion
  77183. */
  77184. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  77185. }
  77186. /**
  77187. * Class used to store matrix data (4x4)
  77188. */
  77189. export class Matrix {
  77190. private static _updateFlagSeed;
  77191. private static _identityReadOnly;
  77192. private _isIdentity;
  77193. private _isIdentityDirty;
  77194. private _isIdentity3x2;
  77195. private _isIdentity3x2Dirty;
  77196. /**
  77197. * Gets the update flag of the matrix which is an unique number for the matrix.
  77198. * It will be incremented every time the matrix data change.
  77199. * You can use it to speed the comparison between two versions of the same matrix.
  77200. */
  77201. updateFlag: number;
  77202. private readonly _m;
  77203. /**
  77204. * Gets the internal data of the matrix
  77205. */
  77206. get m(): DeepImmutable<Float32Array>;
  77207. /** @hidden */
  77208. _markAsUpdated(): void;
  77209. /** @hidden */
  77210. private _updateIdentityStatus;
  77211. /**
  77212. * Creates an empty matrix (filled with zeros)
  77213. */
  77214. constructor();
  77215. /**
  77216. * Check if the current matrix is identity
  77217. * @returns true is the matrix is the identity matrix
  77218. */
  77219. isIdentity(): boolean;
  77220. /**
  77221. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  77222. * @returns true is the matrix is the identity matrix
  77223. */
  77224. isIdentityAs3x2(): boolean;
  77225. /**
  77226. * Gets the determinant of the matrix
  77227. * @returns the matrix determinant
  77228. */
  77229. determinant(): number;
  77230. /**
  77231. * Returns the matrix as a Float32Array
  77232. * @returns the matrix underlying array
  77233. */
  77234. toArray(): DeepImmutable<Float32Array>;
  77235. /**
  77236. * Returns the matrix as a Float32Array
  77237. * @returns the matrix underlying array.
  77238. */
  77239. asArray(): DeepImmutable<Float32Array>;
  77240. /**
  77241. * Inverts the current matrix in place
  77242. * @returns the current inverted matrix
  77243. */
  77244. invert(): Matrix;
  77245. /**
  77246. * Sets all the matrix elements to zero
  77247. * @returns the current matrix
  77248. */
  77249. reset(): Matrix;
  77250. /**
  77251. * Adds the current matrix with a second one
  77252. * @param other defines the matrix to add
  77253. * @returns a new matrix as the addition of the current matrix and the given one
  77254. */
  77255. add(other: DeepImmutable<Matrix>): Matrix;
  77256. /**
  77257. * Sets the given matrix "result" to the addition of the current matrix and the given one
  77258. * @param other defines the matrix to add
  77259. * @param result defines the target matrix
  77260. * @returns the current matrix
  77261. */
  77262. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  77263. /**
  77264. * Adds in place the given matrix to the current matrix
  77265. * @param other defines the second operand
  77266. * @returns the current updated matrix
  77267. */
  77268. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  77269. /**
  77270. * Sets the given matrix to the current inverted Matrix
  77271. * @param other defines the target matrix
  77272. * @returns the unmodified current matrix
  77273. */
  77274. invertToRef(other: Matrix): Matrix;
  77275. /**
  77276. * add a value at the specified position in the current Matrix
  77277. * @param index the index of the value within the matrix. between 0 and 15.
  77278. * @param value the value to be added
  77279. * @returns the current updated matrix
  77280. */
  77281. addAtIndex(index: number, value: number): Matrix;
  77282. /**
  77283. * mutiply the specified position in the current Matrix by a value
  77284. * @param index the index of the value within the matrix. between 0 and 15.
  77285. * @param value the value to be added
  77286. * @returns the current updated matrix
  77287. */
  77288. multiplyAtIndex(index: number, value: number): Matrix;
  77289. /**
  77290. * Inserts the translation vector (using 3 floats) in the current matrix
  77291. * @param x defines the 1st component of the translation
  77292. * @param y defines the 2nd component of the translation
  77293. * @param z defines the 3rd component of the translation
  77294. * @returns the current updated matrix
  77295. */
  77296. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  77297. /**
  77298. * Adds the translation vector (using 3 floats) in the current matrix
  77299. * @param x defines the 1st component of the translation
  77300. * @param y defines the 2nd component of the translation
  77301. * @param z defines the 3rd component of the translation
  77302. * @returns the current updated matrix
  77303. */
  77304. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  77305. /**
  77306. * Inserts the translation vector in the current matrix
  77307. * @param vector3 defines the translation to insert
  77308. * @returns the current updated matrix
  77309. */
  77310. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  77311. /**
  77312. * Gets the translation value of the current matrix
  77313. * @returns a new Vector3 as the extracted translation from the matrix
  77314. */
  77315. getTranslation(): Vector3;
  77316. /**
  77317. * Fill a Vector3 with the extracted translation from the matrix
  77318. * @param result defines the Vector3 where to store the translation
  77319. * @returns the current matrix
  77320. */
  77321. getTranslationToRef(result: Vector3): Matrix;
  77322. /**
  77323. * Remove rotation and scaling part from the matrix
  77324. * @returns the updated matrix
  77325. */
  77326. removeRotationAndScaling(): Matrix;
  77327. /**
  77328. * Multiply two matrices
  77329. * @param other defines the second operand
  77330. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  77331. */
  77332. multiply(other: DeepImmutable<Matrix>): Matrix;
  77333. /**
  77334. * Copy the current matrix from the given one
  77335. * @param other defines the source matrix
  77336. * @returns the current updated matrix
  77337. */
  77338. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  77339. /**
  77340. * Populates the given array from the starting index with the current matrix values
  77341. * @param array defines the target array
  77342. * @param offset defines the offset in the target array where to start storing values
  77343. * @returns the current matrix
  77344. */
  77345. copyToArray(array: Float32Array, offset?: number): Matrix;
  77346. /**
  77347. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  77348. * @param other defines the second operand
  77349. * @param result defines the matrix where to store the multiplication
  77350. * @returns the current matrix
  77351. */
  77352. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  77353. /**
  77354. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  77355. * @param other defines the second operand
  77356. * @param result defines the array where to store the multiplication
  77357. * @param offset defines the offset in the target array where to start storing values
  77358. * @returns the current matrix
  77359. */
  77360. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  77361. /**
  77362. * Check equality between this matrix and a second one
  77363. * @param value defines the second matrix to compare
  77364. * @returns true is the current matrix and the given one values are strictly equal
  77365. */
  77366. equals(value: DeepImmutable<Matrix>): boolean;
  77367. /**
  77368. * Clone the current matrix
  77369. * @returns a new matrix from the current matrix
  77370. */
  77371. clone(): Matrix;
  77372. /**
  77373. * Returns the name of the current matrix class
  77374. * @returns the string "Matrix"
  77375. */
  77376. getClassName(): string;
  77377. /**
  77378. * Gets the hash code of the current matrix
  77379. * @returns the hash code
  77380. */
  77381. getHashCode(): number;
  77382. /**
  77383. * Decomposes the current Matrix into a translation, rotation and scaling components
  77384. * @param scale defines the scale vector3 given as a reference to update
  77385. * @param rotation defines the rotation quaternion given as a reference to update
  77386. * @param translation defines the translation vector3 given as a reference to update
  77387. * @returns true if operation was successful
  77388. */
  77389. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  77390. /**
  77391. * Gets specific row of the matrix
  77392. * @param index defines the number of the row to get
  77393. * @returns the index-th row of the current matrix as a new Vector4
  77394. */
  77395. getRow(index: number): Nullable<Vector4>;
  77396. /**
  77397. * Sets the index-th row of the current matrix to the vector4 values
  77398. * @param index defines the number of the row to set
  77399. * @param row defines the target vector4
  77400. * @returns the updated current matrix
  77401. */
  77402. setRow(index: number, row: Vector4): Matrix;
  77403. /**
  77404. * Compute the transpose of the matrix
  77405. * @returns the new transposed matrix
  77406. */
  77407. transpose(): Matrix;
  77408. /**
  77409. * Compute the transpose of the matrix and store it in a given matrix
  77410. * @param result defines the target matrix
  77411. * @returns the current matrix
  77412. */
  77413. transposeToRef(result: Matrix): Matrix;
  77414. /**
  77415. * Sets the index-th row of the current matrix with the given 4 x float values
  77416. * @param index defines the row index
  77417. * @param x defines the x component to set
  77418. * @param y defines the y component to set
  77419. * @param z defines the z component to set
  77420. * @param w defines the w component to set
  77421. * @returns the updated current matrix
  77422. */
  77423. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  77424. /**
  77425. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  77426. * @param scale defines the scale factor
  77427. * @returns a new matrix
  77428. */
  77429. scale(scale: number): Matrix;
  77430. /**
  77431. * Scale the current matrix values by a factor to a given result matrix
  77432. * @param scale defines the scale factor
  77433. * @param result defines the matrix to store the result
  77434. * @returns the current matrix
  77435. */
  77436. scaleToRef(scale: number, result: Matrix): Matrix;
  77437. /**
  77438. * Scale the current matrix values by a factor and add the result to a given matrix
  77439. * @param scale defines the scale factor
  77440. * @param result defines the Matrix to store the result
  77441. * @returns the current matrix
  77442. */
  77443. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  77444. /**
  77445. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  77446. * @param ref matrix to store the result
  77447. */
  77448. toNormalMatrix(ref: Matrix): void;
  77449. /**
  77450. * Gets only rotation part of the current matrix
  77451. * @returns a new matrix sets to the extracted rotation matrix from the current one
  77452. */
  77453. getRotationMatrix(): Matrix;
  77454. /**
  77455. * Extracts the rotation matrix from the current one and sets it as the given "result"
  77456. * @param result defines the target matrix to store data to
  77457. * @returns the current matrix
  77458. */
  77459. getRotationMatrixToRef(result: Matrix): Matrix;
  77460. /**
  77461. * Toggles model matrix from being right handed to left handed in place and vice versa
  77462. */
  77463. toggleModelMatrixHandInPlace(): void;
  77464. /**
  77465. * Toggles projection matrix from being right handed to left handed in place and vice versa
  77466. */
  77467. toggleProjectionMatrixHandInPlace(): void;
  77468. /**
  77469. * Creates a matrix from an array
  77470. * @param array defines the source array
  77471. * @param offset defines an offset in the source array
  77472. * @returns a new Matrix set from the starting index of the given array
  77473. */
  77474. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  77475. /**
  77476. * Copy the content of an array into a given matrix
  77477. * @param array defines the source array
  77478. * @param offset defines an offset in the source array
  77479. * @param result defines the target matrix
  77480. */
  77481. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  77482. /**
  77483. * Stores an array into a matrix after having multiplied each component by a given factor
  77484. * @param array defines the source array
  77485. * @param offset defines the offset in the source array
  77486. * @param scale defines the scaling factor
  77487. * @param result defines the target matrix
  77488. */
  77489. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  77490. /**
  77491. * Gets an identity matrix that must not be updated
  77492. */
  77493. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  77494. /**
  77495. * Stores a list of values (16) inside a given matrix
  77496. * @param initialM11 defines 1st value of 1st row
  77497. * @param initialM12 defines 2nd value of 1st row
  77498. * @param initialM13 defines 3rd value of 1st row
  77499. * @param initialM14 defines 4th value of 1st row
  77500. * @param initialM21 defines 1st value of 2nd row
  77501. * @param initialM22 defines 2nd value of 2nd row
  77502. * @param initialM23 defines 3rd value of 2nd row
  77503. * @param initialM24 defines 4th value of 2nd row
  77504. * @param initialM31 defines 1st value of 3rd row
  77505. * @param initialM32 defines 2nd value of 3rd row
  77506. * @param initialM33 defines 3rd value of 3rd row
  77507. * @param initialM34 defines 4th value of 3rd row
  77508. * @param initialM41 defines 1st value of 4th row
  77509. * @param initialM42 defines 2nd value of 4th row
  77510. * @param initialM43 defines 3rd value of 4th row
  77511. * @param initialM44 defines 4th value of 4th row
  77512. * @param result defines the target matrix
  77513. */
  77514. 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;
  77515. /**
  77516. * Creates new matrix from a list of values (16)
  77517. * @param initialM11 defines 1st value of 1st row
  77518. * @param initialM12 defines 2nd value of 1st row
  77519. * @param initialM13 defines 3rd value of 1st row
  77520. * @param initialM14 defines 4th value of 1st row
  77521. * @param initialM21 defines 1st value of 2nd row
  77522. * @param initialM22 defines 2nd value of 2nd row
  77523. * @param initialM23 defines 3rd value of 2nd row
  77524. * @param initialM24 defines 4th value of 2nd row
  77525. * @param initialM31 defines 1st value of 3rd row
  77526. * @param initialM32 defines 2nd value of 3rd row
  77527. * @param initialM33 defines 3rd value of 3rd row
  77528. * @param initialM34 defines 4th value of 3rd row
  77529. * @param initialM41 defines 1st value of 4th row
  77530. * @param initialM42 defines 2nd value of 4th row
  77531. * @param initialM43 defines 3rd value of 4th row
  77532. * @param initialM44 defines 4th value of 4th row
  77533. * @returns the new matrix
  77534. */
  77535. 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;
  77536. /**
  77537. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  77538. * @param scale defines the scale vector3
  77539. * @param rotation defines the rotation quaternion
  77540. * @param translation defines the translation vector3
  77541. * @returns a new matrix
  77542. */
  77543. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  77544. /**
  77545. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  77546. * @param scale defines the scale vector3
  77547. * @param rotation defines the rotation quaternion
  77548. * @param translation defines the translation vector3
  77549. * @param result defines the target matrix
  77550. */
  77551. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  77552. /**
  77553. * Creates a new identity matrix
  77554. * @returns a new identity matrix
  77555. */
  77556. static Identity(): Matrix;
  77557. /**
  77558. * Creates a new identity matrix and stores the result in a given matrix
  77559. * @param result defines the target matrix
  77560. */
  77561. static IdentityToRef(result: Matrix): void;
  77562. /**
  77563. * Creates a new zero matrix
  77564. * @returns a new zero matrix
  77565. */
  77566. static Zero(): Matrix;
  77567. /**
  77568. * Creates a new rotation matrix for "angle" radians around the X axis
  77569. * @param angle defines the angle (in radians) to use
  77570. * @return the new matrix
  77571. */
  77572. static RotationX(angle: number): Matrix;
  77573. /**
  77574. * Creates a new matrix as the invert of a given matrix
  77575. * @param source defines the source matrix
  77576. * @returns the new matrix
  77577. */
  77578. static Invert(source: DeepImmutable<Matrix>): Matrix;
  77579. /**
  77580. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  77581. * @param angle defines the angle (in radians) to use
  77582. * @param result defines the target matrix
  77583. */
  77584. static RotationXToRef(angle: number, result: Matrix): void;
  77585. /**
  77586. * Creates a new rotation matrix for "angle" radians around the Y axis
  77587. * @param angle defines the angle (in radians) to use
  77588. * @return the new matrix
  77589. */
  77590. static RotationY(angle: number): Matrix;
  77591. /**
  77592. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  77593. * @param angle defines the angle (in radians) to use
  77594. * @param result defines the target matrix
  77595. */
  77596. static RotationYToRef(angle: number, result: Matrix): void;
  77597. /**
  77598. * Creates a new rotation matrix for "angle" radians around the Z axis
  77599. * @param angle defines the angle (in radians) to use
  77600. * @return the new matrix
  77601. */
  77602. static RotationZ(angle: number): Matrix;
  77603. /**
  77604. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  77605. * @param angle defines the angle (in radians) to use
  77606. * @param result defines the target matrix
  77607. */
  77608. static RotationZToRef(angle: number, result: Matrix): void;
  77609. /**
  77610. * Creates a new rotation matrix for "angle" radians around the given axis
  77611. * @param axis defines the axis to use
  77612. * @param angle defines the angle (in radians) to use
  77613. * @return the new matrix
  77614. */
  77615. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  77616. /**
  77617. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  77618. * @param axis defines the axis to use
  77619. * @param angle defines the angle (in radians) to use
  77620. * @param result defines the target matrix
  77621. */
  77622. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  77623. /**
  77624. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  77625. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  77626. * @param from defines the vector to align
  77627. * @param to defines the vector to align to
  77628. * @param result defines the target matrix
  77629. */
  77630. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  77631. /**
  77632. * Creates a rotation matrix
  77633. * @param yaw defines the yaw angle in radians (Y axis)
  77634. * @param pitch defines the pitch angle in radians (X axis)
  77635. * @param roll defines the roll angle in radians (X axis)
  77636. * @returns the new rotation matrix
  77637. */
  77638. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  77639. /**
  77640. * Creates a rotation matrix and stores it in a given matrix
  77641. * @param yaw defines the yaw angle in radians (Y axis)
  77642. * @param pitch defines the pitch angle in radians (X axis)
  77643. * @param roll defines the roll angle in radians (X axis)
  77644. * @param result defines the target matrix
  77645. */
  77646. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  77647. /**
  77648. * Creates a scaling matrix
  77649. * @param x defines the scale factor on X axis
  77650. * @param y defines the scale factor on Y axis
  77651. * @param z defines the scale factor on Z axis
  77652. * @returns the new matrix
  77653. */
  77654. static Scaling(x: number, y: number, z: number): Matrix;
  77655. /**
  77656. * Creates a scaling matrix and stores it in a given matrix
  77657. * @param x defines the scale factor on X axis
  77658. * @param y defines the scale factor on Y axis
  77659. * @param z defines the scale factor on Z axis
  77660. * @param result defines the target matrix
  77661. */
  77662. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  77663. /**
  77664. * Creates a translation matrix
  77665. * @param x defines the translation on X axis
  77666. * @param y defines the translation on Y axis
  77667. * @param z defines the translationon Z axis
  77668. * @returns the new matrix
  77669. */
  77670. static Translation(x: number, y: number, z: number): Matrix;
  77671. /**
  77672. * Creates a translation matrix and stores it in a given matrix
  77673. * @param x defines the translation on X axis
  77674. * @param y defines the translation on Y axis
  77675. * @param z defines the translationon Z axis
  77676. * @param result defines the target matrix
  77677. */
  77678. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  77679. /**
  77680. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  77681. * @param startValue defines the start value
  77682. * @param endValue defines the end value
  77683. * @param gradient defines the gradient factor
  77684. * @returns the new matrix
  77685. */
  77686. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  77687. /**
  77688. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  77689. * @param startValue defines the start value
  77690. * @param endValue defines the end value
  77691. * @param gradient defines the gradient factor
  77692. * @param result defines the Matrix object where to store data
  77693. */
  77694. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  77695. /**
  77696. * Builds a new matrix whose values 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. * @returns the new matrix
  77704. */
  77705. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  77706. /**
  77707. * Update a matrix to values which are computed by:
  77708. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  77709. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  77710. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  77711. * @param startValue defines the first matrix
  77712. * @param endValue defines the second matrix
  77713. * @param gradient defines the gradient between the two matrices
  77714. * @param result defines the target matrix
  77715. */
  77716. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  77717. /**
  77718. * 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"
  77719. * This function works in left handed mode
  77720. * @param eye defines the final position of the entity
  77721. * @param target defines where the entity should look at
  77722. * @param up defines the up vector for the entity
  77723. * @returns the new matrix
  77724. */
  77725. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  77726. /**
  77727. * 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".
  77728. * This function works in left handed mode
  77729. * @param eye defines the final position of the entity
  77730. * @param target defines where the entity should look at
  77731. * @param up defines the up vector for the entity
  77732. * @param result defines the target matrix
  77733. */
  77734. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  77735. /**
  77736. * 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"
  77737. * This function works in right handed mode
  77738. * @param eye defines the final position of the entity
  77739. * @param target defines where the entity should look at
  77740. * @param up defines the up vector for the entity
  77741. * @returns the new matrix
  77742. */
  77743. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  77744. /**
  77745. * 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".
  77746. * This function works in right handed mode
  77747. * @param eye defines the final position of the entity
  77748. * @param target defines where the entity should look at
  77749. * @param up defines the up vector for the entity
  77750. * @param result defines the target matrix
  77751. */
  77752. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  77753. /**
  77754. * Create a left-handed orthographic projection matrix
  77755. * @param width defines the viewport width
  77756. * @param height defines the viewport height
  77757. * @param znear defines the near clip plane
  77758. * @param zfar defines the far clip plane
  77759. * @returns a new matrix as a left-handed orthographic projection matrix
  77760. */
  77761. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  77762. /**
  77763. * Store a left-handed orthographic projection to a given matrix
  77764. * @param width defines the viewport width
  77765. * @param height defines the viewport height
  77766. * @param znear defines the near clip plane
  77767. * @param zfar defines the far clip plane
  77768. * @param result defines the target matrix
  77769. */
  77770. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  77771. /**
  77772. * Create a left-handed orthographic projection 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. * @returns a new matrix as a left-handed orthographic projection matrix
  77780. */
  77781. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  77782. /**
  77783. * Stores a left-handed orthographic projection into a given 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. * @param result defines the target matrix
  77791. */
  77792. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  77793. /**
  77794. * Creates a right-handed orthographic projection 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. * @returns a new matrix as a right-handed orthographic projection matrix
  77802. */
  77803. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  77804. /**
  77805. * Stores a right-handed orthographic projection into a given matrix
  77806. * @param left defines the viewport left coordinate
  77807. * @param right defines the viewport right coordinate
  77808. * @param bottom defines the viewport bottom coordinate
  77809. * @param top defines the viewport top coordinate
  77810. * @param znear defines the near clip plane
  77811. * @param zfar defines the far clip plane
  77812. * @param result defines the target matrix
  77813. */
  77814. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  77815. /**
  77816. * Creates a left-handed perspective projection matrix
  77817. * @param width defines the viewport width
  77818. * @param height defines the viewport height
  77819. * @param znear defines the near clip plane
  77820. * @param zfar defines the far clip plane
  77821. * @returns a new matrix as a left-handed perspective projection matrix
  77822. */
  77823. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  77824. /**
  77825. * Creates a left-handed perspective projection matrix
  77826. * @param fov defines the horizontal field of view
  77827. * @param aspect defines the aspect ratio
  77828. * @param znear defines the near clip plane
  77829. * @param zfar defines the far clip plane
  77830. * @returns a new matrix as a left-handed perspective projection matrix
  77831. */
  77832. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  77833. /**
  77834. * Stores a left-handed perspective projection into a given matrix
  77835. * @param fov defines the horizontal field of view
  77836. * @param aspect defines the aspect ratio
  77837. * @param znear defines the near clip plane
  77838. * @param zfar defines the far clip plane
  77839. * @param result defines the target matrix
  77840. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77841. */
  77842. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77843. /**
  77844. * Stores a left-handed perspective projection into a given matrix with depth reversed
  77845. * @param fov defines the horizontal field of view
  77846. * @param aspect defines the aspect ratio
  77847. * @param znear defines the near clip plane
  77848. * @param zfar not used as infinity is used as far clip
  77849. * @param result defines the target matrix
  77850. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77851. */
  77852. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77853. /**
  77854. * Creates a right-handed perspective projection matrix
  77855. * @param fov defines the horizontal field of view
  77856. * @param aspect defines the aspect ratio
  77857. * @param znear defines the near clip plane
  77858. * @param zfar defines the far clip plane
  77859. * @returns a new matrix as a right-handed perspective projection matrix
  77860. */
  77861. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  77862. /**
  77863. * Stores a right-handed perspective projection into a given matrix
  77864. * @param fov defines the horizontal field of view
  77865. * @param aspect defines the aspect ratio
  77866. * @param znear defines the near clip plane
  77867. * @param zfar defines the far clip plane
  77868. * @param result defines the target matrix
  77869. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77870. */
  77871. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77872. /**
  77873. * Stores a right-handed perspective projection into a given matrix
  77874. * @param fov defines the horizontal field of view
  77875. * @param aspect defines the aspect ratio
  77876. * @param znear defines the near clip plane
  77877. * @param zfar not used as infinity is used as far clip
  77878. * @param result defines the target matrix
  77879. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77880. */
  77881. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77882. /**
  77883. * Stores a perspective projection for WebVR info a given matrix
  77884. * @param fov defines the field of view
  77885. * @param znear defines the near clip plane
  77886. * @param zfar defines the far clip plane
  77887. * @param result defines the target matrix
  77888. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  77889. */
  77890. static PerspectiveFovWebVRToRef(fov: {
  77891. upDegrees: number;
  77892. downDegrees: number;
  77893. leftDegrees: number;
  77894. rightDegrees: number;
  77895. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  77896. /**
  77897. * Computes a complete transformation matrix
  77898. * @param viewport defines the viewport to use
  77899. * @param world defines the world matrix
  77900. * @param view defines the view matrix
  77901. * @param projection defines the projection matrix
  77902. * @param zmin defines the near clip plane
  77903. * @param zmax defines the far clip plane
  77904. * @returns the transformation matrix
  77905. */
  77906. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  77907. /**
  77908. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  77909. * @param matrix defines the matrix to use
  77910. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  77911. */
  77912. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  77913. /**
  77914. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  77915. * @param matrix defines the matrix to use
  77916. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  77917. */
  77918. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  77919. /**
  77920. * Compute the transpose of a given matrix
  77921. * @param matrix defines the matrix to transpose
  77922. * @returns the new matrix
  77923. */
  77924. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  77925. /**
  77926. * Compute the transpose of a matrix and store it in a target matrix
  77927. * @param matrix defines the matrix to transpose
  77928. * @param result defines the target matrix
  77929. */
  77930. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  77931. /**
  77932. * Computes a reflection matrix from a plane
  77933. * @param plane defines the reflection plane
  77934. * @returns a new matrix
  77935. */
  77936. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  77937. /**
  77938. * Computes a reflection matrix from a plane
  77939. * @param plane defines the reflection plane
  77940. * @param result defines the target matrix
  77941. */
  77942. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  77943. /**
  77944. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  77945. * @param xaxis defines the value of the 1st axis
  77946. * @param yaxis defines the value of the 2nd axis
  77947. * @param zaxis defines the value of the 3rd axis
  77948. * @param result defines the target matrix
  77949. */
  77950. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  77951. /**
  77952. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  77953. * @param quat defines the quaternion to use
  77954. * @param result defines the target matrix
  77955. */
  77956. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  77957. }
  77958. /**
  77959. * @hidden
  77960. */
  77961. export class TmpVectors {
  77962. static Vector2: Vector2[];
  77963. static Vector3: Vector3[];
  77964. static Vector4: Vector4[];
  77965. static Quaternion: Quaternion[];
  77966. static Matrix: Matrix[];
  77967. }
  77968. }
  77969. declare module BABYLON {
  77970. /**
  77971. * Defines potential orientation for back face culling
  77972. */
  77973. export enum Orientation {
  77974. /**
  77975. * Clockwise
  77976. */
  77977. CW = 0,
  77978. /** Counter clockwise */
  77979. CCW = 1
  77980. }
  77981. /** Class used to represent a Bezier curve */
  77982. export class BezierCurve {
  77983. /**
  77984. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  77985. * @param t defines the time
  77986. * @param x1 defines the left coordinate on X axis
  77987. * @param y1 defines the left coordinate on Y axis
  77988. * @param x2 defines the right coordinate on X axis
  77989. * @param y2 defines the right coordinate on Y axis
  77990. * @returns the interpolated value
  77991. */
  77992. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  77993. }
  77994. /**
  77995. * Defines angle representation
  77996. */
  77997. export class Angle {
  77998. private _radians;
  77999. /**
  78000. * Creates an Angle object of "radians" radians (float).
  78001. * @param radians the angle in radians
  78002. */
  78003. constructor(radians: number);
  78004. /**
  78005. * Get value in degrees
  78006. * @returns the Angle value in degrees (float)
  78007. */
  78008. degrees(): number;
  78009. /**
  78010. * Get value in radians
  78011. * @returns the Angle value in radians (float)
  78012. */
  78013. radians(): number;
  78014. /**
  78015. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  78016. * @param a defines first vector
  78017. * @param b defines second vector
  78018. * @returns a new Angle
  78019. */
  78020. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  78021. /**
  78022. * Gets a new Angle object from the given float in radians
  78023. * @param radians defines the angle value in radians
  78024. * @returns a new Angle
  78025. */
  78026. static FromRadians(radians: number): Angle;
  78027. /**
  78028. * Gets a new Angle object from the given float in degrees
  78029. * @param degrees defines the angle value in degrees
  78030. * @returns a new Angle
  78031. */
  78032. static FromDegrees(degrees: number): Angle;
  78033. }
  78034. /**
  78035. * This represents an arc in a 2d space.
  78036. */
  78037. export class Arc2 {
  78038. /** Defines the start point of the arc */
  78039. startPoint: Vector2;
  78040. /** Defines the mid point of the arc */
  78041. midPoint: Vector2;
  78042. /** Defines the end point of the arc */
  78043. endPoint: Vector2;
  78044. /**
  78045. * Defines the center point of the arc.
  78046. */
  78047. centerPoint: Vector2;
  78048. /**
  78049. * Defines the radius of the arc.
  78050. */
  78051. radius: number;
  78052. /**
  78053. * Defines the angle of the arc (from mid point to end point).
  78054. */
  78055. angle: Angle;
  78056. /**
  78057. * Defines the start angle of the arc (from start point to middle point).
  78058. */
  78059. startAngle: Angle;
  78060. /**
  78061. * Defines the orientation of the arc (clock wise/counter clock wise).
  78062. */
  78063. orientation: Orientation;
  78064. /**
  78065. * Creates an Arc object from the three given points : start, middle and end.
  78066. * @param startPoint Defines the start point of the arc
  78067. * @param midPoint Defines the midlle point of the arc
  78068. * @param endPoint Defines the end point of the arc
  78069. */
  78070. constructor(
  78071. /** Defines the start point of the arc */
  78072. startPoint: Vector2,
  78073. /** Defines the mid point of the arc */
  78074. midPoint: Vector2,
  78075. /** Defines the end point of the arc */
  78076. endPoint: Vector2);
  78077. }
  78078. /**
  78079. * Represents a 2D path made up of multiple 2D points
  78080. */
  78081. export class Path2 {
  78082. private _points;
  78083. private _length;
  78084. /**
  78085. * If the path start and end point are the same
  78086. */
  78087. closed: boolean;
  78088. /**
  78089. * Creates a Path2 object from the starting 2D coordinates x and y.
  78090. * @param x the starting points x value
  78091. * @param y the starting points y value
  78092. */
  78093. constructor(x: number, y: number);
  78094. /**
  78095. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  78096. * @param x the added points x value
  78097. * @param y the added points y value
  78098. * @returns the updated Path2.
  78099. */
  78100. addLineTo(x: number, y: number): Path2;
  78101. /**
  78102. * 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.
  78103. * @param midX middle point x value
  78104. * @param midY middle point y value
  78105. * @param endX end point x value
  78106. * @param endY end point y value
  78107. * @param numberOfSegments (default: 36)
  78108. * @returns the updated Path2.
  78109. */
  78110. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  78111. /**
  78112. * Closes the Path2.
  78113. * @returns the Path2.
  78114. */
  78115. close(): Path2;
  78116. /**
  78117. * Gets the sum of the distance between each sequential point in the path
  78118. * @returns the Path2 total length (float).
  78119. */
  78120. length(): number;
  78121. /**
  78122. * Gets the points which construct the path
  78123. * @returns the Path2 internal array of points.
  78124. */
  78125. getPoints(): Vector2[];
  78126. /**
  78127. * Retreives the point at the distance aways from the starting point
  78128. * @param normalizedLengthPosition the length along the path to retreive the point from
  78129. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  78130. */
  78131. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  78132. /**
  78133. * Creates a new path starting from an x and y position
  78134. * @param x starting x value
  78135. * @param y starting y value
  78136. * @returns a new Path2 starting at the coordinates (x, y).
  78137. */
  78138. static StartingAt(x: number, y: number): Path2;
  78139. }
  78140. /**
  78141. * Represents a 3D path made up of multiple 3D points
  78142. */
  78143. export class Path3D {
  78144. /**
  78145. * an array of Vector3, the curve axis of the Path3D
  78146. */
  78147. path: Vector3[];
  78148. private _curve;
  78149. private _distances;
  78150. private _tangents;
  78151. private _normals;
  78152. private _binormals;
  78153. private _raw;
  78154. private _alignTangentsWithPath;
  78155. private readonly _pointAtData;
  78156. /**
  78157. * new Path3D(path, normal, raw)
  78158. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  78159. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  78160. * @param path an array of Vector3, the curve axis of the Path3D
  78161. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  78162. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  78163. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  78164. */
  78165. constructor(
  78166. /**
  78167. * an array of Vector3, the curve axis of the Path3D
  78168. */
  78169. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  78170. /**
  78171. * Returns the Path3D array of successive Vector3 designing its curve.
  78172. * @returns the Path3D array of successive Vector3 designing its curve.
  78173. */
  78174. getCurve(): Vector3[];
  78175. /**
  78176. * Returns the Path3D array of successive Vector3 designing its curve.
  78177. * @returns the Path3D array of successive Vector3 designing its curve.
  78178. */
  78179. getPoints(): Vector3[];
  78180. /**
  78181. * @returns the computed length (float) of the path.
  78182. */
  78183. length(): number;
  78184. /**
  78185. * Returns an array populated with tangent vectors on each Path3D curve point.
  78186. * @returns an array populated with tangent vectors on each Path3D curve point.
  78187. */
  78188. getTangents(): Vector3[];
  78189. /**
  78190. * Returns an array populated with normal vectors on each Path3D curve point.
  78191. * @returns an array populated with normal vectors on each Path3D curve point.
  78192. */
  78193. getNormals(): Vector3[];
  78194. /**
  78195. * Returns an array populated with binormal vectors on each Path3D curve point.
  78196. * @returns an array populated with binormal vectors on each Path3D curve point.
  78197. */
  78198. getBinormals(): Vector3[];
  78199. /**
  78200. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  78201. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  78202. */
  78203. getDistances(): number[];
  78204. /**
  78205. * Returns an interpolated point along this path
  78206. * @param position the position of the point along this path, from 0.0 to 1.0
  78207. * @returns a new Vector3 as the point
  78208. */
  78209. getPointAt(position: number): Vector3;
  78210. /**
  78211. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  78212. * @param position the position of the point along this path, from 0.0 to 1.0
  78213. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  78214. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  78215. */
  78216. getTangentAt(position: number, interpolated?: boolean): Vector3;
  78217. /**
  78218. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  78219. * @param position the position of the point along this path, from 0.0 to 1.0
  78220. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  78221. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  78222. */
  78223. getNormalAt(position: number, interpolated?: boolean): Vector3;
  78224. /**
  78225. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  78226. * @param position the position of the point along this path, from 0.0 to 1.0
  78227. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  78228. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  78229. */
  78230. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  78231. /**
  78232. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  78233. * @param position the position of the point along this path, from 0.0 to 1.0
  78234. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  78235. */
  78236. getDistanceAt(position: number): number;
  78237. /**
  78238. * Returns the array index of the previous point of an interpolated point along this path
  78239. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  78240. * @returns the array index
  78241. */
  78242. getPreviousPointIndexAt(position: number): number;
  78243. /**
  78244. * 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)
  78245. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  78246. * @returns the sub position
  78247. */
  78248. getSubPositionAt(position: number): number;
  78249. /**
  78250. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  78251. * @param target the vector of which to get the closest position to
  78252. * @returns the position of the closest virtual point on this path to the target vector
  78253. */
  78254. getClosestPositionTo(target: Vector3): number;
  78255. /**
  78256. * Returns a sub path (slice) of this path
  78257. * @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
  78258. * @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
  78259. * @returns a sub path (slice) of this path
  78260. */
  78261. slice(start?: number, end?: number): Path3D;
  78262. /**
  78263. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  78264. * @param path path which all values are copied into the curves points
  78265. * @param firstNormal which should be projected onto the curve
  78266. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  78267. * @returns the same object updated.
  78268. */
  78269. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  78270. private _compute;
  78271. private _getFirstNonNullVector;
  78272. private _getLastNonNullVector;
  78273. private _normalVector;
  78274. /**
  78275. * Updates the point at data for an interpolated point along this curve
  78276. * @param position the position of the point along this curve, from 0.0 to 1.0
  78277. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  78278. * @returns the (updated) point at data
  78279. */
  78280. private _updatePointAtData;
  78281. /**
  78282. * Updates the point at data from the specified parameters
  78283. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  78284. * @param point the interpolated point
  78285. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  78286. */
  78287. private _setPointAtData;
  78288. /**
  78289. * Updates the point at interpolation matrix for the tangents, normals and binormals
  78290. */
  78291. private _updateInterpolationMatrix;
  78292. }
  78293. /**
  78294. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  78295. * A Curve3 is designed from a series of successive Vector3.
  78296. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  78297. */
  78298. export class Curve3 {
  78299. private _points;
  78300. private _length;
  78301. /**
  78302. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  78303. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  78304. * @param v1 (Vector3) the control point
  78305. * @param v2 (Vector3) the end point of the Quadratic Bezier
  78306. * @param nbPoints (integer) the wanted number of points in the curve
  78307. * @returns the created Curve3
  78308. */
  78309. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78310. /**
  78311. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  78312. * @param v0 (Vector3) the origin point of the Cubic Bezier
  78313. * @param v1 (Vector3) the first control point
  78314. * @param v2 (Vector3) the second control point
  78315. * @param v3 (Vector3) the end point of the Cubic Bezier
  78316. * @param nbPoints (integer) the wanted number of points in the curve
  78317. * @returns the created Curve3
  78318. */
  78319. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78320. /**
  78321. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  78322. * @param p1 (Vector3) the origin point of the Hermite Spline
  78323. * @param t1 (Vector3) the tangent vector at the origin point
  78324. * @param p2 (Vector3) the end point of the Hermite Spline
  78325. * @param t2 (Vector3) the tangent vector at the end point
  78326. * @param nbPoints (integer) the wanted number of points in the curve
  78327. * @returns the created Curve3
  78328. */
  78329. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78330. /**
  78331. * Returns a Curve3 object along a CatmullRom Spline curve :
  78332. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  78333. * @param nbPoints (integer) the wanted number of points between each curve control points
  78334. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  78335. * @returns the created Curve3
  78336. */
  78337. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  78338. /**
  78339. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  78340. * A Curve3 is designed from a series of successive Vector3.
  78341. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  78342. * @param points points which make up the curve
  78343. */
  78344. constructor(points: Vector3[]);
  78345. /**
  78346. * @returns the Curve3 stored array of successive Vector3
  78347. */
  78348. getPoints(): Vector3[];
  78349. /**
  78350. * @returns the computed length (float) of the curve.
  78351. */
  78352. length(): number;
  78353. /**
  78354. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  78355. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  78356. * curveA and curveB keep unchanged.
  78357. * @param curve the curve to continue from this curve
  78358. * @returns the newly constructed curve
  78359. */
  78360. continue(curve: DeepImmutable<Curve3>): Curve3;
  78361. private _computeLength;
  78362. }
  78363. }
  78364. declare module BABYLON {
  78365. /**
  78366. * This represents the main contract an easing function should follow.
  78367. * Easing functions are used throughout the animation system.
  78368. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78369. */
  78370. export interface IEasingFunction {
  78371. /**
  78372. * Given an input gradient between 0 and 1, this returns the corrseponding value
  78373. * of the easing function.
  78374. * The link below provides some of the most common examples of easing functions.
  78375. * @see https://easings.net/
  78376. * @param gradient Defines the value between 0 and 1 we want the easing value for
  78377. * @returns the corresponding value on the curve defined by the easing function
  78378. */
  78379. ease(gradient: number): number;
  78380. }
  78381. /**
  78382. * Base class used for every default easing function.
  78383. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78384. */
  78385. export class EasingFunction implements IEasingFunction {
  78386. /**
  78387. * Interpolation follows the mathematical formula associated with the easing function.
  78388. */
  78389. static readonly EASINGMODE_EASEIN: number;
  78390. /**
  78391. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  78392. */
  78393. static readonly EASINGMODE_EASEOUT: number;
  78394. /**
  78395. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  78396. */
  78397. static readonly EASINGMODE_EASEINOUT: number;
  78398. private _easingMode;
  78399. /**
  78400. * Sets the easing mode of the current function.
  78401. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  78402. */
  78403. setEasingMode(easingMode: number): void;
  78404. /**
  78405. * Gets the current easing mode.
  78406. * @returns the easing mode
  78407. */
  78408. getEasingMode(): number;
  78409. /**
  78410. * @hidden
  78411. */
  78412. easeInCore(gradient: number): number;
  78413. /**
  78414. * Given an input gradient between 0 and 1, this returns the corresponding value
  78415. * of the easing function.
  78416. * @param gradient Defines the value between 0 and 1 we want the easing value for
  78417. * @returns the corresponding value on the curve defined by the easing function
  78418. */
  78419. ease(gradient: number): number;
  78420. }
  78421. /**
  78422. * Easing function with a circle shape (see link below).
  78423. * @see https://easings.net/#easeInCirc
  78424. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78425. */
  78426. export class CircleEase extends EasingFunction implements IEasingFunction {
  78427. /** @hidden */
  78428. easeInCore(gradient: number): number;
  78429. }
  78430. /**
  78431. * Easing function with a ease back shape (see link below).
  78432. * @see https://easings.net/#easeInBack
  78433. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78434. */
  78435. export class BackEase extends EasingFunction implements IEasingFunction {
  78436. /** Defines the amplitude of the function */
  78437. amplitude: number;
  78438. /**
  78439. * Instantiates a back ease easing
  78440. * @see https://easings.net/#easeInBack
  78441. * @param amplitude Defines the amplitude of the function
  78442. */
  78443. constructor(
  78444. /** Defines the amplitude of the function */
  78445. amplitude?: number);
  78446. /** @hidden */
  78447. easeInCore(gradient: number): number;
  78448. }
  78449. /**
  78450. * Easing function with a bouncing shape (see link below).
  78451. * @see https://easings.net/#easeInBounce
  78452. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78453. */
  78454. export class BounceEase extends EasingFunction implements IEasingFunction {
  78455. /** Defines the number of bounces */
  78456. bounces: number;
  78457. /** Defines the amplitude of the bounce */
  78458. bounciness: number;
  78459. /**
  78460. * Instantiates a bounce easing
  78461. * @see https://easings.net/#easeInBounce
  78462. * @param bounces Defines the number of bounces
  78463. * @param bounciness Defines the amplitude of the bounce
  78464. */
  78465. constructor(
  78466. /** Defines the number of bounces */
  78467. bounces?: number,
  78468. /** Defines the amplitude of the bounce */
  78469. bounciness?: number);
  78470. /** @hidden */
  78471. easeInCore(gradient: number): number;
  78472. }
  78473. /**
  78474. * Easing function with a power of 3 shape (see link below).
  78475. * @see https://easings.net/#easeInCubic
  78476. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78477. */
  78478. export class CubicEase extends EasingFunction implements IEasingFunction {
  78479. /** @hidden */
  78480. easeInCore(gradient: number): number;
  78481. }
  78482. /**
  78483. * Easing function with an elastic shape (see link below).
  78484. * @see https://easings.net/#easeInElastic
  78485. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78486. */
  78487. export class ElasticEase extends EasingFunction implements IEasingFunction {
  78488. /** Defines the number of oscillations*/
  78489. oscillations: number;
  78490. /** Defines the amplitude of the oscillations*/
  78491. springiness: number;
  78492. /**
  78493. * Instantiates an elastic easing function
  78494. * @see https://easings.net/#easeInElastic
  78495. * @param oscillations Defines the number of oscillations
  78496. * @param springiness Defines the amplitude of the oscillations
  78497. */
  78498. constructor(
  78499. /** Defines the number of oscillations*/
  78500. oscillations?: number,
  78501. /** Defines the amplitude of the oscillations*/
  78502. springiness?: number);
  78503. /** @hidden */
  78504. easeInCore(gradient: number): number;
  78505. }
  78506. /**
  78507. * Easing function with an exponential shape (see link below).
  78508. * @see https://easings.net/#easeInExpo
  78509. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78510. */
  78511. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  78512. /** Defines the exponent of the function */
  78513. exponent: number;
  78514. /**
  78515. * Instantiates an exponential easing function
  78516. * @see https://easings.net/#easeInExpo
  78517. * @param exponent Defines the exponent of the function
  78518. */
  78519. constructor(
  78520. /** Defines the exponent of the function */
  78521. exponent?: number);
  78522. /** @hidden */
  78523. easeInCore(gradient: number): number;
  78524. }
  78525. /**
  78526. * Easing function with a power shape (see link below).
  78527. * @see https://easings.net/#easeInQuad
  78528. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78529. */
  78530. export class PowerEase extends EasingFunction implements IEasingFunction {
  78531. /** Defines the power of the function */
  78532. power: number;
  78533. /**
  78534. * Instantiates an power base easing function
  78535. * @see https://easings.net/#easeInQuad
  78536. * @param power Defines the power of the function
  78537. */
  78538. constructor(
  78539. /** Defines the power of the function */
  78540. power?: number);
  78541. /** @hidden */
  78542. easeInCore(gradient: number): number;
  78543. }
  78544. /**
  78545. * Easing function with a power of 2 shape (see link below).
  78546. * @see https://easings.net/#easeInQuad
  78547. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78548. */
  78549. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  78550. /** @hidden */
  78551. easeInCore(gradient: number): number;
  78552. }
  78553. /**
  78554. * Easing function with a power of 4 shape (see link below).
  78555. * @see https://easings.net/#easeInQuart
  78556. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78557. */
  78558. export class QuarticEase extends EasingFunction implements IEasingFunction {
  78559. /** @hidden */
  78560. easeInCore(gradient: number): number;
  78561. }
  78562. /**
  78563. * Easing function with a power of 5 shape (see link below).
  78564. * @see https://easings.net/#easeInQuint
  78565. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78566. */
  78567. export class QuinticEase extends EasingFunction implements IEasingFunction {
  78568. /** @hidden */
  78569. easeInCore(gradient: number): number;
  78570. }
  78571. /**
  78572. * Easing function with a sin shape (see link below).
  78573. * @see https://easings.net/#easeInSine
  78574. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78575. */
  78576. export class SineEase extends EasingFunction implements IEasingFunction {
  78577. /** @hidden */
  78578. easeInCore(gradient: number): number;
  78579. }
  78580. /**
  78581. * Easing function with a bezier shape (see link below).
  78582. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  78583. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78584. */
  78585. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  78586. /** Defines the x component of the start tangent in the bezier curve */
  78587. x1: number;
  78588. /** Defines the y component of the start tangent in the bezier curve */
  78589. y1: number;
  78590. /** Defines the x component of the end tangent in the bezier curve */
  78591. x2: number;
  78592. /** Defines the y component of the end tangent in the bezier curve */
  78593. y2: number;
  78594. /**
  78595. * Instantiates a bezier function
  78596. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  78597. * @param x1 Defines the x component of the start tangent in the bezier curve
  78598. * @param y1 Defines the y component of the start tangent in the bezier curve
  78599. * @param x2 Defines the x component of the end tangent in the bezier curve
  78600. * @param y2 Defines the y component of the end tangent in the bezier curve
  78601. */
  78602. constructor(
  78603. /** Defines the x component of the start tangent in the bezier curve */
  78604. x1?: number,
  78605. /** Defines the y component of the start tangent in the bezier curve */
  78606. y1?: number,
  78607. /** Defines the x component of the end tangent in the bezier curve */
  78608. x2?: number,
  78609. /** Defines the y component of the end tangent in the bezier curve */
  78610. y2?: number);
  78611. /** @hidden */
  78612. easeInCore(gradient: number): number;
  78613. }
  78614. }
  78615. declare module BABYLON {
  78616. /**
  78617. * Class used to hold a RBG color
  78618. */
  78619. export class Color3 {
  78620. /**
  78621. * Defines the red component (between 0 and 1, default is 0)
  78622. */
  78623. r: number;
  78624. /**
  78625. * Defines the green component (between 0 and 1, default is 0)
  78626. */
  78627. g: number;
  78628. /**
  78629. * Defines the blue component (between 0 and 1, default is 0)
  78630. */
  78631. b: number;
  78632. /**
  78633. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  78634. * @param r defines the red component (between 0 and 1, default is 0)
  78635. * @param g defines the green component (between 0 and 1, default is 0)
  78636. * @param b defines the blue component (between 0 and 1, default is 0)
  78637. */
  78638. constructor(
  78639. /**
  78640. * Defines the red component (between 0 and 1, default is 0)
  78641. */
  78642. r?: number,
  78643. /**
  78644. * Defines the green component (between 0 and 1, default is 0)
  78645. */
  78646. g?: number,
  78647. /**
  78648. * Defines the blue component (between 0 and 1, default is 0)
  78649. */
  78650. b?: number);
  78651. /**
  78652. * Creates a string with the Color3 current values
  78653. * @returns the string representation of the Color3 object
  78654. */
  78655. toString(): string;
  78656. /**
  78657. * Returns the string "Color3"
  78658. * @returns "Color3"
  78659. */
  78660. getClassName(): string;
  78661. /**
  78662. * Compute the Color3 hash code
  78663. * @returns an unique number that can be used to hash Color3 objects
  78664. */
  78665. getHashCode(): number;
  78666. /**
  78667. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  78668. * @param array defines the array where to store the r,g,b components
  78669. * @param index defines an optional index in the target array to define where to start storing values
  78670. * @returns the current Color3 object
  78671. */
  78672. toArray(array: FloatArray, index?: number): Color3;
  78673. /**
  78674. * Returns a new Color4 object from the current Color3 and the given alpha
  78675. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  78676. * @returns a new Color4 object
  78677. */
  78678. toColor4(alpha?: number): Color4;
  78679. /**
  78680. * Returns a new array populated with 3 numeric elements : red, green and blue values
  78681. * @returns the new array
  78682. */
  78683. asArray(): number[];
  78684. /**
  78685. * Returns the luminance value
  78686. * @returns a float value
  78687. */
  78688. toLuminance(): number;
  78689. /**
  78690. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  78691. * @param otherColor defines the second operand
  78692. * @returns the new Color3 object
  78693. */
  78694. multiply(otherColor: DeepImmutable<Color3>): Color3;
  78695. /**
  78696. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  78697. * @param otherColor defines the second operand
  78698. * @param result defines the Color3 object where to store the result
  78699. * @returns the current Color3
  78700. */
  78701. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78702. /**
  78703. * Determines equality between Color3 objects
  78704. * @param otherColor defines the second operand
  78705. * @returns true if the rgb values are equal to the given ones
  78706. */
  78707. equals(otherColor: DeepImmutable<Color3>): boolean;
  78708. /**
  78709. * Determines equality between the current Color3 object and a set of r,b,g values
  78710. * @param r defines the red component to check
  78711. * @param g defines the green component to check
  78712. * @param b defines the blue component to check
  78713. * @returns true if the rgb values are equal to the given ones
  78714. */
  78715. equalsFloats(r: number, g: number, b: number): boolean;
  78716. /**
  78717. * Multiplies in place each rgb value by scale
  78718. * @param scale defines the scaling factor
  78719. * @returns the updated Color3
  78720. */
  78721. scale(scale: number): Color3;
  78722. /**
  78723. * Multiplies the rgb values by scale and stores the result into "result"
  78724. * @param scale defines the scaling factor
  78725. * @param result defines the Color3 object where to store the result
  78726. * @returns the unmodified current Color3
  78727. */
  78728. scaleToRef(scale: number, result: Color3): Color3;
  78729. /**
  78730. * Scale the current Color3 values by a factor and add the result to a given Color3
  78731. * @param scale defines the scale factor
  78732. * @param result defines color to store the result into
  78733. * @returns the unmodified current Color3
  78734. */
  78735. scaleAndAddToRef(scale: number, result: Color3): Color3;
  78736. /**
  78737. * Clamps the rgb values by the min and max values and stores the result into "result"
  78738. * @param min defines minimum clamping value (default is 0)
  78739. * @param max defines maximum clamping value (default is 1)
  78740. * @param result defines color to store the result into
  78741. * @returns the original Color3
  78742. */
  78743. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  78744. /**
  78745. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  78746. * @param otherColor defines the second operand
  78747. * @returns the new Color3
  78748. */
  78749. add(otherColor: DeepImmutable<Color3>): Color3;
  78750. /**
  78751. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  78752. * @param otherColor defines the second operand
  78753. * @param result defines Color3 object to store the result into
  78754. * @returns the unmodified current Color3
  78755. */
  78756. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78757. /**
  78758. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  78759. * @param otherColor defines the second operand
  78760. * @returns the new Color3
  78761. */
  78762. subtract(otherColor: DeepImmutable<Color3>): Color3;
  78763. /**
  78764. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  78765. * @param otherColor defines the second operand
  78766. * @param result defines Color3 object to store the result into
  78767. * @returns the unmodified current Color3
  78768. */
  78769. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78770. /**
  78771. * Copy the current object
  78772. * @returns a new Color3 copied the current one
  78773. */
  78774. clone(): Color3;
  78775. /**
  78776. * Copies the rgb values from the source in the current Color3
  78777. * @param source defines the source Color3 object
  78778. * @returns the updated Color3 object
  78779. */
  78780. copyFrom(source: DeepImmutable<Color3>): Color3;
  78781. /**
  78782. * Updates the Color3 rgb values from the given floats
  78783. * @param r defines the red component to read from
  78784. * @param g defines the green component to read from
  78785. * @param b defines the blue component to read from
  78786. * @returns the current Color3 object
  78787. */
  78788. copyFromFloats(r: number, g: number, b: number): Color3;
  78789. /**
  78790. * Updates the Color3 rgb values from the given floats
  78791. * @param r defines the red component to read from
  78792. * @param g defines the green component to read from
  78793. * @param b defines the blue component to read from
  78794. * @returns the current Color3 object
  78795. */
  78796. set(r: number, g: number, b: number): Color3;
  78797. /**
  78798. * Compute the Color3 hexadecimal code as a string
  78799. * @returns a string containing the hexadecimal representation of the Color3 object
  78800. */
  78801. toHexString(): string;
  78802. /**
  78803. * Computes a new Color3 converted from the current one to linear space
  78804. * @returns a new Color3 object
  78805. */
  78806. toLinearSpace(): Color3;
  78807. /**
  78808. * Converts current color in rgb space to HSV values
  78809. * @returns a new color3 representing the HSV values
  78810. */
  78811. toHSV(): Color3;
  78812. /**
  78813. * Converts current color in rgb space to HSV values
  78814. * @param result defines the Color3 where to store the HSV values
  78815. */
  78816. toHSVToRef(result: Color3): void;
  78817. /**
  78818. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  78819. * @param convertedColor defines the Color3 object where to store the linear space version
  78820. * @returns the unmodified Color3
  78821. */
  78822. toLinearSpaceToRef(convertedColor: Color3): Color3;
  78823. /**
  78824. * Computes a new Color3 converted from the current one to gamma space
  78825. * @returns a new Color3 object
  78826. */
  78827. toGammaSpace(): Color3;
  78828. /**
  78829. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  78830. * @param convertedColor defines the Color3 object where to store the gamma space version
  78831. * @returns the unmodified Color3
  78832. */
  78833. toGammaSpaceToRef(convertedColor: Color3): Color3;
  78834. private static _BlackReadOnly;
  78835. /**
  78836. * Convert Hue, saturation and value to a Color3 (RGB)
  78837. * @param hue defines the hue
  78838. * @param saturation defines the saturation
  78839. * @param value defines the value
  78840. * @param result defines the Color3 where to store the RGB values
  78841. */
  78842. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  78843. /**
  78844. * Creates a new Color3 from the string containing valid hexadecimal values
  78845. * @param hex defines a string containing valid hexadecimal values
  78846. * @returns a new Color3 object
  78847. */
  78848. static FromHexString(hex: string): Color3;
  78849. /**
  78850. * Creates a new Color3 from the starting index of the given array
  78851. * @param array defines the source array
  78852. * @param offset defines an offset in the source array
  78853. * @returns a new Color3 object
  78854. */
  78855. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  78856. /**
  78857. * Creates a new Color3 from integer values (< 256)
  78858. * @param r defines the red component to read from (value between 0 and 255)
  78859. * @param g defines the green component to read from (value between 0 and 255)
  78860. * @param b defines the blue component to read from (value between 0 and 255)
  78861. * @returns a new Color3 object
  78862. */
  78863. static FromInts(r: number, g: number, b: number): Color3;
  78864. /**
  78865. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  78866. * @param start defines the start Color3 value
  78867. * @param end defines the end Color3 value
  78868. * @param amount defines the gradient value between start and end
  78869. * @returns a new Color3 object
  78870. */
  78871. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  78872. /**
  78873. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  78874. * @param left defines the start value
  78875. * @param right defines the end value
  78876. * @param amount defines the gradient factor
  78877. * @param result defines the Color3 object where to store the result
  78878. */
  78879. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  78880. /**
  78881. * Returns a Color3 value containing a red color
  78882. * @returns a new Color3 object
  78883. */
  78884. static Red(): Color3;
  78885. /**
  78886. * Returns a Color3 value containing a green color
  78887. * @returns a new Color3 object
  78888. */
  78889. static Green(): Color3;
  78890. /**
  78891. * Returns a Color3 value containing a blue color
  78892. * @returns a new Color3 object
  78893. */
  78894. static Blue(): Color3;
  78895. /**
  78896. * Returns a Color3 value containing a black color
  78897. * @returns a new Color3 object
  78898. */
  78899. static Black(): Color3;
  78900. /**
  78901. * Gets a Color3 value containing a black color that must not be updated
  78902. */
  78903. static get BlackReadOnly(): DeepImmutable<Color3>;
  78904. /**
  78905. * Returns a Color3 value containing a white color
  78906. * @returns a new Color3 object
  78907. */
  78908. static White(): Color3;
  78909. /**
  78910. * Returns a Color3 value containing a purple color
  78911. * @returns a new Color3 object
  78912. */
  78913. static Purple(): Color3;
  78914. /**
  78915. * Returns a Color3 value containing a magenta color
  78916. * @returns a new Color3 object
  78917. */
  78918. static Magenta(): Color3;
  78919. /**
  78920. * Returns a Color3 value containing a yellow color
  78921. * @returns a new Color3 object
  78922. */
  78923. static Yellow(): Color3;
  78924. /**
  78925. * Returns a Color3 value containing a gray color
  78926. * @returns a new Color3 object
  78927. */
  78928. static Gray(): Color3;
  78929. /**
  78930. * Returns a Color3 value containing a teal color
  78931. * @returns a new Color3 object
  78932. */
  78933. static Teal(): Color3;
  78934. /**
  78935. * Returns a Color3 value containing a random color
  78936. * @returns a new Color3 object
  78937. */
  78938. static Random(): Color3;
  78939. }
  78940. /**
  78941. * Class used to hold a RBGA color
  78942. */
  78943. export class Color4 {
  78944. /**
  78945. * Defines the red component (between 0 and 1, default is 0)
  78946. */
  78947. r: number;
  78948. /**
  78949. * Defines the green component (between 0 and 1, default is 0)
  78950. */
  78951. g: number;
  78952. /**
  78953. * Defines the blue component (between 0 and 1, default is 0)
  78954. */
  78955. b: number;
  78956. /**
  78957. * Defines the alpha component (between 0 and 1, default is 1)
  78958. */
  78959. a: number;
  78960. /**
  78961. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  78962. * @param r defines the red component (between 0 and 1, default is 0)
  78963. * @param g defines the green component (between 0 and 1, default is 0)
  78964. * @param b defines the blue component (between 0 and 1, default is 0)
  78965. * @param a defines the alpha component (between 0 and 1, default is 1)
  78966. */
  78967. constructor(
  78968. /**
  78969. * Defines the red component (between 0 and 1, default is 0)
  78970. */
  78971. r?: number,
  78972. /**
  78973. * Defines the green component (between 0 and 1, default is 0)
  78974. */
  78975. g?: number,
  78976. /**
  78977. * Defines the blue component (between 0 and 1, default is 0)
  78978. */
  78979. b?: number,
  78980. /**
  78981. * Defines the alpha component (between 0 and 1, default is 1)
  78982. */
  78983. a?: number);
  78984. /**
  78985. * Adds in place the given Color4 values to the current Color4 object
  78986. * @param right defines the second operand
  78987. * @returns the current updated Color4 object
  78988. */
  78989. addInPlace(right: DeepImmutable<Color4>): Color4;
  78990. /**
  78991. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  78992. * @returns the new array
  78993. */
  78994. asArray(): number[];
  78995. /**
  78996. * Stores from the starting index in the given array the Color4 successive values
  78997. * @param array defines the array where to store the r,g,b components
  78998. * @param index defines an optional index in the target array to define where to start storing values
  78999. * @returns the current Color4 object
  79000. */
  79001. toArray(array: number[], index?: number): Color4;
  79002. /**
  79003. * Determines equality between Color4 objects
  79004. * @param otherColor defines the second operand
  79005. * @returns true if the rgba values are equal to the given ones
  79006. */
  79007. equals(otherColor: DeepImmutable<Color4>): boolean;
  79008. /**
  79009. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  79010. * @param right defines the second operand
  79011. * @returns a new Color4 object
  79012. */
  79013. add(right: DeepImmutable<Color4>): Color4;
  79014. /**
  79015. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  79016. * @param right defines the second operand
  79017. * @returns a new Color4 object
  79018. */
  79019. subtract(right: DeepImmutable<Color4>): Color4;
  79020. /**
  79021. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  79022. * @param right defines the second operand
  79023. * @param result defines the Color4 object where to store the result
  79024. * @returns the current Color4 object
  79025. */
  79026. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  79027. /**
  79028. * Creates a new Color4 with the current Color4 values multiplied by scale
  79029. * @param scale defines the scaling factor to apply
  79030. * @returns a new Color4 object
  79031. */
  79032. scale(scale: number): Color4;
  79033. /**
  79034. * Multiplies the current Color4 values by scale and stores the result in "result"
  79035. * @param scale defines the scaling factor to apply
  79036. * @param result defines the Color4 object where to store the result
  79037. * @returns the current unmodified Color4
  79038. */
  79039. scaleToRef(scale: number, result: Color4): Color4;
  79040. /**
  79041. * Scale the current Color4 values by a factor and add the result to a given Color4
  79042. * @param scale defines the scale factor
  79043. * @param result defines the Color4 object where to store the result
  79044. * @returns the unmodified current Color4
  79045. */
  79046. scaleAndAddToRef(scale: number, result: Color4): Color4;
  79047. /**
  79048. * Clamps the rgb values by the min and max values and stores the result into "result"
  79049. * @param min defines minimum clamping value (default is 0)
  79050. * @param max defines maximum clamping value (default is 1)
  79051. * @param result defines color to store the result into.
  79052. * @returns the cuurent Color4
  79053. */
  79054. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  79055. /**
  79056. * Multipy an Color4 value by another and return a new Color4 object
  79057. * @param color defines the Color4 value to multiply by
  79058. * @returns a new Color4 object
  79059. */
  79060. multiply(color: Color4): Color4;
  79061. /**
  79062. * Multipy a Color4 value by another and push the result in a reference value
  79063. * @param color defines the Color4 value to multiply by
  79064. * @param result defines the Color4 to fill the result in
  79065. * @returns the result Color4
  79066. */
  79067. multiplyToRef(color: Color4, result: Color4): Color4;
  79068. /**
  79069. * Creates a string with the Color4 current values
  79070. * @returns the string representation of the Color4 object
  79071. */
  79072. toString(): string;
  79073. /**
  79074. * Returns the string "Color4"
  79075. * @returns "Color4"
  79076. */
  79077. getClassName(): string;
  79078. /**
  79079. * Compute the Color4 hash code
  79080. * @returns an unique number that can be used to hash Color4 objects
  79081. */
  79082. getHashCode(): number;
  79083. /**
  79084. * Creates a new Color4 copied from the current one
  79085. * @returns a new Color4 object
  79086. */
  79087. clone(): Color4;
  79088. /**
  79089. * Copies the given Color4 values into the current one
  79090. * @param source defines the source Color4 object
  79091. * @returns the current updated Color4 object
  79092. */
  79093. copyFrom(source: Color4): Color4;
  79094. /**
  79095. * Copies the given float values into the current one
  79096. * @param r defines the red component to read from
  79097. * @param g defines the green component to read from
  79098. * @param b defines the blue component to read from
  79099. * @param a defines the alpha component to read from
  79100. * @returns the current updated Color4 object
  79101. */
  79102. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  79103. /**
  79104. * Copies the given float values into the current one
  79105. * @param r defines the red component to read from
  79106. * @param g defines the green component to read from
  79107. * @param b defines the blue component to read from
  79108. * @param a defines the alpha component to read from
  79109. * @returns the current updated Color4 object
  79110. */
  79111. set(r: number, g: number, b: number, a: number): Color4;
  79112. /**
  79113. * Compute the Color4 hexadecimal code as a string
  79114. * @returns a string containing the hexadecimal representation of the Color4 object
  79115. */
  79116. toHexString(): string;
  79117. /**
  79118. * Computes a new Color4 converted from the current one to linear space
  79119. * @returns a new Color4 object
  79120. */
  79121. toLinearSpace(): Color4;
  79122. /**
  79123. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  79124. * @param convertedColor defines the Color4 object where to store the linear space version
  79125. * @returns the unmodified Color4
  79126. */
  79127. toLinearSpaceToRef(convertedColor: Color4): Color4;
  79128. /**
  79129. * Computes a new Color4 converted from the current one to gamma space
  79130. * @returns a new Color4 object
  79131. */
  79132. toGammaSpace(): Color4;
  79133. /**
  79134. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  79135. * @param convertedColor defines the Color4 object where to store the gamma space version
  79136. * @returns the unmodified Color4
  79137. */
  79138. toGammaSpaceToRef(convertedColor: Color4): Color4;
  79139. /**
  79140. * Creates a new Color4 from the string containing valid hexadecimal values
  79141. * @param hex defines a string containing valid hexadecimal values
  79142. * @returns a new Color4 object
  79143. */
  79144. static FromHexString(hex: string): Color4;
  79145. /**
  79146. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  79147. * @param left defines the start value
  79148. * @param right defines the end value
  79149. * @param amount defines the gradient factor
  79150. * @returns a new Color4 object
  79151. */
  79152. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  79153. /**
  79154. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  79155. * @param left defines the start value
  79156. * @param right defines the end value
  79157. * @param amount defines the gradient factor
  79158. * @param result defines the Color4 object where to store data
  79159. */
  79160. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  79161. /**
  79162. * Creates a new Color4 from a Color3 and an alpha value
  79163. * @param color3 defines the source Color3 to read from
  79164. * @param alpha defines the alpha component (1.0 by default)
  79165. * @returns a new Color4 object
  79166. */
  79167. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  79168. /**
  79169. * Creates a new Color4 from the starting index element of the given array
  79170. * @param array defines the source array to read from
  79171. * @param offset defines the offset in the source array
  79172. * @returns a new Color4 object
  79173. */
  79174. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  79175. /**
  79176. * Creates a new Color3 from integer values (< 256)
  79177. * @param r defines the red component to read from (value between 0 and 255)
  79178. * @param g defines the green component to read from (value between 0 and 255)
  79179. * @param b defines the blue component to read from (value between 0 and 255)
  79180. * @param a defines the alpha component to read from (value between 0 and 255)
  79181. * @returns a new Color3 object
  79182. */
  79183. static FromInts(r: number, g: number, b: number, a: number): Color4;
  79184. /**
  79185. * Check the content of a given array and convert it to an array containing RGBA data
  79186. * If the original array was already containing count * 4 values then it is returned directly
  79187. * @param colors defines the array to check
  79188. * @param count defines the number of RGBA data to expect
  79189. * @returns an array containing count * 4 values (RGBA)
  79190. */
  79191. static CheckColors4(colors: number[], count: number): number[];
  79192. }
  79193. /**
  79194. * @hidden
  79195. */
  79196. export class TmpColors {
  79197. static Color3: Color3[];
  79198. static Color4: Color4[];
  79199. }
  79200. }
  79201. declare module BABYLON {
  79202. /**
  79203. * Defines an interface which represents an animation key frame
  79204. */
  79205. export interface IAnimationKey {
  79206. /**
  79207. * Frame of the key frame
  79208. */
  79209. frame: number;
  79210. /**
  79211. * Value at the specifies key frame
  79212. */
  79213. value: any;
  79214. /**
  79215. * The input tangent for the cubic hermite spline
  79216. */
  79217. inTangent?: any;
  79218. /**
  79219. * The output tangent for the cubic hermite spline
  79220. */
  79221. outTangent?: any;
  79222. /**
  79223. * The animation interpolation type
  79224. */
  79225. interpolation?: AnimationKeyInterpolation;
  79226. }
  79227. /**
  79228. * Enum for the animation key frame interpolation type
  79229. */
  79230. export enum AnimationKeyInterpolation {
  79231. /**
  79232. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  79233. */
  79234. STEP = 1
  79235. }
  79236. }
  79237. declare module BABYLON {
  79238. /**
  79239. * Represents the range of an animation
  79240. */
  79241. export class AnimationRange {
  79242. /**The name of the animation range**/
  79243. name: string;
  79244. /**The starting frame of the animation */
  79245. from: number;
  79246. /**The ending frame of the animation*/
  79247. to: number;
  79248. /**
  79249. * Initializes the range of an animation
  79250. * @param name The name of the animation range
  79251. * @param from The starting frame of the animation
  79252. * @param to The ending frame of the animation
  79253. */
  79254. constructor(
  79255. /**The name of the animation range**/
  79256. name: string,
  79257. /**The starting frame of the animation */
  79258. from: number,
  79259. /**The ending frame of the animation*/
  79260. to: number);
  79261. /**
  79262. * Makes a copy of the animation range
  79263. * @returns A copy of the animation range
  79264. */
  79265. clone(): AnimationRange;
  79266. }
  79267. }
  79268. declare module BABYLON {
  79269. /**
  79270. * Composed of a frame, and an action function
  79271. */
  79272. export class AnimationEvent {
  79273. /** The frame for which the event is triggered **/
  79274. frame: number;
  79275. /** The event to perform when triggered **/
  79276. action: (currentFrame: number) => void;
  79277. /** Specifies if the event should be triggered only once**/
  79278. onlyOnce?: boolean | undefined;
  79279. /**
  79280. * Specifies if the animation event is done
  79281. */
  79282. isDone: boolean;
  79283. /**
  79284. * Initializes the animation event
  79285. * @param frame The frame for which the event is triggered
  79286. * @param action The event to perform when triggered
  79287. * @param onlyOnce Specifies if the event should be triggered only once
  79288. */
  79289. constructor(
  79290. /** The frame for which the event is triggered **/
  79291. frame: number,
  79292. /** The event to perform when triggered **/
  79293. action: (currentFrame: number) => void,
  79294. /** Specifies if the event should be triggered only once**/
  79295. onlyOnce?: boolean | undefined);
  79296. /** @hidden */
  79297. _clone(): AnimationEvent;
  79298. }
  79299. }
  79300. declare module BABYLON {
  79301. /**
  79302. * Interface used to define a behavior
  79303. */
  79304. export interface Behavior<T> {
  79305. /** gets or sets behavior's name */
  79306. name: string;
  79307. /**
  79308. * Function called when the behavior needs to be initialized (after attaching it to a target)
  79309. */
  79310. init(): void;
  79311. /**
  79312. * Called when the behavior is attached to a target
  79313. * @param target defines the target where the behavior is attached to
  79314. */
  79315. attach(target: T): void;
  79316. /**
  79317. * Called when the behavior is detached from its target
  79318. */
  79319. detach(): void;
  79320. }
  79321. /**
  79322. * Interface implemented by classes supporting behaviors
  79323. */
  79324. export interface IBehaviorAware<T> {
  79325. /**
  79326. * Attach a behavior
  79327. * @param behavior defines the behavior to attach
  79328. * @returns the current host
  79329. */
  79330. addBehavior(behavior: Behavior<T>): T;
  79331. /**
  79332. * Remove a behavior from the current object
  79333. * @param behavior defines the behavior to detach
  79334. * @returns the current host
  79335. */
  79336. removeBehavior(behavior: Behavior<T>): T;
  79337. /**
  79338. * Gets a behavior using its name to search
  79339. * @param name defines the name to search
  79340. * @returns the behavior or null if not found
  79341. */
  79342. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  79343. }
  79344. }
  79345. declare module BABYLON {
  79346. /**
  79347. * Defines an array and its length.
  79348. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  79349. */
  79350. export interface ISmartArrayLike<T> {
  79351. /**
  79352. * The data of the array.
  79353. */
  79354. data: Array<T>;
  79355. /**
  79356. * The active length of the array.
  79357. */
  79358. length: number;
  79359. }
  79360. /**
  79361. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  79362. */
  79363. export class SmartArray<T> implements ISmartArrayLike<T> {
  79364. /**
  79365. * The full set of data from the array.
  79366. */
  79367. data: Array<T>;
  79368. /**
  79369. * The active length of the array.
  79370. */
  79371. length: number;
  79372. protected _id: number;
  79373. /**
  79374. * Instantiates a Smart Array.
  79375. * @param capacity defines the default capacity of the array.
  79376. */
  79377. constructor(capacity: number);
  79378. /**
  79379. * Pushes a value at the end of the active data.
  79380. * @param value defines the object to push in the array.
  79381. */
  79382. push(value: T): void;
  79383. /**
  79384. * Iterates over the active data and apply the lambda to them.
  79385. * @param func defines the action to apply on each value.
  79386. */
  79387. forEach(func: (content: T) => void): void;
  79388. /**
  79389. * Sorts the full sets of data.
  79390. * @param compareFn defines the comparison function to apply.
  79391. */
  79392. sort(compareFn: (a: T, b: T) => number): void;
  79393. /**
  79394. * Resets the active data to an empty array.
  79395. */
  79396. reset(): void;
  79397. /**
  79398. * Releases all the data from the array as well as the array.
  79399. */
  79400. dispose(): void;
  79401. /**
  79402. * Concats the active data with a given array.
  79403. * @param array defines the data to concatenate with.
  79404. */
  79405. concat(array: any): void;
  79406. /**
  79407. * Returns the position of a value in the active data.
  79408. * @param value defines the value to find the index for
  79409. * @returns the index if found in the active data otherwise -1
  79410. */
  79411. indexOf(value: T): number;
  79412. /**
  79413. * Returns whether an element is part of the active data.
  79414. * @param value defines the value to look for
  79415. * @returns true if found in the active data otherwise false
  79416. */
  79417. contains(value: T): boolean;
  79418. private static _GlobalId;
  79419. }
  79420. /**
  79421. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  79422. * The data in this array can only be present once
  79423. */
  79424. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  79425. private _duplicateId;
  79426. /**
  79427. * Pushes a value at the end of the active data.
  79428. * THIS DOES NOT PREVENT DUPPLICATE DATA
  79429. * @param value defines the object to push in the array.
  79430. */
  79431. push(value: T): void;
  79432. /**
  79433. * Pushes a value at the end of the active data.
  79434. * If the data is already present, it won t be added again
  79435. * @param value defines the object to push in the array.
  79436. * @returns true if added false if it was already present
  79437. */
  79438. pushNoDuplicate(value: T): boolean;
  79439. /**
  79440. * Resets the active data to an empty array.
  79441. */
  79442. reset(): void;
  79443. /**
  79444. * Concats the active data with a given array.
  79445. * This ensures no dupplicate will be present in the result.
  79446. * @param array defines the data to concatenate with.
  79447. */
  79448. concatWithNoDuplicate(array: any): void;
  79449. }
  79450. }
  79451. declare module BABYLON {
  79452. /**
  79453. * @ignore
  79454. * This is a list of all the different input types that are available in the application.
  79455. * Fo instance: ArcRotateCameraGamepadInput...
  79456. */
  79457. export var CameraInputTypes: {};
  79458. /**
  79459. * This is the contract to implement in order to create a new input class.
  79460. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  79461. */
  79462. export interface ICameraInput<TCamera extends Camera> {
  79463. /**
  79464. * Defines the camera the input is attached to.
  79465. */
  79466. camera: Nullable<TCamera>;
  79467. /**
  79468. * Gets the class name of the current intput.
  79469. * @returns the class name
  79470. */
  79471. getClassName(): string;
  79472. /**
  79473. * Get the friendly name associated with the input class.
  79474. * @returns the input friendly name
  79475. */
  79476. getSimpleName(): string;
  79477. /**
  79478. * Attach the input controls to a specific dom element to get the input from.
  79479. * @param element Defines the element the controls should be listened from
  79480. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79481. */
  79482. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79483. /**
  79484. * Detach the current controls from the specified dom element.
  79485. * @param element Defines the element to stop listening the inputs from
  79486. */
  79487. detachControl(element: Nullable<HTMLElement>): void;
  79488. /**
  79489. * Update the current camera state depending on the inputs that have been used this frame.
  79490. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79491. */
  79492. checkInputs?: () => void;
  79493. }
  79494. /**
  79495. * Represents a map of input types to input instance or input index to input instance.
  79496. */
  79497. export interface CameraInputsMap<TCamera extends Camera> {
  79498. /**
  79499. * Accessor to the input by input type.
  79500. */
  79501. [name: string]: ICameraInput<TCamera>;
  79502. /**
  79503. * Accessor to the input by input index.
  79504. */
  79505. [idx: number]: ICameraInput<TCamera>;
  79506. }
  79507. /**
  79508. * This represents the input manager used within a camera.
  79509. * It helps dealing with all the different kind of input attached to a camera.
  79510. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79511. */
  79512. export class CameraInputsManager<TCamera extends Camera> {
  79513. /**
  79514. * Defines the list of inputs attahed to the camera.
  79515. */
  79516. attached: CameraInputsMap<TCamera>;
  79517. /**
  79518. * Defines the dom element the camera is collecting inputs from.
  79519. * This is null if the controls have not been attached.
  79520. */
  79521. attachedElement: Nullable<HTMLElement>;
  79522. /**
  79523. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79524. */
  79525. noPreventDefault: boolean;
  79526. /**
  79527. * Defined the camera the input manager belongs to.
  79528. */
  79529. camera: TCamera;
  79530. /**
  79531. * Update the current camera state depending on the inputs that have been used this frame.
  79532. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79533. */
  79534. checkInputs: () => void;
  79535. /**
  79536. * Instantiate a new Camera Input Manager.
  79537. * @param camera Defines the camera the input manager blongs to
  79538. */
  79539. constructor(camera: TCamera);
  79540. /**
  79541. * Add an input method to a camera
  79542. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79543. * @param input camera input method
  79544. */
  79545. add(input: ICameraInput<TCamera>): void;
  79546. /**
  79547. * Remove a specific input method from a camera
  79548. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  79549. * @param inputToRemove camera input method
  79550. */
  79551. remove(inputToRemove: ICameraInput<TCamera>): void;
  79552. /**
  79553. * Remove a specific input type from a camera
  79554. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  79555. * @param inputType the type of the input to remove
  79556. */
  79557. removeByType(inputType: string): void;
  79558. private _addCheckInputs;
  79559. /**
  79560. * Attach the input controls to the currently attached dom element to listen the events from.
  79561. * @param input Defines the input to attach
  79562. */
  79563. attachInput(input: ICameraInput<TCamera>): void;
  79564. /**
  79565. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  79566. * @param element Defines the dom element to collect the events from
  79567. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79568. */
  79569. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  79570. /**
  79571. * Detach the current manager inputs controls from a specific dom element.
  79572. * @param element Defines the dom element to collect the events from
  79573. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  79574. */
  79575. detachElement(element: HTMLElement, disconnect?: boolean): void;
  79576. /**
  79577. * Rebuild the dynamic inputCheck function from the current list of
  79578. * defined inputs in the manager.
  79579. */
  79580. rebuildInputCheck(): void;
  79581. /**
  79582. * Remove all attached input methods from a camera
  79583. */
  79584. clear(): void;
  79585. /**
  79586. * Serialize the current input manager attached to a camera.
  79587. * This ensures than once parsed,
  79588. * the input associated to the camera will be identical to the current ones
  79589. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  79590. */
  79591. serialize(serializedCamera: any): void;
  79592. /**
  79593. * Parses an input manager serialized JSON to restore the previous list of inputs
  79594. * and states associated to a camera.
  79595. * @param parsedCamera Defines the JSON to parse
  79596. */
  79597. parse(parsedCamera: any): void;
  79598. }
  79599. }
  79600. declare module BABYLON {
  79601. /**
  79602. * Class used to store data that will be store in GPU memory
  79603. */
  79604. export class Buffer {
  79605. private _engine;
  79606. private _buffer;
  79607. /** @hidden */
  79608. _data: Nullable<DataArray>;
  79609. private _updatable;
  79610. private _instanced;
  79611. private _divisor;
  79612. /**
  79613. * Gets the byte stride.
  79614. */
  79615. readonly byteStride: number;
  79616. /**
  79617. * Constructor
  79618. * @param engine the engine
  79619. * @param data the data to use for this buffer
  79620. * @param updatable whether the data is updatable
  79621. * @param stride the stride (optional)
  79622. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  79623. * @param instanced whether the buffer is instanced (optional)
  79624. * @param useBytes set to true if the stride in in bytes (optional)
  79625. * @param divisor sets an optional divisor for instances (1 by default)
  79626. */
  79627. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  79628. /**
  79629. * Create a new VertexBuffer based on the current buffer
  79630. * @param kind defines the vertex buffer kind (position, normal, etc.)
  79631. * @param offset defines offset in the buffer (0 by default)
  79632. * @param size defines the size in floats of attributes (position is 3 for instance)
  79633. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  79634. * @param instanced defines if the vertex buffer contains indexed data
  79635. * @param useBytes defines if the offset and stride are in bytes *
  79636. * @param divisor sets an optional divisor for instances (1 by default)
  79637. * @returns the new vertex buffer
  79638. */
  79639. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  79640. /**
  79641. * Gets a boolean indicating if the Buffer is updatable?
  79642. * @returns true if the buffer is updatable
  79643. */
  79644. isUpdatable(): boolean;
  79645. /**
  79646. * Gets current buffer's data
  79647. * @returns a DataArray or null
  79648. */
  79649. getData(): Nullable<DataArray>;
  79650. /**
  79651. * Gets underlying native buffer
  79652. * @returns underlying native buffer
  79653. */
  79654. getBuffer(): Nullable<DataBuffer>;
  79655. /**
  79656. * Gets the stride in float32 units (i.e. byte stride / 4).
  79657. * May not be an integer if the byte stride is not divisible by 4.
  79658. * @returns the stride in float32 units
  79659. * @deprecated Please use byteStride instead.
  79660. */
  79661. getStrideSize(): number;
  79662. /**
  79663. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  79664. * @param data defines the data to store
  79665. */
  79666. create(data?: Nullable<DataArray>): void;
  79667. /** @hidden */
  79668. _rebuild(): void;
  79669. /**
  79670. * Update current buffer data
  79671. * @param data defines the data to store
  79672. */
  79673. update(data: DataArray): void;
  79674. /**
  79675. * Updates the data directly.
  79676. * @param data the new data
  79677. * @param offset the new offset
  79678. * @param vertexCount the vertex count (optional)
  79679. * @param useBytes set to true if the offset is in bytes
  79680. */
  79681. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  79682. /**
  79683. * Release all resources
  79684. */
  79685. dispose(): void;
  79686. }
  79687. /**
  79688. * Specialized buffer used to store vertex data
  79689. */
  79690. export class VertexBuffer {
  79691. /** @hidden */
  79692. _buffer: Buffer;
  79693. private _kind;
  79694. private _size;
  79695. private _ownsBuffer;
  79696. private _instanced;
  79697. private _instanceDivisor;
  79698. /**
  79699. * The byte type.
  79700. */
  79701. static readonly BYTE: number;
  79702. /**
  79703. * The unsigned byte type.
  79704. */
  79705. static readonly UNSIGNED_BYTE: number;
  79706. /**
  79707. * The short type.
  79708. */
  79709. static readonly SHORT: number;
  79710. /**
  79711. * The unsigned short type.
  79712. */
  79713. static readonly UNSIGNED_SHORT: number;
  79714. /**
  79715. * The integer type.
  79716. */
  79717. static readonly INT: number;
  79718. /**
  79719. * The unsigned integer type.
  79720. */
  79721. static readonly UNSIGNED_INT: number;
  79722. /**
  79723. * The float type.
  79724. */
  79725. static readonly FLOAT: number;
  79726. /**
  79727. * Gets or sets the instance divisor when in instanced mode
  79728. */
  79729. get instanceDivisor(): number;
  79730. set instanceDivisor(value: number);
  79731. /**
  79732. * Gets the byte stride.
  79733. */
  79734. readonly byteStride: number;
  79735. /**
  79736. * Gets the byte offset.
  79737. */
  79738. readonly byteOffset: number;
  79739. /**
  79740. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  79741. */
  79742. readonly normalized: boolean;
  79743. /**
  79744. * Gets the data type of each component in the array.
  79745. */
  79746. readonly type: number;
  79747. /**
  79748. * Constructor
  79749. * @param engine the engine
  79750. * @param data the data to use for this vertex buffer
  79751. * @param kind the vertex buffer kind
  79752. * @param updatable whether the data is updatable
  79753. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  79754. * @param stride the stride (optional)
  79755. * @param instanced whether the buffer is instanced (optional)
  79756. * @param offset the offset of the data (optional)
  79757. * @param size the number of components (optional)
  79758. * @param type the type of the component (optional)
  79759. * @param normalized whether the data contains normalized data (optional)
  79760. * @param useBytes set to true if stride and offset are in bytes (optional)
  79761. * @param divisor defines the instance divisor to use (1 by default)
  79762. */
  79763. 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);
  79764. /** @hidden */
  79765. _rebuild(): void;
  79766. /**
  79767. * Returns the kind of the VertexBuffer (string)
  79768. * @returns a string
  79769. */
  79770. getKind(): string;
  79771. /**
  79772. * Gets a boolean indicating if the VertexBuffer is updatable?
  79773. * @returns true if the buffer is updatable
  79774. */
  79775. isUpdatable(): boolean;
  79776. /**
  79777. * Gets current buffer's data
  79778. * @returns a DataArray or null
  79779. */
  79780. getData(): Nullable<DataArray>;
  79781. /**
  79782. * Gets underlying native buffer
  79783. * @returns underlying native buffer
  79784. */
  79785. getBuffer(): Nullable<DataBuffer>;
  79786. /**
  79787. * Gets the stride in float32 units (i.e. byte stride / 4).
  79788. * May not be an integer if the byte stride is not divisible by 4.
  79789. * @returns the stride in float32 units
  79790. * @deprecated Please use byteStride instead.
  79791. */
  79792. getStrideSize(): number;
  79793. /**
  79794. * Returns the offset as a multiple of the type byte length.
  79795. * @returns the offset in bytes
  79796. * @deprecated Please use byteOffset instead.
  79797. */
  79798. getOffset(): number;
  79799. /**
  79800. * Returns the number of components per vertex attribute (integer)
  79801. * @returns the size in float
  79802. */
  79803. getSize(): number;
  79804. /**
  79805. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  79806. * @returns true if this buffer is instanced
  79807. */
  79808. getIsInstanced(): boolean;
  79809. /**
  79810. * Returns the instancing divisor, zero for non-instanced (integer).
  79811. * @returns a number
  79812. */
  79813. getInstanceDivisor(): number;
  79814. /**
  79815. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  79816. * @param data defines the data to store
  79817. */
  79818. create(data?: DataArray): void;
  79819. /**
  79820. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  79821. * This function will create a new buffer if the current one is not updatable
  79822. * @param data defines the data to store
  79823. */
  79824. update(data: DataArray): void;
  79825. /**
  79826. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  79827. * Returns the directly updated WebGLBuffer.
  79828. * @param data the new data
  79829. * @param offset the new offset
  79830. * @param useBytes set to true if the offset is in bytes
  79831. */
  79832. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  79833. /**
  79834. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  79835. */
  79836. dispose(): void;
  79837. /**
  79838. * Enumerates each value of this vertex buffer as numbers.
  79839. * @param count the number of values to enumerate
  79840. * @param callback the callback function called for each value
  79841. */
  79842. forEach(count: number, callback: (value: number, index: number) => void): void;
  79843. /**
  79844. * Positions
  79845. */
  79846. static readonly PositionKind: string;
  79847. /**
  79848. * Normals
  79849. */
  79850. static readonly NormalKind: string;
  79851. /**
  79852. * Tangents
  79853. */
  79854. static readonly TangentKind: string;
  79855. /**
  79856. * Texture coordinates
  79857. */
  79858. static readonly UVKind: string;
  79859. /**
  79860. * Texture coordinates 2
  79861. */
  79862. static readonly UV2Kind: string;
  79863. /**
  79864. * Texture coordinates 3
  79865. */
  79866. static readonly UV3Kind: string;
  79867. /**
  79868. * Texture coordinates 4
  79869. */
  79870. static readonly UV4Kind: string;
  79871. /**
  79872. * Texture coordinates 5
  79873. */
  79874. static readonly UV5Kind: string;
  79875. /**
  79876. * Texture coordinates 6
  79877. */
  79878. static readonly UV6Kind: string;
  79879. /**
  79880. * Colors
  79881. */
  79882. static readonly ColorKind: string;
  79883. /**
  79884. * Matrix indices (for bones)
  79885. */
  79886. static readonly MatricesIndicesKind: string;
  79887. /**
  79888. * Matrix weights (for bones)
  79889. */
  79890. static readonly MatricesWeightsKind: string;
  79891. /**
  79892. * Additional matrix indices (for bones)
  79893. */
  79894. static readonly MatricesIndicesExtraKind: string;
  79895. /**
  79896. * Additional matrix weights (for bones)
  79897. */
  79898. static readonly MatricesWeightsExtraKind: string;
  79899. /**
  79900. * Deduces the stride given a kind.
  79901. * @param kind The kind string to deduce
  79902. * @returns The deduced stride
  79903. */
  79904. static DeduceStride(kind: string): number;
  79905. /**
  79906. * Gets the byte length of the given type.
  79907. * @param type the type
  79908. * @returns the number of bytes
  79909. */
  79910. static GetTypeByteLength(type: number): number;
  79911. /**
  79912. * Enumerates each value of the given parameters as numbers.
  79913. * @param data the data to enumerate
  79914. * @param byteOffset the byte offset of the data
  79915. * @param byteStride the byte stride of the data
  79916. * @param componentCount the number of components per element
  79917. * @param componentType the type of the component
  79918. * @param count the number of values to enumerate
  79919. * @param normalized whether the data is normalized
  79920. * @param callback the callback function called for each value
  79921. */
  79922. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  79923. private static _GetFloatValue;
  79924. }
  79925. }
  79926. declare module BABYLON {
  79927. /**
  79928. * @hidden
  79929. */
  79930. export class IntersectionInfo {
  79931. bu: Nullable<number>;
  79932. bv: Nullable<number>;
  79933. distance: number;
  79934. faceId: number;
  79935. subMeshId: number;
  79936. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  79937. }
  79938. }
  79939. declare module BABYLON {
  79940. /**
  79941. * Represens a plane by the equation ax + by + cz + d = 0
  79942. */
  79943. export class Plane {
  79944. private static _TmpMatrix;
  79945. /**
  79946. * Normal of the plane (a,b,c)
  79947. */
  79948. normal: Vector3;
  79949. /**
  79950. * d component of the plane
  79951. */
  79952. d: number;
  79953. /**
  79954. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  79955. * @param a a component of the plane
  79956. * @param b b component of the plane
  79957. * @param c c component of the plane
  79958. * @param d d component of the plane
  79959. */
  79960. constructor(a: number, b: number, c: number, d: number);
  79961. /**
  79962. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  79963. */
  79964. asArray(): number[];
  79965. /**
  79966. * @returns a new plane copied from the current Plane.
  79967. */
  79968. clone(): Plane;
  79969. /**
  79970. * @returns the string "Plane".
  79971. */
  79972. getClassName(): string;
  79973. /**
  79974. * @returns the Plane hash code.
  79975. */
  79976. getHashCode(): number;
  79977. /**
  79978. * Normalize the current Plane in place.
  79979. * @returns the updated Plane.
  79980. */
  79981. normalize(): Plane;
  79982. /**
  79983. * Applies a transformation the plane and returns the result
  79984. * @param transformation the transformation matrix to be applied to the plane
  79985. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  79986. */
  79987. transform(transformation: DeepImmutable<Matrix>): Plane;
  79988. /**
  79989. * Calcualtte the dot product between the point and the plane normal
  79990. * @param point point to calculate the dot product with
  79991. * @returns the dot product (float) of the point coordinates and the plane normal.
  79992. */
  79993. dotCoordinate(point: DeepImmutable<Vector3>): number;
  79994. /**
  79995. * Updates the current Plane from the plane defined by the three given points.
  79996. * @param point1 one of the points used to contruct the plane
  79997. * @param point2 one of the points used to contruct the plane
  79998. * @param point3 one of the points used to contruct the plane
  79999. * @returns the updated Plane.
  80000. */
  80001. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80002. /**
  80003. * Checks if the plane is facing a given direction
  80004. * @param direction the direction to check if the plane is facing
  80005. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  80006. * @returns True is the vector "direction" is the same side than the plane normal.
  80007. */
  80008. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  80009. /**
  80010. * Calculates the distance to a point
  80011. * @param point point to calculate distance to
  80012. * @returns the signed distance (float) from the given point to the Plane.
  80013. */
  80014. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  80015. /**
  80016. * Creates a plane from an array
  80017. * @param array the array to create a plane from
  80018. * @returns a new Plane from the given array.
  80019. */
  80020. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  80021. /**
  80022. * Creates a plane from three points
  80023. * @param point1 point used to create the plane
  80024. * @param point2 point used to create the plane
  80025. * @param point3 point used to create the plane
  80026. * @returns a new Plane defined by the three given points.
  80027. */
  80028. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80029. /**
  80030. * Creates a plane from an origin point and a normal
  80031. * @param origin origin of the plane to be constructed
  80032. * @param normal normal of the plane to be constructed
  80033. * @returns a new Plane the normal vector to this plane at the given origin point.
  80034. * Note : the vector "normal" is updated because normalized.
  80035. */
  80036. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  80037. /**
  80038. * Calculates the distance from a plane and a point
  80039. * @param origin origin of the plane to be constructed
  80040. * @param normal normal of the plane to be constructed
  80041. * @param point point to calculate distance to
  80042. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  80043. */
  80044. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  80045. }
  80046. }
  80047. declare module BABYLON {
  80048. /**
  80049. * Class used to store bounding sphere information
  80050. */
  80051. export class BoundingSphere {
  80052. /**
  80053. * Gets the center of the bounding sphere in local space
  80054. */
  80055. readonly center: Vector3;
  80056. /**
  80057. * Radius of the bounding sphere in local space
  80058. */
  80059. radius: number;
  80060. /**
  80061. * Gets the center of the bounding sphere in world space
  80062. */
  80063. readonly centerWorld: Vector3;
  80064. /**
  80065. * Radius of the bounding sphere in world space
  80066. */
  80067. radiusWorld: number;
  80068. /**
  80069. * Gets the minimum vector in local space
  80070. */
  80071. readonly minimum: Vector3;
  80072. /**
  80073. * Gets the maximum vector in local space
  80074. */
  80075. readonly maximum: Vector3;
  80076. private _worldMatrix;
  80077. private static readonly TmpVector3;
  80078. /**
  80079. * Creates a new bounding sphere
  80080. * @param min defines the minimum vector (in local space)
  80081. * @param max defines the maximum vector (in local space)
  80082. * @param worldMatrix defines the new world matrix
  80083. */
  80084. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80085. /**
  80086. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  80087. * @param min defines the new minimum vector (in local space)
  80088. * @param max defines the new maximum vector (in local space)
  80089. * @param worldMatrix defines the new world matrix
  80090. */
  80091. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80092. /**
  80093. * Scale the current bounding sphere by applying a scale factor
  80094. * @param factor defines the scale factor to apply
  80095. * @returns the current bounding box
  80096. */
  80097. scale(factor: number): BoundingSphere;
  80098. /**
  80099. * Gets the world matrix of the bounding box
  80100. * @returns a matrix
  80101. */
  80102. getWorldMatrix(): DeepImmutable<Matrix>;
  80103. /** @hidden */
  80104. _update(worldMatrix: DeepImmutable<Matrix>): void;
  80105. /**
  80106. * Tests if the bounding sphere is intersecting the frustum planes
  80107. * @param frustumPlanes defines the frustum planes to test
  80108. * @returns true if there is an intersection
  80109. */
  80110. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80111. /**
  80112. * Tests if the bounding sphere center is in between the frustum planes.
  80113. * Used for optimistic fast inclusion.
  80114. * @param frustumPlanes defines the frustum planes to test
  80115. * @returns true if the sphere center is in between the frustum planes
  80116. */
  80117. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80118. /**
  80119. * Tests if a point is inside the bounding sphere
  80120. * @param point defines the point to test
  80121. * @returns true if the point is inside the bounding sphere
  80122. */
  80123. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80124. /**
  80125. * Checks if two sphere intersct
  80126. * @param sphere0 sphere 0
  80127. * @param sphere1 sphere 1
  80128. * @returns true if the speres intersect
  80129. */
  80130. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  80131. }
  80132. }
  80133. declare module BABYLON {
  80134. /**
  80135. * Class used to store bounding box information
  80136. */
  80137. export class BoundingBox implements ICullable {
  80138. /**
  80139. * Gets the 8 vectors representing the bounding box in local space
  80140. */
  80141. readonly vectors: Vector3[];
  80142. /**
  80143. * Gets the center of the bounding box in local space
  80144. */
  80145. readonly center: Vector3;
  80146. /**
  80147. * Gets the center of the bounding box in world space
  80148. */
  80149. readonly centerWorld: Vector3;
  80150. /**
  80151. * Gets the extend size in local space
  80152. */
  80153. readonly extendSize: Vector3;
  80154. /**
  80155. * Gets the extend size in world space
  80156. */
  80157. readonly extendSizeWorld: Vector3;
  80158. /**
  80159. * Gets the OBB (object bounding box) directions
  80160. */
  80161. readonly directions: Vector3[];
  80162. /**
  80163. * Gets the 8 vectors representing the bounding box in world space
  80164. */
  80165. readonly vectorsWorld: Vector3[];
  80166. /**
  80167. * Gets the minimum vector in world space
  80168. */
  80169. readonly minimumWorld: Vector3;
  80170. /**
  80171. * Gets the maximum vector in world space
  80172. */
  80173. readonly maximumWorld: Vector3;
  80174. /**
  80175. * Gets the minimum vector in local space
  80176. */
  80177. readonly minimum: Vector3;
  80178. /**
  80179. * Gets the maximum vector in local space
  80180. */
  80181. readonly maximum: Vector3;
  80182. private _worldMatrix;
  80183. private static readonly TmpVector3;
  80184. /**
  80185. * @hidden
  80186. */
  80187. _tag: number;
  80188. /**
  80189. * Creates a new bounding box
  80190. * @param min defines the minimum vector (in local space)
  80191. * @param max defines the maximum vector (in local space)
  80192. * @param worldMatrix defines the new world matrix
  80193. */
  80194. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80195. /**
  80196. * Recreates the entire bounding box from scratch as if we call the constructor in place
  80197. * @param min defines the new minimum vector (in local space)
  80198. * @param max defines the new maximum vector (in local space)
  80199. * @param worldMatrix defines the new world matrix
  80200. */
  80201. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80202. /**
  80203. * Scale the current bounding box by applying a scale factor
  80204. * @param factor defines the scale factor to apply
  80205. * @returns the current bounding box
  80206. */
  80207. scale(factor: number): BoundingBox;
  80208. /**
  80209. * Gets the world matrix of the bounding box
  80210. * @returns a matrix
  80211. */
  80212. getWorldMatrix(): DeepImmutable<Matrix>;
  80213. /** @hidden */
  80214. _update(world: DeepImmutable<Matrix>): void;
  80215. /**
  80216. * Tests if the bounding box is intersecting the frustum planes
  80217. * @param frustumPlanes defines the frustum planes to test
  80218. * @returns true if there is an intersection
  80219. */
  80220. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80221. /**
  80222. * Tests if the bounding box is entirely inside the frustum planes
  80223. * @param frustumPlanes defines the frustum planes to test
  80224. * @returns true if there is an inclusion
  80225. */
  80226. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80227. /**
  80228. * Tests if a point is inside the bounding box
  80229. * @param point defines the point to test
  80230. * @returns true if the point is inside the bounding box
  80231. */
  80232. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80233. /**
  80234. * Tests if the bounding box intersects with a bounding sphere
  80235. * @param sphere defines the sphere to test
  80236. * @returns true if there is an intersection
  80237. */
  80238. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  80239. /**
  80240. * Tests if the bounding box intersects with a box defined by a min and max vectors
  80241. * @param min defines the min vector to use
  80242. * @param max defines the max vector to use
  80243. * @returns true if there is an intersection
  80244. */
  80245. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  80246. /**
  80247. * Tests if two bounding boxes are intersections
  80248. * @param box0 defines the first box to test
  80249. * @param box1 defines the second box to test
  80250. * @returns true if there is an intersection
  80251. */
  80252. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  80253. /**
  80254. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  80255. * @param minPoint defines the minimum vector of the bounding box
  80256. * @param maxPoint defines the maximum vector of the bounding box
  80257. * @param sphereCenter defines the sphere center
  80258. * @param sphereRadius defines the sphere radius
  80259. * @returns true if there is an intersection
  80260. */
  80261. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  80262. /**
  80263. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  80264. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  80265. * @param frustumPlanes defines the frustum planes to test
  80266. * @return true if there is an inclusion
  80267. */
  80268. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80269. /**
  80270. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  80271. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  80272. * @param frustumPlanes defines the frustum planes to test
  80273. * @return true if there is an intersection
  80274. */
  80275. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80276. }
  80277. }
  80278. declare module BABYLON {
  80279. /** @hidden */
  80280. export class Collider {
  80281. /** Define if a collision was found */
  80282. collisionFound: boolean;
  80283. /**
  80284. * Define last intersection point in local space
  80285. */
  80286. intersectionPoint: Vector3;
  80287. /**
  80288. * Define last collided mesh
  80289. */
  80290. collidedMesh: Nullable<AbstractMesh>;
  80291. private _collisionPoint;
  80292. private _planeIntersectionPoint;
  80293. private _tempVector;
  80294. private _tempVector2;
  80295. private _tempVector3;
  80296. private _tempVector4;
  80297. private _edge;
  80298. private _baseToVertex;
  80299. private _destinationPoint;
  80300. private _slidePlaneNormal;
  80301. private _displacementVector;
  80302. /** @hidden */
  80303. _radius: Vector3;
  80304. /** @hidden */
  80305. _retry: number;
  80306. private _velocity;
  80307. private _basePoint;
  80308. private _epsilon;
  80309. /** @hidden */
  80310. _velocityWorldLength: number;
  80311. /** @hidden */
  80312. _basePointWorld: Vector3;
  80313. private _velocityWorld;
  80314. private _normalizedVelocity;
  80315. /** @hidden */
  80316. _initialVelocity: Vector3;
  80317. /** @hidden */
  80318. _initialPosition: Vector3;
  80319. private _nearestDistance;
  80320. private _collisionMask;
  80321. get collisionMask(): number;
  80322. set collisionMask(mask: number);
  80323. /**
  80324. * Gets the plane normal used to compute the sliding response (in local space)
  80325. */
  80326. get slidePlaneNormal(): Vector3;
  80327. /** @hidden */
  80328. _initialize(source: Vector3, dir: Vector3, e: number): void;
  80329. /** @hidden */
  80330. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  80331. /** @hidden */
  80332. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  80333. /** @hidden */
  80334. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  80335. /** @hidden */
  80336. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  80337. /** @hidden */
  80338. _getResponse(pos: Vector3, vel: Vector3): void;
  80339. }
  80340. }
  80341. declare module BABYLON {
  80342. /**
  80343. * Interface for cullable objects
  80344. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  80345. */
  80346. export interface ICullable {
  80347. /**
  80348. * Checks if the object or part of the object is in the frustum
  80349. * @param frustumPlanes Camera near/planes
  80350. * @returns true if the object is in frustum otherwise false
  80351. */
  80352. isInFrustum(frustumPlanes: Plane[]): boolean;
  80353. /**
  80354. * Checks if a cullable object (mesh...) is in the camera frustum
  80355. * Unlike isInFrustum this cheks the full bounding box
  80356. * @param frustumPlanes Camera near/planes
  80357. * @returns true if the object is in frustum otherwise false
  80358. */
  80359. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  80360. }
  80361. /**
  80362. * Info for a bounding data of a mesh
  80363. */
  80364. export class BoundingInfo implements ICullable {
  80365. /**
  80366. * Bounding box for the mesh
  80367. */
  80368. readonly boundingBox: BoundingBox;
  80369. /**
  80370. * Bounding sphere for the mesh
  80371. */
  80372. readonly boundingSphere: BoundingSphere;
  80373. private _isLocked;
  80374. private static readonly TmpVector3;
  80375. /**
  80376. * Constructs bounding info
  80377. * @param minimum min vector of the bounding box/sphere
  80378. * @param maximum max vector of the bounding box/sphere
  80379. * @param worldMatrix defines the new world matrix
  80380. */
  80381. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80382. /**
  80383. * Recreates the entire bounding info from scratch as if we call the constructor in place
  80384. * @param min defines the new minimum vector (in local space)
  80385. * @param max defines the new maximum vector (in local space)
  80386. * @param worldMatrix defines the new world matrix
  80387. */
  80388. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80389. /**
  80390. * min vector of the bounding box/sphere
  80391. */
  80392. get minimum(): Vector3;
  80393. /**
  80394. * max vector of the bounding box/sphere
  80395. */
  80396. get maximum(): Vector3;
  80397. /**
  80398. * If the info is locked and won't be updated to avoid perf overhead
  80399. */
  80400. get isLocked(): boolean;
  80401. set isLocked(value: boolean);
  80402. /**
  80403. * Updates the bounding sphere and box
  80404. * @param world world matrix to be used to update
  80405. */
  80406. update(world: DeepImmutable<Matrix>): void;
  80407. /**
  80408. * Recreate the bounding info to be centered around a specific point given a specific extend.
  80409. * @param center New center of the bounding info
  80410. * @param extend New extend of the bounding info
  80411. * @returns the current bounding info
  80412. */
  80413. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  80414. /**
  80415. * Scale the current bounding info by applying a scale factor
  80416. * @param factor defines the scale factor to apply
  80417. * @returns the current bounding info
  80418. */
  80419. scale(factor: number): BoundingInfo;
  80420. /**
  80421. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  80422. * @param frustumPlanes defines the frustum to test
  80423. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  80424. * @returns true if the bounding info is in the frustum planes
  80425. */
  80426. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  80427. /**
  80428. * Gets the world distance between the min and max points of the bounding box
  80429. */
  80430. get diagonalLength(): number;
  80431. /**
  80432. * Checks if a cullable object (mesh...) is in the camera frustum
  80433. * Unlike isInFrustum this cheks the full bounding box
  80434. * @param frustumPlanes Camera near/planes
  80435. * @returns true if the object is in frustum otherwise false
  80436. */
  80437. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80438. /** @hidden */
  80439. _checkCollision(collider: Collider): boolean;
  80440. /**
  80441. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  80442. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  80443. * @param point the point to check intersection with
  80444. * @returns if the point intersects
  80445. */
  80446. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80447. /**
  80448. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  80449. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  80450. * @param boundingInfo the bounding info to check intersection with
  80451. * @param precise if the intersection should be done using OBB
  80452. * @returns if the bounding info intersects
  80453. */
  80454. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  80455. }
  80456. }
  80457. declare module BABYLON {
  80458. /**
  80459. * Extracts minimum and maximum values from a list of indexed positions
  80460. * @param positions defines the positions to use
  80461. * @param indices defines the indices to the positions
  80462. * @param indexStart defines the start index
  80463. * @param indexCount defines the end index
  80464. * @param bias defines bias value to add to the result
  80465. * @return minimum and maximum values
  80466. */
  80467. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  80468. minimum: Vector3;
  80469. maximum: Vector3;
  80470. };
  80471. /**
  80472. * Extracts minimum and maximum values from a list of positions
  80473. * @param positions defines the positions to use
  80474. * @param start defines the start index in the positions array
  80475. * @param count defines the number of positions to handle
  80476. * @param bias defines bias value to add to the result
  80477. * @param stride defines the stride size to use (distance between two positions in the positions array)
  80478. * @return minimum and maximum values
  80479. */
  80480. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  80481. minimum: Vector3;
  80482. maximum: Vector3;
  80483. };
  80484. }
  80485. declare module BABYLON {
  80486. /** @hidden */
  80487. export class WebGLDataBuffer extends DataBuffer {
  80488. private _buffer;
  80489. constructor(resource: WebGLBuffer);
  80490. get underlyingResource(): any;
  80491. }
  80492. }
  80493. declare module BABYLON {
  80494. /** @hidden */
  80495. export class WebGLPipelineContext implements IPipelineContext {
  80496. engine: ThinEngine;
  80497. program: Nullable<WebGLProgram>;
  80498. context?: WebGLRenderingContext;
  80499. vertexShader?: WebGLShader;
  80500. fragmentShader?: WebGLShader;
  80501. isParallelCompiled: boolean;
  80502. onCompiled?: () => void;
  80503. transformFeedback?: WebGLTransformFeedback | null;
  80504. vertexCompilationError: Nullable<string>;
  80505. fragmentCompilationError: Nullable<string>;
  80506. programLinkError: Nullable<string>;
  80507. programValidationError: Nullable<string>;
  80508. get isAsync(): boolean;
  80509. get isReady(): boolean;
  80510. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  80511. }
  80512. }
  80513. declare module BABYLON {
  80514. interface ThinEngine {
  80515. /**
  80516. * Create an uniform buffer
  80517. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80518. * @param elements defines the content of the uniform buffer
  80519. * @returns the webGL uniform buffer
  80520. */
  80521. createUniformBuffer(elements: FloatArray): DataBuffer;
  80522. /**
  80523. * Create a dynamic uniform buffer
  80524. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80525. * @param elements defines the content of the uniform buffer
  80526. * @returns the webGL uniform buffer
  80527. */
  80528. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  80529. /**
  80530. * Update an existing uniform buffer
  80531. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80532. * @param uniformBuffer defines the target uniform buffer
  80533. * @param elements defines the content to update
  80534. * @param offset defines the offset in the uniform buffer where update should start
  80535. * @param count defines the size of the data to update
  80536. */
  80537. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  80538. /**
  80539. * Bind an uniform buffer to the current webGL context
  80540. * @param buffer defines the buffer to bind
  80541. */
  80542. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  80543. /**
  80544. * Bind a buffer to the current webGL context at a given location
  80545. * @param buffer defines the buffer to bind
  80546. * @param location defines the index where to bind the buffer
  80547. */
  80548. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  80549. /**
  80550. * Bind a specific block at a given index in a specific shader program
  80551. * @param pipelineContext defines the pipeline context to use
  80552. * @param blockName defines the block name
  80553. * @param index defines the index where to bind the block
  80554. */
  80555. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  80556. }
  80557. }
  80558. declare module BABYLON {
  80559. /**
  80560. * Uniform buffer objects.
  80561. *
  80562. * Handles blocks of uniform on the GPU.
  80563. *
  80564. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  80565. *
  80566. * For more information, please refer to :
  80567. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  80568. */
  80569. export class UniformBuffer {
  80570. private _engine;
  80571. private _buffer;
  80572. private _data;
  80573. private _bufferData;
  80574. private _dynamic?;
  80575. private _uniformLocations;
  80576. private _uniformSizes;
  80577. private _uniformLocationPointer;
  80578. private _needSync;
  80579. private _noUBO;
  80580. private _currentEffect;
  80581. /** @hidden */
  80582. _alreadyBound: boolean;
  80583. private static _MAX_UNIFORM_SIZE;
  80584. private static _tempBuffer;
  80585. /**
  80586. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  80587. * This is dynamic to allow compat with webgl 1 and 2.
  80588. * You will need to pass the name of the uniform as well as the value.
  80589. */
  80590. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  80591. /**
  80592. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  80593. * This is dynamic to allow compat with webgl 1 and 2.
  80594. * You will need to pass the name of the uniform as well as the value.
  80595. */
  80596. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  80597. /**
  80598. * Lambda to Update a single float in a uniform buffer.
  80599. * This is dynamic to allow compat with webgl 1 and 2.
  80600. * You will need to pass the name of the uniform as well as the value.
  80601. */
  80602. updateFloat: (name: string, x: number) => void;
  80603. /**
  80604. * Lambda to Update a vec2 of float in a uniform buffer.
  80605. * This is dynamic to allow compat with webgl 1 and 2.
  80606. * You will need to pass the name of the uniform as well as the value.
  80607. */
  80608. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  80609. /**
  80610. * Lambda to Update a vec3 of float in a uniform buffer.
  80611. * This is dynamic to allow compat with webgl 1 and 2.
  80612. * You will need to pass the name of the uniform as well as the value.
  80613. */
  80614. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  80615. /**
  80616. * Lambda to Update a vec4 of float in a uniform buffer.
  80617. * This is dynamic to allow compat with webgl 1 and 2.
  80618. * You will need to pass the name of the uniform as well as the value.
  80619. */
  80620. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  80621. /**
  80622. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  80623. * This is dynamic to allow compat with webgl 1 and 2.
  80624. * You will need to pass the name of the uniform as well as the value.
  80625. */
  80626. updateMatrix: (name: string, mat: Matrix) => void;
  80627. /**
  80628. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  80629. * This is dynamic to allow compat with webgl 1 and 2.
  80630. * You will need to pass the name of the uniform as well as the value.
  80631. */
  80632. updateVector3: (name: string, vector: Vector3) => void;
  80633. /**
  80634. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  80635. * This is dynamic to allow compat with webgl 1 and 2.
  80636. * You will need to pass the name of the uniform as well as the value.
  80637. */
  80638. updateVector4: (name: string, vector: Vector4) => void;
  80639. /**
  80640. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  80641. * This is dynamic to allow compat with webgl 1 and 2.
  80642. * You will need to pass the name of the uniform as well as the value.
  80643. */
  80644. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  80645. /**
  80646. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  80647. * This is dynamic to allow compat with webgl 1 and 2.
  80648. * You will need to pass the name of the uniform as well as the value.
  80649. */
  80650. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  80651. /**
  80652. * Instantiates a new Uniform buffer objects.
  80653. *
  80654. * Handles blocks of uniform on the GPU.
  80655. *
  80656. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  80657. *
  80658. * For more information, please refer to :
  80659. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  80660. * @param engine Define the engine the buffer is associated with
  80661. * @param data Define the data contained in the buffer
  80662. * @param dynamic Define if the buffer is updatable
  80663. */
  80664. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  80665. /**
  80666. * Indicates if the buffer is using the WebGL2 UBO implementation,
  80667. * or just falling back on setUniformXXX calls.
  80668. */
  80669. get useUbo(): boolean;
  80670. /**
  80671. * Indicates if the WebGL underlying uniform buffer is in sync
  80672. * with the javascript cache data.
  80673. */
  80674. get isSync(): boolean;
  80675. /**
  80676. * Indicates if the WebGL underlying uniform buffer is dynamic.
  80677. * Also, a dynamic UniformBuffer will disable cache verification and always
  80678. * update the underlying WebGL uniform buffer to the GPU.
  80679. * @returns if Dynamic, otherwise false
  80680. */
  80681. isDynamic(): boolean;
  80682. /**
  80683. * The data cache on JS side.
  80684. * @returns the underlying data as a float array
  80685. */
  80686. getData(): Float32Array;
  80687. /**
  80688. * The underlying WebGL Uniform buffer.
  80689. * @returns the webgl buffer
  80690. */
  80691. getBuffer(): Nullable<DataBuffer>;
  80692. /**
  80693. * std140 layout specifies how to align data within an UBO structure.
  80694. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  80695. * for specs.
  80696. */
  80697. private _fillAlignment;
  80698. /**
  80699. * Adds an uniform in the buffer.
  80700. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  80701. * for the layout to be correct !
  80702. * @param name Name of the uniform, as used in the uniform block in the shader.
  80703. * @param size Data size, or data directly.
  80704. */
  80705. addUniform(name: string, size: number | number[]): void;
  80706. /**
  80707. * Adds a Matrix 4x4 to the uniform buffer.
  80708. * @param name Name of the uniform, as used in the uniform block in the shader.
  80709. * @param mat A 4x4 matrix.
  80710. */
  80711. addMatrix(name: string, mat: Matrix): void;
  80712. /**
  80713. * Adds a vec2 to the uniform buffer.
  80714. * @param name Name of the uniform, as used in the uniform block in the shader.
  80715. * @param x Define the x component value of the vec2
  80716. * @param y Define the y component value of the vec2
  80717. */
  80718. addFloat2(name: string, x: number, y: number): void;
  80719. /**
  80720. * Adds a vec3 to the uniform buffer.
  80721. * @param name Name of the uniform, as used in the uniform block in the shader.
  80722. * @param x Define the x component value of the vec3
  80723. * @param y Define the y component value of the vec3
  80724. * @param z Define the z component value of the vec3
  80725. */
  80726. addFloat3(name: string, x: number, y: number, z: number): void;
  80727. /**
  80728. * Adds a vec3 to the uniform buffer.
  80729. * @param name Name of the uniform, as used in the uniform block in the shader.
  80730. * @param color Define the vec3 from a Color
  80731. */
  80732. addColor3(name: string, color: Color3): void;
  80733. /**
  80734. * Adds a vec4 to the uniform buffer.
  80735. * @param name Name of the uniform, as used in the uniform block in the shader.
  80736. * @param color Define the rgb components from a Color
  80737. * @param alpha Define the a component of the vec4
  80738. */
  80739. addColor4(name: string, color: Color3, alpha: number): void;
  80740. /**
  80741. * Adds a vec3 to the uniform buffer.
  80742. * @param name Name of the uniform, as used in the uniform block in the shader.
  80743. * @param vector Define the vec3 components from a Vector
  80744. */
  80745. addVector3(name: string, vector: Vector3): void;
  80746. /**
  80747. * Adds a Matrix 3x3 to the uniform buffer.
  80748. * @param name Name of the uniform, as used in the uniform block in the shader.
  80749. */
  80750. addMatrix3x3(name: string): void;
  80751. /**
  80752. * Adds a Matrix 2x2 to the uniform buffer.
  80753. * @param name Name of the uniform, as used in the uniform block in the shader.
  80754. */
  80755. addMatrix2x2(name: string): void;
  80756. /**
  80757. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  80758. */
  80759. create(): void;
  80760. /** @hidden */
  80761. _rebuild(): void;
  80762. /**
  80763. * Updates the WebGL Uniform Buffer on the GPU.
  80764. * If the `dynamic` flag is set to true, no cache comparison is done.
  80765. * Otherwise, the buffer will be updated only if the cache differs.
  80766. */
  80767. update(): void;
  80768. /**
  80769. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  80770. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  80771. * @param data Define the flattened data
  80772. * @param size Define the size of the data.
  80773. */
  80774. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  80775. private _valueCache;
  80776. private _cacheMatrix;
  80777. private _updateMatrix3x3ForUniform;
  80778. private _updateMatrix3x3ForEffect;
  80779. private _updateMatrix2x2ForEffect;
  80780. private _updateMatrix2x2ForUniform;
  80781. private _updateFloatForEffect;
  80782. private _updateFloatForUniform;
  80783. private _updateFloat2ForEffect;
  80784. private _updateFloat2ForUniform;
  80785. private _updateFloat3ForEffect;
  80786. private _updateFloat3ForUniform;
  80787. private _updateFloat4ForEffect;
  80788. private _updateFloat4ForUniform;
  80789. private _updateMatrixForEffect;
  80790. private _updateMatrixForUniform;
  80791. private _updateVector3ForEffect;
  80792. private _updateVector3ForUniform;
  80793. private _updateVector4ForEffect;
  80794. private _updateVector4ForUniform;
  80795. private _updateColor3ForEffect;
  80796. private _updateColor3ForUniform;
  80797. private _updateColor4ForEffect;
  80798. private _updateColor4ForUniform;
  80799. /**
  80800. * Sets a sampler uniform on the effect.
  80801. * @param name Define the name of the sampler.
  80802. * @param texture Define the texture to set in the sampler
  80803. */
  80804. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  80805. /**
  80806. * Directly updates the value of the uniform in the cache AND on the GPU.
  80807. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  80808. * @param data Define the flattened data
  80809. */
  80810. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  80811. /**
  80812. * Binds this uniform buffer to an effect.
  80813. * @param effect Define the effect to bind the buffer to
  80814. * @param name Name of the uniform block in the shader.
  80815. */
  80816. bindToEffect(effect: Effect, name: string): void;
  80817. /**
  80818. * Disposes the uniform buffer.
  80819. */
  80820. dispose(): void;
  80821. }
  80822. }
  80823. declare module BABYLON {
  80824. /**
  80825. * Enum that determines the text-wrapping mode to use.
  80826. */
  80827. export enum InspectableType {
  80828. /**
  80829. * Checkbox for booleans
  80830. */
  80831. Checkbox = 0,
  80832. /**
  80833. * Sliders for numbers
  80834. */
  80835. Slider = 1,
  80836. /**
  80837. * Vector3
  80838. */
  80839. Vector3 = 2,
  80840. /**
  80841. * Quaternions
  80842. */
  80843. Quaternion = 3,
  80844. /**
  80845. * Color3
  80846. */
  80847. Color3 = 4,
  80848. /**
  80849. * String
  80850. */
  80851. String = 5
  80852. }
  80853. /**
  80854. * Interface used to define custom inspectable properties.
  80855. * This interface is used by the inspector to display custom property grids
  80856. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80857. */
  80858. export interface IInspectable {
  80859. /**
  80860. * Gets the label to display
  80861. */
  80862. label: string;
  80863. /**
  80864. * Gets the name of the property to edit
  80865. */
  80866. propertyName: string;
  80867. /**
  80868. * Gets the type of the editor to use
  80869. */
  80870. type: InspectableType;
  80871. /**
  80872. * Gets the minimum value of the property when using in "slider" mode
  80873. */
  80874. min?: number;
  80875. /**
  80876. * Gets the maximum value of the property when using in "slider" mode
  80877. */
  80878. max?: number;
  80879. /**
  80880. * Gets the setp to use when using in "slider" mode
  80881. */
  80882. step?: number;
  80883. }
  80884. }
  80885. declare module BABYLON {
  80886. /**
  80887. * Class used to provide helper for timing
  80888. */
  80889. export class TimingTools {
  80890. /**
  80891. * Polyfill for setImmediate
  80892. * @param action defines the action to execute after the current execution block
  80893. */
  80894. static SetImmediate(action: () => void): void;
  80895. }
  80896. }
  80897. declare module BABYLON {
  80898. /**
  80899. * Class used to enable instatition of objects by class name
  80900. */
  80901. export class InstantiationTools {
  80902. /**
  80903. * Use this object to register external classes like custom textures or material
  80904. * to allow the laoders to instantiate them
  80905. */
  80906. static RegisteredExternalClasses: {
  80907. [key: string]: Object;
  80908. };
  80909. /**
  80910. * Tries to instantiate a new object from a given class name
  80911. * @param className defines the class name to instantiate
  80912. * @returns the new object or null if the system was not able to do the instantiation
  80913. */
  80914. static Instantiate(className: string): any;
  80915. }
  80916. }
  80917. declare module BABYLON {
  80918. /**
  80919. * Define options used to create a depth texture
  80920. */
  80921. export class DepthTextureCreationOptions {
  80922. /** Specifies whether or not a stencil should be allocated in the texture */
  80923. generateStencil?: boolean;
  80924. /** Specifies whether or not bilinear filtering is enable on the texture */
  80925. bilinearFiltering?: boolean;
  80926. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  80927. comparisonFunction?: number;
  80928. /** Specifies if the created texture is a cube texture */
  80929. isCube?: boolean;
  80930. }
  80931. }
  80932. declare module BABYLON {
  80933. interface ThinEngine {
  80934. /**
  80935. * Creates a depth stencil cube texture.
  80936. * This is only available in WebGL 2.
  80937. * @param size The size of face edge in the cube texture.
  80938. * @param options The options defining the cube texture.
  80939. * @returns The cube texture
  80940. */
  80941. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  80942. /**
  80943. * Creates a cube texture
  80944. * @param rootUrl defines the url where the files to load is located
  80945. * @param scene defines the current scene
  80946. * @param files defines the list of files to load (1 per face)
  80947. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80948. * @param onLoad defines an optional callback raised when the texture is loaded
  80949. * @param onError defines an optional callback raised if there is an issue to load the texture
  80950. * @param format defines the format of the data
  80951. * @param forcedExtension defines the extension to use to pick the right loader
  80952. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  80953. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  80954. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  80955. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  80956. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  80957. * @returns the cube texture as an InternalTexture
  80958. */
  80959. 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;
  80960. /**
  80961. * Creates a cube texture
  80962. * @param rootUrl defines the url where the files to load is located
  80963. * @param scene defines the current scene
  80964. * @param files defines the list of files to load (1 per face)
  80965. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80966. * @param onLoad defines an optional callback raised when the texture is loaded
  80967. * @param onError defines an optional callback raised if there is an issue to load the texture
  80968. * @param format defines the format of the data
  80969. * @param forcedExtension defines the extension to use to pick the right loader
  80970. * @returns the cube texture as an InternalTexture
  80971. */
  80972. 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;
  80973. /**
  80974. * Creates a cube texture
  80975. * @param rootUrl defines the url where the files to load is located
  80976. * @param scene defines the current scene
  80977. * @param files defines the list of files to load (1 per face)
  80978. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80979. * @param onLoad defines an optional callback raised when the texture is loaded
  80980. * @param onError defines an optional callback raised if there is an issue to load the texture
  80981. * @param format defines the format of the data
  80982. * @param forcedExtension defines the extension to use to pick the right loader
  80983. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  80984. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  80985. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  80986. * @returns the cube texture as an InternalTexture
  80987. */
  80988. 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;
  80989. /** @hidden */
  80990. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  80991. /** @hidden */
  80992. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  80993. /** @hidden */
  80994. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  80995. /** @hidden */
  80996. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  80997. /**
  80998. * @hidden
  80999. */
  81000. _setCubeMapTextureParams(loadMipmap: boolean): void;
  81001. }
  81002. }
  81003. declare module BABYLON {
  81004. /**
  81005. * Class for creating a cube texture
  81006. */
  81007. export class CubeTexture extends BaseTexture {
  81008. private _delayedOnLoad;
  81009. /**
  81010. * Observable triggered once the texture has been loaded.
  81011. */
  81012. onLoadObservable: Observable<CubeTexture>;
  81013. /**
  81014. * The url of the texture
  81015. */
  81016. url: string;
  81017. /**
  81018. * Gets or sets the center of the bounding box associated with the cube texture.
  81019. * It must define where the camera used to render the texture was set
  81020. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  81021. */
  81022. boundingBoxPosition: Vector3;
  81023. private _boundingBoxSize;
  81024. /**
  81025. * Gets or sets the size of the bounding box associated with the cube texture
  81026. * When defined, the cubemap will switch to local mode
  81027. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  81028. * @example https://www.babylonjs-playground.com/#RNASML
  81029. */
  81030. set boundingBoxSize(value: Vector3);
  81031. /**
  81032. * Returns the bounding box size
  81033. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  81034. */
  81035. get boundingBoxSize(): Vector3;
  81036. protected _rotationY: number;
  81037. /**
  81038. * Sets texture matrix rotation angle around Y axis in radians.
  81039. */
  81040. set rotationY(value: number);
  81041. /**
  81042. * Gets texture matrix rotation angle around Y axis radians.
  81043. */
  81044. get rotationY(): number;
  81045. /**
  81046. * Are mip maps generated for this texture or not.
  81047. */
  81048. get noMipmap(): boolean;
  81049. private _noMipmap;
  81050. private _files;
  81051. protected _forcedExtension: Nullable<string>;
  81052. private _extensions;
  81053. private _textureMatrix;
  81054. private _format;
  81055. private _createPolynomials;
  81056. /** @hidden */
  81057. _prefiltered: boolean;
  81058. /**
  81059. * Creates a cube texture from an array of image urls
  81060. * @param files defines an array of image urls
  81061. * @param scene defines the hosting scene
  81062. * @param noMipmap specifies if mip maps are not used
  81063. * @returns a cube texture
  81064. */
  81065. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  81066. /**
  81067. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  81068. * @param url defines the url of the prefiltered texture
  81069. * @param scene defines the scene the texture is attached to
  81070. * @param forcedExtension defines the extension of the file if different from the url
  81071. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  81072. * @return the prefiltered texture
  81073. */
  81074. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  81075. /**
  81076. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  81077. * as prefiltered data.
  81078. * @param rootUrl defines the url of the texture or the root name of the six images
  81079. * @param scene defines the scene the texture is attached to
  81080. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  81081. * @param noMipmap defines if mipmaps should be created or not
  81082. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  81083. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  81084. * @param onError defines a callback triggered in case of error during load
  81085. * @param format defines the internal format to use for the texture once loaded
  81086. * @param prefiltered defines whether or not the texture is created from prefiltered data
  81087. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  81088. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  81089. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  81090. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  81091. * @return the cube texture
  81092. */
  81093. 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);
  81094. /**
  81095. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  81096. */
  81097. get isPrefiltered(): boolean;
  81098. /**
  81099. * Get the current class name of the texture useful for serialization or dynamic coding.
  81100. * @returns "CubeTexture"
  81101. */
  81102. getClassName(): string;
  81103. /**
  81104. * Update the url (and optional buffer) of this texture if url was null during construction.
  81105. * @param url the url of the texture
  81106. * @param forcedExtension defines the extension to use
  81107. * @param onLoad callback called when the texture is loaded (defaults to null)
  81108. * @param prefiltered Defines whether the updated texture is prefiltered or not
  81109. */
  81110. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  81111. /**
  81112. * Delays loading of the cube texture
  81113. * @param forcedExtension defines the extension to use
  81114. */
  81115. delayLoad(forcedExtension?: string): void;
  81116. /**
  81117. * Returns the reflection texture matrix
  81118. * @returns the reflection texture matrix
  81119. */
  81120. getReflectionTextureMatrix(): Matrix;
  81121. /**
  81122. * Sets the reflection texture matrix
  81123. * @param value Reflection texture matrix
  81124. */
  81125. setReflectionTextureMatrix(value: Matrix): void;
  81126. /**
  81127. * Parses text to create a cube texture
  81128. * @param parsedTexture define the serialized text to read from
  81129. * @param scene defines the hosting scene
  81130. * @param rootUrl defines the root url of the cube texture
  81131. * @returns a cube texture
  81132. */
  81133. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  81134. /**
  81135. * Makes a clone, or deep copy, of the cube texture
  81136. * @returns a new cube texture
  81137. */
  81138. clone(): CubeTexture;
  81139. }
  81140. }
  81141. declare module BABYLON {
  81142. /**
  81143. * Manages the defines for the Material
  81144. */
  81145. export class MaterialDefines {
  81146. /** @hidden */
  81147. protected _keys: string[];
  81148. private _isDirty;
  81149. /** @hidden */
  81150. _renderId: number;
  81151. /** @hidden */
  81152. _areLightsDirty: boolean;
  81153. /** @hidden */
  81154. _areLightsDisposed: boolean;
  81155. /** @hidden */
  81156. _areAttributesDirty: boolean;
  81157. /** @hidden */
  81158. _areTexturesDirty: boolean;
  81159. /** @hidden */
  81160. _areFresnelDirty: boolean;
  81161. /** @hidden */
  81162. _areMiscDirty: boolean;
  81163. /** @hidden */
  81164. _areImageProcessingDirty: boolean;
  81165. /** @hidden */
  81166. _normals: boolean;
  81167. /** @hidden */
  81168. _uvs: boolean;
  81169. /** @hidden */
  81170. _needNormals: boolean;
  81171. /** @hidden */
  81172. _needUVs: boolean;
  81173. [id: string]: any;
  81174. /**
  81175. * Specifies if the material needs to be re-calculated
  81176. */
  81177. get isDirty(): boolean;
  81178. /**
  81179. * Marks the material to indicate that it has been re-calculated
  81180. */
  81181. markAsProcessed(): void;
  81182. /**
  81183. * Marks the material to indicate that it needs to be re-calculated
  81184. */
  81185. markAsUnprocessed(): void;
  81186. /**
  81187. * Marks the material to indicate all of its defines need to be re-calculated
  81188. */
  81189. markAllAsDirty(): void;
  81190. /**
  81191. * Marks the material to indicate that image processing needs to be re-calculated
  81192. */
  81193. markAsImageProcessingDirty(): void;
  81194. /**
  81195. * Marks the material to indicate the lights need to be re-calculated
  81196. * @param disposed Defines whether the light is dirty due to dispose or not
  81197. */
  81198. markAsLightDirty(disposed?: boolean): void;
  81199. /**
  81200. * Marks the attribute state as changed
  81201. */
  81202. markAsAttributesDirty(): void;
  81203. /**
  81204. * Marks the texture state as changed
  81205. */
  81206. markAsTexturesDirty(): void;
  81207. /**
  81208. * Marks the fresnel state as changed
  81209. */
  81210. markAsFresnelDirty(): void;
  81211. /**
  81212. * Marks the misc state as changed
  81213. */
  81214. markAsMiscDirty(): void;
  81215. /**
  81216. * Rebuilds the material defines
  81217. */
  81218. rebuild(): void;
  81219. /**
  81220. * Specifies if two material defines are equal
  81221. * @param other - A material define instance to compare to
  81222. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  81223. */
  81224. isEqual(other: MaterialDefines): boolean;
  81225. /**
  81226. * Clones this instance's defines to another instance
  81227. * @param other - material defines to clone values to
  81228. */
  81229. cloneTo(other: MaterialDefines): void;
  81230. /**
  81231. * Resets the material define values
  81232. */
  81233. reset(): void;
  81234. /**
  81235. * Converts the material define values to a string
  81236. * @returns - String of material define information
  81237. */
  81238. toString(): string;
  81239. }
  81240. }
  81241. declare module BABYLON {
  81242. /**
  81243. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  81244. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  81245. * 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;
  81246. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  81247. */
  81248. export class ColorCurves {
  81249. private _dirty;
  81250. private _tempColor;
  81251. private _globalCurve;
  81252. private _highlightsCurve;
  81253. private _midtonesCurve;
  81254. private _shadowsCurve;
  81255. private _positiveCurve;
  81256. private _negativeCurve;
  81257. private _globalHue;
  81258. private _globalDensity;
  81259. private _globalSaturation;
  81260. private _globalExposure;
  81261. /**
  81262. * Gets the global Hue value.
  81263. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  81264. */
  81265. get globalHue(): number;
  81266. /**
  81267. * Sets the global Hue value.
  81268. * 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).
  81269. */
  81270. set globalHue(value: number);
  81271. /**
  81272. * Gets the global Density value.
  81273. * 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.
  81274. * Values less than zero provide a filter of opposite hue.
  81275. */
  81276. get globalDensity(): number;
  81277. /**
  81278. * Sets the global Density value.
  81279. * 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.
  81280. * Values less than zero provide a filter of opposite hue.
  81281. */
  81282. set globalDensity(value: number);
  81283. /**
  81284. * Gets the global Saturation value.
  81285. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  81286. */
  81287. get globalSaturation(): number;
  81288. /**
  81289. * Sets the global Saturation value.
  81290. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  81291. */
  81292. set globalSaturation(value: number);
  81293. /**
  81294. * Gets the global Exposure value.
  81295. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  81296. */
  81297. get globalExposure(): number;
  81298. /**
  81299. * Sets the global Exposure value.
  81300. * 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.
  81301. */
  81302. set globalExposure(value: number);
  81303. private _highlightsHue;
  81304. private _highlightsDensity;
  81305. private _highlightsSaturation;
  81306. private _highlightsExposure;
  81307. /**
  81308. * Gets the highlights Hue value.
  81309. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  81310. */
  81311. get highlightsHue(): number;
  81312. /**
  81313. * Sets the highlights Hue value.
  81314. * 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).
  81315. */
  81316. set highlightsHue(value: number);
  81317. /**
  81318. * Gets the highlights Density value.
  81319. * 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.
  81320. * Values less than zero provide a filter of opposite hue.
  81321. */
  81322. get highlightsDensity(): number;
  81323. /**
  81324. * Sets the highlights Density value.
  81325. * 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.
  81326. * Values less than zero provide a filter of opposite hue.
  81327. */
  81328. set highlightsDensity(value: number);
  81329. /**
  81330. * Gets the highlights Saturation value.
  81331. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  81332. */
  81333. get highlightsSaturation(): number;
  81334. /**
  81335. * Sets the highlights Saturation value.
  81336. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  81337. */
  81338. set highlightsSaturation(value: number);
  81339. /**
  81340. * Gets the highlights Exposure value.
  81341. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  81342. */
  81343. get highlightsExposure(): number;
  81344. /**
  81345. * Sets the highlights Exposure value.
  81346. * 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.
  81347. */
  81348. set highlightsExposure(value: number);
  81349. private _midtonesHue;
  81350. private _midtonesDensity;
  81351. private _midtonesSaturation;
  81352. private _midtonesExposure;
  81353. /**
  81354. * Gets the midtones Hue value.
  81355. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  81356. */
  81357. get midtonesHue(): number;
  81358. /**
  81359. * Sets the midtones Hue value.
  81360. * 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).
  81361. */
  81362. set midtonesHue(value: number);
  81363. /**
  81364. * Gets the midtones Density value.
  81365. * 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.
  81366. * Values less than zero provide a filter of opposite hue.
  81367. */
  81368. get midtonesDensity(): number;
  81369. /**
  81370. * Sets the midtones Density value.
  81371. * 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.
  81372. * Values less than zero provide a filter of opposite hue.
  81373. */
  81374. set midtonesDensity(value: number);
  81375. /**
  81376. * Gets the midtones Saturation value.
  81377. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  81378. */
  81379. get midtonesSaturation(): number;
  81380. /**
  81381. * Sets the midtones Saturation value.
  81382. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  81383. */
  81384. set midtonesSaturation(value: number);
  81385. /**
  81386. * Gets the midtones Exposure value.
  81387. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  81388. */
  81389. get midtonesExposure(): number;
  81390. /**
  81391. * Sets the midtones Exposure value.
  81392. * 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.
  81393. */
  81394. set midtonesExposure(value: number);
  81395. private _shadowsHue;
  81396. private _shadowsDensity;
  81397. private _shadowsSaturation;
  81398. private _shadowsExposure;
  81399. /**
  81400. * Gets the shadows Hue value.
  81401. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  81402. */
  81403. get shadowsHue(): number;
  81404. /**
  81405. * Sets the shadows Hue value.
  81406. * 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).
  81407. */
  81408. set shadowsHue(value: number);
  81409. /**
  81410. * Gets the shadows Density value.
  81411. * 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.
  81412. * Values less than zero provide a filter of opposite hue.
  81413. */
  81414. get shadowsDensity(): number;
  81415. /**
  81416. * Sets the shadows Density value.
  81417. * 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.
  81418. * Values less than zero provide a filter of opposite hue.
  81419. */
  81420. set shadowsDensity(value: number);
  81421. /**
  81422. * Gets the shadows Saturation value.
  81423. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  81424. */
  81425. get shadowsSaturation(): number;
  81426. /**
  81427. * Sets the shadows Saturation value.
  81428. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  81429. */
  81430. set shadowsSaturation(value: number);
  81431. /**
  81432. * Gets the shadows Exposure value.
  81433. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  81434. */
  81435. get shadowsExposure(): number;
  81436. /**
  81437. * Sets the shadows Exposure value.
  81438. * 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.
  81439. */
  81440. set shadowsExposure(value: number);
  81441. /**
  81442. * Returns the class name
  81443. * @returns The class name
  81444. */
  81445. getClassName(): string;
  81446. /**
  81447. * Binds the color curves to the shader.
  81448. * @param colorCurves The color curve to bind
  81449. * @param effect The effect to bind to
  81450. * @param positiveUniform The positive uniform shader parameter
  81451. * @param neutralUniform The neutral uniform shader parameter
  81452. * @param negativeUniform The negative uniform shader parameter
  81453. */
  81454. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  81455. /**
  81456. * Prepare the list of uniforms associated with the ColorCurves effects.
  81457. * @param uniformsList The list of uniforms used in the effect
  81458. */
  81459. static PrepareUniforms(uniformsList: string[]): void;
  81460. /**
  81461. * Returns color grading data based on a hue, density, saturation and exposure value.
  81462. * @param filterHue The hue of the color filter.
  81463. * @param filterDensity The density of the color filter.
  81464. * @param saturation The saturation.
  81465. * @param exposure The exposure.
  81466. * @param result The result data container.
  81467. */
  81468. private getColorGradingDataToRef;
  81469. /**
  81470. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  81471. * @param value The input slider value in range [-100,100].
  81472. * @returns Adjusted value.
  81473. */
  81474. private static applyColorGradingSliderNonlinear;
  81475. /**
  81476. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  81477. * @param hue The hue (H) input.
  81478. * @param saturation The saturation (S) input.
  81479. * @param brightness The brightness (B) input.
  81480. * @result An RGBA color represented as Vector4.
  81481. */
  81482. private static fromHSBToRef;
  81483. /**
  81484. * Returns a value clamped between min and max
  81485. * @param value The value to clamp
  81486. * @param min The minimum of value
  81487. * @param max The maximum of value
  81488. * @returns The clamped value.
  81489. */
  81490. private static clamp;
  81491. /**
  81492. * Clones the current color curve instance.
  81493. * @return The cloned curves
  81494. */
  81495. clone(): ColorCurves;
  81496. /**
  81497. * Serializes the current color curve instance to a json representation.
  81498. * @return a JSON representation
  81499. */
  81500. serialize(): any;
  81501. /**
  81502. * Parses the color curve from a json representation.
  81503. * @param source the JSON source to parse
  81504. * @return The parsed curves
  81505. */
  81506. static Parse(source: any): ColorCurves;
  81507. }
  81508. }
  81509. declare module BABYLON {
  81510. /**
  81511. * Interface to follow in your material defines to integrate easily the
  81512. * Image proccessing functions.
  81513. * @hidden
  81514. */
  81515. export interface IImageProcessingConfigurationDefines {
  81516. IMAGEPROCESSING: boolean;
  81517. VIGNETTE: boolean;
  81518. VIGNETTEBLENDMODEMULTIPLY: boolean;
  81519. VIGNETTEBLENDMODEOPAQUE: boolean;
  81520. TONEMAPPING: boolean;
  81521. TONEMAPPING_ACES: boolean;
  81522. CONTRAST: boolean;
  81523. EXPOSURE: boolean;
  81524. COLORCURVES: boolean;
  81525. COLORGRADING: boolean;
  81526. COLORGRADING3D: boolean;
  81527. SAMPLER3DGREENDEPTH: boolean;
  81528. SAMPLER3DBGRMAP: boolean;
  81529. IMAGEPROCESSINGPOSTPROCESS: boolean;
  81530. }
  81531. /**
  81532. * @hidden
  81533. */
  81534. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  81535. IMAGEPROCESSING: boolean;
  81536. VIGNETTE: boolean;
  81537. VIGNETTEBLENDMODEMULTIPLY: boolean;
  81538. VIGNETTEBLENDMODEOPAQUE: boolean;
  81539. TONEMAPPING: boolean;
  81540. TONEMAPPING_ACES: boolean;
  81541. CONTRAST: boolean;
  81542. COLORCURVES: boolean;
  81543. COLORGRADING: boolean;
  81544. COLORGRADING3D: boolean;
  81545. SAMPLER3DGREENDEPTH: boolean;
  81546. SAMPLER3DBGRMAP: boolean;
  81547. IMAGEPROCESSINGPOSTPROCESS: boolean;
  81548. EXPOSURE: boolean;
  81549. constructor();
  81550. }
  81551. /**
  81552. * This groups together the common properties used for image processing either in direct forward pass
  81553. * or through post processing effect depending on the use of the image processing pipeline in your scene
  81554. * or not.
  81555. */
  81556. export class ImageProcessingConfiguration {
  81557. /**
  81558. * Default tone mapping applied in BabylonJS.
  81559. */
  81560. static readonly TONEMAPPING_STANDARD: number;
  81561. /**
  81562. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  81563. * to other engines rendering to increase portability.
  81564. */
  81565. static readonly TONEMAPPING_ACES: number;
  81566. /**
  81567. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  81568. */
  81569. colorCurves: Nullable<ColorCurves>;
  81570. private _colorCurvesEnabled;
  81571. /**
  81572. * Gets wether the color curves effect is enabled.
  81573. */
  81574. get colorCurvesEnabled(): boolean;
  81575. /**
  81576. * Sets wether the color curves effect is enabled.
  81577. */
  81578. set colorCurvesEnabled(value: boolean);
  81579. private _colorGradingTexture;
  81580. /**
  81581. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  81582. */
  81583. get colorGradingTexture(): Nullable<BaseTexture>;
  81584. /**
  81585. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  81586. */
  81587. set colorGradingTexture(value: Nullable<BaseTexture>);
  81588. private _colorGradingEnabled;
  81589. /**
  81590. * Gets wether the color grading effect is enabled.
  81591. */
  81592. get colorGradingEnabled(): boolean;
  81593. /**
  81594. * Sets wether the color grading effect is enabled.
  81595. */
  81596. set colorGradingEnabled(value: boolean);
  81597. private _colorGradingWithGreenDepth;
  81598. /**
  81599. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  81600. */
  81601. get colorGradingWithGreenDepth(): boolean;
  81602. /**
  81603. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  81604. */
  81605. set colorGradingWithGreenDepth(value: boolean);
  81606. private _colorGradingBGR;
  81607. /**
  81608. * Gets wether the color grading texture contains BGR values.
  81609. */
  81610. get colorGradingBGR(): boolean;
  81611. /**
  81612. * Sets wether the color grading texture contains BGR values.
  81613. */
  81614. set colorGradingBGR(value: boolean);
  81615. /** @hidden */
  81616. _exposure: number;
  81617. /**
  81618. * Gets the Exposure used in the effect.
  81619. */
  81620. get exposure(): number;
  81621. /**
  81622. * Sets the Exposure used in the effect.
  81623. */
  81624. set exposure(value: number);
  81625. private _toneMappingEnabled;
  81626. /**
  81627. * Gets wether the tone mapping effect is enabled.
  81628. */
  81629. get toneMappingEnabled(): boolean;
  81630. /**
  81631. * Sets wether the tone mapping effect is enabled.
  81632. */
  81633. set toneMappingEnabled(value: boolean);
  81634. private _toneMappingType;
  81635. /**
  81636. * Gets the type of tone mapping effect.
  81637. */
  81638. get toneMappingType(): number;
  81639. /**
  81640. * Sets the type of tone mapping effect used in BabylonJS.
  81641. */
  81642. set toneMappingType(value: number);
  81643. protected _contrast: number;
  81644. /**
  81645. * Gets the contrast used in the effect.
  81646. */
  81647. get contrast(): number;
  81648. /**
  81649. * Sets the contrast used in the effect.
  81650. */
  81651. set contrast(value: number);
  81652. /**
  81653. * Vignette stretch size.
  81654. */
  81655. vignetteStretch: number;
  81656. /**
  81657. * Vignette centre X Offset.
  81658. */
  81659. vignetteCentreX: number;
  81660. /**
  81661. * Vignette centre Y Offset.
  81662. */
  81663. vignetteCentreY: number;
  81664. /**
  81665. * Vignette weight or intensity of the vignette effect.
  81666. */
  81667. vignetteWeight: number;
  81668. /**
  81669. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  81670. * if vignetteEnabled is set to true.
  81671. */
  81672. vignetteColor: Color4;
  81673. /**
  81674. * Camera field of view used by the Vignette effect.
  81675. */
  81676. vignetteCameraFov: number;
  81677. private _vignetteBlendMode;
  81678. /**
  81679. * Gets the vignette blend mode allowing different kind of effect.
  81680. */
  81681. get vignetteBlendMode(): number;
  81682. /**
  81683. * Sets the vignette blend mode allowing different kind of effect.
  81684. */
  81685. set vignetteBlendMode(value: number);
  81686. private _vignetteEnabled;
  81687. /**
  81688. * Gets wether the vignette effect is enabled.
  81689. */
  81690. get vignetteEnabled(): boolean;
  81691. /**
  81692. * Sets wether the vignette effect is enabled.
  81693. */
  81694. set vignetteEnabled(value: boolean);
  81695. private _applyByPostProcess;
  81696. /**
  81697. * Gets wether the image processing is applied through a post process or not.
  81698. */
  81699. get applyByPostProcess(): boolean;
  81700. /**
  81701. * Sets wether the image processing is applied through a post process or not.
  81702. */
  81703. set applyByPostProcess(value: boolean);
  81704. private _isEnabled;
  81705. /**
  81706. * Gets wether the image processing is enabled or not.
  81707. */
  81708. get isEnabled(): boolean;
  81709. /**
  81710. * Sets wether the image processing is enabled or not.
  81711. */
  81712. set isEnabled(value: boolean);
  81713. /**
  81714. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  81715. */
  81716. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  81717. /**
  81718. * Method called each time the image processing information changes requires to recompile the effect.
  81719. */
  81720. protected _updateParameters(): void;
  81721. /**
  81722. * Gets the current class name.
  81723. * @return "ImageProcessingConfiguration"
  81724. */
  81725. getClassName(): string;
  81726. /**
  81727. * Prepare the list of uniforms associated with the Image Processing effects.
  81728. * @param uniforms The list of uniforms used in the effect
  81729. * @param defines the list of defines currently in use
  81730. */
  81731. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  81732. /**
  81733. * Prepare the list of samplers associated with the Image Processing effects.
  81734. * @param samplersList The list of uniforms used in the effect
  81735. * @param defines the list of defines currently in use
  81736. */
  81737. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  81738. /**
  81739. * Prepare the list of defines associated to the shader.
  81740. * @param defines the list of defines to complete
  81741. * @param forPostProcess Define if we are currently in post process mode or not
  81742. */
  81743. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  81744. /**
  81745. * Returns true if all the image processing information are ready.
  81746. * @returns True if ready, otherwise, false
  81747. */
  81748. isReady(): boolean;
  81749. /**
  81750. * Binds the image processing to the shader.
  81751. * @param effect The effect to bind to
  81752. * @param overrideAspectRatio Override the aspect ratio of the effect
  81753. */
  81754. bind(effect: Effect, overrideAspectRatio?: number): void;
  81755. /**
  81756. * Clones the current image processing instance.
  81757. * @return The cloned image processing
  81758. */
  81759. clone(): ImageProcessingConfiguration;
  81760. /**
  81761. * Serializes the current image processing instance to a json representation.
  81762. * @return a JSON representation
  81763. */
  81764. serialize(): any;
  81765. /**
  81766. * Parses the image processing from a json representation.
  81767. * @param source the JSON source to parse
  81768. * @return The parsed image processing
  81769. */
  81770. static Parse(source: any): ImageProcessingConfiguration;
  81771. private static _VIGNETTEMODE_MULTIPLY;
  81772. private static _VIGNETTEMODE_OPAQUE;
  81773. /**
  81774. * Used to apply the vignette as a mix with the pixel color.
  81775. */
  81776. static get VIGNETTEMODE_MULTIPLY(): number;
  81777. /**
  81778. * Used to apply the vignette as a replacement of the pixel color.
  81779. */
  81780. static get VIGNETTEMODE_OPAQUE(): number;
  81781. }
  81782. }
  81783. declare module BABYLON {
  81784. /** @hidden */
  81785. export var postprocessVertexShader: {
  81786. name: string;
  81787. shader: string;
  81788. };
  81789. }
  81790. declare module BABYLON {
  81791. interface ThinEngine {
  81792. /**
  81793. * Creates a new render target texture
  81794. * @param size defines the size of the texture
  81795. * @param options defines the options used to create the texture
  81796. * @returns a new render target texture stored in an InternalTexture
  81797. */
  81798. createRenderTargetTexture(size: number | {
  81799. width: number;
  81800. height: number;
  81801. layers?: number;
  81802. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  81803. /**
  81804. * Creates a depth stencil texture.
  81805. * This is only available in WebGL 2 or with the depth texture extension available.
  81806. * @param size The size of face edge in the texture.
  81807. * @param options The options defining the texture.
  81808. * @returns The texture
  81809. */
  81810. createDepthStencilTexture(size: number | {
  81811. width: number;
  81812. height: number;
  81813. layers?: number;
  81814. }, options: DepthTextureCreationOptions): InternalTexture;
  81815. /** @hidden */
  81816. _createDepthStencilTexture(size: number | {
  81817. width: number;
  81818. height: number;
  81819. layers?: number;
  81820. }, options: DepthTextureCreationOptions): InternalTexture;
  81821. }
  81822. }
  81823. declare module BABYLON {
  81824. /** Defines supported spaces */
  81825. export enum Space {
  81826. /** Local (object) space */
  81827. LOCAL = 0,
  81828. /** World space */
  81829. WORLD = 1,
  81830. /** Bone space */
  81831. BONE = 2
  81832. }
  81833. /** Defines the 3 main axes */
  81834. export class Axis {
  81835. /** X axis */
  81836. static X: Vector3;
  81837. /** Y axis */
  81838. static Y: Vector3;
  81839. /** Z axis */
  81840. static Z: Vector3;
  81841. }
  81842. }
  81843. declare module BABYLON {
  81844. /**
  81845. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  81846. * This is the base of the follow, arc rotate cameras and Free camera
  81847. * @see http://doc.babylonjs.com/features/cameras
  81848. */
  81849. export class TargetCamera extends Camera {
  81850. private static _RigCamTransformMatrix;
  81851. private static _TargetTransformMatrix;
  81852. private static _TargetFocalPoint;
  81853. /**
  81854. * Define the current direction the camera is moving to
  81855. */
  81856. cameraDirection: Vector3;
  81857. /**
  81858. * Define the current rotation the camera is rotating to
  81859. */
  81860. cameraRotation: Vector2;
  81861. /**
  81862. * When set, the up vector of the camera will be updated by the rotation of the camera
  81863. */
  81864. updateUpVectorFromRotation: boolean;
  81865. private _tmpQuaternion;
  81866. /**
  81867. * Define the current rotation of the camera
  81868. */
  81869. rotation: Vector3;
  81870. /**
  81871. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  81872. */
  81873. rotationQuaternion: Quaternion;
  81874. /**
  81875. * Define the current speed of the camera
  81876. */
  81877. speed: number;
  81878. /**
  81879. * Add constraint to the camera to prevent it to move freely in all directions and
  81880. * around all axis.
  81881. */
  81882. noRotationConstraint: boolean;
  81883. /**
  81884. * Define the current target of the camera as an object or a position.
  81885. */
  81886. lockedTarget: any;
  81887. /** @hidden */
  81888. _currentTarget: Vector3;
  81889. /** @hidden */
  81890. _initialFocalDistance: number;
  81891. /** @hidden */
  81892. _viewMatrix: Matrix;
  81893. /** @hidden */
  81894. _camMatrix: Matrix;
  81895. /** @hidden */
  81896. _cameraTransformMatrix: Matrix;
  81897. /** @hidden */
  81898. _cameraRotationMatrix: Matrix;
  81899. /** @hidden */
  81900. _referencePoint: Vector3;
  81901. /** @hidden */
  81902. _transformedReferencePoint: Vector3;
  81903. protected _globalCurrentTarget: Vector3;
  81904. protected _globalCurrentUpVector: Vector3;
  81905. /** @hidden */
  81906. _reset: () => void;
  81907. private _defaultUp;
  81908. /**
  81909. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  81910. * This is the base of the follow, arc rotate cameras and Free camera
  81911. * @see http://doc.babylonjs.com/features/cameras
  81912. * @param name Defines the name of the camera in the scene
  81913. * @param position Defines the start position of the camera in the scene
  81914. * @param scene Defines the scene the camera belongs to
  81915. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  81916. */
  81917. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  81918. /**
  81919. * Gets the position in front of the camera at a given distance.
  81920. * @param distance The distance from the camera we want the position to be
  81921. * @returns the position
  81922. */
  81923. getFrontPosition(distance: number): Vector3;
  81924. /** @hidden */
  81925. _getLockedTargetPosition(): Nullable<Vector3>;
  81926. private _storedPosition;
  81927. private _storedRotation;
  81928. private _storedRotationQuaternion;
  81929. /**
  81930. * Store current camera state of the camera (fov, position, rotation, etc..)
  81931. * @returns the camera
  81932. */
  81933. storeState(): Camera;
  81934. /**
  81935. * Restored camera state. You must call storeState() first
  81936. * @returns whether it was successful or not
  81937. * @hidden
  81938. */
  81939. _restoreStateValues(): boolean;
  81940. /** @hidden */
  81941. _initCache(): void;
  81942. /** @hidden */
  81943. _updateCache(ignoreParentClass?: boolean): void;
  81944. /** @hidden */
  81945. _isSynchronizedViewMatrix(): boolean;
  81946. /** @hidden */
  81947. _computeLocalCameraSpeed(): number;
  81948. /**
  81949. * Defines the target the camera should look at.
  81950. * @param target Defines the new target as a Vector or a mesh
  81951. */
  81952. setTarget(target: Vector3): void;
  81953. /**
  81954. * Return the current target position of the camera. This value is expressed in local space.
  81955. * @returns the target position
  81956. */
  81957. getTarget(): Vector3;
  81958. /** @hidden */
  81959. _decideIfNeedsToMove(): boolean;
  81960. /** @hidden */
  81961. _updatePosition(): void;
  81962. /** @hidden */
  81963. _checkInputs(): void;
  81964. protected _updateCameraRotationMatrix(): void;
  81965. /**
  81966. * 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)
  81967. * @returns the current camera
  81968. */
  81969. private _rotateUpVectorWithCameraRotationMatrix;
  81970. private _cachedRotationZ;
  81971. private _cachedQuaternionRotationZ;
  81972. /** @hidden */
  81973. _getViewMatrix(): Matrix;
  81974. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  81975. /**
  81976. * @hidden
  81977. */
  81978. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  81979. /**
  81980. * @hidden
  81981. */
  81982. _updateRigCameras(): void;
  81983. private _getRigCamPositionAndTarget;
  81984. /**
  81985. * Gets the current object class name.
  81986. * @return the class name
  81987. */
  81988. getClassName(): string;
  81989. }
  81990. }
  81991. declare module BABYLON {
  81992. /**
  81993. * Gather the list of keyboard event types as constants.
  81994. */
  81995. export class KeyboardEventTypes {
  81996. /**
  81997. * The keydown event is fired when a key becomes active (pressed).
  81998. */
  81999. static readonly KEYDOWN: number;
  82000. /**
  82001. * The keyup event is fired when a key has been released.
  82002. */
  82003. static readonly KEYUP: number;
  82004. }
  82005. /**
  82006. * This class is used to store keyboard related info for the onKeyboardObservable event.
  82007. */
  82008. export class KeyboardInfo {
  82009. /**
  82010. * Defines the type of event (KeyboardEventTypes)
  82011. */
  82012. type: number;
  82013. /**
  82014. * Defines the related dom event
  82015. */
  82016. event: KeyboardEvent;
  82017. /**
  82018. * Instantiates a new keyboard info.
  82019. * This class is used to store keyboard related info for the onKeyboardObservable event.
  82020. * @param type Defines the type of event (KeyboardEventTypes)
  82021. * @param event Defines the related dom event
  82022. */
  82023. constructor(
  82024. /**
  82025. * Defines the type of event (KeyboardEventTypes)
  82026. */
  82027. type: number,
  82028. /**
  82029. * Defines the related dom event
  82030. */
  82031. event: KeyboardEvent);
  82032. }
  82033. /**
  82034. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  82035. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  82036. */
  82037. export class KeyboardInfoPre extends KeyboardInfo {
  82038. /**
  82039. * Defines the type of event (KeyboardEventTypes)
  82040. */
  82041. type: number;
  82042. /**
  82043. * Defines the related dom event
  82044. */
  82045. event: KeyboardEvent;
  82046. /**
  82047. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  82048. */
  82049. skipOnPointerObservable: boolean;
  82050. /**
  82051. * Instantiates a new keyboard pre info.
  82052. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  82053. * @param type Defines the type of event (KeyboardEventTypes)
  82054. * @param event Defines the related dom event
  82055. */
  82056. constructor(
  82057. /**
  82058. * Defines the type of event (KeyboardEventTypes)
  82059. */
  82060. type: number,
  82061. /**
  82062. * Defines the related dom event
  82063. */
  82064. event: KeyboardEvent);
  82065. }
  82066. }
  82067. declare module BABYLON {
  82068. /**
  82069. * Manage the keyboard inputs to control the movement of a free camera.
  82070. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82071. */
  82072. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  82073. /**
  82074. * Defines the camera the input is attached to.
  82075. */
  82076. camera: FreeCamera;
  82077. /**
  82078. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  82079. */
  82080. keysUp: number[];
  82081. /**
  82082. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  82083. */
  82084. keysDown: number[];
  82085. /**
  82086. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  82087. */
  82088. keysLeft: number[];
  82089. /**
  82090. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  82091. */
  82092. keysRight: number[];
  82093. private _keys;
  82094. private _onCanvasBlurObserver;
  82095. private _onKeyboardObserver;
  82096. private _engine;
  82097. private _scene;
  82098. /**
  82099. * Attach the input controls to a specific dom element to get the input from.
  82100. * @param element Defines the element the controls should be listened from
  82101. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82102. */
  82103. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82104. /**
  82105. * Detach the current controls from the specified dom element.
  82106. * @param element Defines the element to stop listening the inputs from
  82107. */
  82108. detachControl(element: Nullable<HTMLElement>): void;
  82109. /**
  82110. * Update the current camera state depending on the inputs that have been used this frame.
  82111. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  82112. */
  82113. checkInputs(): void;
  82114. /**
  82115. * Gets the class name of the current intput.
  82116. * @returns the class name
  82117. */
  82118. getClassName(): string;
  82119. /** @hidden */
  82120. _onLostFocus(): void;
  82121. /**
  82122. * Get the friendly name associated with the input class.
  82123. * @returns the input friendly name
  82124. */
  82125. getSimpleName(): string;
  82126. }
  82127. }
  82128. declare module BABYLON {
  82129. /**
  82130. * Interface describing all the common properties and methods a shadow light needs to implement.
  82131. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  82132. * as well as binding the different shadow properties to the effects.
  82133. */
  82134. export interface IShadowLight extends Light {
  82135. /**
  82136. * The light id in the scene (used in scene.findLighById for instance)
  82137. */
  82138. id: string;
  82139. /**
  82140. * The position the shdow will be casted from.
  82141. */
  82142. position: Vector3;
  82143. /**
  82144. * In 2d mode (needCube being false), the direction used to cast the shadow.
  82145. */
  82146. direction: Vector3;
  82147. /**
  82148. * The transformed position. Position of the light in world space taking parenting in account.
  82149. */
  82150. transformedPosition: Vector3;
  82151. /**
  82152. * The transformed direction. Direction of the light in world space taking parenting in account.
  82153. */
  82154. transformedDirection: Vector3;
  82155. /**
  82156. * The friendly name of the light in the scene.
  82157. */
  82158. name: string;
  82159. /**
  82160. * Defines the shadow projection clipping minimum z value.
  82161. */
  82162. shadowMinZ: number;
  82163. /**
  82164. * Defines the shadow projection clipping maximum z value.
  82165. */
  82166. shadowMaxZ: number;
  82167. /**
  82168. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  82169. * @returns true if the information has been computed, false if it does not need to (no parenting)
  82170. */
  82171. computeTransformedInformation(): boolean;
  82172. /**
  82173. * Gets the scene the light belongs to.
  82174. * @returns The scene
  82175. */
  82176. getScene(): Scene;
  82177. /**
  82178. * Callback defining a custom Projection Matrix Builder.
  82179. * This can be used to override the default projection matrix computation.
  82180. */
  82181. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  82182. /**
  82183. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  82184. * @param matrix The materix to updated with the projection information
  82185. * @param viewMatrix The transform matrix of the light
  82186. * @param renderList The list of mesh to render in the map
  82187. * @returns The current light
  82188. */
  82189. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  82190. /**
  82191. * Gets the current depth scale used in ESM.
  82192. * @returns The scale
  82193. */
  82194. getDepthScale(): number;
  82195. /**
  82196. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  82197. * @returns true if a cube texture needs to be use
  82198. */
  82199. needCube(): boolean;
  82200. /**
  82201. * Detects if the projection matrix requires to be recomputed this frame.
  82202. * @returns true if it requires to be recomputed otherwise, false.
  82203. */
  82204. needProjectionMatrixCompute(): boolean;
  82205. /**
  82206. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  82207. */
  82208. forceProjectionMatrixCompute(): void;
  82209. /**
  82210. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  82211. * @param faceIndex The index of the face we are computed the direction to generate shadow
  82212. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  82213. */
  82214. getShadowDirection(faceIndex?: number): Vector3;
  82215. /**
  82216. * Gets the minZ used for shadow according to both the scene and the light.
  82217. * @param activeCamera The camera we are returning the min for
  82218. * @returns the depth min z
  82219. */
  82220. getDepthMinZ(activeCamera: Camera): number;
  82221. /**
  82222. * Gets the maxZ used for shadow according to both the scene and the light.
  82223. * @param activeCamera The camera we are returning the max for
  82224. * @returns the depth max z
  82225. */
  82226. getDepthMaxZ(activeCamera: Camera): number;
  82227. }
  82228. /**
  82229. * Base implementation IShadowLight
  82230. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  82231. */
  82232. export abstract class ShadowLight extends Light implements IShadowLight {
  82233. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  82234. protected _position: Vector3;
  82235. protected _setPosition(value: Vector3): void;
  82236. /**
  82237. * Sets the position the shadow will be casted from. Also use as the light position for both
  82238. * point and spot lights.
  82239. */
  82240. get position(): Vector3;
  82241. /**
  82242. * Sets the position the shadow will be casted from. Also use as the light position for both
  82243. * point and spot lights.
  82244. */
  82245. set position(value: Vector3);
  82246. protected _direction: Vector3;
  82247. protected _setDirection(value: Vector3): void;
  82248. /**
  82249. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  82250. * Also use as the light direction on spot and directional lights.
  82251. */
  82252. get direction(): Vector3;
  82253. /**
  82254. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  82255. * Also use as the light direction on spot and directional lights.
  82256. */
  82257. set direction(value: Vector3);
  82258. protected _shadowMinZ: number;
  82259. /**
  82260. * Gets the shadow projection clipping minimum z value.
  82261. */
  82262. get shadowMinZ(): number;
  82263. /**
  82264. * Sets the shadow projection clipping minimum z value.
  82265. */
  82266. set shadowMinZ(value: number);
  82267. protected _shadowMaxZ: number;
  82268. /**
  82269. * Sets the shadow projection clipping maximum z value.
  82270. */
  82271. get shadowMaxZ(): number;
  82272. /**
  82273. * Gets the shadow projection clipping maximum z value.
  82274. */
  82275. set shadowMaxZ(value: number);
  82276. /**
  82277. * Callback defining a custom Projection Matrix Builder.
  82278. * This can be used to override the default projection matrix computation.
  82279. */
  82280. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  82281. /**
  82282. * The transformed position. Position of the light in world space taking parenting in account.
  82283. */
  82284. transformedPosition: Vector3;
  82285. /**
  82286. * The transformed direction. Direction of the light in world space taking parenting in account.
  82287. */
  82288. transformedDirection: Vector3;
  82289. private _needProjectionMatrixCompute;
  82290. /**
  82291. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  82292. * @returns true if the information has been computed, false if it does not need to (no parenting)
  82293. */
  82294. computeTransformedInformation(): boolean;
  82295. /**
  82296. * Return the depth scale used for the shadow map.
  82297. * @returns the depth scale.
  82298. */
  82299. getDepthScale(): number;
  82300. /**
  82301. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  82302. * @param faceIndex The index of the face we are computed the direction to generate shadow
  82303. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  82304. */
  82305. getShadowDirection(faceIndex?: number): Vector3;
  82306. /**
  82307. * Returns the ShadowLight absolute position in the World.
  82308. * @returns the position vector in world space
  82309. */
  82310. getAbsolutePosition(): Vector3;
  82311. /**
  82312. * Sets the ShadowLight direction toward the passed target.
  82313. * @param target The point to target in local space
  82314. * @returns the updated ShadowLight direction
  82315. */
  82316. setDirectionToTarget(target: Vector3): Vector3;
  82317. /**
  82318. * Returns the light rotation in euler definition.
  82319. * @returns the x y z rotation in local space.
  82320. */
  82321. getRotation(): Vector3;
  82322. /**
  82323. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  82324. * @returns true if a cube texture needs to be use
  82325. */
  82326. needCube(): boolean;
  82327. /**
  82328. * Detects if the projection matrix requires to be recomputed this frame.
  82329. * @returns true if it requires to be recomputed otherwise, false.
  82330. */
  82331. needProjectionMatrixCompute(): boolean;
  82332. /**
  82333. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  82334. */
  82335. forceProjectionMatrixCompute(): void;
  82336. /** @hidden */
  82337. _initCache(): void;
  82338. /** @hidden */
  82339. _isSynchronized(): boolean;
  82340. /**
  82341. * Computes the world matrix of the node
  82342. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82343. * @returns the world matrix
  82344. */
  82345. computeWorldMatrix(force?: boolean): Matrix;
  82346. /**
  82347. * Gets the minZ used for shadow according to both the scene and the light.
  82348. * @param activeCamera The camera we are returning the min for
  82349. * @returns the depth min z
  82350. */
  82351. getDepthMinZ(activeCamera: Camera): number;
  82352. /**
  82353. * Gets the maxZ used for shadow according to both the scene and the light.
  82354. * @param activeCamera The camera we are returning the max for
  82355. * @returns the depth max z
  82356. */
  82357. getDepthMaxZ(activeCamera: Camera): number;
  82358. /**
  82359. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  82360. * @param matrix The materix to updated with the projection information
  82361. * @param viewMatrix The transform matrix of the light
  82362. * @param renderList The list of mesh to render in the map
  82363. * @returns The current light
  82364. */
  82365. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  82366. }
  82367. }
  82368. declare module BABYLON {
  82369. /**
  82370. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  82371. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  82372. */
  82373. export class EffectFallbacks implements IEffectFallbacks {
  82374. private _defines;
  82375. private _currentRank;
  82376. private _maxRank;
  82377. private _mesh;
  82378. /**
  82379. * Removes the fallback from the bound mesh.
  82380. */
  82381. unBindMesh(): void;
  82382. /**
  82383. * Adds a fallback on the specified property.
  82384. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  82385. * @param define The name of the define in the shader
  82386. */
  82387. addFallback(rank: number, define: string): void;
  82388. /**
  82389. * Sets the mesh to use CPU skinning when needing to fallback.
  82390. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  82391. * @param mesh The mesh to use the fallbacks.
  82392. */
  82393. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  82394. /**
  82395. * Checks to see if more fallbacks are still availible.
  82396. */
  82397. get hasMoreFallbacks(): boolean;
  82398. /**
  82399. * Removes the defines that should be removed when falling back.
  82400. * @param currentDefines defines the current define statements for the shader.
  82401. * @param effect defines the current effect we try to compile
  82402. * @returns The resulting defines with defines of the current rank removed.
  82403. */
  82404. reduce(currentDefines: string, effect: Effect): string;
  82405. }
  82406. }
  82407. declare module BABYLON {
  82408. /**
  82409. * "Static Class" containing the most commonly used helper while dealing with material for
  82410. * rendering purpose.
  82411. *
  82412. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  82413. *
  82414. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  82415. */
  82416. export class MaterialHelper {
  82417. /**
  82418. * Bind the current view position to an effect.
  82419. * @param effect The effect to be bound
  82420. * @param scene The scene the eyes position is used from
  82421. */
  82422. static BindEyePosition(effect: Effect, scene: Scene): void;
  82423. /**
  82424. * Helps preparing the defines values about the UVs in used in the effect.
  82425. * UVs are shared as much as we can accross channels in the shaders.
  82426. * @param texture The texture we are preparing the UVs for
  82427. * @param defines The defines to update
  82428. * @param key The channel key "diffuse", "specular"... used in the shader
  82429. */
  82430. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  82431. /**
  82432. * Binds a texture matrix value to its corrsponding uniform
  82433. * @param texture The texture to bind the matrix for
  82434. * @param uniformBuffer The uniform buffer receivin the data
  82435. * @param key The channel key "diffuse", "specular"... used in the shader
  82436. */
  82437. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  82438. /**
  82439. * Gets the current status of the fog (should it be enabled?)
  82440. * @param mesh defines the mesh to evaluate for fog support
  82441. * @param scene defines the hosting scene
  82442. * @returns true if fog must be enabled
  82443. */
  82444. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  82445. /**
  82446. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  82447. * @param mesh defines the current mesh
  82448. * @param scene defines the current scene
  82449. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  82450. * @param pointsCloud defines if point cloud rendering has to be turned on
  82451. * @param fogEnabled defines if fog has to be turned on
  82452. * @param alphaTest defines if alpha testing has to be turned on
  82453. * @param defines defines the current list of defines
  82454. */
  82455. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  82456. /**
  82457. * Helper used to prepare the list of defines associated with frame values for shader compilation
  82458. * @param scene defines the current scene
  82459. * @param engine defines the current engine
  82460. * @param defines specifies the list of active defines
  82461. * @param useInstances defines if instances have to be turned on
  82462. * @param useClipPlane defines if clip plane have to be turned on
  82463. */
  82464. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  82465. /**
  82466. * Prepares the defines for bones
  82467. * @param mesh The mesh containing the geometry data we will draw
  82468. * @param defines The defines to update
  82469. */
  82470. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  82471. /**
  82472. * Prepares the defines for morph targets
  82473. * @param mesh The mesh containing the geometry data we will draw
  82474. * @param defines The defines to update
  82475. */
  82476. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  82477. /**
  82478. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  82479. * @param mesh The mesh containing the geometry data we will draw
  82480. * @param defines The defines to update
  82481. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  82482. * @param useBones Precise whether bones should be used or not (override mesh info)
  82483. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  82484. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  82485. * @returns false if defines are considered not dirty and have not been checked
  82486. */
  82487. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  82488. /**
  82489. * Prepares the defines related to multiview
  82490. * @param scene The scene we are intending to draw
  82491. * @param defines The defines to update
  82492. */
  82493. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  82494. /**
  82495. * Prepares the defines related to the light information passed in parameter
  82496. * @param scene The scene we are intending to draw
  82497. * @param mesh The mesh the effect is compiling for
  82498. * @param light The light the effect is compiling for
  82499. * @param lightIndex The index of the light
  82500. * @param defines The defines to update
  82501. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  82502. * @param state Defines the current state regarding what is needed (normals, etc...)
  82503. */
  82504. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  82505. needNormals: boolean;
  82506. needRebuild: boolean;
  82507. shadowEnabled: boolean;
  82508. specularEnabled: boolean;
  82509. lightmapMode: boolean;
  82510. }): void;
  82511. /**
  82512. * Prepares the defines related to the light information passed in parameter
  82513. * @param scene The scene we are intending to draw
  82514. * @param mesh The mesh the effect is compiling for
  82515. * @param defines The defines to update
  82516. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  82517. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  82518. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  82519. * @returns true if normals will be required for the rest of the effect
  82520. */
  82521. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  82522. /**
  82523. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  82524. * @param lightIndex defines the light index
  82525. * @param uniformsList The uniform list
  82526. * @param samplersList The sampler list
  82527. * @param projectedLightTexture defines if projected texture must be used
  82528. * @param uniformBuffersList defines an optional list of uniform buffers
  82529. */
  82530. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  82531. /**
  82532. * Prepares the uniforms and samplers list to be used in the effect
  82533. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  82534. * @param samplersList The sampler list
  82535. * @param defines The defines helping in the list generation
  82536. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  82537. */
  82538. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  82539. /**
  82540. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  82541. * @param defines The defines to update while falling back
  82542. * @param fallbacks The authorized effect fallbacks
  82543. * @param maxSimultaneousLights The maximum number of lights allowed
  82544. * @param rank the current rank of the Effect
  82545. * @returns The newly affected rank
  82546. */
  82547. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  82548. private static _TmpMorphInfluencers;
  82549. /**
  82550. * Prepares the list of attributes required for morph targets according to the effect defines.
  82551. * @param attribs The current list of supported attribs
  82552. * @param mesh The mesh to prepare the morph targets attributes for
  82553. * @param influencers The number of influencers
  82554. */
  82555. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  82556. /**
  82557. * Prepares the list of attributes required for morph targets according to the effect defines.
  82558. * @param attribs The current list of supported attribs
  82559. * @param mesh The mesh to prepare the morph targets attributes for
  82560. * @param defines The current Defines of the effect
  82561. */
  82562. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  82563. /**
  82564. * Prepares the list of attributes required for bones according to the effect defines.
  82565. * @param attribs The current list of supported attribs
  82566. * @param mesh The mesh to prepare the bones attributes for
  82567. * @param defines The current Defines of the effect
  82568. * @param fallbacks The current efffect fallback strategy
  82569. */
  82570. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  82571. /**
  82572. * Check and prepare the list of attributes required for instances according to the effect defines.
  82573. * @param attribs The current list of supported attribs
  82574. * @param defines The current MaterialDefines of the effect
  82575. */
  82576. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  82577. /**
  82578. * Add the list of attributes required for instances to the attribs array.
  82579. * @param attribs The current list of supported attribs
  82580. */
  82581. static PushAttributesForInstances(attribs: string[]): void;
  82582. /**
  82583. * Binds the light information to the effect.
  82584. * @param light The light containing the generator
  82585. * @param effect The effect we are binding the data to
  82586. * @param lightIndex The light index in the effect used to render
  82587. */
  82588. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  82589. /**
  82590. * Binds the lights information from the scene to the effect for the given mesh.
  82591. * @param light Light to bind
  82592. * @param lightIndex Light index
  82593. * @param scene The scene where the light belongs to
  82594. * @param effect The effect we are binding the data to
  82595. * @param useSpecular Defines if specular is supported
  82596. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  82597. */
  82598. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  82599. /**
  82600. * Binds the lights 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 defines The generated defines for the effect
  82605. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  82606. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  82607. */
  82608. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  82609. private static _tempFogColor;
  82610. /**
  82611. * Binds the fog information from the scene to the effect for the given mesh.
  82612. * @param scene The scene the lights belongs to
  82613. * @param mesh The mesh we are binding the information to render
  82614. * @param effect The effect we are binding the data to
  82615. * @param linearSpace Defines if the fog effect is applied in linear space
  82616. */
  82617. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  82618. /**
  82619. * Binds the bones information from the mesh to the effect.
  82620. * @param mesh The mesh we are binding the information to render
  82621. * @param effect The effect we are binding the data to
  82622. */
  82623. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  82624. /**
  82625. * Binds the morph targets information from the mesh to the effect.
  82626. * @param abstractMesh The mesh we are binding the information to render
  82627. * @param effect The effect we are binding the data to
  82628. */
  82629. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  82630. /**
  82631. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  82632. * @param defines The generated defines used in the effect
  82633. * @param effect The effect we are binding the data to
  82634. * @param scene The scene we are willing to render with logarithmic scale for
  82635. */
  82636. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  82637. /**
  82638. * Binds the clip plane information from the scene to the effect.
  82639. * @param scene The scene the clip plane information are extracted from
  82640. * @param effect The effect we are binding the data to
  82641. */
  82642. static BindClipPlane(effect: Effect, scene: Scene): void;
  82643. }
  82644. }
  82645. declare module BABYLON {
  82646. /** @hidden */
  82647. export var packingFunctions: {
  82648. name: string;
  82649. shader: string;
  82650. };
  82651. }
  82652. declare module BABYLON {
  82653. /** @hidden */
  82654. export var clipPlaneFragmentDeclaration: {
  82655. name: string;
  82656. shader: string;
  82657. };
  82658. }
  82659. declare module BABYLON {
  82660. /** @hidden */
  82661. export var clipPlaneFragment: {
  82662. name: string;
  82663. shader: string;
  82664. };
  82665. }
  82666. declare module BABYLON {
  82667. /** @hidden */
  82668. export var shadowMapPixelShader: {
  82669. name: string;
  82670. shader: string;
  82671. };
  82672. }
  82673. declare module BABYLON {
  82674. /** @hidden */
  82675. export var bonesDeclaration: {
  82676. name: string;
  82677. shader: string;
  82678. };
  82679. }
  82680. declare module BABYLON {
  82681. /** @hidden */
  82682. export var morphTargetsVertexGlobalDeclaration: {
  82683. name: string;
  82684. shader: string;
  82685. };
  82686. }
  82687. declare module BABYLON {
  82688. /** @hidden */
  82689. export var morphTargetsVertexDeclaration: {
  82690. name: string;
  82691. shader: string;
  82692. };
  82693. }
  82694. declare module BABYLON {
  82695. /** @hidden */
  82696. export var instancesDeclaration: {
  82697. name: string;
  82698. shader: string;
  82699. };
  82700. }
  82701. declare module BABYLON {
  82702. /** @hidden */
  82703. export var helperFunctions: {
  82704. name: string;
  82705. shader: string;
  82706. };
  82707. }
  82708. declare module BABYLON {
  82709. /** @hidden */
  82710. export var clipPlaneVertexDeclaration: {
  82711. name: string;
  82712. shader: string;
  82713. };
  82714. }
  82715. declare module BABYLON {
  82716. /** @hidden */
  82717. export var morphTargetsVertex: {
  82718. name: string;
  82719. shader: string;
  82720. };
  82721. }
  82722. declare module BABYLON {
  82723. /** @hidden */
  82724. export var instancesVertex: {
  82725. name: string;
  82726. shader: string;
  82727. };
  82728. }
  82729. declare module BABYLON {
  82730. /** @hidden */
  82731. export var bonesVertex: {
  82732. name: string;
  82733. shader: string;
  82734. };
  82735. }
  82736. declare module BABYLON {
  82737. /** @hidden */
  82738. export var clipPlaneVertex: {
  82739. name: string;
  82740. shader: string;
  82741. };
  82742. }
  82743. declare module BABYLON {
  82744. /** @hidden */
  82745. export var shadowMapVertexShader: {
  82746. name: string;
  82747. shader: string;
  82748. };
  82749. }
  82750. declare module BABYLON {
  82751. /** @hidden */
  82752. export var depthBoxBlurPixelShader: {
  82753. name: string;
  82754. shader: string;
  82755. };
  82756. }
  82757. declare module BABYLON {
  82758. /**
  82759. * Class representing a ray with position and direction
  82760. */
  82761. export class Ray {
  82762. /** origin point */
  82763. origin: Vector3;
  82764. /** direction */
  82765. direction: Vector3;
  82766. /** length of the ray */
  82767. length: number;
  82768. private static readonly TmpVector3;
  82769. private _tmpRay;
  82770. /**
  82771. * Creates a new ray
  82772. * @param origin origin point
  82773. * @param direction direction
  82774. * @param length length of the ray
  82775. */
  82776. constructor(
  82777. /** origin point */
  82778. origin: Vector3,
  82779. /** direction */
  82780. direction: Vector3,
  82781. /** length of the ray */
  82782. length?: number);
  82783. /**
  82784. * Checks if the ray intersects a box
  82785. * @param minimum bound of the box
  82786. * @param maximum bound of the box
  82787. * @param intersectionTreshold extra extend to be added to the box in all direction
  82788. * @returns if the box was hit
  82789. */
  82790. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  82791. /**
  82792. * Checks if the ray intersects a box
  82793. * @param box the bounding box to check
  82794. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  82795. * @returns if the box was hit
  82796. */
  82797. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  82798. /**
  82799. * If the ray hits a sphere
  82800. * @param sphere the bounding sphere to check
  82801. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  82802. * @returns true if it hits the sphere
  82803. */
  82804. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  82805. /**
  82806. * If the ray hits a triange
  82807. * @param vertex0 triangle vertex
  82808. * @param vertex1 triangle vertex
  82809. * @param vertex2 triangle vertex
  82810. * @returns intersection information if hit
  82811. */
  82812. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  82813. /**
  82814. * Checks if ray intersects a plane
  82815. * @param plane the plane to check
  82816. * @returns the distance away it was hit
  82817. */
  82818. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  82819. /**
  82820. * Calculate the intercept of a ray on a given axis
  82821. * @param axis to check 'x' | 'y' | 'z'
  82822. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  82823. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  82824. */
  82825. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  82826. /**
  82827. * Checks if ray intersects a mesh
  82828. * @param mesh the mesh to check
  82829. * @param fastCheck if only the bounding box should checked
  82830. * @returns picking info of the intersecton
  82831. */
  82832. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  82833. /**
  82834. * Checks if ray intersects a mesh
  82835. * @param meshes the meshes to check
  82836. * @param fastCheck if only the bounding box should checked
  82837. * @param results array to store result in
  82838. * @returns Array of picking infos
  82839. */
  82840. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  82841. private _comparePickingInfo;
  82842. private static smallnum;
  82843. private static rayl;
  82844. /**
  82845. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  82846. * @param sega the first point of the segment to test the intersection against
  82847. * @param segb the second point of the segment to test the intersection against
  82848. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  82849. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  82850. */
  82851. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  82852. /**
  82853. * Update the ray from viewport position
  82854. * @param x position
  82855. * @param y y position
  82856. * @param viewportWidth viewport width
  82857. * @param viewportHeight viewport height
  82858. * @param world world matrix
  82859. * @param view view matrix
  82860. * @param projection projection matrix
  82861. * @returns this ray updated
  82862. */
  82863. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  82864. /**
  82865. * Creates a ray with origin and direction of 0,0,0
  82866. * @returns the new ray
  82867. */
  82868. static Zero(): Ray;
  82869. /**
  82870. * Creates a new ray from screen space and viewport
  82871. * @param x position
  82872. * @param y y position
  82873. * @param viewportWidth viewport width
  82874. * @param viewportHeight viewport height
  82875. * @param world world matrix
  82876. * @param view view matrix
  82877. * @param projection projection matrix
  82878. * @returns new ray
  82879. */
  82880. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  82881. /**
  82882. * 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
  82883. * transformed to the given world matrix.
  82884. * @param origin The origin point
  82885. * @param end The end point
  82886. * @param world a matrix to transform the ray to. Default is the identity matrix.
  82887. * @returns the new ray
  82888. */
  82889. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  82890. /**
  82891. * Transforms a ray by a matrix
  82892. * @param ray ray to transform
  82893. * @param matrix matrix to apply
  82894. * @returns the resulting new ray
  82895. */
  82896. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  82897. /**
  82898. * Transforms a ray by a matrix
  82899. * @param ray ray to transform
  82900. * @param matrix matrix to apply
  82901. * @param result ray to store result in
  82902. */
  82903. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  82904. /**
  82905. * Unproject a ray from screen space to object space
  82906. * @param sourceX defines the screen space x coordinate to use
  82907. * @param sourceY defines the screen space y coordinate to use
  82908. * @param viewportWidth defines the current width of the viewport
  82909. * @param viewportHeight defines the current height of the viewport
  82910. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82911. * @param view defines the view matrix to use
  82912. * @param projection defines the projection matrix to use
  82913. */
  82914. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  82915. }
  82916. /**
  82917. * Type used to define predicate used to select faces when a mesh intersection is detected
  82918. */
  82919. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  82920. interface Scene {
  82921. /** @hidden */
  82922. _tempPickingRay: Nullable<Ray>;
  82923. /** @hidden */
  82924. _cachedRayForTransform: Ray;
  82925. /** @hidden */
  82926. _pickWithRayInverseMatrix: Matrix;
  82927. /** @hidden */
  82928. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  82929. /** @hidden */
  82930. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  82931. }
  82932. }
  82933. declare module BABYLON {
  82934. /**
  82935. * Groups all the scene component constants in one place to ease maintenance.
  82936. * @hidden
  82937. */
  82938. export class SceneComponentConstants {
  82939. static readonly NAME_EFFECTLAYER: string;
  82940. static readonly NAME_LAYER: string;
  82941. static readonly NAME_LENSFLARESYSTEM: string;
  82942. static readonly NAME_BOUNDINGBOXRENDERER: string;
  82943. static readonly NAME_PARTICLESYSTEM: string;
  82944. static readonly NAME_GAMEPAD: string;
  82945. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  82946. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  82947. static readonly NAME_DEPTHRENDERER: string;
  82948. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  82949. static readonly NAME_SPRITE: string;
  82950. static readonly NAME_OUTLINERENDERER: string;
  82951. static readonly NAME_PROCEDURALTEXTURE: string;
  82952. static readonly NAME_SHADOWGENERATOR: string;
  82953. static readonly NAME_OCTREE: string;
  82954. static readonly NAME_PHYSICSENGINE: string;
  82955. static readonly NAME_AUDIO: string;
  82956. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  82957. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  82958. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  82959. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  82960. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  82961. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  82962. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  82963. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  82964. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  82965. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  82966. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  82967. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  82968. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  82969. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  82970. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  82971. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  82972. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  82973. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  82974. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  82975. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  82976. static readonly STEP_AFTERRENDER_AUDIO: number;
  82977. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  82978. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  82979. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  82980. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  82981. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  82982. static readonly STEP_POINTERMOVE_SPRITE: number;
  82983. static readonly STEP_POINTERDOWN_SPRITE: number;
  82984. static readonly STEP_POINTERUP_SPRITE: number;
  82985. }
  82986. /**
  82987. * This represents a scene component.
  82988. *
  82989. * This is used to decouple the dependency the scene is having on the different workloads like
  82990. * layers, post processes...
  82991. */
  82992. export interface ISceneComponent {
  82993. /**
  82994. * The name of the component. Each component must have a unique name.
  82995. */
  82996. name: string;
  82997. /**
  82998. * The scene the component belongs to.
  82999. */
  83000. scene: Scene;
  83001. /**
  83002. * Register the component to one instance of a scene.
  83003. */
  83004. register(): void;
  83005. /**
  83006. * Rebuilds the elements related to this component in case of
  83007. * context lost for instance.
  83008. */
  83009. rebuild(): void;
  83010. /**
  83011. * Disposes the component and the associated ressources.
  83012. */
  83013. dispose(): void;
  83014. }
  83015. /**
  83016. * This represents a SERIALIZABLE scene component.
  83017. *
  83018. * This extends Scene Component to add Serialization methods on top.
  83019. */
  83020. export interface ISceneSerializableComponent extends ISceneComponent {
  83021. /**
  83022. * Adds all the elements from the container to the scene
  83023. * @param container the container holding the elements
  83024. */
  83025. addFromContainer(container: AbstractScene): void;
  83026. /**
  83027. * Removes all the elements in the container from the scene
  83028. * @param container contains the elements to remove
  83029. * @param dispose if the removed element should be disposed (default: false)
  83030. */
  83031. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  83032. /**
  83033. * Serializes the component data to the specified json object
  83034. * @param serializationObject The object to serialize to
  83035. */
  83036. serialize(serializationObject: any): void;
  83037. }
  83038. /**
  83039. * Strong typing of a Mesh related stage step action
  83040. */
  83041. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  83042. /**
  83043. * Strong typing of a Evaluate Sub Mesh related stage step action
  83044. */
  83045. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  83046. /**
  83047. * Strong typing of a Active Mesh related stage step action
  83048. */
  83049. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  83050. /**
  83051. * Strong typing of a Camera related stage step action
  83052. */
  83053. export type CameraStageAction = (camera: Camera) => void;
  83054. /**
  83055. * Strong typing of a Camera Frame buffer related stage step action
  83056. */
  83057. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  83058. /**
  83059. * Strong typing of a Render Target related stage step action
  83060. */
  83061. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  83062. /**
  83063. * Strong typing of a RenderingGroup related stage step action
  83064. */
  83065. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  83066. /**
  83067. * Strong typing of a Mesh Render related stage step action
  83068. */
  83069. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  83070. /**
  83071. * Strong typing of a simple stage step action
  83072. */
  83073. export type SimpleStageAction = () => void;
  83074. /**
  83075. * Strong typing of a render target action.
  83076. */
  83077. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  83078. /**
  83079. * Strong typing of a pointer move action.
  83080. */
  83081. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  83082. /**
  83083. * Strong typing of a pointer up/down action.
  83084. */
  83085. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  83086. /**
  83087. * Representation of a stage in the scene (Basically a list of ordered steps)
  83088. * @hidden
  83089. */
  83090. export class Stage<T extends Function> extends Array<{
  83091. index: number;
  83092. component: ISceneComponent;
  83093. action: T;
  83094. }> {
  83095. /**
  83096. * Hide ctor from the rest of the world.
  83097. * @param items The items to add.
  83098. */
  83099. private constructor();
  83100. /**
  83101. * Creates a new Stage.
  83102. * @returns A new instance of a Stage
  83103. */
  83104. static Create<T extends Function>(): Stage<T>;
  83105. /**
  83106. * Registers a step in an ordered way in the targeted stage.
  83107. * @param index Defines the position to register the step in
  83108. * @param component Defines the component attached to the step
  83109. * @param action Defines the action to launch during the step
  83110. */
  83111. registerStep(index: number, component: ISceneComponent, action: T): void;
  83112. /**
  83113. * Clears all the steps from the stage.
  83114. */
  83115. clear(): void;
  83116. }
  83117. }
  83118. declare module BABYLON {
  83119. interface Scene {
  83120. /** @hidden */
  83121. _pointerOverSprite: Nullable<Sprite>;
  83122. /** @hidden */
  83123. _pickedDownSprite: Nullable<Sprite>;
  83124. /** @hidden */
  83125. _tempSpritePickingRay: Nullable<Ray>;
  83126. /**
  83127. * All of the sprite managers added to this scene
  83128. * @see http://doc.babylonjs.com/babylon101/sprites
  83129. */
  83130. spriteManagers: Array<ISpriteManager>;
  83131. /**
  83132. * An event triggered when sprites rendering is about to start
  83133. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  83134. */
  83135. onBeforeSpritesRenderingObservable: Observable<Scene>;
  83136. /**
  83137. * An event triggered when sprites rendering is done
  83138. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  83139. */
  83140. onAfterSpritesRenderingObservable: Observable<Scene>;
  83141. /** @hidden */
  83142. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83143. /** Launch a ray to try to pick a sprite in the scene
  83144. * @param x position on screen
  83145. * @param y position on screen
  83146. * @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
  83147. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  83148. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  83149. * @returns a PickingInfo
  83150. */
  83151. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83152. /** Use the given ray to pick a sprite in the scene
  83153. * @param ray The ray (in world space) to use to pick meshes
  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 fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  83156. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  83157. * @returns a PickingInfo
  83158. */
  83159. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83160. /** @hidden */
  83161. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83162. /** Launch a ray to try to pick sprites in the scene
  83163. * @param x position on screen
  83164. * @param y position on screen
  83165. * @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
  83166. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  83167. * @returns a PickingInfo array
  83168. */
  83169. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83170. /** Use the given ray to pick sprites in the scene
  83171. * @param ray The ray (in world space) to use to pick meshes
  83172. * @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
  83173. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  83174. * @returns a PickingInfo array
  83175. */
  83176. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83177. /**
  83178. * Force the sprite under the pointer
  83179. * @param sprite defines the sprite to use
  83180. */
  83181. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  83182. /**
  83183. * Gets the sprite under the pointer
  83184. * @returns a Sprite or null if no sprite is under the pointer
  83185. */
  83186. getPointerOverSprite(): Nullable<Sprite>;
  83187. }
  83188. /**
  83189. * Defines the sprite scene component responsible to manage sprites
  83190. * in a given scene.
  83191. */
  83192. export class SpriteSceneComponent implements ISceneComponent {
  83193. /**
  83194. * The component name helpfull to identify the component in the list of scene components.
  83195. */
  83196. readonly name: string;
  83197. /**
  83198. * The scene the component belongs to.
  83199. */
  83200. scene: Scene;
  83201. /** @hidden */
  83202. private _spritePredicate;
  83203. /**
  83204. * Creates a new instance of the component for the given scene
  83205. * @param scene Defines the scene to register the component in
  83206. */
  83207. constructor(scene: Scene);
  83208. /**
  83209. * Registers the component in a given scene
  83210. */
  83211. register(): void;
  83212. /**
  83213. * Rebuilds the elements related to this component in case of
  83214. * context lost for instance.
  83215. */
  83216. rebuild(): void;
  83217. /**
  83218. * Disposes the component and the associated ressources.
  83219. */
  83220. dispose(): void;
  83221. private _pickSpriteButKeepRay;
  83222. private _pointerMove;
  83223. private _pointerDown;
  83224. private _pointerUp;
  83225. }
  83226. }
  83227. declare module BABYLON {
  83228. /** @hidden */
  83229. export var fogFragmentDeclaration: {
  83230. name: string;
  83231. shader: string;
  83232. };
  83233. }
  83234. declare module BABYLON {
  83235. /** @hidden */
  83236. export var fogFragment: {
  83237. name: string;
  83238. shader: string;
  83239. };
  83240. }
  83241. declare module BABYLON {
  83242. /** @hidden */
  83243. export var spritesPixelShader: {
  83244. name: string;
  83245. shader: string;
  83246. };
  83247. }
  83248. declare module BABYLON {
  83249. /** @hidden */
  83250. export var fogVertexDeclaration: {
  83251. name: string;
  83252. shader: string;
  83253. };
  83254. }
  83255. declare module BABYLON {
  83256. /** @hidden */
  83257. export var spritesVertexShader: {
  83258. name: string;
  83259. shader: string;
  83260. };
  83261. }
  83262. declare module BABYLON {
  83263. /**
  83264. * Defines the minimum interface to fullfil in order to be a sprite manager.
  83265. */
  83266. export interface ISpriteManager extends IDisposable {
  83267. /**
  83268. * Restricts the camera to viewing objects with the same layerMask.
  83269. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  83270. */
  83271. layerMask: number;
  83272. /**
  83273. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  83274. */
  83275. isPickable: boolean;
  83276. /**
  83277. * Specifies the rendering group id for this mesh (0 by default)
  83278. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  83279. */
  83280. renderingGroupId: number;
  83281. /**
  83282. * Defines the list of sprites managed by the manager.
  83283. */
  83284. sprites: Array<Sprite>;
  83285. /**
  83286. * Tests the intersection of a sprite with a specific ray.
  83287. * @param ray The ray we are sending to test the collision
  83288. * @param camera The camera space we are sending rays in
  83289. * @param predicate A predicate allowing excluding sprites from the list of object to test
  83290. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  83291. * @returns picking info or null.
  83292. */
  83293. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  83294. /**
  83295. * Intersects the sprites with a ray
  83296. * @param ray defines the ray to intersect with
  83297. * @param camera defines the current active camera
  83298. * @param predicate defines a predicate used to select candidate sprites
  83299. * @returns null if no hit or a PickingInfo array
  83300. */
  83301. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  83302. /**
  83303. * Renders the list of sprites on screen.
  83304. */
  83305. render(): void;
  83306. }
  83307. /**
  83308. * Class used to manage multiple sprites on the same spritesheet
  83309. * @see http://doc.babylonjs.com/babylon101/sprites
  83310. */
  83311. export class SpriteManager implements ISpriteManager {
  83312. /** defines the manager's name */
  83313. name: string;
  83314. /** Gets the list of sprites */
  83315. sprites: Sprite[];
  83316. /** Gets or sets the rendering group id (0 by default) */
  83317. renderingGroupId: number;
  83318. /** Gets or sets camera layer mask */
  83319. layerMask: number;
  83320. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  83321. fogEnabled: boolean;
  83322. /** Gets or sets a boolean indicating if the sprites are pickable */
  83323. isPickable: boolean;
  83324. /** Defines the default width of a cell in the spritesheet */
  83325. cellWidth: number;
  83326. /** Defines the default height of a cell in the spritesheet */
  83327. cellHeight: number;
  83328. /** Associative array from JSON sprite data file */
  83329. private _cellData;
  83330. /** Array of sprite names from JSON sprite data file */
  83331. private _spriteMap;
  83332. /** True when packed cell data from JSON file is ready*/
  83333. private _packedAndReady;
  83334. /**
  83335. * An event triggered when the manager is disposed.
  83336. */
  83337. onDisposeObservable: Observable<SpriteManager>;
  83338. private _onDisposeObserver;
  83339. /**
  83340. * Callback called when the manager is disposed
  83341. */
  83342. set onDispose(callback: () => void);
  83343. private _capacity;
  83344. private _fromPacked;
  83345. private _spriteTexture;
  83346. private _epsilon;
  83347. private _scene;
  83348. private _vertexData;
  83349. private _buffer;
  83350. private _vertexBuffers;
  83351. private _indexBuffer;
  83352. private _effectBase;
  83353. private _effectFog;
  83354. /**
  83355. * Gets or sets the spritesheet texture
  83356. */
  83357. get texture(): Texture;
  83358. set texture(value: Texture);
  83359. private _blendMode;
  83360. /**
  83361. * Blend mode use to render the particle, it can be any of
  83362. * the static Constants.ALPHA_x properties provided in this class.
  83363. * Default value is Constants.ALPHA_COMBINE
  83364. */
  83365. get blendMode(): number;
  83366. set blendMode(blendMode: number);
  83367. /**
  83368. * Creates a new sprite manager
  83369. * @param name defines the manager's name
  83370. * @param imgUrl defines the sprite sheet url
  83371. * @param capacity defines the maximum allowed number of sprites
  83372. * @param cellSize defines the size of a sprite cell
  83373. * @param scene defines the hosting scene
  83374. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  83375. * @param samplingMode defines the smapling mode to use with spritesheet
  83376. * @param fromPacked set to false; do not alter
  83377. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  83378. */
  83379. constructor(
  83380. /** defines the manager's name */
  83381. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  83382. private _makePacked;
  83383. private _appendSpriteVertex;
  83384. /**
  83385. * Intersects the sprites with a ray
  83386. * @param ray defines the ray to intersect with
  83387. * @param camera defines the current active camera
  83388. * @param predicate defines a predicate used to select candidate sprites
  83389. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  83390. * @returns null if no hit or a PickingInfo
  83391. */
  83392. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  83393. /**
  83394. * Intersects the sprites with a ray
  83395. * @param ray defines the ray to intersect with
  83396. * @param camera defines the current active camera
  83397. * @param predicate defines a predicate used to select candidate sprites
  83398. * @returns null if no hit or a PickingInfo array
  83399. */
  83400. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  83401. /**
  83402. * Render all child sprites
  83403. */
  83404. render(): void;
  83405. /**
  83406. * Release associated resources
  83407. */
  83408. dispose(): void;
  83409. }
  83410. }
  83411. declare module BABYLON {
  83412. /** Interface used by value gradients (color, factor, ...) */
  83413. export interface IValueGradient {
  83414. /**
  83415. * Gets or sets the gradient value (between 0 and 1)
  83416. */
  83417. gradient: number;
  83418. }
  83419. /** Class used to store color4 gradient */
  83420. export class ColorGradient implements IValueGradient {
  83421. /**
  83422. * Gets or sets the gradient value (between 0 and 1)
  83423. */
  83424. gradient: number;
  83425. /**
  83426. * Gets or sets first associated color
  83427. */
  83428. color1: Color4;
  83429. /**
  83430. * Gets or sets second associated color
  83431. */
  83432. color2?: Color4;
  83433. /**
  83434. * Will get a color picked randomly between color1 and color2.
  83435. * If color2 is undefined then color1 will be used
  83436. * @param result defines the target Color4 to store the result in
  83437. */
  83438. getColorToRef(result: Color4): void;
  83439. }
  83440. /** Class used to store color 3 gradient */
  83441. export class Color3Gradient implements IValueGradient {
  83442. /**
  83443. * Gets or sets the gradient value (between 0 and 1)
  83444. */
  83445. gradient: number;
  83446. /**
  83447. * Gets or sets the associated color
  83448. */
  83449. color: Color3;
  83450. }
  83451. /** Class used to store factor gradient */
  83452. export class FactorGradient implements IValueGradient {
  83453. /**
  83454. * Gets or sets the gradient value (between 0 and 1)
  83455. */
  83456. gradient: number;
  83457. /**
  83458. * Gets or sets first associated factor
  83459. */
  83460. factor1: number;
  83461. /**
  83462. * Gets or sets second associated factor
  83463. */
  83464. factor2?: number;
  83465. /**
  83466. * Will get a number picked randomly between factor1 and factor2.
  83467. * If factor2 is undefined then factor1 will be used
  83468. * @returns the picked number
  83469. */
  83470. getFactor(): number;
  83471. }
  83472. /**
  83473. * Helper used to simplify some generic gradient tasks
  83474. */
  83475. export class GradientHelper {
  83476. /**
  83477. * Gets the current gradient from an array of IValueGradient
  83478. * @param ratio defines the current ratio to get
  83479. * @param gradients defines the array of IValueGradient
  83480. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  83481. */
  83482. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  83483. }
  83484. }
  83485. declare module BABYLON {
  83486. /**
  83487. * Interface for the size containing width and height
  83488. */
  83489. export interface ISize {
  83490. /**
  83491. * Width
  83492. */
  83493. width: number;
  83494. /**
  83495. * Heighht
  83496. */
  83497. height: number;
  83498. }
  83499. /**
  83500. * Size containing widht and height
  83501. */
  83502. export class Size implements ISize {
  83503. /**
  83504. * Width
  83505. */
  83506. width: number;
  83507. /**
  83508. * Height
  83509. */
  83510. height: number;
  83511. /**
  83512. * Creates a Size object from the given width and height (floats).
  83513. * @param width width of the new size
  83514. * @param height height of the new size
  83515. */
  83516. constructor(width: number, height: number);
  83517. /**
  83518. * Returns a string with the Size width and height
  83519. * @returns a string with the Size width and height
  83520. */
  83521. toString(): string;
  83522. /**
  83523. * "Size"
  83524. * @returns the string "Size"
  83525. */
  83526. getClassName(): string;
  83527. /**
  83528. * Returns the Size hash code.
  83529. * @returns a hash code for a unique width and height
  83530. */
  83531. getHashCode(): number;
  83532. /**
  83533. * Updates the current size from the given one.
  83534. * @param src the given size
  83535. */
  83536. copyFrom(src: Size): void;
  83537. /**
  83538. * Updates in place the current Size from the given floats.
  83539. * @param width width of the new size
  83540. * @param height height of the new size
  83541. * @returns the updated Size.
  83542. */
  83543. copyFromFloats(width: number, height: number): Size;
  83544. /**
  83545. * Updates in place the current Size from the given floats.
  83546. * @param width width to set
  83547. * @param height height to set
  83548. * @returns the updated Size.
  83549. */
  83550. set(width: number, height: number): Size;
  83551. /**
  83552. * Multiplies the width and height by numbers
  83553. * @param w factor to multiple the width by
  83554. * @param h factor to multiple the height by
  83555. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  83556. */
  83557. multiplyByFloats(w: number, h: number): Size;
  83558. /**
  83559. * Clones the size
  83560. * @returns a new Size copied from the given one.
  83561. */
  83562. clone(): Size;
  83563. /**
  83564. * True if the current Size and the given one width and height are strictly equal.
  83565. * @param other the other size to compare against
  83566. * @returns True if the current Size and the given one width and height are strictly equal.
  83567. */
  83568. equals(other: Size): boolean;
  83569. /**
  83570. * The surface of the Size : width * height (float).
  83571. */
  83572. get surface(): number;
  83573. /**
  83574. * Create a new size of zero
  83575. * @returns a new Size set to (0.0, 0.0)
  83576. */
  83577. static Zero(): Size;
  83578. /**
  83579. * Sums the width and height of two sizes
  83580. * @param otherSize size to add to this size
  83581. * @returns a new Size set as the addition result of the current Size and the given one.
  83582. */
  83583. add(otherSize: Size): Size;
  83584. /**
  83585. * Subtracts the width and height of two
  83586. * @param otherSize size to subtract to this size
  83587. * @returns a new Size set as the subtraction result of the given one from the current Size.
  83588. */
  83589. subtract(otherSize: Size): Size;
  83590. /**
  83591. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  83592. * @param start starting size to lerp between
  83593. * @param end end size to lerp between
  83594. * @param amount amount to lerp between the start and end values
  83595. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  83596. */
  83597. static Lerp(start: Size, end: Size, amount: number): Size;
  83598. }
  83599. }
  83600. declare module BABYLON {
  83601. interface ThinEngine {
  83602. /**
  83603. * Creates a dynamic texture
  83604. * @param width defines the width of the texture
  83605. * @param height defines the height of the texture
  83606. * @param generateMipMaps defines if the engine should generate the mip levels
  83607. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83608. * @returns the dynamic texture inside an InternalTexture
  83609. */
  83610. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  83611. /**
  83612. * Update the content of a dynamic texture
  83613. * @param texture defines the texture to update
  83614. * @param canvas defines the canvas containing the source
  83615. * @param invertY defines if data must be stored with Y axis inverted
  83616. * @param premulAlpha defines if alpha is stored as premultiplied
  83617. * @param format defines the format of the data
  83618. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  83619. */
  83620. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  83621. }
  83622. }
  83623. declare module BABYLON {
  83624. /**
  83625. * Helper class used to generate a canvas to manipulate images
  83626. */
  83627. export class CanvasGenerator {
  83628. /**
  83629. * Create a new canvas (or offscreen canvas depending on the context)
  83630. * @param width defines the expected width
  83631. * @param height defines the expected height
  83632. * @return a new canvas or offscreen canvas
  83633. */
  83634. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  83635. }
  83636. }
  83637. declare module BABYLON {
  83638. /**
  83639. * A class extending Texture allowing drawing on a texture
  83640. * @see http://doc.babylonjs.com/how_to/dynamictexture
  83641. */
  83642. export class DynamicTexture extends Texture {
  83643. private _generateMipMaps;
  83644. private _canvas;
  83645. private _context;
  83646. private _engine;
  83647. /**
  83648. * Creates a DynamicTexture
  83649. * @param name defines the name of the texture
  83650. * @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
  83651. * @param scene defines the scene where you want the texture
  83652. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  83653. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  83654. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  83655. */
  83656. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  83657. /**
  83658. * Get the current class name of the texture useful for serialization or dynamic coding.
  83659. * @returns "DynamicTexture"
  83660. */
  83661. getClassName(): string;
  83662. /**
  83663. * Gets the current state of canRescale
  83664. */
  83665. get canRescale(): boolean;
  83666. private _recreate;
  83667. /**
  83668. * Scales the texture
  83669. * @param ratio the scale factor to apply to both width and height
  83670. */
  83671. scale(ratio: number): void;
  83672. /**
  83673. * Resizes the texture
  83674. * @param width the new width
  83675. * @param height the new height
  83676. */
  83677. scaleTo(width: number, height: number): void;
  83678. /**
  83679. * Gets the context of the canvas used by the texture
  83680. * @returns the canvas context of the dynamic texture
  83681. */
  83682. getContext(): CanvasRenderingContext2D;
  83683. /**
  83684. * Clears the texture
  83685. */
  83686. clear(): void;
  83687. /**
  83688. * Updates the texture
  83689. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83690. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  83691. */
  83692. update(invertY?: boolean, premulAlpha?: boolean): void;
  83693. /**
  83694. * Draws text onto the texture
  83695. * @param text defines the text to be drawn
  83696. * @param x defines the placement of the text from the left
  83697. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  83698. * @param font defines the font to be used with font-style, font-size, font-name
  83699. * @param color defines the color used for the text
  83700. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  83701. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83702. * @param update defines whether texture is immediately update (default is true)
  83703. */
  83704. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  83705. /**
  83706. * Clones the texture
  83707. * @returns the clone of the texture.
  83708. */
  83709. clone(): DynamicTexture;
  83710. /**
  83711. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  83712. * @returns a serialized dynamic texture object
  83713. */
  83714. serialize(): any;
  83715. /** @hidden */
  83716. _rebuild(): void;
  83717. }
  83718. }
  83719. declare module BABYLON {
  83720. interface Engine {
  83721. /**
  83722. * Creates a raw texture
  83723. * @param data defines the data to store in the texture
  83724. * @param width defines the width of the texture
  83725. * @param height defines the height of the texture
  83726. * @param format defines the format of the data
  83727. * @param generateMipMaps defines if the engine should generate the mip levels
  83728. * @param invertY defines if data must be stored with Y axis inverted
  83729. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  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. * @returns the raw texture inside an InternalTexture
  83733. */
  83734. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  83735. /**
  83736. * Update a raw texture
  83737. * @param texture defines the texture to update
  83738. * @param data defines the data to store in the texture
  83739. * @param format defines the format of the data
  83740. * @param invertY defines if data must be stored with Y axis inverted
  83741. */
  83742. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83743. /**
  83744. * Update a raw texture
  83745. * @param texture defines the texture to update
  83746. * @param data defines the data to store in the texture
  83747. * @param format defines the format of the data
  83748. * @param invertY defines if data must be stored with Y axis inverted
  83749. * @param compression defines the compression used (null by default)
  83750. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83751. */
  83752. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  83753. /**
  83754. * Creates a new raw cube texture
  83755. * @param data defines the array of data to use to create each face
  83756. * @param size defines the size of the textures
  83757. * @param format defines the format of the data
  83758. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83759. * @param generateMipMaps defines if the engine should generate the mip levels
  83760. * @param invertY defines if data must be stored with Y axis inverted
  83761. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83762. * @param compression defines the compression used (null by default)
  83763. * @returns the cube texture as an InternalTexture
  83764. */
  83765. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  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. */
  83774. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  83775. /**
  83776. * Update a raw cube texture
  83777. * @param texture defines the texture to udpdate
  83778. * @param data defines the data to store
  83779. * @param format defines the data format
  83780. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83781. * @param invertY defines if data must be stored with Y axis inverted
  83782. * @param compression defines the compression used (null by default)
  83783. */
  83784. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  83785. /**
  83786. * Update a raw cube texture
  83787. * @param texture defines the texture to udpdate
  83788. * @param data defines the data to store
  83789. * @param format defines the data format
  83790. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83791. * @param invertY defines if data must be stored with Y axis inverted
  83792. * @param compression defines the compression used (null by default)
  83793. * @param level defines which level of the texture to update
  83794. */
  83795. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  83796. /**
  83797. * Creates a new raw cube texture from a specified url
  83798. * @param url defines the url where the data is located
  83799. * @param scene defines the current scene
  83800. * @param size defines the size of the textures
  83801. * @param format defines the format of the data
  83802. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83803. * @param noMipmap defines if the engine should avoid generating the mip levels
  83804. * @param callback defines a callback used to extract texture data from loaded data
  83805. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  83806. * @param onLoad defines a callback called when texture is loaded
  83807. * @param onError defines a callback called if there is an error
  83808. * @returns the cube texture as an InternalTexture
  83809. */
  83810. 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;
  83811. /**
  83812. * Creates a new raw cube texture from a specified url
  83813. * @param url defines the url where the data is located
  83814. * @param scene defines the current scene
  83815. * @param size defines the size of the textures
  83816. * @param format defines the format of the data
  83817. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83818. * @param noMipmap defines if the engine should avoid generating the mip levels
  83819. * @param callback defines a callback used to extract texture data from loaded data
  83820. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  83821. * @param onLoad defines a callback called when texture is loaded
  83822. * @param onError defines a callback called if there is an error
  83823. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83824. * @param invertY defines if data must be stored with Y axis inverted
  83825. * @returns the cube texture as an InternalTexture
  83826. */
  83827. 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;
  83828. /**
  83829. * Creates a new raw 3D texture
  83830. * @param data defines the data used to create the texture
  83831. * @param width defines the width of the texture
  83832. * @param height defines the height of the texture
  83833. * @param depth defines the depth of the texture
  83834. * @param format defines the format of the texture
  83835. * @param generateMipMaps defines if the engine must generate mip levels
  83836. * @param invertY defines if data must be stored with Y axis inverted
  83837. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83838. * @param compression defines the compressed used (can be null)
  83839. * @param textureType defines the compressed used (can be null)
  83840. * @returns a new raw 3D texture (stored in an InternalTexture)
  83841. */
  83842. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  83843. /**
  83844. * Update a raw 3D texture
  83845. * @param texture defines the texture to update
  83846. * @param data defines the data to store
  83847. * @param format defines the data format
  83848. * @param invertY defines if data must be stored with Y axis inverted
  83849. */
  83850. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83851. /**
  83852. * Update a raw 3D texture
  83853. * @param texture defines the texture to update
  83854. * @param data defines the data to store
  83855. * @param format defines the data format
  83856. * @param invertY defines if data must be stored with Y axis inverted
  83857. * @param compression defines the used compression (can be null)
  83858. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  83859. */
  83860. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  83861. /**
  83862. * Creates a new raw 2D array texture
  83863. * @param data defines the data used to create the texture
  83864. * @param width defines the width of the texture
  83865. * @param height defines the height of the texture
  83866. * @param depth defines the number of layers of the texture
  83867. * @param format defines the format of the texture
  83868. * @param generateMipMaps defines if the engine must generate mip levels
  83869. * @param invertY defines if data must be stored with Y axis inverted
  83870. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83871. * @param compression defines the compressed used (can be null)
  83872. * @param textureType defines the compressed used (can be null)
  83873. * @returns a new raw 2D array texture (stored in an InternalTexture)
  83874. */
  83875. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  83876. /**
  83877. * Update a raw 2D array texture
  83878. * @param texture defines the texture to update
  83879. * @param data defines the data to store
  83880. * @param format defines the data format
  83881. * @param invertY defines if data must be stored with Y axis inverted
  83882. */
  83883. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83884. /**
  83885. * Update a raw 2D array texture
  83886. * @param texture defines the texture to update
  83887. * @param data defines the data to store
  83888. * @param format defines the data format
  83889. * @param invertY defines if data must be stored with Y axis inverted
  83890. * @param compression defines the used compression (can be null)
  83891. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  83892. */
  83893. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  83894. }
  83895. }
  83896. declare module BABYLON {
  83897. /**
  83898. * Raw texture can help creating a texture directly from an array of data.
  83899. * This can be super useful if you either get the data from an uncompressed source or
  83900. * if you wish to create your texture pixel by pixel.
  83901. */
  83902. export class RawTexture extends Texture {
  83903. /**
  83904. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83905. */
  83906. format: number;
  83907. private _engine;
  83908. /**
  83909. * Instantiates a new RawTexture.
  83910. * Raw texture can help creating a texture directly from an array of data.
  83911. * This can be super useful if you either get the data from an uncompressed source or
  83912. * if you wish to create your texture pixel by pixel.
  83913. * @param data define the array of data to use to create the texture
  83914. * @param width define the width of the texture
  83915. * @param height define the height of the texture
  83916. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83917. * @param scene define the scene the texture belongs to
  83918. * @param generateMipMaps define whether mip maps should be generated or not
  83919. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83920. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83921. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83922. */
  83923. constructor(data: ArrayBufferView, width: number, height: number,
  83924. /**
  83925. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83926. */
  83927. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  83928. /**
  83929. * Updates the texture underlying data.
  83930. * @param data Define the new data of the texture
  83931. */
  83932. update(data: ArrayBufferView): void;
  83933. /**
  83934. * Creates a luminance texture from some data.
  83935. * @param data Define the texture data
  83936. * @param width Define the width of the texture
  83937. * @param height Define the height of the texture
  83938. * @param scene Define the scene the texture belongs to
  83939. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83940. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83941. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83942. * @returns the luminance texture
  83943. */
  83944. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83945. /**
  83946. * Creates a luminance alpha texture from some data.
  83947. * @param data Define the texture data
  83948. * @param width Define the width of the texture
  83949. * @param height Define the height of the texture
  83950. * @param scene Define the scene the texture belongs to
  83951. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83952. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83953. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83954. * @returns the luminance alpha texture
  83955. */
  83956. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83957. /**
  83958. * Creates an alpha texture from some data.
  83959. * @param data Define the texture data
  83960. * @param width Define the width of the texture
  83961. * @param height Define the height of the texture
  83962. * @param scene Define the scene the texture belongs to
  83963. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83964. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83965. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83966. * @returns the alpha texture
  83967. */
  83968. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83969. /**
  83970. * Creates a RGB texture from some data.
  83971. * @param data Define the texture data
  83972. * @param width Define the width of the texture
  83973. * @param height Define the height of the texture
  83974. * @param scene Define the scene the texture belongs to
  83975. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83976. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83977. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83978. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83979. * @returns the RGB alpha texture
  83980. */
  83981. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83982. /**
  83983. * Creates a RGBA texture from some data.
  83984. * @param data Define the texture data
  83985. * @param width Define the width of the texture
  83986. * @param height Define the height of the texture
  83987. * @param scene Define the scene the texture belongs to
  83988. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83989. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83990. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83991. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83992. * @returns the RGBA texture
  83993. */
  83994. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83995. /**
  83996. * Creates a R texture from some data.
  83997. * @param data Define the texture data
  83998. * @param width Define the width of the texture
  83999. * @param height Define the height of the texture
  84000. * @param scene Define the scene the texture belongs to
  84001. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84002. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84003. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84004. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  84005. * @returns the R texture
  84006. */
  84007. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  84008. }
  84009. }
  84010. declare module BABYLON {
  84011. interface AbstractScene {
  84012. /**
  84013. * The list of procedural textures added to the scene
  84014. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84015. */
  84016. proceduralTextures: Array<ProceduralTexture>;
  84017. }
  84018. /**
  84019. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  84020. * in a given scene.
  84021. */
  84022. export class ProceduralTextureSceneComponent implements ISceneComponent {
  84023. /**
  84024. * The component name helpfull to identify the component in the list of scene components.
  84025. */
  84026. readonly name: string;
  84027. /**
  84028. * The scene the component belongs to.
  84029. */
  84030. scene: Scene;
  84031. /**
  84032. * Creates a new instance of the component for the given scene
  84033. * @param scene Defines the scene to register the component in
  84034. */
  84035. constructor(scene: Scene);
  84036. /**
  84037. * Registers the component in a given scene
  84038. */
  84039. register(): void;
  84040. /**
  84041. * Rebuilds the elements related to this component in case of
  84042. * context lost for instance.
  84043. */
  84044. rebuild(): void;
  84045. /**
  84046. * Disposes the component and the associated ressources.
  84047. */
  84048. dispose(): void;
  84049. private _beforeClear;
  84050. }
  84051. }
  84052. declare module BABYLON {
  84053. interface ThinEngine {
  84054. /**
  84055. * Creates a new render target cube texture
  84056. * @param size defines the size of the texture
  84057. * @param options defines the options used to create the texture
  84058. * @returns a new render target cube texture stored in an InternalTexture
  84059. */
  84060. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  84061. }
  84062. }
  84063. declare module BABYLON {
  84064. /** @hidden */
  84065. export var proceduralVertexShader: {
  84066. name: string;
  84067. shader: string;
  84068. };
  84069. }
  84070. declare module BABYLON {
  84071. /**
  84072. * 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.
  84073. * This is the base class of any Procedural texture and contains most of the shareable code.
  84074. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84075. */
  84076. export class ProceduralTexture extends Texture {
  84077. isCube: boolean;
  84078. /**
  84079. * Define if the texture is enabled or not (disabled texture will not render)
  84080. */
  84081. isEnabled: boolean;
  84082. /**
  84083. * Define if the texture must be cleared before rendering (default is true)
  84084. */
  84085. autoClear: boolean;
  84086. /**
  84087. * Callback called when the texture is generated
  84088. */
  84089. onGenerated: () => void;
  84090. /**
  84091. * Event raised when the texture is generated
  84092. */
  84093. onGeneratedObservable: Observable<ProceduralTexture>;
  84094. /** @hidden */
  84095. _generateMipMaps: boolean;
  84096. /** @hidden **/
  84097. _effect: Effect;
  84098. /** @hidden */
  84099. _textures: {
  84100. [key: string]: Texture;
  84101. };
  84102. private _size;
  84103. private _currentRefreshId;
  84104. private _frameId;
  84105. private _refreshRate;
  84106. private _vertexBuffers;
  84107. private _indexBuffer;
  84108. private _uniforms;
  84109. private _samplers;
  84110. private _fragment;
  84111. private _floats;
  84112. private _ints;
  84113. private _floatsArrays;
  84114. private _colors3;
  84115. private _colors4;
  84116. private _vectors2;
  84117. private _vectors3;
  84118. private _matrices;
  84119. private _fallbackTexture;
  84120. private _fallbackTextureUsed;
  84121. private _engine;
  84122. private _cachedDefines;
  84123. private _contentUpdateId;
  84124. private _contentData;
  84125. /**
  84126. * Instantiates a new procedural texture.
  84127. * 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.
  84128. * This is the base class of any Procedural texture and contains most of the shareable code.
  84129. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84130. * @param name Define the name of the texture
  84131. * @param size Define the size of the texture to create
  84132. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  84133. * @param scene Define the scene the texture belongs to
  84134. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  84135. * @param generateMipMaps Define if the texture should creates mip maps or not
  84136. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  84137. */
  84138. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  84139. /**
  84140. * The effect that is created when initializing the post process.
  84141. * @returns The created effect corresponding the the postprocess.
  84142. */
  84143. getEffect(): Effect;
  84144. /**
  84145. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  84146. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  84147. */
  84148. getContent(): Nullable<ArrayBufferView>;
  84149. private _createIndexBuffer;
  84150. /** @hidden */
  84151. _rebuild(): void;
  84152. /**
  84153. * Resets the texture in order to recreate its associated resources.
  84154. * This can be called in case of context loss
  84155. */
  84156. reset(): void;
  84157. protected _getDefines(): string;
  84158. /**
  84159. * Is the texture ready to be used ? (rendered at least once)
  84160. * @returns true if ready, otherwise, false.
  84161. */
  84162. isReady(): boolean;
  84163. /**
  84164. * Resets the refresh counter of the texture and start bak from scratch.
  84165. * Could be useful to regenerate the texture if it is setup to render only once.
  84166. */
  84167. resetRefreshCounter(): void;
  84168. /**
  84169. * Set the fragment shader to use in order to render the texture.
  84170. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  84171. */
  84172. setFragment(fragment: any): void;
  84173. /**
  84174. * Define the refresh rate of the texture or the rendering frequency.
  84175. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84176. */
  84177. get refreshRate(): number;
  84178. set refreshRate(value: number);
  84179. /** @hidden */
  84180. _shouldRender(): boolean;
  84181. /**
  84182. * Get the size the texture is rendering at.
  84183. * @returns the size (texture is always squared)
  84184. */
  84185. getRenderSize(): number;
  84186. /**
  84187. * Resize the texture to new value.
  84188. * @param size Define the new size the texture should have
  84189. * @param generateMipMaps Define whether the new texture should create mip maps
  84190. */
  84191. resize(size: number, generateMipMaps: boolean): void;
  84192. private _checkUniform;
  84193. /**
  84194. * Set a texture in the shader program used to render.
  84195. * @param name Define the name of the uniform samplers as defined in the shader
  84196. * @param texture Define the texture to bind to this sampler
  84197. * @return the texture itself allowing "fluent" like uniform updates
  84198. */
  84199. setTexture(name: string, texture: Texture): ProceduralTexture;
  84200. /**
  84201. * Set a float in the shader.
  84202. * @param name Define the name of the uniform as defined in the shader
  84203. * @param value Define the value to give to the uniform
  84204. * @return the texture itself allowing "fluent" like uniform updates
  84205. */
  84206. setFloat(name: string, value: number): ProceduralTexture;
  84207. /**
  84208. * Set a int in the shader.
  84209. * @param name Define the name of the uniform as defined in the shader
  84210. * @param value Define the value to give to the uniform
  84211. * @return the texture itself allowing "fluent" like uniform updates
  84212. */
  84213. setInt(name: string, value: number): ProceduralTexture;
  84214. /**
  84215. * Set an array of floats in the shader.
  84216. * @param name Define the name of the uniform as defined in the shader
  84217. * @param value Define the value to give to the uniform
  84218. * @return the texture itself allowing "fluent" like uniform updates
  84219. */
  84220. setFloats(name: string, value: number[]): ProceduralTexture;
  84221. /**
  84222. * Set a vec3 in the shader from a Color3.
  84223. * @param name Define the name of the uniform as defined in the shader
  84224. * @param value Define the value to give to the uniform
  84225. * @return the texture itself allowing "fluent" like uniform updates
  84226. */
  84227. setColor3(name: string, value: Color3): ProceduralTexture;
  84228. /**
  84229. * Set a vec4 in the shader from a Color4.
  84230. * @param name Define the name of the uniform as defined in the shader
  84231. * @param value Define the value to give to the uniform
  84232. * @return the texture itself allowing "fluent" like uniform updates
  84233. */
  84234. setColor4(name: string, value: Color4): ProceduralTexture;
  84235. /**
  84236. * Set a vec2 in the shader from a Vector2.
  84237. * @param name Define the name of the uniform as defined in the shader
  84238. * @param value Define the value to give to the uniform
  84239. * @return the texture itself allowing "fluent" like uniform updates
  84240. */
  84241. setVector2(name: string, value: Vector2): ProceduralTexture;
  84242. /**
  84243. * Set a vec3 in the shader from a Vector3.
  84244. * @param name Define the name of the uniform as defined in the shader
  84245. * @param value Define the value to give to the uniform
  84246. * @return the texture itself allowing "fluent" like uniform updates
  84247. */
  84248. setVector3(name: string, value: Vector3): ProceduralTexture;
  84249. /**
  84250. * Set a mat4 in the shader from a MAtrix.
  84251. * @param name Define the name of the uniform as defined in the shader
  84252. * @param value Define the value to give to the uniform
  84253. * @return the texture itself allowing "fluent" like uniform updates
  84254. */
  84255. setMatrix(name: string, value: Matrix): ProceduralTexture;
  84256. /**
  84257. * Render the texture to its associated render target.
  84258. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  84259. */
  84260. render(useCameraPostProcess?: boolean): void;
  84261. /**
  84262. * Clone the texture.
  84263. * @returns the cloned texture
  84264. */
  84265. clone(): ProceduralTexture;
  84266. /**
  84267. * Dispose the texture and release its asoociated resources.
  84268. */
  84269. dispose(): void;
  84270. }
  84271. }
  84272. declare module BABYLON {
  84273. /**
  84274. * This represents the base class for particle system in Babylon.
  84275. * 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.
  84276. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84277. * @example https://doc.babylonjs.com/babylon101/particles
  84278. */
  84279. export class BaseParticleSystem {
  84280. /**
  84281. * Source color is added to the destination color without alpha affecting the result
  84282. */
  84283. static BLENDMODE_ONEONE: number;
  84284. /**
  84285. * Blend current color and particle color using particle’s alpha
  84286. */
  84287. static BLENDMODE_STANDARD: number;
  84288. /**
  84289. * Add current color and particle color multiplied by particle’s alpha
  84290. */
  84291. static BLENDMODE_ADD: number;
  84292. /**
  84293. * Multiply current color with particle color
  84294. */
  84295. static BLENDMODE_MULTIPLY: number;
  84296. /**
  84297. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  84298. */
  84299. static BLENDMODE_MULTIPLYADD: number;
  84300. /**
  84301. * List of animations used by the particle system.
  84302. */
  84303. animations: Animation[];
  84304. /**
  84305. * The id of the Particle system.
  84306. */
  84307. id: string;
  84308. /**
  84309. * The friendly name of the Particle system.
  84310. */
  84311. name: string;
  84312. /**
  84313. * The rendering group used by the Particle system to chose when to render.
  84314. */
  84315. renderingGroupId: number;
  84316. /**
  84317. * The emitter represents the Mesh or position we are attaching the particle system to.
  84318. */
  84319. emitter: Nullable<AbstractMesh | Vector3>;
  84320. /**
  84321. * The maximum number of particles to emit per frame
  84322. */
  84323. emitRate: number;
  84324. /**
  84325. * If you want to launch only a few particles at once, that can be done, as well.
  84326. */
  84327. manualEmitCount: number;
  84328. /**
  84329. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  84330. */
  84331. updateSpeed: number;
  84332. /**
  84333. * The amount of time the particle system is running (depends of the overall update speed).
  84334. */
  84335. targetStopDuration: number;
  84336. /**
  84337. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  84338. */
  84339. disposeOnStop: boolean;
  84340. /**
  84341. * Minimum power of emitting particles.
  84342. */
  84343. minEmitPower: number;
  84344. /**
  84345. * Maximum power of emitting particles.
  84346. */
  84347. maxEmitPower: number;
  84348. /**
  84349. * Minimum life time of emitting particles.
  84350. */
  84351. minLifeTime: number;
  84352. /**
  84353. * Maximum life time of emitting particles.
  84354. */
  84355. maxLifeTime: number;
  84356. /**
  84357. * Minimum Size of emitting particles.
  84358. */
  84359. minSize: number;
  84360. /**
  84361. * Maximum Size of emitting particles.
  84362. */
  84363. maxSize: number;
  84364. /**
  84365. * Minimum scale of emitting particles on X axis.
  84366. */
  84367. minScaleX: number;
  84368. /**
  84369. * Maximum scale of emitting particles on X axis.
  84370. */
  84371. maxScaleX: number;
  84372. /**
  84373. * Minimum scale of emitting particles on Y axis.
  84374. */
  84375. minScaleY: number;
  84376. /**
  84377. * Maximum scale of emitting particles on Y axis.
  84378. */
  84379. maxScaleY: number;
  84380. /**
  84381. * Gets or sets the minimal initial rotation in radians.
  84382. */
  84383. minInitialRotation: number;
  84384. /**
  84385. * Gets or sets the maximal initial rotation in radians.
  84386. */
  84387. maxInitialRotation: number;
  84388. /**
  84389. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  84390. */
  84391. minAngularSpeed: number;
  84392. /**
  84393. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  84394. */
  84395. maxAngularSpeed: number;
  84396. /**
  84397. * The texture used to render each particle. (this can be a spritesheet)
  84398. */
  84399. particleTexture: Nullable<Texture>;
  84400. /**
  84401. * The layer mask we are rendering the particles through.
  84402. */
  84403. layerMask: number;
  84404. /**
  84405. * This can help using your own shader to render the particle system.
  84406. * The according effect will be created
  84407. */
  84408. customShader: any;
  84409. /**
  84410. * By default particle system starts as soon as they are created. This prevents the
  84411. * automatic start to happen and let you decide when to start emitting particles.
  84412. */
  84413. preventAutoStart: boolean;
  84414. private _noiseTexture;
  84415. /**
  84416. * Gets or sets a texture used to add random noise to particle positions
  84417. */
  84418. get noiseTexture(): Nullable<ProceduralTexture>;
  84419. set noiseTexture(value: Nullable<ProceduralTexture>);
  84420. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  84421. noiseStrength: Vector3;
  84422. /**
  84423. * Callback triggered when the particle animation is ending.
  84424. */
  84425. onAnimationEnd: Nullable<() => void>;
  84426. /**
  84427. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  84428. */
  84429. blendMode: number;
  84430. /**
  84431. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  84432. * to override the particles.
  84433. */
  84434. forceDepthWrite: boolean;
  84435. /** 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 */
  84436. preWarmCycles: number;
  84437. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  84438. preWarmStepOffset: number;
  84439. /**
  84440. * 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)
  84441. */
  84442. spriteCellChangeSpeed: number;
  84443. /**
  84444. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  84445. */
  84446. startSpriteCellID: number;
  84447. /**
  84448. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  84449. */
  84450. endSpriteCellID: number;
  84451. /**
  84452. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  84453. */
  84454. spriteCellWidth: number;
  84455. /**
  84456. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  84457. */
  84458. spriteCellHeight: number;
  84459. /**
  84460. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  84461. */
  84462. spriteRandomStartCell: boolean;
  84463. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  84464. translationPivot: Vector2;
  84465. /** @hidden */
  84466. protected _isAnimationSheetEnabled: boolean;
  84467. /**
  84468. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  84469. */
  84470. beginAnimationOnStart: boolean;
  84471. /**
  84472. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  84473. */
  84474. beginAnimationFrom: number;
  84475. /**
  84476. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  84477. */
  84478. beginAnimationTo: number;
  84479. /**
  84480. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  84481. */
  84482. beginAnimationLoop: boolean;
  84483. /**
  84484. * Gets or sets a world offset applied to all particles
  84485. */
  84486. worldOffset: Vector3;
  84487. /**
  84488. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  84489. */
  84490. get isAnimationSheetEnabled(): boolean;
  84491. set isAnimationSheetEnabled(value: boolean);
  84492. /**
  84493. * Get hosting scene
  84494. * @returns the scene
  84495. */
  84496. getScene(): Scene;
  84497. /**
  84498. * You can use gravity if you want to give an orientation to your particles.
  84499. */
  84500. gravity: Vector3;
  84501. protected _colorGradients: Nullable<Array<ColorGradient>>;
  84502. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  84503. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  84504. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  84505. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  84506. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  84507. protected _dragGradients: Nullable<Array<FactorGradient>>;
  84508. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  84509. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  84510. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  84511. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  84512. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  84513. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  84514. /**
  84515. * Defines the delay in milliseconds before starting the system (0 by default)
  84516. */
  84517. startDelay: number;
  84518. /**
  84519. * Gets the current list of drag gradients.
  84520. * You must use addDragGradient and removeDragGradient to udpate this list
  84521. * @returns the list of drag gradients
  84522. */
  84523. getDragGradients(): Nullable<Array<FactorGradient>>;
  84524. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  84525. limitVelocityDamping: number;
  84526. /**
  84527. * Gets the current list of limit velocity gradients.
  84528. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  84529. * @returns the list of limit velocity gradients
  84530. */
  84531. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  84532. /**
  84533. * Gets the current list of color gradients.
  84534. * You must use addColorGradient and removeColorGradient to udpate this list
  84535. * @returns the list of color gradients
  84536. */
  84537. getColorGradients(): Nullable<Array<ColorGradient>>;
  84538. /**
  84539. * Gets the current list of size gradients.
  84540. * You must use addSizeGradient and removeSizeGradient to udpate this list
  84541. * @returns the list of size gradients
  84542. */
  84543. getSizeGradients(): Nullable<Array<FactorGradient>>;
  84544. /**
  84545. * Gets the current list of color remap gradients.
  84546. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  84547. * @returns the list of color remap gradients
  84548. */
  84549. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  84550. /**
  84551. * Gets the current list of alpha remap gradients.
  84552. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  84553. * @returns the list of alpha remap gradients
  84554. */
  84555. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  84556. /**
  84557. * Gets the current list of life time gradients.
  84558. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  84559. * @returns the list of life time gradients
  84560. */
  84561. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  84562. /**
  84563. * Gets the current list of angular speed gradients.
  84564. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  84565. * @returns the list of angular speed gradients
  84566. */
  84567. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  84568. /**
  84569. * Gets the current list of velocity gradients.
  84570. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  84571. * @returns the list of velocity gradients
  84572. */
  84573. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  84574. /**
  84575. * Gets the current list of start size gradients.
  84576. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  84577. * @returns the list of start size gradients
  84578. */
  84579. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  84580. /**
  84581. * Gets the current list of emit rate gradients.
  84582. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  84583. * @returns the list of emit rate gradients
  84584. */
  84585. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  84586. /**
  84587. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84588. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84589. */
  84590. get direction1(): Vector3;
  84591. set direction1(value: Vector3);
  84592. /**
  84593. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84594. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84595. */
  84596. get direction2(): Vector3;
  84597. set direction2(value: Vector3);
  84598. /**
  84599. * 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.
  84600. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84601. */
  84602. get minEmitBox(): Vector3;
  84603. set minEmitBox(value: Vector3);
  84604. /**
  84605. * 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.
  84606. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84607. */
  84608. get maxEmitBox(): Vector3;
  84609. set maxEmitBox(value: Vector3);
  84610. /**
  84611. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84612. */
  84613. color1: Color4;
  84614. /**
  84615. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84616. */
  84617. color2: Color4;
  84618. /**
  84619. * Color the particle will have at the end of its lifetime
  84620. */
  84621. colorDead: Color4;
  84622. /**
  84623. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  84624. */
  84625. textureMask: Color4;
  84626. /**
  84627. * The particle emitter type defines the emitter used by the particle system.
  84628. * It can be for example box, sphere, or cone...
  84629. */
  84630. particleEmitterType: IParticleEmitterType;
  84631. /** @hidden */
  84632. _isSubEmitter: boolean;
  84633. /**
  84634. * Gets or sets the billboard mode to use when isBillboardBased = true.
  84635. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  84636. */
  84637. billboardMode: number;
  84638. protected _isBillboardBased: boolean;
  84639. /**
  84640. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  84641. */
  84642. get isBillboardBased(): boolean;
  84643. set isBillboardBased(value: boolean);
  84644. /**
  84645. * The scene the particle system belongs to.
  84646. */
  84647. protected _scene: Scene;
  84648. /**
  84649. * Local cache of defines for image processing.
  84650. */
  84651. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  84652. /**
  84653. * Default configuration related to image processing available in the standard Material.
  84654. */
  84655. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  84656. /**
  84657. * Gets the image processing configuration used either in this material.
  84658. */
  84659. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  84660. /**
  84661. * Sets the Default image processing configuration used either in the this material.
  84662. *
  84663. * If sets to null, the scene one is in use.
  84664. */
  84665. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  84666. /**
  84667. * Attaches a new image processing configuration to the Standard Material.
  84668. * @param configuration
  84669. */
  84670. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  84671. /** @hidden */
  84672. protected _reset(): void;
  84673. /** @hidden */
  84674. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  84675. /**
  84676. * Instantiates a particle system.
  84677. * 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.
  84678. * @param name The name of the particle system
  84679. */
  84680. constructor(name: string);
  84681. /**
  84682. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  84683. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84684. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84685. * @returns the emitter
  84686. */
  84687. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  84688. /**
  84689. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  84690. * @param radius The radius of the hemisphere to emit from
  84691. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84692. * @returns the emitter
  84693. */
  84694. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  84695. /**
  84696. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  84697. * @param radius The radius of the sphere to emit from
  84698. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84699. * @returns the emitter
  84700. */
  84701. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  84702. /**
  84703. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  84704. * @param radius The radius of the sphere to emit from
  84705. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  84706. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  84707. * @returns the emitter
  84708. */
  84709. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  84710. /**
  84711. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  84712. * @param radius The radius of the emission cylinder
  84713. * @param height The height of the emission cylinder
  84714. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  84715. * @param directionRandomizer How much to randomize the particle direction [0-1]
  84716. * @returns the emitter
  84717. */
  84718. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  84719. /**
  84720. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  84721. * @param radius The radius of the cylinder to emit from
  84722. * @param height The height of the emission cylinder
  84723. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84724. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  84725. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  84726. * @returns the emitter
  84727. */
  84728. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  84729. /**
  84730. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  84731. * @param radius The radius of the cone to emit from
  84732. * @param angle The base angle of the cone
  84733. * @returns the emitter
  84734. */
  84735. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  84736. /**
  84737. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  84738. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84739. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84740. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84741. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84742. * @returns the emitter
  84743. */
  84744. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  84745. }
  84746. }
  84747. declare module BABYLON {
  84748. /**
  84749. * Type of sub emitter
  84750. */
  84751. export enum SubEmitterType {
  84752. /**
  84753. * Attached to the particle over it's lifetime
  84754. */
  84755. ATTACHED = 0,
  84756. /**
  84757. * Created when the particle dies
  84758. */
  84759. END = 1
  84760. }
  84761. /**
  84762. * Sub emitter class used to emit particles from an existing particle
  84763. */
  84764. export class SubEmitter {
  84765. /**
  84766. * the particle system to be used by the sub emitter
  84767. */
  84768. particleSystem: ParticleSystem;
  84769. /**
  84770. * Type of the submitter (Default: END)
  84771. */
  84772. type: SubEmitterType;
  84773. /**
  84774. * 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)
  84775. * Note: This only is supported when using an emitter of type Mesh
  84776. */
  84777. inheritDirection: boolean;
  84778. /**
  84779. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  84780. */
  84781. inheritedVelocityAmount: number;
  84782. /**
  84783. * Creates a sub emitter
  84784. * @param particleSystem the particle system to be used by the sub emitter
  84785. */
  84786. constructor(
  84787. /**
  84788. * the particle system to be used by the sub emitter
  84789. */
  84790. particleSystem: ParticleSystem);
  84791. /**
  84792. * Clones the sub emitter
  84793. * @returns the cloned sub emitter
  84794. */
  84795. clone(): SubEmitter;
  84796. /**
  84797. * Serialize current object to a JSON object
  84798. * @returns the serialized object
  84799. */
  84800. serialize(): any;
  84801. /** @hidden */
  84802. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  84803. /**
  84804. * Creates a new SubEmitter from a serialized JSON version
  84805. * @param serializationObject defines the JSON object to read from
  84806. * @param scene defines the hosting scene
  84807. * @param rootUrl defines the rootUrl for data loading
  84808. * @returns a new SubEmitter
  84809. */
  84810. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  84811. /** Release associated resources */
  84812. dispose(): void;
  84813. }
  84814. }
  84815. declare module BABYLON {
  84816. /** @hidden */
  84817. export var imageProcessingDeclaration: {
  84818. name: string;
  84819. shader: string;
  84820. };
  84821. }
  84822. declare module BABYLON {
  84823. /** @hidden */
  84824. export var imageProcessingFunctions: {
  84825. name: string;
  84826. shader: string;
  84827. };
  84828. }
  84829. declare module BABYLON {
  84830. /** @hidden */
  84831. export var particlesPixelShader: {
  84832. name: string;
  84833. shader: string;
  84834. };
  84835. }
  84836. declare module BABYLON {
  84837. /** @hidden */
  84838. export var particlesVertexShader: {
  84839. name: string;
  84840. shader: string;
  84841. };
  84842. }
  84843. declare module BABYLON {
  84844. /**
  84845. * This represents a particle system in Babylon.
  84846. * 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.
  84847. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84848. * @example https://doc.babylonjs.com/babylon101/particles
  84849. */
  84850. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  84851. /**
  84852. * Billboard mode will only apply to Y axis
  84853. */
  84854. static readonly BILLBOARDMODE_Y: number;
  84855. /**
  84856. * Billboard mode will apply to all axes
  84857. */
  84858. static readonly BILLBOARDMODE_ALL: number;
  84859. /**
  84860. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  84861. */
  84862. static readonly BILLBOARDMODE_STRETCHED: number;
  84863. /**
  84864. * This function can be defined to provide custom update for active particles.
  84865. * This function will be called instead of regular update (age, position, color, etc.).
  84866. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  84867. */
  84868. updateFunction: (particles: Particle[]) => void;
  84869. private _emitterWorldMatrix;
  84870. /**
  84871. * This function can be defined to specify initial direction for every new particle.
  84872. * It by default use the emitterType defined function
  84873. */
  84874. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  84875. /**
  84876. * This function can be defined to specify initial position for every new particle.
  84877. * It by default use the emitterType defined function
  84878. */
  84879. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  84880. /**
  84881. * @hidden
  84882. */
  84883. _inheritedVelocityOffset: Vector3;
  84884. /**
  84885. * An event triggered when the system is disposed
  84886. */
  84887. onDisposeObservable: Observable<ParticleSystem>;
  84888. private _onDisposeObserver;
  84889. /**
  84890. * Sets a callback that will be triggered when the system is disposed
  84891. */
  84892. set onDispose(callback: () => void);
  84893. private _particles;
  84894. private _epsilon;
  84895. private _capacity;
  84896. private _stockParticles;
  84897. private _newPartsExcess;
  84898. private _vertexData;
  84899. private _vertexBuffer;
  84900. private _vertexBuffers;
  84901. private _spriteBuffer;
  84902. private _indexBuffer;
  84903. private _effect;
  84904. private _customEffect;
  84905. private _cachedDefines;
  84906. private _scaledColorStep;
  84907. private _colorDiff;
  84908. private _scaledDirection;
  84909. private _scaledGravity;
  84910. private _currentRenderId;
  84911. private _alive;
  84912. private _useInstancing;
  84913. private _started;
  84914. private _stopped;
  84915. private _actualFrame;
  84916. private _scaledUpdateSpeed;
  84917. private _vertexBufferSize;
  84918. /** @hidden */
  84919. _currentEmitRateGradient: Nullable<FactorGradient>;
  84920. /** @hidden */
  84921. _currentEmitRate1: number;
  84922. /** @hidden */
  84923. _currentEmitRate2: number;
  84924. /** @hidden */
  84925. _currentStartSizeGradient: Nullable<FactorGradient>;
  84926. /** @hidden */
  84927. _currentStartSize1: number;
  84928. /** @hidden */
  84929. _currentStartSize2: number;
  84930. private readonly _rawTextureWidth;
  84931. private _rampGradientsTexture;
  84932. private _useRampGradients;
  84933. /** Gets or sets a boolean indicating that ramp gradients must be used
  84934. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  84935. */
  84936. get useRampGradients(): boolean;
  84937. set useRampGradients(value: boolean);
  84938. /**
  84939. * 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.
  84940. * 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: [])
  84941. */
  84942. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  84943. private _subEmitters;
  84944. /**
  84945. * @hidden
  84946. * If the particle systems emitter should be disposed when the particle system is disposed
  84947. */
  84948. _disposeEmitterOnDispose: boolean;
  84949. /**
  84950. * The current active Sub-systems, this property is used by the root particle system only.
  84951. */
  84952. activeSubSystems: Array<ParticleSystem>;
  84953. private _rootParticleSystem;
  84954. /**
  84955. * Gets the current list of active particles
  84956. */
  84957. get particles(): Particle[];
  84958. /**
  84959. * Returns the string "ParticleSystem"
  84960. * @returns a string containing the class name
  84961. */
  84962. getClassName(): string;
  84963. /**
  84964. * Instantiates a particle system.
  84965. * 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.
  84966. * @param name The name of the particle system
  84967. * @param capacity The max number of particles alive at the same time
  84968. * @param scene The scene the particle system belongs to
  84969. * @param customEffect a custom effect used to change the way particles are rendered by default
  84970. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  84971. * @param epsilon Offset used to render the particles
  84972. */
  84973. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  84974. private _addFactorGradient;
  84975. private _removeFactorGradient;
  84976. /**
  84977. * Adds a new life time gradient
  84978. * @param gradient defines the gradient to use (between 0 and 1)
  84979. * @param factor defines the life time factor to affect to the specified gradient
  84980. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84981. * @returns the current particle system
  84982. */
  84983. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84984. /**
  84985. * Remove a specific life time gradient
  84986. * @param gradient defines the gradient to remove
  84987. * @returns the current particle system
  84988. */
  84989. removeLifeTimeGradient(gradient: number): IParticleSystem;
  84990. /**
  84991. * Adds a new size gradient
  84992. * @param gradient defines the gradient to use (between 0 and 1)
  84993. * @param factor defines the size factor to affect to the specified gradient
  84994. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84995. * @returns the current particle system
  84996. */
  84997. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84998. /**
  84999. * Remove a specific size gradient
  85000. * @param gradient defines the gradient to remove
  85001. * @returns the current particle system
  85002. */
  85003. removeSizeGradient(gradient: number): IParticleSystem;
  85004. /**
  85005. * Adds a new color remap gradient
  85006. * @param gradient defines the gradient to use (between 0 and 1)
  85007. * @param min defines the color remap minimal range
  85008. * @param max defines the color remap maximal range
  85009. * @returns the current particle system
  85010. */
  85011. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85012. /**
  85013. * Remove a specific color remap gradient
  85014. * @param gradient defines the gradient to remove
  85015. * @returns the current particle system
  85016. */
  85017. removeColorRemapGradient(gradient: number): IParticleSystem;
  85018. /**
  85019. * Adds a new alpha remap gradient
  85020. * @param gradient defines the gradient to use (between 0 and 1)
  85021. * @param min defines the alpha remap minimal range
  85022. * @param max defines the alpha remap maximal range
  85023. * @returns the current particle system
  85024. */
  85025. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85026. /**
  85027. * Remove a specific alpha remap gradient
  85028. * @param gradient defines the gradient to remove
  85029. * @returns the current particle system
  85030. */
  85031. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  85032. /**
  85033. * Adds a new angular speed gradient
  85034. * @param gradient defines the gradient to use (between 0 and 1)
  85035. * @param factor defines the angular speed to affect to the specified gradient
  85036. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85037. * @returns the current particle system
  85038. */
  85039. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85040. /**
  85041. * Remove a specific angular speed gradient
  85042. * @param gradient defines the gradient to remove
  85043. * @returns the current particle system
  85044. */
  85045. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  85046. /**
  85047. * Adds a new velocity gradient
  85048. * @param gradient defines the gradient to use (between 0 and 1)
  85049. * @param factor defines the velocity to affect to the specified gradient
  85050. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85051. * @returns the current particle system
  85052. */
  85053. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85054. /**
  85055. * Remove a specific velocity gradient
  85056. * @param gradient defines the gradient to remove
  85057. * @returns the current particle system
  85058. */
  85059. removeVelocityGradient(gradient: number): IParticleSystem;
  85060. /**
  85061. * Adds a new limit velocity gradient
  85062. * @param gradient defines the gradient to use (between 0 and 1)
  85063. * @param factor defines the limit velocity value to affect to the specified gradient
  85064. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85065. * @returns the current particle system
  85066. */
  85067. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85068. /**
  85069. * Remove a specific limit velocity gradient
  85070. * @param gradient defines the gradient to remove
  85071. * @returns the current particle system
  85072. */
  85073. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  85074. /**
  85075. * Adds a new drag gradient
  85076. * @param gradient defines the gradient to use (between 0 and 1)
  85077. * @param factor defines the drag value to affect to the specified gradient
  85078. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85079. * @returns the current particle system
  85080. */
  85081. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85082. /**
  85083. * Remove a specific drag gradient
  85084. * @param gradient defines the gradient to remove
  85085. * @returns the current particle system
  85086. */
  85087. removeDragGradient(gradient: number): IParticleSystem;
  85088. /**
  85089. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  85090. * @param gradient defines the gradient to use (between 0 and 1)
  85091. * @param factor defines the emit rate value to affect to the specified gradient
  85092. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85093. * @returns the current particle system
  85094. */
  85095. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85096. /**
  85097. * Remove a specific emit rate gradient
  85098. * @param gradient defines the gradient to remove
  85099. * @returns the current particle system
  85100. */
  85101. removeEmitRateGradient(gradient: number): IParticleSystem;
  85102. /**
  85103. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  85104. * @param gradient defines the gradient to use (between 0 and 1)
  85105. * @param factor defines the start size value to affect to the specified gradient
  85106. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85107. * @returns the current particle system
  85108. */
  85109. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85110. /**
  85111. * Remove a specific start size gradient
  85112. * @param gradient defines the gradient to remove
  85113. * @returns the current particle system
  85114. */
  85115. removeStartSizeGradient(gradient: number): IParticleSystem;
  85116. private _createRampGradientTexture;
  85117. /**
  85118. * Gets the current list of ramp gradients.
  85119. * You must use addRampGradient and removeRampGradient to udpate this list
  85120. * @returns the list of ramp gradients
  85121. */
  85122. getRampGradients(): Nullable<Array<Color3Gradient>>;
  85123. /**
  85124. * Adds a new ramp gradient used to remap particle colors
  85125. * @param gradient defines the gradient to use (between 0 and 1)
  85126. * @param color defines the color to affect to the specified gradient
  85127. * @returns the current particle system
  85128. */
  85129. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  85130. /**
  85131. * Remove a specific ramp gradient
  85132. * @param gradient defines the gradient to remove
  85133. * @returns the current particle system
  85134. */
  85135. removeRampGradient(gradient: number): ParticleSystem;
  85136. /**
  85137. * Adds a new color gradient
  85138. * @param gradient defines the gradient to use (between 0 and 1)
  85139. * @param color1 defines the color to affect to the specified gradient
  85140. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  85141. * @returns this particle system
  85142. */
  85143. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  85144. /**
  85145. * Remove a specific color gradient
  85146. * @param gradient defines the gradient to remove
  85147. * @returns this particle system
  85148. */
  85149. removeColorGradient(gradient: number): IParticleSystem;
  85150. private _fetchR;
  85151. protected _reset(): void;
  85152. private _resetEffect;
  85153. private _createVertexBuffers;
  85154. private _createIndexBuffer;
  85155. /**
  85156. * Gets the maximum number of particles active at the same time.
  85157. * @returns The max number of active particles.
  85158. */
  85159. getCapacity(): number;
  85160. /**
  85161. * Gets whether there are still active particles in the system.
  85162. * @returns True if it is alive, otherwise false.
  85163. */
  85164. isAlive(): boolean;
  85165. /**
  85166. * Gets if the system has been started. (Note: this will still be true after stop is called)
  85167. * @returns True if it has been started, otherwise false.
  85168. */
  85169. isStarted(): boolean;
  85170. private _prepareSubEmitterInternalArray;
  85171. /**
  85172. * Starts the particle system and begins to emit
  85173. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  85174. */
  85175. start(delay?: number): void;
  85176. /**
  85177. * Stops the particle system.
  85178. * @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.
  85179. */
  85180. stop(stopSubEmitters?: boolean): void;
  85181. /**
  85182. * Remove all active particles
  85183. */
  85184. reset(): void;
  85185. /**
  85186. * @hidden (for internal use only)
  85187. */
  85188. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  85189. /**
  85190. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  85191. * Its lifetime will start back at 0.
  85192. */
  85193. recycleParticle: (particle: Particle) => void;
  85194. private _stopSubEmitters;
  85195. private _createParticle;
  85196. private _removeFromRoot;
  85197. private _emitFromParticle;
  85198. private _update;
  85199. /** @hidden */
  85200. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  85201. /** @hidden */
  85202. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  85203. /** @hidden */
  85204. private _getEffect;
  85205. /**
  85206. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  85207. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  85208. */
  85209. animate(preWarmOnly?: boolean): void;
  85210. private _appendParticleVertices;
  85211. /**
  85212. * Rebuilds the particle system.
  85213. */
  85214. rebuild(): void;
  85215. /**
  85216. * Is this system ready to be used/rendered
  85217. * @return true if the system is ready
  85218. */
  85219. isReady(): boolean;
  85220. private _render;
  85221. /**
  85222. * Renders the particle system in its current state.
  85223. * @returns the current number of particles
  85224. */
  85225. render(): number;
  85226. /**
  85227. * Disposes the particle system and free the associated resources
  85228. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  85229. */
  85230. dispose(disposeTexture?: boolean): void;
  85231. /**
  85232. * Clones the particle system.
  85233. * @param name The name of the cloned object
  85234. * @param newEmitter The new emitter to use
  85235. * @returns the cloned particle system
  85236. */
  85237. clone(name: string, newEmitter: any): ParticleSystem;
  85238. /**
  85239. * Serializes the particle system to a JSON object.
  85240. * @returns the JSON object
  85241. */
  85242. serialize(): any;
  85243. /** @hidden */
  85244. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  85245. /** @hidden */
  85246. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  85247. /**
  85248. * Parses a JSON object to create a particle system.
  85249. * @param parsedParticleSystem The JSON object to parse
  85250. * @param scene The scene to create the particle system in
  85251. * @param rootUrl The root url to use to load external dependencies like texture
  85252. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  85253. * @returns the Parsed particle system
  85254. */
  85255. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  85256. }
  85257. }
  85258. declare module BABYLON {
  85259. /**
  85260. * A particle represents one of the element emitted by a particle system.
  85261. * This is mainly define by its coordinates, direction, velocity and age.
  85262. */
  85263. export class Particle {
  85264. /**
  85265. * The particle system the particle belongs to.
  85266. */
  85267. particleSystem: ParticleSystem;
  85268. private static _Count;
  85269. /**
  85270. * Unique ID of the particle
  85271. */
  85272. id: number;
  85273. /**
  85274. * The world position of the particle in the scene.
  85275. */
  85276. position: Vector3;
  85277. /**
  85278. * The world direction of the particle in the scene.
  85279. */
  85280. direction: Vector3;
  85281. /**
  85282. * The color of the particle.
  85283. */
  85284. color: Color4;
  85285. /**
  85286. * The color change of the particle per step.
  85287. */
  85288. colorStep: Color4;
  85289. /**
  85290. * Defines how long will the life of the particle be.
  85291. */
  85292. lifeTime: number;
  85293. /**
  85294. * The current age of the particle.
  85295. */
  85296. age: number;
  85297. /**
  85298. * The current size of the particle.
  85299. */
  85300. size: number;
  85301. /**
  85302. * The current scale of the particle.
  85303. */
  85304. scale: Vector2;
  85305. /**
  85306. * The current angle of the particle.
  85307. */
  85308. angle: number;
  85309. /**
  85310. * Defines how fast is the angle changing.
  85311. */
  85312. angularSpeed: number;
  85313. /**
  85314. * Defines the cell index used by the particle to be rendered from a sprite.
  85315. */
  85316. cellIndex: number;
  85317. /**
  85318. * The information required to support color remapping
  85319. */
  85320. remapData: Vector4;
  85321. /** @hidden */
  85322. _randomCellOffset?: number;
  85323. /** @hidden */
  85324. _initialDirection: Nullable<Vector3>;
  85325. /** @hidden */
  85326. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  85327. /** @hidden */
  85328. _initialStartSpriteCellID: number;
  85329. /** @hidden */
  85330. _initialEndSpriteCellID: number;
  85331. /** @hidden */
  85332. _currentColorGradient: Nullable<ColorGradient>;
  85333. /** @hidden */
  85334. _currentColor1: Color4;
  85335. /** @hidden */
  85336. _currentColor2: Color4;
  85337. /** @hidden */
  85338. _currentSizeGradient: Nullable<FactorGradient>;
  85339. /** @hidden */
  85340. _currentSize1: number;
  85341. /** @hidden */
  85342. _currentSize2: number;
  85343. /** @hidden */
  85344. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  85345. /** @hidden */
  85346. _currentAngularSpeed1: number;
  85347. /** @hidden */
  85348. _currentAngularSpeed2: number;
  85349. /** @hidden */
  85350. _currentVelocityGradient: Nullable<FactorGradient>;
  85351. /** @hidden */
  85352. _currentVelocity1: number;
  85353. /** @hidden */
  85354. _currentVelocity2: number;
  85355. /** @hidden */
  85356. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  85357. /** @hidden */
  85358. _currentLimitVelocity1: number;
  85359. /** @hidden */
  85360. _currentLimitVelocity2: number;
  85361. /** @hidden */
  85362. _currentDragGradient: Nullable<FactorGradient>;
  85363. /** @hidden */
  85364. _currentDrag1: number;
  85365. /** @hidden */
  85366. _currentDrag2: number;
  85367. /** @hidden */
  85368. _randomNoiseCoordinates1: Vector3;
  85369. /** @hidden */
  85370. _randomNoiseCoordinates2: Vector3;
  85371. /**
  85372. * Creates a new instance Particle
  85373. * @param particleSystem the particle system the particle belongs to
  85374. */
  85375. constructor(
  85376. /**
  85377. * The particle system the particle belongs to.
  85378. */
  85379. particleSystem: ParticleSystem);
  85380. private updateCellInfoFromSystem;
  85381. /**
  85382. * Defines how the sprite cell index is updated for the particle
  85383. */
  85384. updateCellIndex(): void;
  85385. /** @hidden */
  85386. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  85387. /** @hidden */
  85388. _inheritParticleInfoToSubEmitters(): void;
  85389. /** @hidden */
  85390. _reset(): void;
  85391. /**
  85392. * Copy the properties of particle to another one.
  85393. * @param other the particle to copy the information to.
  85394. */
  85395. copyTo(other: Particle): void;
  85396. }
  85397. }
  85398. declare module BABYLON {
  85399. /**
  85400. * Particle emitter represents a volume emitting particles.
  85401. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  85402. */
  85403. export interface IParticleEmitterType {
  85404. /**
  85405. * Called by the particle System when the direction is computed for the created particle.
  85406. * @param worldMatrix is the world matrix of the particle system
  85407. * @param directionToUpdate is the direction vector to update with the result
  85408. * @param particle is the particle we are computed the direction for
  85409. */
  85410. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85411. /**
  85412. * Called by the particle System when the position is computed for the created particle.
  85413. * @param worldMatrix is the world matrix of the particle system
  85414. * @param positionToUpdate is the position vector to update with the result
  85415. * @param particle is the particle we are computed the position for
  85416. */
  85417. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85418. /**
  85419. * Clones the current emitter and returns a copy of it
  85420. * @returns the new emitter
  85421. */
  85422. clone(): IParticleEmitterType;
  85423. /**
  85424. * Called by the GPUParticleSystem to setup the update shader
  85425. * @param effect defines the update shader
  85426. */
  85427. applyToShader(effect: Effect): void;
  85428. /**
  85429. * Returns a string to use to update the GPU particles update shader
  85430. * @returns the effect defines string
  85431. */
  85432. getEffectDefines(): string;
  85433. /**
  85434. * Returns a string representing the class name
  85435. * @returns a string containing the class name
  85436. */
  85437. getClassName(): string;
  85438. /**
  85439. * Serializes the particle system to a JSON object.
  85440. * @returns the JSON object
  85441. */
  85442. serialize(): any;
  85443. /**
  85444. * Parse properties from a JSON object
  85445. * @param serializationObject defines the JSON object
  85446. * @param scene defines the hosting scene
  85447. */
  85448. parse(serializationObject: any, scene: Scene): void;
  85449. }
  85450. }
  85451. declare module BABYLON {
  85452. /**
  85453. * Particle emitter emitting particles from the inside of a box.
  85454. * It emits the particles randomly between 2 given directions.
  85455. */
  85456. export class BoxParticleEmitter implements IParticleEmitterType {
  85457. /**
  85458. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85459. */
  85460. direction1: Vector3;
  85461. /**
  85462. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85463. */
  85464. direction2: Vector3;
  85465. /**
  85466. * 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.
  85467. */
  85468. minEmitBox: Vector3;
  85469. /**
  85470. * 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.
  85471. */
  85472. maxEmitBox: Vector3;
  85473. /**
  85474. * Creates a new instance BoxParticleEmitter
  85475. */
  85476. constructor();
  85477. /**
  85478. * Called by the particle System when the direction is computed for the created particle.
  85479. * @param worldMatrix is the world matrix of the particle system
  85480. * @param directionToUpdate is the direction vector to update with the result
  85481. * @param particle is the particle we are computed the direction for
  85482. */
  85483. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85484. /**
  85485. * Called by the particle System when the position is computed for the created particle.
  85486. * @param worldMatrix is the world matrix of the particle system
  85487. * @param positionToUpdate is the position vector to update with the result
  85488. * @param particle is the particle we are computed the position for
  85489. */
  85490. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85491. /**
  85492. * Clones the current emitter and returns a copy of it
  85493. * @returns the new emitter
  85494. */
  85495. clone(): BoxParticleEmitter;
  85496. /**
  85497. * Called by the GPUParticleSystem to setup the update shader
  85498. * @param effect defines the update shader
  85499. */
  85500. applyToShader(effect: Effect): void;
  85501. /**
  85502. * Returns a string to use to update the GPU particles update shader
  85503. * @returns a string containng the defines string
  85504. */
  85505. getEffectDefines(): string;
  85506. /**
  85507. * Returns the string "BoxParticleEmitter"
  85508. * @returns a string containing the class name
  85509. */
  85510. getClassName(): string;
  85511. /**
  85512. * Serializes the particle system to a JSON object.
  85513. * @returns the JSON object
  85514. */
  85515. serialize(): any;
  85516. /**
  85517. * Parse properties from a JSON object
  85518. * @param serializationObject defines the JSON object
  85519. */
  85520. parse(serializationObject: any): void;
  85521. }
  85522. }
  85523. declare module BABYLON {
  85524. /**
  85525. * Particle emitter emitting particles from the inside of a cone.
  85526. * It emits the particles alongside the cone volume from the base to the particle.
  85527. * The emission direction might be randomized.
  85528. */
  85529. export class ConeParticleEmitter implements IParticleEmitterType {
  85530. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85531. directionRandomizer: number;
  85532. private _radius;
  85533. private _angle;
  85534. private _height;
  85535. /**
  85536. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  85537. */
  85538. radiusRange: number;
  85539. /**
  85540. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  85541. */
  85542. heightRange: number;
  85543. /**
  85544. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  85545. */
  85546. emitFromSpawnPointOnly: boolean;
  85547. /**
  85548. * Gets or sets the radius of the emission cone
  85549. */
  85550. get radius(): number;
  85551. set radius(value: number);
  85552. /**
  85553. * Gets or sets the angle of the emission cone
  85554. */
  85555. get angle(): number;
  85556. set angle(value: number);
  85557. private _buildHeight;
  85558. /**
  85559. * Creates a new instance ConeParticleEmitter
  85560. * @param radius the radius of the emission cone (1 by default)
  85561. * @param angle the cone base angle (PI by default)
  85562. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  85563. */
  85564. constructor(radius?: number, angle?: number,
  85565. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85566. directionRandomizer?: number);
  85567. /**
  85568. * Called by the particle System when the direction is computed for the created particle.
  85569. * @param worldMatrix is the world matrix of the particle system
  85570. * @param directionToUpdate is the direction vector to update with the result
  85571. * @param particle is the particle we are computed the direction for
  85572. */
  85573. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85574. /**
  85575. * Called by the particle System when the position is computed for the created particle.
  85576. * @param worldMatrix is the world matrix of the particle system
  85577. * @param positionToUpdate is the position vector to update with the result
  85578. * @param particle is the particle we are computed the position for
  85579. */
  85580. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85581. /**
  85582. * Clones the current emitter and returns a copy of it
  85583. * @returns the new emitter
  85584. */
  85585. clone(): ConeParticleEmitter;
  85586. /**
  85587. * Called by the GPUParticleSystem to setup the update shader
  85588. * @param effect defines the update shader
  85589. */
  85590. applyToShader(effect: Effect): void;
  85591. /**
  85592. * Returns a string to use to update the GPU particles update shader
  85593. * @returns a string containng the defines string
  85594. */
  85595. getEffectDefines(): string;
  85596. /**
  85597. * Returns the string "ConeParticleEmitter"
  85598. * @returns a string containing the class name
  85599. */
  85600. getClassName(): string;
  85601. /**
  85602. * Serializes the particle system to a JSON object.
  85603. * @returns the JSON object
  85604. */
  85605. serialize(): any;
  85606. /**
  85607. * Parse properties from a JSON object
  85608. * @param serializationObject defines the JSON object
  85609. */
  85610. parse(serializationObject: any): void;
  85611. }
  85612. }
  85613. declare module BABYLON {
  85614. /**
  85615. * Particle emitter emitting particles from the inside of a cylinder.
  85616. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  85617. */
  85618. export class CylinderParticleEmitter implements IParticleEmitterType {
  85619. /**
  85620. * The radius of the emission cylinder.
  85621. */
  85622. radius: number;
  85623. /**
  85624. * The height of the emission cylinder.
  85625. */
  85626. height: number;
  85627. /**
  85628. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85629. */
  85630. radiusRange: number;
  85631. /**
  85632. * How much to randomize the particle direction [0-1].
  85633. */
  85634. directionRandomizer: number;
  85635. /**
  85636. * Creates a new instance CylinderParticleEmitter
  85637. * @param radius the radius of the emission cylinder (1 by default)
  85638. * @param height the height of the emission cylinder (1 by default)
  85639. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85640. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85641. */
  85642. constructor(
  85643. /**
  85644. * The radius of the emission cylinder.
  85645. */
  85646. radius?: number,
  85647. /**
  85648. * The height of the emission cylinder.
  85649. */
  85650. height?: number,
  85651. /**
  85652. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85653. */
  85654. radiusRange?: number,
  85655. /**
  85656. * How much to randomize the particle direction [0-1].
  85657. */
  85658. directionRandomizer?: number);
  85659. /**
  85660. * Called by the particle System when the direction is computed for the created particle.
  85661. * @param worldMatrix is the world matrix of the particle system
  85662. * @param directionToUpdate is the direction vector to update with the result
  85663. * @param particle is the particle we are computed the direction for
  85664. */
  85665. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85666. /**
  85667. * Called by the particle System when the position is computed for the created particle.
  85668. * @param worldMatrix is the world matrix of the particle system
  85669. * @param positionToUpdate is the position vector to update with the result
  85670. * @param particle is the particle we are computed the position for
  85671. */
  85672. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85673. /**
  85674. * Clones the current emitter and returns a copy of it
  85675. * @returns the new emitter
  85676. */
  85677. clone(): CylinderParticleEmitter;
  85678. /**
  85679. * Called by the GPUParticleSystem to setup the update shader
  85680. * @param effect defines the update shader
  85681. */
  85682. applyToShader(effect: Effect): void;
  85683. /**
  85684. * Returns a string to use to update the GPU particles update shader
  85685. * @returns a string containng the defines string
  85686. */
  85687. getEffectDefines(): string;
  85688. /**
  85689. * Returns the string "CylinderParticleEmitter"
  85690. * @returns a string containing the class name
  85691. */
  85692. getClassName(): string;
  85693. /**
  85694. * Serializes the particle system to a JSON object.
  85695. * @returns the JSON object
  85696. */
  85697. serialize(): any;
  85698. /**
  85699. * Parse properties from a JSON object
  85700. * @param serializationObject defines the JSON object
  85701. */
  85702. parse(serializationObject: any): void;
  85703. }
  85704. /**
  85705. * Particle emitter emitting particles from the inside of a cylinder.
  85706. * It emits the particles randomly between two vectors.
  85707. */
  85708. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  85709. /**
  85710. * The min limit of the emission direction.
  85711. */
  85712. direction1: Vector3;
  85713. /**
  85714. * The max limit of the emission direction.
  85715. */
  85716. direction2: Vector3;
  85717. /**
  85718. * Creates a new instance CylinderDirectedParticleEmitter
  85719. * @param radius the radius of the emission cylinder (1 by default)
  85720. * @param height the height of the emission cylinder (1 by default)
  85721. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85722. * @param direction1 the min limit of the emission direction (up vector by default)
  85723. * @param direction2 the max limit of the emission direction (up vector by default)
  85724. */
  85725. constructor(radius?: number, height?: number, radiusRange?: number,
  85726. /**
  85727. * The min limit of the emission direction.
  85728. */
  85729. direction1?: Vector3,
  85730. /**
  85731. * The max limit of the emission direction.
  85732. */
  85733. direction2?: Vector3);
  85734. /**
  85735. * Called by the particle System when the direction is computed for the created particle.
  85736. * @param worldMatrix is the world matrix of the particle system
  85737. * @param directionToUpdate is the direction vector to update with the result
  85738. * @param particle is the particle we are computed the direction for
  85739. */
  85740. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85741. /**
  85742. * Clones the current emitter and returns a copy of it
  85743. * @returns the new emitter
  85744. */
  85745. clone(): CylinderDirectedParticleEmitter;
  85746. /**
  85747. * Called by the GPUParticleSystem to setup the update shader
  85748. * @param effect defines the update shader
  85749. */
  85750. applyToShader(effect: Effect): void;
  85751. /**
  85752. * Returns a string to use to update the GPU particles update shader
  85753. * @returns a string containng the defines string
  85754. */
  85755. getEffectDefines(): string;
  85756. /**
  85757. * Returns the string "CylinderDirectedParticleEmitter"
  85758. * @returns a string containing the class name
  85759. */
  85760. getClassName(): string;
  85761. /**
  85762. * Serializes the particle system to a JSON object.
  85763. * @returns the JSON object
  85764. */
  85765. serialize(): any;
  85766. /**
  85767. * Parse properties from a JSON object
  85768. * @param serializationObject defines the JSON object
  85769. */
  85770. parse(serializationObject: any): void;
  85771. }
  85772. }
  85773. declare module BABYLON {
  85774. /**
  85775. * Particle emitter emitting particles from the inside of a hemisphere.
  85776. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  85777. */
  85778. export class HemisphericParticleEmitter implements IParticleEmitterType {
  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. * Creates a new instance HemisphericParticleEmitter
  85793. * @param radius the radius of the emission hemisphere (1 by default)
  85794. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85795. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85796. */
  85797. constructor(
  85798. /**
  85799. * The radius of the emission hemisphere.
  85800. */
  85801. radius?: number,
  85802. /**
  85803. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85804. */
  85805. radiusRange?: number,
  85806. /**
  85807. * How much to randomize the particle direction [0-1].
  85808. */
  85809. directionRandomizer?: number);
  85810. /**
  85811. * Called by the particle System when the direction is computed for the created particle.
  85812. * @param worldMatrix is the world matrix of the particle system
  85813. * @param directionToUpdate is the direction vector to update with the result
  85814. * @param particle is the particle we are computed the direction for
  85815. */
  85816. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85817. /**
  85818. * Called by the particle System when the position is computed for the created particle.
  85819. * @param worldMatrix is the world matrix of the particle system
  85820. * @param positionToUpdate is the position vector to update with the result
  85821. * @param particle is the particle we are computed the position for
  85822. */
  85823. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85824. /**
  85825. * Clones the current emitter and returns a copy of it
  85826. * @returns the new emitter
  85827. */
  85828. clone(): HemisphericParticleEmitter;
  85829. /**
  85830. * Called by the GPUParticleSystem to setup the update shader
  85831. * @param effect defines the update shader
  85832. */
  85833. applyToShader(effect: Effect): void;
  85834. /**
  85835. * Returns a string to use to update the GPU particles update shader
  85836. * @returns a string containng the defines string
  85837. */
  85838. getEffectDefines(): string;
  85839. /**
  85840. * Returns the string "HemisphericParticleEmitter"
  85841. * @returns a string containing the class name
  85842. */
  85843. getClassName(): string;
  85844. /**
  85845. * Serializes the particle system to a JSON object.
  85846. * @returns the JSON object
  85847. */
  85848. serialize(): any;
  85849. /**
  85850. * Parse properties from a JSON object
  85851. * @param serializationObject defines the JSON object
  85852. */
  85853. parse(serializationObject: any): void;
  85854. }
  85855. }
  85856. declare module BABYLON {
  85857. /**
  85858. * Particle emitter emitting particles from a point.
  85859. * It emits the particles randomly between 2 given directions.
  85860. */
  85861. export class PointParticleEmitter implements IParticleEmitterType {
  85862. /**
  85863. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85864. */
  85865. direction1: Vector3;
  85866. /**
  85867. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85868. */
  85869. direction2: Vector3;
  85870. /**
  85871. * Creates a new instance PointParticleEmitter
  85872. */
  85873. constructor();
  85874. /**
  85875. * Called by the particle System when the direction is computed for the created particle.
  85876. * @param worldMatrix is the world matrix of the particle system
  85877. * @param directionToUpdate is the direction vector to update with the result
  85878. * @param particle is the particle we are computed the direction for
  85879. */
  85880. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85881. /**
  85882. * Called by the particle System when the position is computed for the created particle.
  85883. * @param worldMatrix is the world matrix of the particle system
  85884. * @param positionToUpdate is the position vector to update with the result
  85885. * @param particle is the particle we are computed the position for
  85886. */
  85887. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85888. /**
  85889. * Clones the current emitter and returns a copy of it
  85890. * @returns the new emitter
  85891. */
  85892. clone(): PointParticleEmitter;
  85893. /**
  85894. * Called by the GPUParticleSystem to setup the update shader
  85895. * @param effect defines the update shader
  85896. */
  85897. applyToShader(effect: Effect): void;
  85898. /**
  85899. * Returns a string to use to update the GPU particles update shader
  85900. * @returns a string containng the defines string
  85901. */
  85902. getEffectDefines(): string;
  85903. /**
  85904. * Returns the string "PointParticleEmitter"
  85905. * @returns a string containing the class name
  85906. */
  85907. getClassName(): string;
  85908. /**
  85909. * Serializes the particle system to a JSON object.
  85910. * @returns the JSON object
  85911. */
  85912. serialize(): any;
  85913. /**
  85914. * Parse properties from a JSON object
  85915. * @param serializationObject defines the JSON object
  85916. */
  85917. parse(serializationObject: any): void;
  85918. }
  85919. }
  85920. declare module BABYLON {
  85921. /**
  85922. * Particle emitter emitting particles from the inside of a sphere.
  85923. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  85924. */
  85925. export class SphereParticleEmitter implements IParticleEmitterType {
  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. * Creates a new instance SphereParticleEmitter
  85940. * @param radius the radius of the emission sphere (1 by default)
  85941. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85942. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85943. */
  85944. constructor(
  85945. /**
  85946. * The radius of the emission sphere.
  85947. */
  85948. radius?: number,
  85949. /**
  85950. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85951. */
  85952. radiusRange?: number,
  85953. /**
  85954. * How much to randomize the particle direction [0-1].
  85955. */
  85956. directionRandomizer?: number);
  85957. /**
  85958. * Called by the particle System when the direction is computed for the created particle.
  85959. * @param worldMatrix is the world matrix of the particle system
  85960. * @param directionToUpdate is the direction vector to update with the result
  85961. * @param particle is the particle we are computed the direction for
  85962. */
  85963. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85964. /**
  85965. * Called by the particle System when the position is computed for the created particle.
  85966. * @param worldMatrix is the world matrix of the particle system
  85967. * @param positionToUpdate is the position vector to update with the result
  85968. * @param particle is the particle we are computed the position for
  85969. */
  85970. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85971. /**
  85972. * Clones the current emitter and returns a copy of it
  85973. * @returns the new emitter
  85974. */
  85975. clone(): SphereParticleEmitter;
  85976. /**
  85977. * Called by the GPUParticleSystem to setup the update shader
  85978. * @param effect defines the update shader
  85979. */
  85980. applyToShader(effect: Effect): void;
  85981. /**
  85982. * Returns a string to use to update the GPU particles update shader
  85983. * @returns a string containng the defines string
  85984. */
  85985. getEffectDefines(): string;
  85986. /**
  85987. * Returns the string "SphereParticleEmitter"
  85988. * @returns a string containing the class name
  85989. */
  85990. getClassName(): string;
  85991. /**
  85992. * Serializes the particle system to a JSON object.
  85993. * @returns the JSON object
  85994. */
  85995. serialize(): any;
  85996. /**
  85997. * Parse properties from a JSON object
  85998. * @param serializationObject defines the JSON object
  85999. */
  86000. parse(serializationObject: any): void;
  86001. }
  86002. /**
  86003. * Particle emitter emitting particles from the inside of a sphere.
  86004. * It emits the particles randomly between two vectors.
  86005. */
  86006. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  86007. /**
  86008. * The min limit of the emission direction.
  86009. */
  86010. direction1: Vector3;
  86011. /**
  86012. * The max limit of the emission direction.
  86013. */
  86014. direction2: Vector3;
  86015. /**
  86016. * Creates a new instance SphereDirectedParticleEmitter
  86017. * @param radius the radius of the emission sphere (1 by default)
  86018. * @param direction1 the min limit of the emission direction (up vector by default)
  86019. * @param direction2 the max limit of the emission direction (up vector by default)
  86020. */
  86021. constructor(radius?: number,
  86022. /**
  86023. * The min limit of the emission direction.
  86024. */
  86025. direction1?: Vector3,
  86026. /**
  86027. * The max limit of the emission direction.
  86028. */
  86029. direction2?: Vector3);
  86030. /**
  86031. * Called by the particle System when the direction is computed for the created particle.
  86032. * @param worldMatrix is the world matrix of the particle system
  86033. * @param directionToUpdate is the direction vector to update with the result
  86034. * @param particle is the particle we are computed the direction for
  86035. */
  86036. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86037. /**
  86038. * Clones the current emitter and returns a copy of it
  86039. * @returns the new emitter
  86040. */
  86041. clone(): SphereDirectedParticleEmitter;
  86042. /**
  86043. * Called by the GPUParticleSystem to setup the update shader
  86044. * @param effect defines the update shader
  86045. */
  86046. applyToShader(effect: Effect): void;
  86047. /**
  86048. * Returns a string to use to update the GPU particles update shader
  86049. * @returns a string containng the defines string
  86050. */
  86051. getEffectDefines(): string;
  86052. /**
  86053. * Returns the string "SphereDirectedParticleEmitter"
  86054. * @returns a string containing the class name
  86055. */
  86056. getClassName(): string;
  86057. /**
  86058. * Serializes the particle system to a JSON object.
  86059. * @returns the JSON object
  86060. */
  86061. serialize(): any;
  86062. /**
  86063. * Parse properties from a JSON object
  86064. * @param serializationObject defines the JSON object
  86065. */
  86066. parse(serializationObject: any): void;
  86067. }
  86068. }
  86069. declare module BABYLON {
  86070. /**
  86071. * Particle emitter emitting particles from a custom list of positions.
  86072. */
  86073. export class CustomParticleEmitter implements IParticleEmitterType {
  86074. /**
  86075. * Gets or sets the position generator that will create the inital position of each particle.
  86076. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  86077. */
  86078. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  86079. /**
  86080. * Gets or sets the destination generator that will create the final destination of each particle.
  86081. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  86082. */
  86083. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  86084. /**
  86085. * Creates a new instance CustomParticleEmitter
  86086. */
  86087. constructor();
  86088. /**
  86089. * Called by the particle System when the direction is computed for the created particle.
  86090. * @param worldMatrix is the world matrix of the particle system
  86091. * @param directionToUpdate is the direction vector to update with the result
  86092. * @param particle is the particle we are computed the direction for
  86093. */
  86094. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86095. /**
  86096. * Called by the particle System when the position is computed for the created particle.
  86097. * @param worldMatrix is the world matrix of the particle system
  86098. * @param positionToUpdate is the position vector to update with the result
  86099. * @param particle is the particle we are computed the position for
  86100. */
  86101. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86102. /**
  86103. * Clones the current emitter and returns a copy of it
  86104. * @returns the new emitter
  86105. */
  86106. clone(): CustomParticleEmitter;
  86107. /**
  86108. * Called by the GPUParticleSystem to setup the update shader
  86109. * @param effect defines the update shader
  86110. */
  86111. applyToShader(effect: Effect): void;
  86112. /**
  86113. * Returns a string to use to update the GPU particles update shader
  86114. * @returns a string containng the defines string
  86115. */
  86116. getEffectDefines(): string;
  86117. /**
  86118. * Returns the string "PointParticleEmitter"
  86119. * @returns a string containing the class name
  86120. */
  86121. getClassName(): string;
  86122. /**
  86123. * Serializes the particle system to a JSON object.
  86124. * @returns the JSON object
  86125. */
  86126. serialize(): any;
  86127. /**
  86128. * Parse properties from a JSON object
  86129. * @param serializationObject defines the JSON object
  86130. */
  86131. parse(serializationObject: any): void;
  86132. }
  86133. }
  86134. declare module BABYLON {
  86135. /**
  86136. * Particle emitter emitting particles from the inside of a box.
  86137. * It emits the particles randomly between 2 given directions.
  86138. */
  86139. export class MeshParticleEmitter implements IParticleEmitterType {
  86140. /** Defines the mesh to use as source */
  86141. mesh?: AbstractMesh | undefined;
  86142. private _indices;
  86143. private _positions;
  86144. private _normals;
  86145. private _storedNormal;
  86146. /**
  86147. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86148. */
  86149. direction1: Vector3;
  86150. /**
  86151. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86152. */
  86153. direction2: Vector3;
  86154. /**
  86155. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  86156. */
  86157. useMeshNormalsForDirection: boolean;
  86158. /**
  86159. * Creates a new instance MeshParticleEmitter
  86160. * @param mesh defines the mesh to use as source
  86161. */
  86162. constructor(
  86163. /** Defines the mesh to use as source */
  86164. mesh?: AbstractMesh | undefined);
  86165. /**
  86166. * Called by the particle System when the direction is computed for the created particle.
  86167. * @param worldMatrix is the world matrix of the particle system
  86168. * @param directionToUpdate is the direction vector to update with the result
  86169. * @param particle is the particle we are computed the direction for
  86170. */
  86171. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86172. /**
  86173. * Called by the particle System when the position is computed for the created particle.
  86174. * @param worldMatrix is the world matrix of the particle system
  86175. * @param positionToUpdate is the position vector to update with the result
  86176. * @param particle is the particle we are computed the position for
  86177. */
  86178. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86179. /**
  86180. * Clones the current emitter and returns a copy of it
  86181. * @returns the new emitter
  86182. */
  86183. clone(): MeshParticleEmitter;
  86184. /**
  86185. * Called by the GPUParticleSystem to setup the update shader
  86186. * @param effect defines the update shader
  86187. */
  86188. applyToShader(effect: Effect): void;
  86189. /**
  86190. * Returns a string to use to update the GPU particles update shader
  86191. * @returns a string containng the defines string
  86192. */
  86193. getEffectDefines(): string;
  86194. /**
  86195. * Returns the string "BoxParticleEmitter"
  86196. * @returns a string containing the class name
  86197. */
  86198. getClassName(): string;
  86199. /**
  86200. * Serializes the particle system to a JSON object.
  86201. * @returns the JSON object
  86202. */
  86203. serialize(): any;
  86204. /**
  86205. * Parse properties from a JSON object
  86206. * @param serializationObject defines the JSON object
  86207. * @param scene defines the hosting scene
  86208. */
  86209. parse(serializationObject: any, scene: Scene): void;
  86210. }
  86211. }
  86212. declare module BABYLON {
  86213. /**
  86214. * Interface representing a particle system in Babylon.js.
  86215. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  86216. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  86217. */
  86218. export interface IParticleSystem {
  86219. /**
  86220. * List of animations used by the particle system.
  86221. */
  86222. animations: Animation[];
  86223. /**
  86224. * The id of the Particle system.
  86225. */
  86226. id: string;
  86227. /**
  86228. * The name of the Particle system.
  86229. */
  86230. name: string;
  86231. /**
  86232. * The emitter represents the Mesh or position we are attaching the particle system to.
  86233. */
  86234. emitter: Nullable<AbstractMesh | Vector3>;
  86235. /**
  86236. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  86237. */
  86238. isBillboardBased: boolean;
  86239. /**
  86240. * The rendering group used by the Particle system to chose when to render.
  86241. */
  86242. renderingGroupId: number;
  86243. /**
  86244. * The layer mask we are rendering the particles through.
  86245. */
  86246. layerMask: number;
  86247. /**
  86248. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  86249. */
  86250. updateSpeed: number;
  86251. /**
  86252. * The amount of time the particle system is running (depends of the overall update speed).
  86253. */
  86254. targetStopDuration: number;
  86255. /**
  86256. * The texture used to render each particle. (this can be a spritesheet)
  86257. */
  86258. particleTexture: Nullable<Texture>;
  86259. /**
  86260. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  86261. */
  86262. blendMode: number;
  86263. /**
  86264. * Minimum life time of emitting particles.
  86265. */
  86266. minLifeTime: number;
  86267. /**
  86268. * Maximum life time of emitting particles.
  86269. */
  86270. maxLifeTime: number;
  86271. /**
  86272. * Minimum Size of emitting particles.
  86273. */
  86274. minSize: number;
  86275. /**
  86276. * Maximum Size of emitting particles.
  86277. */
  86278. maxSize: number;
  86279. /**
  86280. * Minimum scale of emitting particles on X axis.
  86281. */
  86282. minScaleX: number;
  86283. /**
  86284. * Maximum scale of emitting particles on X axis.
  86285. */
  86286. maxScaleX: number;
  86287. /**
  86288. * Minimum scale of emitting particles on Y axis.
  86289. */
  86290. minScaleY: number;
  86291. /**
  86292. * Maximum scale of emitting particles on Y axis.
  86293. */
  86294. maxScaleY: number;
  86295. /**
  86296. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86297. */
  86298. color1: Color4;
  86299. /**
  86300. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86301. */
  86302. color2: Color4;
  86303. /**
  86304. * Color the particle will have at the end of its lifetime.
  86305. */
  86306. colorDead: Color4;
  86307. /**
  86308. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  86309. */
  86310. emitRate: number;
  86311. /**
  86312. * You can use gravity if you want to give an orientation to your particles.
  86313. */
  86314. gravity: Vector3;
  86315. /**
  86316. * Minimum power of emitting particles.
  86317. */
  86318. minEmitPower: number;
  86319. /**
  86320. * Maximum power of emitting particles.
  86321. */
  86322. maxEmitPower: number;
  86323. /**
  86324. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  86325. */
  86326. minAngularSpeed: number;
  86327. /**
  86328. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  86329. */
  86330. maxAngularSpeed: number;
  86331. /**
  86332. * Gets or sets the minimal initial rotation in radians.
  86333. */
  86334. minInitialRotation: number;
  86335. /**
  86336. * Gets or sets the maximal initial rotation in radians.
  86337. */
  86338. maxInitialRotation: number;
  86339. /**
  86340. * The particle emitter type defines the emitter used by the particle system.
  86341. * It can be for example box, sphere, or cone...
  86342. */
  86343. particleEmitterType: Nullable<IParticleEmitterType>;
  86344. /**
  86345. * Defines the delay in milliseconds before starting the system (0 by default)
  86346. */
  86347. startDelay: number;
  86348. /**
  86349. * 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
  86350. */
  86351. preWarmCycles: number;
  86352. /**
  86353. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  86354. */
  86355. preWarmStepOffset: number;
  86356. /**
  86357. * 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)
  86358. */
  86359. spriteCellChangeSpeed: number;
  86360. /**
  86361. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  86362. */
  86363. startSpriteCellID: number;
  86364. /**
  86365. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  86366. */
  86367. endSpriteCellID: number;
  86368. /**
  86369. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  86370. */
  86371. spriteCellWidth: number;
  86372. /**
  86373. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  86374. */
  86375. spriteCellHeight: number;
  86376. /**
  86377. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  86378. */
  86379. spriteRandomStartCell: boolean;
  86380. /**
  86381. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  86382. */
  86383. isAnimationSheetEnabled: boolean;
  86384. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  86385. translationPivot: Vector2;
  86386. /**
  86387. * Gets or sets a texture used to add random noise to particle positions
  86388. */
  86389. noiseTexture: Nullable<BaseTexture>;
  86390. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  86391. noiseStrength: Vector3;
  86392. /**
  86393. * Gets or sets the billboard mode to use when isBillboardBased = true.
  86394. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  86395. */
  86396. billboardMode: number;
  86397. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  86398. limitVelocityDamping: number;
  86399. /**
  86400. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  86401. */
  86402. beginAnimationOnStart: boolean;
  86403. /**
  86404. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  86405. */
  86406. beginAnimationFrom: number;
  86407. /**
  86408. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  86409. */
  86410. beginAnimationTo: number;
  86411. /**
  86412. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  86413. */
  86414. beginAnimationLoop: boolean;
  86415. /**
  86416. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  86417. */
  86418. disposeOnStop: boolean;
  86419. /**
  86420. * Gets the maximum number of particles active at the same time.
  86421. * @returns The max number of active particles.
  86422. */
  86423. getCapacity(): number;
  86424. /**
  86425. * Gets if the system has been started. (Note: this will still be true after stop is called)
  86426. * @returns True if it has been started, otherwise false.
  86427. */
  86428. isStarted(): boolean;
  86429. /**
  86430. * Animates the particle system for this frame.
  86431. */
  86432. animate(): void;
  86433. /**
  86434. * Renders the particle system in its current state.
  86435. * @returns the current number of particles
  86436. */
  86437. render(): number;
  86438. /**
  86439. * Dispose the particle system and frees its associated resources.
  86440. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  86441. */
  86442. dispose(disposeTexture?: boolean): void;
  86443. /**
  86444. * Clones the particle system.
  86445. * @param name The name of the cloned object
  86446. * @param newEmitter The new emitter to use
  86447. * @returns the cloned particle system
  86448. */
  86449. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  86450. /**
  86451. * Serializes the particle system to a JSON object.
  86452. * @returns the JSON object
  86453. */
  86454. serialize(): any;
  86455. /**
  86456. * Rebuild the particle system
  86457. */
  86458. rebuild(): void;
  86459. /**
  86460. * Starts the particle system and begins to emit
  86461. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  86462. */
  86463. start(delay?: number): void;
  86464. /**
  86465. * Stops the particle system.
  86466. */
  86467. stop(): void;
  86468. /**
  86469. * Remove all active particles
  86470. */
  86471. reset(): void;
  86472. /**
  86473. * Is this system ready to be used/rendered
  86474. * @return true if the system is ready
  86475. */
  86476. isReady(): boolean;
  86477. /**
  86478. * Adds a new color gradient
  86479. * @param gradient defines the gradient to use (between 0 and 1)
  86480. * @param color1 defines the color to affect to the specified gradient
  86481. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  86482. * @returns the current particle system
  86483. */
  86484. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  86485. /**
  86486. * Remove a specific color gradient
  86487. * @param gradient defines the gradient to remove
  86488. * @returns the current particle system
  86489. */
  86490. removeColorGradient(gradient: number): IParticleSystem;
  86491. /**
  86492. * Adds a new size gradient
  86493. * @param gradient defines the gradient to use (between 0 and 1)
  86494. * @param factor defines the size factor to affect to the specified gradient
  86495. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86496. * @returns the current particle system
  86497. */
  86498. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86499. /**
  86500. * Remove a specific size gradient
  86501. * @param gradient defines the gradient to remove
  86502. * @returns the current particle system
  86503. */
  86504. removeSizeGradient(gradient: number): IParticleSystem;
  86505. /**
  86506. * Gets the current list of color gradients.
  86507. * You must use addColorGradient and removeColorGradient to udpate this list
  86508. * @returns the list of color gradients
  86509. */
  86510. getColorGradients(): Nullable<Array<ColorGradient>>;
  86511. /**
  86512. * Gets the current list of size gradients.
  86513. * You must use addSizeGradient and removeSizeGradient to udpate this list
  86514. * @returns the list of size gradients
  86515. */
  86516. getSizeGradients(): Nullable<Array<FactorGradient>>;
  86517. /**
  86518. * Gets the current list of angular speed gradients.
  86519. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  86520. * @returns the list of angular speed gradients
  86521. */
  86522. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  86523. /**
  86524. * Adds a new angular speed gradient
  86525. * @param gradient defines the gradient to use (between 0 and 1)
  86526. * @param factor defines the angular speed to affect to the specified gradient
  86527. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86528. * @returns the current particle system
  86529. */
  86530. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86531. /**
  86532. * Remove a specific angular speed gradient
  86533. * @param gradient defines the gradient to remove
  86534. * @returns the current particle system
  86535. */
  86536. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  86537. /**
  86538. * Gets the current list of velocity gradients.
  86539. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  86540. * @returns the list of velocity gradients
  86541. */
  86542. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  86543. /**
  86544. * Adds a new velocity gradient
  86545. * @param gradient defines the gradient to use (between 0 and 1)
  86546. * @param factor defines the velocity to affect to the specified gradient
  86547. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86548. * @returns the current particle system
  86549. */
  86550. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86551. /**
  86552. * Remove a specific velocity gradient
  86553. * @param gradient defines the gradient to remove
  86554. * @returns the current particle system
  86555. */
  86556. removeVelocityGradient(gradient: number): IParticleSystem;
  86557. /**
  86558. * Gets the current list of limit velocity gradients.
  86559. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  86560. * @returns the list of limit velocity gradients
  86561. */
  86562. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  86563. /**
  86564. * Adds a new limit velocity gradient
  86565. * @param gradient defines the gradient to use (between 0 and 1)
  86566. * @param factor defines the limit velocity to affect to the specified gradient
  86567. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86568. * @returns the current particle system
  86569. */
  86570. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86571. /**
  86572. * Remove a specific limit velocity gradient
  86573. * @param gradient defines the gradient to remove
  86574. * @returns the current particle system
  86575. */
  86576. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  86577. /**
  86578. * Adds a new drag gradient
  86579. * @param gradient defines the gradient to use (between 0 and 1)
  86580. * @param factor defines the drag to affect to the specified gradient
  86581. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86582. * @returns the current particle system
  86583. */
  86584. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86585. /**
  86586. * Remove a specific drag gradient
  86587. * @param gradient defines the gradient to remove
  86588. * @returns the current particle system
  86589. */
  86590. removeDragGradient(gradient: number): IParticleSystem;
  86591. /**
  86592. * Gets the current list of drag gradients.
  86593. * You must use addDragGradient and removeDragGradient to udpate this list
  86594. * @returns the list of drag gradients
  86595. */
  86596. getDragGradients(): Nullable<Array<FactorGradient>>;
  86597. /**
  86598. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  86599. * @param gradient defines the gradient to use (between 0 and 1)
  86600. * @param factor defines the emit rate to affect to the specified gradient
  86601. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86602. * @returns the current particle system
  86603. */
  86604. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86605. /**
  86606. * Remove a specific emit rate gradient
  86607. * @param gradient defines the gradient to remove
  86608. * @returns the current particle system
  86609. */
  86610. removeEmitRateGradient(gradient: number): IParticleSystem;
  86611. /**
  86612. * Gets the current list of emit rate gradients.
  86613. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  86614. * @returns the list of emit rate gradients
  86615. */
  86616. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  86617. /**
  86618. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  86619. * @param gradient defines the gradient to use (between 0 and 1)
  86620. * @param factor defines the start size to affect to the specified gradient
  86621. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86622. * @returns the current particle system
  86623. */
  86624. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86625. /**
  86626. * Remove a specific start size gradient
  86627. * @param gradient defines the gradient to remove
  86628. * @returns the current particle system
  86629. */
  86630. removeStartSizeGradient(gradient: number): IParticleSystem;
  86631. /**
  86632. * Gets the current list of start size gradients.
  86633. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  86634. * @returns the list of start size gradients
  86635. */
  86636. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  86637. /**
  86638. * Adds a new life time gradient
  86639. * @param gradient defines the gradient to use (between 0 and 1)
  86640. * @param factor defines the life time factor to affect to the specified gradient
  86641. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86642. * @returns the current particle system
  86643. */
  86644. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86645. /**
  86646. * Remove a specific life time gradient
  86647. * @param gradient defines the gradient to remove
  86648. * @returns the current particle system
  86649. */
  86650. removeLifeTimeGradient(gradient: number): IParticleSystem;
  86651. /**
  86652. * Gets the current list of life time gradients.
  86653. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  86654. * @returns the list of life time gradients
  86655. */
  86656. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  86657. /**
  86658. * Gets the current list of color gradients.
  86659. * You must use addColorGradient and removeColorGradient to udpate this list
  86660. * @returns the list of color gradients
  86661. */
  86662. getColorGradients(): Nullable<Array<ColorGradient>>;
  86663. /**
  86664. * Adds a new ramp gradient used to remap particle colors
  86665. * @param gradient defines the gradient to use (between 0 and 1)
  86666. * @param color defines the color to affect to the specified gradient
  86667. * @returns the current particle system
  86668. */
  86669. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  86670. /**
  86671. * Gets the current list of ramp gradients.
  86672. * You must use addRampGradient and removeRampGradient to udpate this list
  86673. * @returns the list of ramp gradients
  86674. */
  86675. getRampGradients(): Nullable<Array<Color3Gradient>>;
  86676. /** Gets or sets a boolean indicating that ramp gradients must be used
  86677. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  86678. */
  86679. useRampGradients: boolean;
  86680. /**
  86681. * Adds a new color remap gradient
  86682. * @param gradient defines the gradient to use (between 0 and 1)
  86683. * @param min defines the color remap minimal range
  86684. * @param max defines the color remap maximal range
  86685. * @returns the current particle system
  86686. */
  86687. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86688. /**
  86689. * Gets the current list of color remap gradients.
  86690. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  86691. * @returns the list of color remap gradients
  86692. */
  86693. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  86694. /**
  86695. * Adds a new alpha remap gradient
  86696. * @param gradient defines the gradient to use (between 0 and 1)
  86697. * @param min defines the alpha remap minimal range
  86698. * @param max defines the alpha remap maximal range
  86699. * @returns the current particle system
  86700. */
  86701. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86702. /**
  86703. * Gets the current list of alpha remap gradients.
  86704. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  86705. * @returns the list of alpha remap gradients
  86706. */
  86707. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  86708. /**
  86709. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  86710. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86711. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86712. * @returns the emitter
  86713. */
  86714. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  86715. /**
  86716. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  86717. * @param radius The radius of the hemisphere to emit from
  86718. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86719. * @returns the emitter
  86720. */
  86721. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  86722. /**
  86723. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  86724. * @param radius The radius of the sphere to emit from
  86725. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86726. * @returns the emitter
  86727. */
  86728. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  86729. /**
  86730. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  86731. * @param radius The radius of the sphere to emit from
  86732. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  86733. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  86734. * @returns the emitter
  86735. */
  86736. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86737. /**
  86738. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  86739. * @param radius The radius of the emission cylinder
  86740. * @param height The height of the emission cylinder
  86741. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  86742. * @param directionRandomizer How much to randomize the particle direction [0-1]
  86743. * @returns the emitter
  86744. */
  86745. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  86746. /**
  86747. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  86748. * @param radius The radius of the cylinder to emit from
  86749. * @param height The height of the emission cylinder
  86750. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86751. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  86752. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  86753. * @returns the emitter
  86754. */
  86755. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86756. /**
  86757. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  86758. * @param radius The radius of the cone to emit from
  86759. * @param angle The base angle of the cone
  86760. * @returns the emitter
  86761. */
  86762. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  86763. /**
  86764. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  86765. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86766. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86767. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86768. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86769. * @returns the emitter
  86770. */
  86771. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  86772. /**
  86773. * Get hosting scene
  86774. * @returns the scene
  86775. */
  86776. getScene(): Scene;
  86777. }
  86778. }
  86779. declare module BABYLON {
  86780. /**
  86781. * 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.
  86782. * @see https://doc.babylonjs.com/how_to/transformnode
  86783. */
  86784. export class TransformNode extends Node {
  86785. /**
  86786. * Object will not rotate to face the camera
  86787. */
  86788. static BILLBOARDMODE_NONE: number;
  86789. /**
  86790. * Object will rotate to face the camera but only on the x axis
  86791. */
  86792. static BILLBOARDMODE_X: number;
  86793. /**
  86794. * Object will rotate to face the camera but only on the y axis
  86795. */
  86796. static BILLBOARDMODE_Y: number;
  86797. /**
  86798. * Object will rotate to face the camera but only on the z axis
  86799. */
  86800. static BILLBOARDMODE_Z: number;
  86801. /**
  86802. * Object will rotate to face the camera
  86803. */
  86804. static BILLBOARDMODE_ALL: number;
  86805. /**
  86806. * Object will rotate to face the camera's position instead of orientation
  86807. */
  86808. static BILLBOARDMODE_USE_POSITION: number;
  86809. private _forward;
  86810. private _forwardInverted;
  86811. private _up;
  86812. private _right;
  86813. private _rightInverted;
  86814. private _position;
  86815. private _rotation;
  86816. private _rotationQuaternion;
  86817. protected _scaling: Vector3;
  86818. protected _isDirty: boolean;
  86819. private _transformToBoneReferal;
  86820. private _isAbsoluteSynced;
  86821. private _billboardMode;
  86822. /**
  86823. * Gets or sets the billboard mode. Default is 0.
  86824. *
  86825. * | Value | Type | Description |
  86826. * | --- | --- | --- |
  86827. * | 0 | BILLBOARDMODE_NONE | |
  86828. * | 1 | BILLBOARDMODE_X | |
  86829. * | 2 | BILLBOARDMODE_Y | |
  86830. * | 4 | BILLBOARDMODE_Z | |
  86831. * | 7 | BILLBOARDMODE_ALL | |
  86832. *
  86833. */
  86834. get billboardMode(): number;
  86835. set billboardMode(value: number);
  86836. private _preserveParentRotationForBillboard;
  86837. /**
  86838. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  86839. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  86840. */
  86841. get preserveParentRotationForBillboard(): boolean;
  86842. set preserveParentRotationForBillboard(value: boolean);
  86843. /**
  86844. * 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
  86845. */
  86846. scalingDeterminant: number;
  86847. private _infiniteDistance;
  86848. /**
  86849. * Gets or sets the distance of the object to max, often used by skybox
  86850. */
  86851. get infiniteDistance(): boolean;
  86852. set infiniteDistance(value: boolean);
  86853. /**
  86854. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  86855. * By default the system will update normals to compensate
  86856. */
  86857. ignoreNonUniformScaling: boolean;
  86858. /**
  86859. * 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
  86860. */
  86861. reIntegrateRotationIntoRotationQuaternion: boolean;
  86862. /** @hidden */
  86863. _poseMatrix: Nullable<Matrix>;
  86864. /** @hidden */
  86865. _localMatrix: Matrix;
  86866. private _usePivotMatrix;
  86867. private _absolutePosition;
  86868. private _absoluteScaling;
  86869. private _absoluteRotationQuaternion;
  86870. private _pivotMatrix;
  86871. private _pivotMatrixInverse;
  86872. protected _postMultiplyPivotMatrix: boolean;
  86873. protected _isWorldMatrixFrozen: boolean;
  86874. /** @hidden */
  86875. _indexInSceneTransformNodesArray: number;
  86876. /**
  86877. * An event triggered after the world matrix is updated
  86878. */
  86879. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  86880. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  86881. /**
  86882. * Gets a string identifying the name of the class
  86883. * @returns "TransformNode" string
  86884. */
  86885. getClassName(): string;
  86886. /**
  86887. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  86888. */
  86889. get position(): Vector3;
  86890. set position(newPosition: Vector3);
  86891. /**
  86892. * 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)).
  86893. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  86894. */
  86895. get rotation(): Vector3;
  86896. set rotation(newRotation: Vector3);
  86897. /**
  86898. * 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)).
  86899. */
  86900. get scaling(): Vector3;
  86901. set scaling(newScaling: Vector3);
  86902. /**
  86903. * 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).
  86904. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  86905. */
  86906. get rotationQuaternion(): Nullable<Quaternion>;
  86907. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  86908. /**
  86909. * The forward direction of that transform in world space.
  86910. */
  86911. get forward(): Vector3;
  86912. /**
  86913. * The up direction of that transform in world space.
  86914. */
  86915. get up(): Vector3;
  86916. /**
  86917. * The right direction of that transform in world space.
  86918. */
  86919. get right(): Vector3;
  86920. /**
  86921. * Copies the parameter passed Matrix into the mesh Pose matrix.
  86922. * @param matrix the matrix to copy the pose from
  86923. * @returns this TransformNode.
  86924. */
  86925. updatePoseMatrix(matrix: Matrix): TransformNode;
  86926. /**
  86927. * Returns the mesh Pose matrix.
  86928. * @returns the pose matrix
  86929. */
  86930. getPoseMatrix(): Matrix;
  86931. /** @hidden */
  86932. _isSynchronized(): boolean;
  86933. /** @hidden */
  86934. _initCache(): void;
  86935. /**
  86936. * Flag the transform node as dirty (Forcing it to update everything)
  86937. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  86938. * @returns this transform node
  86939. */
  86940. markAsDirty(property: string): TransformNode;
  86941. /**
  86942. * Returns the current mesh absolute position.
  86943. * Returns a Vector3.
  86944. */
  86945. get absolutePosition(): Vector3;
  86946. /**
  86947. * Returns the current mesh absolute scaling.
  86948. * Returns a Vector3.
  86949. */
  86950. get absoluteScaling(): Vector3;
  86951. /**
  86952. * Returns the current mesh absolute rotation.
  86953. * Returns a Quaternion.
  86954. */
  86955. get absoluteRotationQuaternion(): Quaternion;
  86956. /**
  86957. * Sets a new matrix to apply before all other transformation
  86958. * @param matrix defines the transform matrix
  86959. * @returns the current TransformNode
  86960. */
  86961. setPreTransformMatrix(matrix: Matrix): TransformNode;
  86962. /**
  86963. * Sets a new pivot matrix to the current node
  86964. * @param matrix defines the new pivot matrix to use
  86965. * @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
  86966. * @returns the current TransformNode
  86967. */
  86968. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  86969. /**
  86970. * Returns the mesh pivot matrix.
  86971. * Default : Identity.
  86972. * @returns the matrix
  86973. */
  86974. getPivotMatrix(): Matrix;
  86975. /**
  86976. * Instantiate (when possible) or clone that node with its hierarchy
  86977. * @param newParent defines the new parent to use for the instance (or clone)
  86978. * @param options defines options to configure how copy is done
  86979. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  86980. * @returns an instance (or a clone) of the current node with its hiearchy
  86981. */
  86982. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  86983. doNotInstantiate: boolean;
  86984. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  86985. /**
  86986. * Prevents the World matrix to be computed any longer
  86987. * @param newWorldMatrix defines an optional matrix to use as world matrix
  86988. * @returns the TransformNode.
  86989. */
  86990. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  86991. /**
  86992. * Allows back the World matrix computation.
  86993. * @returns the TransformNode.
  86994. */
  86995. unfreezeWorldMatrix(): this;
  86996. /**
  86997. * True if the World matrix has been frozen.
  86998. */
  86999. get isWorldMatrixFrozen(): boolean;
  87000. /**
  87001. * Retuns the mesh absolute position in the World.
  87002. * @returns a Vector3.
  87003. */
  87004. getAbsolutePosition(): Vector3;
  87005. /**
  87006. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  87007. * @param absolutePosition the absolute position to set
  87008. * @returns the TransformNode.
  87009. */
  87010. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  87011. /**
  87012. * Sets the mesh position in its local space.
  87013. * @param vector3 the position to set in localspace
  87014. * @returns the TransformNode.
  87015. */
  87016. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  87017. /**
  87018. * Returns the mesh position in the local space from the current World matrix values.
  87019. * @returns a new Vector3.
  87020. */
  87021. getPositionExpressedInLocalSpace(): Vector3;
  87022. /**
  87023. * Translates the mesh along the passed Vector3 in its local space.
  87024. * @param vector3 the distance to translate in localspace
  87025. * @returns the TransformNode.
  87026. */
  87027. locallyTranslate(vector3: Vector3): TransformNode;
  87028. private static _lookAtVectorCache;
  87029. /**
  87030. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  87031. * @param targetPoint the position (must be in same space as current mesh) to look at
  87032. * @param yawCor optional yaw (y-axis) correction in radians
  87033. * @param pitchCor optional pitch (x-axis) correction in radians
  87034. * @param rollCor optional roll (z-axis) correction in radians
  87035. * @param space the choosen space of the target
  87036. * @returns the TransformNode.
  87037. */
  87038. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  87039. /**
  87040. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  87041. * This Vector3 is expressed in the World space.
  87042. * @param localAxis axis to rotate
  87043. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  87044. */
  87045. getDirection(localAxis: Vector3): Vector3;
  87046. /**
  87047. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  87048. * localAxis is expressed in the mesh local space.
  87049. * result is computed in the Wordl space from the mesh World matrix.
  87050. * @param localAxis axis to rotate
  87051. * @param result the resulting transformnode
  87052. * @returns this TransformNode.
  87053. */
  87054. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  87055. /**
  87056. * Sets this transform node rotation to the given local axis.
  87057. * @param localAxis the axis in local space
  87058. * @param yawCor optional yaw (y-axis) correction in radians
  87059. * @param pitchCor optional pitch (x-axis) correction in radians
  87060. * @param rollCor optional roll (z-axis) correction in radians
  87061. * @returns this TransformNode
  87062. */
  87063. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  87064. /**
  87065. * Sets a new pivot point to the current node
  87066. * @param point defines the new pivot point to use
  87067. * @param space defines if the point is in world or local space (local by default)
  87068. * @returns the current TransformNode
  87069. */
  87070. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  87071. /**
  87072. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  87073. * @returns the pivot point
  87074. */
  87075. getPivotPoint(): Vector3;
  87076. /**
  87077. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  87078. * @param result the vector3 to store the result
  87079. * @returns this TransformNode.
  87080. */
  87081. getPivotPointToRef(result: Vector3): TransformNode;
  87082. /**
  87083. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  87084. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  87085. */
  87086. getAbsolutePivotPoint(): Vector3;
  87087. /**
  87088. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  87089. * @param result vector3 to store the result
  87090. * @returns this TransformNode.
  87091. */
  87092. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  87093. /**
  87094. * Defines the passed node as the parent of the current node.
  87095. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  87096. * @see https://doc.babylonjs.com/how_to/parenting
  87097. * @param node the node ot set as the parent
  87098. * @returns this TransformNode.
  87099. */
  87100. setParent(node: Nullable<Node>): TransformNode;
  87101. private _nonUniformScaling;
  87102. /**
  87103. * True if the scaling property of this object is non uniform eg. (1,2,1)
  87104. */
  87105. get nonUniformScaling(): boolean;
  87106. /** @hidden */
  87107. _updateNonUniformScalingState(value: boolean): boolean;
  87108. /**
  87109. * Attach the current TransformNode to another TransformNode associated with a bone
  87110. * @param bone Bone affecting the TransformNode
  87111. * @param affectedTransformNode TransformNode associated with the bone
  87112. * @returns this object
  87113. */
  87114. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  87115. /**
  87116. * Detach the transform node if its associated with a bone
  87117. * @returns this object
  87118. */
  87119. detachFromBone(): TransformNode;
  87120. private static _rotationAxisCache;
  87121. /**
  87122. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  87123. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  87124. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  87125. * The passed axis is also normalized.
  87126. * @param axis the axis to rotate around
  87127. * @param amount the amount to rotate in radians
  87128. * @param space Space to rotate in (Default: local)
  87129. * @returns the TransformNode.
  87130. */
  87131. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  87132. /**
  87133. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  87134. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  87135. * The passed axis is also normalized. .
  87136. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  87137. * @param point the point to rotate around
  87138. * @param axis the axis to rotate around
  87139. * @param amount the amount to rotate in radians
  87140. * @returns the TransformNode
  87141. */
  87142. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  87143. /**
  87144. * Translates the mesh along the axis vector for the passed distance in the given space.
  87145. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  87146. * @param axis the axis to translate in
  87147. * @param distance the distance to translate
  87148. * @param space Space to rotate in (Default: local)
  87149. * @returns the TransformNode.
  87150. */
  87151. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  87152. /**
  87153. * Adds a rotation step to the mesh current rotation.
  87154. * x, y, z are Euler angles expressed in radians.
  87155. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  87156. * This means this rotation is made in the mesh local space only.
  87157. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  87158. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  87159. * ```javascript
  87160. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  87161. * ```
  87162. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  87163. * 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.
  87164. * @param x Rotation to add
  87165. * @param y Rotation to add
  87166. * @param z Rotation to add
  87167. * @returns the TransformNode.
  87168. */
  87169. addRotation(x: number, y: number, z: number): TransformNode;
  87170. /**
  87171. * @hidden
  87172. */
  87173. protected _getEffectiveParent(): Nullable<Node>;
  87174. /**
  87175. * Computes the world matrix of the node
  87176. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  87177. * @returns the world matrix
  87178. */
  87179. computeWorldMatrix(force?: boolean): Matrix;
  87180. /**
  87181. * Resets this nodeTransform's local matrix to Matrix.Identity().
  87182. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  87183. */
  87184. resetLocalMatrix(independentOfChildren?: boolean): void;
  87185. protected _afterComputeWorldMatrix(): void;
  87186. /**
  87187. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  87188. * @param func callback function to add
  87189. *
  87190. * @returns the TransformNode.
  87191. */
  87192. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  87193. /**
  87194. * Removes a registered callback function.
  87195. * @param func callback function to remove
  87196. * @returns the TransformNode.
  87197. */
  87198. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  87199. /**
  87200. * Gets the position of the current mesh in camera space
  87201. * @param camera defines the camera to use
  87202. * @returns a position
  87203. */
  87204. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  87205. /**
  87206. * Returns the distance from the mesh to the active camera
  87207. * @param camera defines the camera to use
  87208. * @returns the distance
  87209. */
  87210. getDistanceToCamera(camera?: Nullable<Camera>): number;
  87211. /**
  87212. * Clone the current transform node
  87213. * @param name Name of the new clone
  87214. * @param newParent New parent for the clone
  87215. * @param doNotCloneChildren Do not clone children hierarchy
  87216. * @returns the new transform node
  87217. */
  87218. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  87219. /**
  87220. * Serializes the objects information.
  87221. * @param currentSerializationObject defines the object to serialize in
  87222. * @returns the serialized object
  87223. */
  87224. serialize(currentSerializationObject?: any): any;
  87225. /**
  87226. * Returns a new TransformNode object parsed from the source provided.
  87227. * @param parsedTransformNode is the source.
  87228. * @param scene the scne the object belongs to
  87229. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  87230. * @returns a new TransformNode object parsed from the source provided.
  87231. */
  87232. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  87233. /**
  87234. * Get all child-transformNodes of this node
  87235. * @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
  87236. * @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
  87237. * @returns an array of TransformNode
  87238. */
  87239. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  87240. /**
  87241. * Releases resources associated with this transform node.
  87242. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87243. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87244. */
  87245. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87246. /**
  87247. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  87248. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  87249. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  87250. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  87251. * @returns the current mesh
  87252. */
  87253. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  87254. private _syncAbsoluteScalingAndRotation;
  87255. }
  87256. }
  87257. declare module BABYLON {
  87258. /**
  87259. * Class used to override all child animations of a given target
  87260. */
  87261. export class AnimationPropertiesOverride {
  87262. /**
  87263. * Gets or sets a value indicating if animation blending must be used
  87264. */
  87265. enableBlending: boolean;
  87266. /**
  87267. * Gets or sets the blending speed to use when enableBlending is true
  87268. */
  87269. blendingSpeed: number;
  87270. /**
  87271. * Gets or sets the default loop mode to use
  87272. */
  87273. loopMode: number;
  87274. }
  87275. }
  87276. declare module BABYLON {
  87277. /**
  87278. * Class used to store bone information
  87279. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  87280. */
  87281. export class Bone extends Node {
  87282. /**
  87283. * defines the bone name
  87284. */
  87285. name: string;
  87286. private static _tmpVecs;
  87287. private static _tmpQuat;
  87288. private static _tmpMats;
  87289. /**
  87290. * Gets the list of child bones
  87291. */
  87292. children: Bone[];
  87293. /** Gets the animations associated with this bone */
  87294. animations: Animation[];
  87295. /**
  87296. * Gets or sets bone length
  87297. */
  87298. length: number;
  87299. /**
  87300. * @hidden Internal only
  87301. * Set this value to map this bone to a different index in the transform matrices
  87302. * Set this value to -1 to exclude the bone from the transform matrices
  87303. */
  87304. _index: Nullable<number>;
  87305. private _skeleton;
  87306. private _localMatrix;
  87307. private _restPose;
  87308. private _baseMatrix;
  87309. private _absoluteTransform;
  87310. private _invertedAbsoluteTransform;
  87311. private _parent;
  87312. private _scalingDeterminant;
  87313. private _worldTransform;
  87314. private _localScaling;
  87315. private _localRotation;
  87316. private _localPosition;
  87317. private _needToDecompose;
  87318. private _needToCompose;
  87319. /** @hidden */
  87320. _linkedTransformNode: Nullable<TransformNode>;
  87321. /** @hidden */
  87322. _waitingTransformNodeId: Nullable<string>;
  87323. /** @hidden */
  87324. get _matrix(): Matrix;
  87325. /** @hidden */
  87326. set _matrix(value: Matrix);
  87327. /**
  87328. * Create a new bone
  87329. * @param name defines the bone name
  87330. * @param skeleton defines the parent skeleton
  87331. * @param parentBone defines the parent (can be null if the bone is the root)
  87332. * @param localMatrix defines the local matrix
  87333. * @param restPose defines the rest pose matrix
  87334. * @param baseMatrix defines the base matrix
  87335. * @param index defines index of the bone in the hiearchy
  87336. */
  87337. constructor(
  87338. /**
  87339. * defines the bone name
  87340. */
  87341. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  87342. /**
  87343. * Gets the current object class name.
  87344. * @return the class name
  87345. */
  87346. getClassName(): string;
  87347. /**
  87348. * Gets the parent skeleton
  87349. * @returns a skeleton
  87350. */
  87351. getSkeleton(): Skeleton;
  87352. /**
  87353. * Gets parent bone
  87354. * @returns a bone or null if the bone is the root of the bone hierarchy
  87355. */
  87356. getParent(): Nullable<Bone>;
  87357. /**
  87358. * Returns an array containing the root bones
  87359. * @returns an array containing the root bones
  87360. */
  87361. getChildren(): Array<Bone>;
  87362. /**
  87363. * Gets the node index in matrix array generated for rendering
  87364. * @returns the node index
  87365. */
  87366. getIndex(): number;
  87367. /**
  87368. * Sets the parent bone
  87369. * @param parent defines the parent (can be null if the bone is the root)
  87370. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  87371. */
  87372. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  87373. /**
  87374. * Gets the local matrix
  87375. * @returns a matrix
  87376. */
  87377. getLocalMatrix(): Matrix;
  87378. /**
  87379. * Gets the base matrix (initial matrix which remains unchanged)
  87380. * @returns a matrix
  87381. */
  87382. getBaseMatrix(): Matrix;
  87383. /**
  87384. * Gets the rest pose matrix
  87385. * @returns a matrix
  87386. */
  87387. getRestPose(): Matrix;
  87388. /**
  87389. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  87390. */
  87391. getWorldMatrix(): Matrix;
  87392. /**
  87393. * Sets the local matrix to rest pose matrix
  87394. */
  87395. returnToRest(): void;
  87396. /**
  87397. * Gets the inverse of the absolute transform matrix.
  87398. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  87399. * @returns a matrix
  87400. */
  87401. getInvertedAbsoluteTransform(): Matrix;
  87402. /**
  87403. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  87404. * @returns a matrix
  87405. */
  87406. getAbsoluteTransform(): Matrix;
  87407. /**
  87408. * Links with the given transform node.
  87409. * The local matrix of this bone is copied from the transform node every frame.
  87410. * @param transformNode defines the transform node to link to
  87411. */
  87412. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  87413. /**
  87414. * Gets the node used to drive the bone's transformation
  87415. * @returns a transform node or null
  87416. */
  87417. getTransformNode(): Nullable<TransformNode>;
  87418. /** Gets or sets current position (in local space) */
  87419. get position(): Vector3;
  87420. set position(newPosition: Vector3);
  87421. /** Gets or sets current rotation (in local space) */
  87422. get rotation(): Vector3;
  87423. set rotation(newRotation: Vector3);
  87424. /** Gets or sets current rotation quaternion (in local space) */
  87425. get rotationQuaternion(): Quaternion;
  87426. set rotationQuaternion(newRotation: Quaternion);
  87427. /** Gets or sets current scaling (in local space) */
  87428. get scaling(): Vector3;
  87429. set scaling(newScaling: Vector3);
  87430. /**
  87431. * Gets the animation properties override
  87432. */
  87433. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  87434. private _decompose;
  87435. private _compose;
  87436. /**
  87437. * Update the base and local matrices
  87438. * @param matrix defines the new base or local matrix
  87439. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  87440. * @param updateLocalMatrix defines if the local matrix should be updated
  87441. */
  87442. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  87443. /** @hidden */
  87444. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  87445. /**
  87446. * Flag the bone as dirty (Forcing it to update everything)
  87447. */
  87448. markAsDirty(): void;
  87449. /** @hidden */
  87450. _markAsDirtyAndCompose(): void;
  87451. private _markAsDirtyAndDecompose;
  87452. /**
  87453. * Translate the bone in local or world space
  87454. * @param vec The amount to translate the bone
  87455. * @param space The space that the translation is in
  87456. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87457. */
  87458. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87459. /**
  87460. * Set the postion of the bone in local or world space
  87461. * @param position The position to set the bone
  87462. * @param space The space that the position is in
  87463. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87464. */
  87465. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87466. /**
  87467. * Set the absolute position of the bone (world space)
  87468. * @param position The position to set the bone
  87469. * @param mesh The mesh that this bone is attached to
  87470. */
  87471. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  87472. /**
  87473. * Scale the bone on the x, y and z axes (in local space)
  87474. * @param x The amount to scale the bone on the x axis
  87475. * @param y The amount to scale the bone on the y axis
  87476. * @param z The amount to scale the bone on the z axis
  87477. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  87478. */
  87479. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  87480. /**
  87481. * Set the bone scaling in local space
  87482. * @param scale defines the scaling vector
  87483. */
  87484. setScale(scale: Vector3): void;
  87485. /**
  87486. * Gets the current scaling in local space
  87487. * @returns the current scaling vector
  87488. */
  87489. getScale(): Vector3;
  87490. /**
  87491. * Gets the current scaling in local space and stores it in a target vector
  87492. * @param result defines the target vector
  87493. */
  87494. getScaleToRef(result: Vector3): void;
  87495. /**
  87496. * Set the yaw, pitch, and roll of the bone in local or world space
  87497. * @param yaw The rotation of the bone on the y axis
  87498. * @param pitch The rotation of the bone on the x axis
  87499. * @param roll The rotation of the bone on the z axis
  87500. * @param space The space that the axes of rotation are in
  87501. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87502. */
  87503. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  87504. /**
  87505. * Add a rotation to the bone on an axis in local or world space
  87506. * @param axis The axis to rotate the bone on
  87507. * @param amount The amount to rotate the bone
  87508. * @param space The space that the axis is in
  87509. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87510. */
  87511. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  87512. /**
  87513. * Set the rotation of the bone to a particular axis angle in local or world space
  87514. * @param axis The axis to rotate the bone on
  87515. * @param angle The angle that the bone should be rotated to
  87516. * @param space The space that the axis is in
  87517. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87518. */
  87519. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  87520. /**
  87521. * Set the euler rotation of the bone in local of world space
  87522. * @param rotation The euler rotation that the bone should be set to
  87523. * @param space The space that the rotation is in
  87524. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87525. */
  87526. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87527. /**
  87528. * Set the quaternion rotation of the bone in local of world space
  87529. * @param quat The quaternion rotation that the bone should be set to
  87530. * @param space The space that the rotation is in
  87531. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87532. */
  87533. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  87534. /**
  87535. * Set the rotation matrix of the bone in local of world space
  87536. * @param rotMat The rotation matrix that the bone should be set to
  87537. * @param space The space that the rotation is in
  87538. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87539. */
  87540. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  87541. private _rotateWithMatrix;
  87542. private _getNegativeRotationToRef;
  87543. /**
  87544. * Get the position of the bone in local or world space
  87545. * @param space The space that the returned position is in
  87546. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87547. * @returns The position of the bone
  87548. */
  87549. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  87550. /**
  87551. * Copy the position of the bone to a vector3 in local or world space
  87552. * @param space The space that the returned position is in
  87553. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87554. * @param result The vector3 to copy the position to
  87555. */
  87556. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  87557. /**
  87558. * Get the absolute position of the bone (world space)
  87559. * @param mesh The mesh that this bone is attached to
  87560. * @returns The absolute position of the bone
  87561. */
  87562. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  87563. /**
  87564. * Copy the absolute position of the bone (world space) to the result param
  87565. * @param mesh The mesh that this bone is attached to
  87566. * @param result The vector3 to copy the absolute position to
  87567. */
  87568. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  87569. /**
  87570. * Compute the absolute transforms of this bone and its children
  87571. */
  87572. computeAbsoluteTransforms(): void;
  87573. /**
  87574. * Get the world direction from an axis that is in the local space of the bone
  87575. * @param localAxis The local direction that is used to compute the world direction
  87576. * @param mesh The mesh that this bone is attached to
  87577. * @returns The world direction
  87578. */
  87579. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87580. /**
  87581. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  87582. * @param localAxis The local direction that is used to compute the world direction
  87583. * @param mesh The mesh that this bone is attached to
  87584. * @param result The vector3 that the world direction will be copied to
  87585. */
  87586. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87587. /**
  87588. * Get the euler rotation of the bone in local or world space
  87589. * @param space The space that the rotation should be in
  87590. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87591. * @returns The euler rotation
  87592. */
  87593. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  87594. /**
  87595. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  87596. * @param space The space that the rotation should be in
  87597. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87598. * @param result The vector3 that the rotation should be copied to
  87599. */
  87600. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87601. /**
  87602. * Get the quaternion rotation of the bone in either local or world space
  87603. * @param space The space that the rotation should be in
  87604. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87605. * @returns The quaternion rotation
  87606. */
  87607. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  87608. /**
  87609. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  87610. * @param space The space that the rotation should be in
  87611. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87612. * @param result The quaternion that the rotation should be copied to
  87613. */
  87614. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  87615. /**
  87616. * Get the rotation matrix of the bone in local or world space
  87617. * @param space The space that the rotation should be in
  87618. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87619. * @returns The rotation matrix
  87620. */
  87621. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  87622. /**
  87623. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  87624. * @param space The space that the rotation should be in
  87625. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87626. * @param result The quaternion that the rotation should be copied to
  87627. */
  87628. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  87629. /**
  87630. * Get the world position of a point that is in the local space of the bone
  87631. * @param position The local position
  87632. * @param mesh The mesh that this bone is attached to
  87633. * @returns The world position
  87634. */
  87635. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87636. /**
  87637. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  87638. * @param position The local position
  87639. * @param mesh The mesh that this bone is attached to
  87640. * @param result The vector3 that the world position should be copied to
  87641. */
  87642. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87643. /**
  87644. * Get the local position of a point that is in world space
  87645. * @param position The world position
  87646. * @param mesh The mesh that this bone is attached to
  87647. * @returns The local position
  87648. */
  87649. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87650. /**
  87651. * Get the local position of a point that is in world space and copy it to the result param
  87652. * @param position The world position
  87653. * @param mesh The mesh that this bone is attached to
  87654. * @param result The vector3 that the local position should be copied to
  87655. */
  87656. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87657. }
  87658. }
  87659. declare module BABYLON {
  87660. /**
  87661. * Defines a runtime animation
  87662. */
  87663. export class RuntimeAnimation {
  87664. private _events;
  87665. /**
  87666. * The current frame of the runtime animation
  87667. */
  87668. private _currentFrame;
  87669. /**
  87670. * The animation used by the runtime animation
  87671. */
  87672. private _animation;
  87673. /**
  87674. * The target of the runtime animation
  87675. */
  87676. private _target;
  87677. /**
  87678. * The initiating animatable
  87679. */
  87680. private _host;
  87681. /**
  87682. * The original value of the runtime animation
  87683. */
  87684. private _originalValue;
  87685. /**
  87686. * The original blend value of the runtime animation
  87687. */
  87688. private _originalBlendValue;
  87689. /**
  87690. * The offsets cache of the runtime animation
  87691. */
  87692. private _offsetsCache;
  87693. /**
  87694. * The high limits cache of the runtime animation
  87695. */
  87696. private _highLimitsCache;
  87697. /**
  87698. * Specifies if the runtime animation has been stopped
  87699. */
  87700. private _stopped;
  87701. /**
  87702. * The blending factor of the runtime animation
  87703. */
  87704. private _blendingFactor;
  87705. /**
  87706. * The BabylonJS scene
  87707. */
  87708. private _scene;
  87709. /**
  87710. * The current value of the runtime animation
  87711. */
  87712. private _currentValue;
  87713. /** @hidden */
  87714. _animationState: _IAnimationState;
  87715. /**
  87716. * The active target of the runtime animation
  87717. */
  87718. private _activeTargets;
  87719. private _currentActiveTarget;
  87720. private _directTarget;
  87721. /**
  87722. * The target path of the runtime animation
  87723. */
  87724. private _targetPath;
  87725. /**
  87726. * The weight of the runtime animation
  87727. */
  87728. private _weight;
  87729. /**
  87730. * The ratio offset of the runtime animation
  87731. */
  87732. private _ratioOffset;
  87733. /**
  87734. * The previous delay of the runtime animation
  87735. */
  87736. private _previousDelay;
  87737. /**
  87738. * The previous ratio of the runtime animation
  87739. */
  87740. private _previousRatio;
  87741. private _enableBlending;
  87742. private _keys;
  87743. private _minFrame;
  87744. private _maxFrame;
  87745. private _minValue;
  87746. private _maxValue;
  87747. private _targetIsArray;
  87748. /**
  87749. * Gets the current frame of the runtime animation
  87750. */
  87751. get currentFrame(): number;
  87752. /**
  87753. * Gets the weight of the runtime animation
  87754. */
  87755. get weight(): number;
  87756. /**
  87757. * Gets the current value of the runtime animation
  87758. */
  87759. get currentValue(): any;
  87760. /**
  87761. * Gets the target path of the runtime animation
  87762. */
  87763. get targetPath(): string;
  87764. /**
  87765. * Gets the actual target of the runtime animation
  87766. */
  87767. get target(): any;
  87768. /** @hidden */
  87769. _onLoop: () => void;
  87770. /**
  87771. * Create a new RuntimeAnimation object
  87772. * @param target defines the target of the animation
  87773. * @param animation defines the source animation object
  87774. * @param scene defines the hosting scene
  87775. * @param host defines the initiating Animatable
  87776. */
  87777. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  87778. private _preparePath;
  87779. /**
  87780. * Gets the animation from the runtime animation
  87781. */
  87782. get animation(): Animation;
  87783. /**
  87784. * Resets the runtime animation to the beginning
  87785. * @param restoreOriginal defines whether to restore the target property to the original value
  87786. */
  87787. reset(restoreOriginal?: boolean): void;
  87788. /**
  87789. * Specifies if the runtime animation is stopped
  87790. * @returns Boolean specifying if the runtime animation is stopped
  87791. */
  87792. isStopped(): boolean;
  87793. /**
  87794. * Disposes of the runtime animation
  87795. */
  87796. dispose(): void;
  87797. /**
  87798. * Apply the interpolated value to the target
  87799. * @param currentValue defines the value computed by the animation
  87800. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  87801. */
  87802. setValue(currentValue: any, weight: number): void;
  87803. private _getOriginalValues;
  87804. private _setValue;
  87805. /**
  87806. * Gets the loop pmode of the runtime animation
  87807. * @returns Loop Mode
  87808. */
  87809. private _getCorrectLoopMode;
  87810. /**
  87811. * Move the current animation to a given frame
  87812. * @param frame defines the frame to move to
  87813. */
  87814. goToFrame(frame: number): void;
  87815. /**
  87816. * @hidden Internal use only
  87817. */
  87818. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  87819. /**
  87820. * Execute the current animation
  87821. * @param delay defines the delay to add to the current frame
  87822. * @param from defines the lower bound of the animation range
  87823. * @param to defines the upper bound of the animation range
  87824. * @param loop defines if the current animation must loop
  87825. * @param speedRatio defines the current speed ratio
  87826. * @param weight defines the weight of the animation (default is -1 so no weight)
  87827. * @param onLoop optional callback called when animation loops
  87828. * @returns a boolean indicating if the animation is running
  87829. */
  87830. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  87831. }
  87832. }
  87833. declare module BABYLON {
  87834. /**
  87835. * Class used to store an actual running animation
  87836. */
  87837. export class Animatable {
  87838. /** defines the target object */
  87839. target: any;
  87840. /** defines the starting frame number (default is 0) */
  87841. fromFrame: number;
  87842. /** defines the ending frame number (default is 100) */
  87843. toFrame: number;
  87844. /** defines if the animation must loop (default is false) */
  87845. loopAnimation: boolean;
  87846. /** defines a callback to call when animation ends if it is not looping */
  87847. onAnimationEnd?: (() => void) | null | undefined;
  87848. /** defines a callback to call when animation loops */
  87849. onAnimationLoop?: (() => void) | null | undefined;
  87850. private _localDelayOffset;
  87851. private _pausedDelay;
  87852. private _runtimeAnimations;
  87853. private _paused;
  87854. private _scene;
  87855. private _speedRatio;
  87856. private _weight;
  87857. private _syncRoot;
  87858. /**
  87859. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  87860. * This will only apply for non looping animation (default is true)
  87861. */
  87862. disposeOnEnd: boolean;
  87863. /**
  87864. * Gets a boolean indicating if the animation has started
  87865. */
  87866. animationStarted: boolean;
  87867. /**
  87868. * Observer raised when the animation ends
  87869. */
  87870. onAnimationEndObservable: Observable<Animatable>;
  87871. /**
  87872. * Observer raised when the animation loops
  87873. */
  87874. onAnimationLoopObservable: Observable<Animatable>;
  87875. /**
  87876. * Gets the root Animatable used to synchronize and normalize animations
  87877. */
  87878. get syncRoot(): Nullable<Animatable>;
  87879. /**
  87880. * Gets the current frame of the first RuntimeAnimation
  87881. * Used to synchronize Animatables
  87882. */
  87883. get masterFrame(): number;
  87884. /**
  87885. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  87886. */
  87887. get weight(): number;
  87888. set weight(value: number);
  87889. /**
  87890. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  87891. */
  87892. get speedRatio(): number;
  87893. set speedRatio(value: number);
  87894. /**
  87895. * Creates a new Animatable
  87896. * @param scene defines the hosting scene
  87897. * @param target defines the target object
  87898. * @param fromFrame defines the starting frame number (default is 0)
  87899. * @param toFrame defines the ending frame number (default is 100)
  87900. * @param loopAnimation defines if the animation must loop (default is false)
  87901. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  87902. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  87903. * @param animations defines a group of animation to add to the new Animatable
  87904. * @param onAnimationLoop defines a callback to call when animation loops
  87905. */
  87906. constructor(scene: Scene,
  87907. /** defines the target object */
  87908. target: any,
  87909. /** defines the starting frame number (default is 0) */
  87910. fromFrame?: number,
  87911. /** defines the ending frame number (default is 100) */
  87912. toFrame?: number,
  87913. /** defines if the animation must loop (default is false) */
  87914. loopAnimation?: boolean, speedRatio?: number,
  87915. /** defines a callback to call when animation ends if it is not looping */
  87916. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  87917. /** defines a callback to call when animation loops */
  87918. onAnimationLoop?: (() => void) | null | undefined);
  87919. /**
  87920. * Synchronize and normalize current Animatable with a source Animatable
  87921. * This is useful when using animation weights and when animations are not of the same length
  87922. * @param root defines the root Animatable to synchronize with
  87923. * @returns the current Animatable
  87924. */
  87925. syncWith(root: Animatable): Animatable;
  87926. /**
  87927. * Gets the list of runtime animations
  87928. * @returns an array of RuntimeAnimation
  87929. */
  87930. getAnimations(): RuntimeAnimation[];
  87931. /**
  87932. * Adds more animations to the current animatable
  87933. * @param target defines the target of the animations
  87934. * @param animations defines the new animations to add
  87935. */
  87936. appendAnimations(target: any, animations: Animation[]): void;
  87937. /**
  87938. * Gets the source animation for a specific property
  87939. * @param property defines the propertyu to look for
  87940. * @returns null or the source animation for the given property
  87941. */
  87942. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  87943. /**
  87944. * Gets the runtime animation for a specific property
  87945. * @param property defines the propertyu to look for
  87946. * @returns null or the runtime animation for the given property
  87947. */
  87948. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  87949. /**
  87950. * Resets the animatable to its original state
  87951. */
  87952. reset(): void;
  87953. /**
  87954. * Allows the animatable to blend with current running animations
  87955. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  87956. * @param blendingSpeed defines the blending speed to use
  87957. */
  87958. enableBlending(blendingSpeed: number): void;
  87959. /**
  87960. * Disable animation blending
  87961. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  87962. */
  87963. disableBlending(): void;
  87964. /**
  87965. * Jump directly to a given frame
  87966. * @param frame defines the frame to jump to
  87967. */
  87968. goToFrame(frame: number): void;
  87969. /**
  87970. * Pause the animation
  87971. */
  87972. pause(): void;
  87973. /**
  87974. * Restart the animation
  87975. */
  87976. restart(): void;
  87977. private _raiseOnAnimationEnd;
  87978. /**
  87979. * Stop and delete the current animation
  87980. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  87981. * @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)
  87982. */
  87983. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  87984. /**
  87985. * Wait asynchronously for the animation to end
  87986. * @returns a promise which will be fullfilled when the animation ends
  87987. */
  87988. waitAsync(): Promise<Animatable>;
  87989. /** @hidden */
  87990. _animate(delay: number): boolean;
  87991. }
  87992. interface Scene {
  87993. /** @hidden */
  87994. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  87995. /** @hidden */
  87996. _processLateAnimationBindingsForMatrices(holder: {
  87997. totalWeight: number;
  87998. animations: RuntimeAnimation[];
  87999. originalValue: Matrix;
  88000. }): any;
  88001. /** @hidden */
  88002. _processLateAnimationBindingsForQuaternions(holder: {
  88003. totalWeight: number;
  88004. animations: RuntimeAnimation[];
  88005. originalValue: Quaternion;
  88006. }, refQuaternion: Quaternion): Quaternion;
  88007. /** @hidden */
  88008. _processLateAnimationBindings(): void;
  88009. /**
  88010. * Will start the animation sequence of a given target
  88011. * @param target defines the target
  88012. * @param from defines from which frame should animation start
  88013. * @param to defines until which frame should animation run.
  88014. * @param weight defines the weight to apply to the animation (1.0 by default)
  88015. * @param loop defines if the animation loops
  88016. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  88017. * @param onAnimationEnd defines the function to be executed when the animation ends
  88018. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  88019. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  88020. * @param onAnimationLoop defines the callback to call when an animation loops
  88021. * @returns the animatable object created for this animation
  88022. */
  88023. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  88024. /**
  88025. * Will start the animation sequence of a given target
  88026. * @param target defines the target
  88027. * @param from defines from which frame should animation start
  88028. * @param to defines until which frame should animation run.
  88029. * @param loop defines if the animation loops
  88030. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  88031. * @param onAnimationEnd defines the function to be executed when the animation ends
  88032. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  88033. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  88034. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  88035. * @param onAnimationLoop defines the callback to call when an animation loops
  88036. * @returns the animatable object created for this animation
  88037. */
  88038. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  88039. /**
  88040. * Will start the animation sequence of a given target and its hierarchy
  88041. * @param target defines the target
  88042. * @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.
  88043. * @param from defines from which frame should animation start
  88044. * @param to defines until which frame should animation run.
  88045. * @param loop defines if the animation loops
  88046. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  88047. * @param onAnimationEnd defines the function to be executed when the animation ends
  88048. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  88049. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  88050. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  88051. * @param onAnimationLoop defines the callback to call when an animation loops
  88052. * @returns the list of created animatables
  88053. */
  88054. 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[];
  88055. /**
  88056. * Begin a new animation on a given node
  88057. * @param target defines the target where the animation will take place
  88058. * @param animations defines the list of animations to start
  88059. * @param from defines the initial value
  88060. * @param to defines the final value
  88061. * @param loop defines if you want animation to loop (off by default)
  88062. * @param speedRatio defines the speed ratio to apply to all animations
  88063. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  88064. * @param onAnimationLoop defines the callback to call when an animation loops
  88065. * @returns the list of created animatables
  88066. */
  88067. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  88068. /**
  88069. * Begin a new animation on a given node and its hierarchy
  88070. * @param target defines the root node where the animation will take place
  88071. * @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.
  88072. * @param animations defines the list of animations to start
  88073. * @param from defines the initial value
  88074. * @param to defines the final value
  88075. * @param loop defines if you want animation to loop (off by default)
  88076. * @param speedRatio defines the speed ratio to apply to all animations
  88077. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  88078. * @param onAnimationLoop defines the callback to call when an animation loops
  88079. * @returns the list of animatables created for all nodes
  88080. */
  88081. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  88082. /**
  88083. * Gets the animatable associated with a specific target
  88084. * @param target defines the target of the animatable
  88085. * @returns the required animatable if found
  88086. */
  88087. getAnimatableByTarget(target: any): Nullable<Animatable>;
  88088. /**
  88089. * Gets all animatables associated with a given target
  88090. * @param target defines the target to look animatables for
  88091. * @returns an array of Animatables
  88092. */
  88093. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  88094. /**
  88095. * Stops and removes all animations that have been applied to the scene
  88096. */
  88097. stopAllAnimations(): void;
  88098. /**
  88099. * Gets the current delta time used by animation engine
  88100. */
  88101. deltaTime: number;
  88102. }
  88103. interface Bone {
  88104. /**
  88105. * Copy an animation range from another bone
  88106. * @param source defines the source bone
  88107. * @param rangeName defines the range name to copy
  88108. * @param frameOffset defines the frame offset
  88109. * @param rescaleAsRequired defines if rescaling must be applied if required
  88110. * @param skelDimensionsRatio defines the scaling ratio
  88111. * @returns true if operation was successful
  88112. */
  88113. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  88114. }
  88115. }
  88116. declare module BABYLON {
  88117. /**
  88118. * Class used to handle skinning animations
  88119. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  88120. */
  88121. export class Skeleton implements IAnimatable {
  88122. /** defines the skeleton name */
  88123. name: string;
  88124. /** defines the skeleton Id */
  88125. id: string;
  88126. /**
  88127. * Defines the list of child bones
  88128. */
  88129. bones: Bone[];
  88130. /**
  88131. * Defines an estimate of the dimension of the skeleton at rest
  88132. */
  88133. dimensionsAtRest: Vector3;
  88134. /**
  88135. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  88136. */
  88137. needInitialSkinMatrix: boolean;
  88138. /**
  88139. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  88140. */
  88141. overrideMesh: Nullable<AbstractMesh>;
  88142. /**
  88143. * Gets the list of animations attached to this skeleton
  88144. */
  88145. animations: Array<Animation>;
  88146. private _scene;
  88147. private _isDirty;
  88148. private _transformMatrices;
  88149. private _transformMatrixTexture;
  88150. private _meshesWithPoseMatrix;
  88151. private _animatables;
  88152. private _identity;
  88153. private _synchronizedWithMesh;
  88154. private _ranges;
  88155. private _lastAbsoluteTransformsUpdateId;
  88156. private _canUseTextureForBones;
  88157. private _uniqueId;
  88158. /** @hidden */
  88159. _numBonesWithLinkedTransformNode: number;
  88160. /** @hidden */
  88161. _hasWaitingData: Nullable<boolean>;
  88162. /**
  88163. * Specifies if the skeleton should be serialized
  88164. */
  88165. doNotSerialize: boolean;
  88166. private _useTextureToStoreBoneMatrices;
  88167. /**
  88168. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  88169. * Please note that this option is not available if the hardware does not support it
  88170. */
  88171. get useTextureToStoreBoneMatrices(): boolean;
  88172. set useTextureToStoreBoneMatrices(value: boolean);
  88173. private _animationPropertiesOverride;
  88174. /**
  88175. * Gets or sets the animation properties override
  88176. */
  88177. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  88178. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  88179. /**
  88180. * List of inspectable custom properties (used by the Inspector)
  88181. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88182. */
  88183. inspectableCustomProperties: IInspectable[];
  88184. /**
  88185. * An observable triggered before computing the skeleton's matrices
  88186. */
  88187. onBeforeComputeObservable: Observable<Skeleton>;
  88188. /**
  88189. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  88190. */
  88191. get isUsingTextureForMatrices(): boolean;
  88192. /**
  88193. * Gets the unique ID of this skeleton
  88194. */
  88195. get uniqueId(): number;
  88196. /**
  88197. * Creates a new skeleton
  88198. * @param name defines the skeleton name
  88199. * @param id defines the skeleton Id
  88200. * @param scene defines the hosting scene
  88201. */
  88202. constructor(
  88203. /** defines the skeleton name */
  88204. name: string,
  88205. /** defines the skeleton Id */
  88206. id: string, scene: Scene);
  88207. /**
  88208. * Gets the current object class name.
  88209. * @return the class name
  88210. */
  88211. getClassName(): string;
  88212. /**
  88213. * Returns an array containing the root bones
  88214. * @returns an array containing the root bones
  88215. */
  88216. getChildren(): Array<Bone>;
  88217. /**
  88218. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  88219. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  88220. * @returns a Float32Array containing matrices data
  88221. */
  88222. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  88223. /**
  88224. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  88225. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  88226. * @returns a raw texture containing the data
  88227. */
  88228. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  88229. /**
  88230. * Gets the current hosting scene
  88231. * @returns a scene object
  88232. */
  88233. getScene(): Scene;
  88234. /**
  88235. * Gets a string representing the current skeleton data
  88236. * @param fullDetails defines a boolean indicating if we want a verbose version
  88237. * @returns a string representing the current skeleton data
  88238. */
  88239. toString(fullDetails?: boolean): string;
  88240. /**
  88241. * Get bone's index searching by name
  88242. * @param name defines bone's name to search for
  88243. * @return the indice of the bone. Returns -1 if not found
  88244. */
  88245. getBoneIndexByName(name: string): number;
  88246. /**
  88247. * Creater a new animation range
  88248. * @param name defines the name of the range
  88249. * @param from defines the start key
  88250. * @param to defines the end key
  88251. */
  88252. createAnimationRange(name: string, from: number, to: number): void;
  88253. /**
  88254. * Delete a specific animation range
  88255. * @param name defines the name of the range
  88256. * @param deleteFrames defines if frames must be removed as well
  88257. */
  88258. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  88259. /**
  88260. * Gets a specific animation range
  88261. * @param name defines the name of the range to look for
  88262. * @returns the requested animation range or null if not found
  88263. */
  88264. getAnimationRange(name: string): Nullable<AnimationRange>;
  88265. /**
  88266. * Gets the list of all animation ranges defined on this skeleton
  88267. * @returns an array
  88268. */
  88269. getAnimationRanges(): Nullable<AnimationRange>[];
  88270. /**
  88271. * Copy animation range from a source skeleton.
  88272. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  88273. * @param source defines the source skeleton
  88274. * @param name defines the name of the range to copy
  88275. * @param rescaleAsRequired defines if rescaling must be applied if required
  88276. * @returns true if operation was successful
  88277. */
  88278. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  88279. /**
  88280. * Forces the skeleton to go to rest pose
  88281. */
  88282. returnToRest(): void;
  88283. private _getHighestAnimationFrame;
  88284. /**
  88285. * Begin a specific animation range
  88286. * @param name defines the name of the range to start
  88287. * @param loop defines if looping must be turned on (false by default)
  88288. * @param speedRatio defines the speed ratio to apply (1 by default)
  88289. * @param onAnimationEnd defines a callback which will be called when animation will end
  88290. * @returns a new animatable
  88291. */
  88292. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  88293. /** @hidden */
  88294. _markAsDirty(): void;
  88295. /** @hidden */
  88296. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  88297. /** @hidden */
  88298. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  88299. private _computeTransformMatrices;
  88300. /**
  88301. * Build all resources required to render a skeleton
  88302. */
  88303. prepare(): void;
  88304. /**
  88305. * Gets the list of animatables currently running for this skeleton
  88306. * @returns an array of animatables
  88307. */
  88308. getAnimatables(): IAnimatable[];
  88309. /**
  88310. * Clone the current skeleton
  88311. * @param name defines the name of the new skeleton
  88312. * @param id defines the id of the new skeleton
  88313. * @returns the new skeleton
  88314. */
  88315. clone(name: string, id?: string): Skeleton;
  88316. /**
  88317. * Enable animation blending for this skeleton
  88318. * @param blendingSpeed defines the blending speed to apply
  88319. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  88320. */
  88321. enableBlending(blendingSpeed?: number): void;
  88322. /**
  88323. * Releases all resources associated with the current skeleton
  88324. */
  88325. dispose(): void;
  88326. /**
  88327. * Serialize the skeleton in a JSON object
  88328. * @returns a JSON object
  88329. */
  88330. serialize(): any;
  88331. /**
  88332. * Creates a new skeleton from serialized data
  88333. * @param parsedSkeleton defines the serialized data
  88334. * @param scene defines the hosting scene
  88335. * @returns a new skeleton
  88336. */
  88337. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  88338. /**
  88339. * Compute all node absolute transforms
  88340. * @param forceUpdate defines if computation must be done even if cache is up to date
  88341. */
  88342. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  88343. /**
  88344. * Gets the root pose matrix
  88345. * @returns a matrix
  88346. */
  88347. getPoseMatrix(): Nullable<Matrix>;
  88348. /**
  88349. * Sorts bones per internal index
  88350. */
  88351. sortBones(): void;
  88352. private _sortBones;
  88353. }
  88354. }
  88355. declare module BABYLON {
  88356. /**
  88357. * Creates an instance based on a source mesh.
  88358. */
  88359. export class InstancedMesh extends AbstractMesh {
  88360. private _sourceMesh;
  88361. private _currentLOD;
  88362. /** @hidden */
  88363. _indexInSourceMeshInstanceArray: number;
  88364. constructor(name: string, source: Mesh);
  88365. /**
  88366. * Returns the string "InstancedMesh".
  88367. */
  88368. getClassName(): string;
  88369. /** Gets the list of lights affecting that mesh */
  88370. get lightSources(): Light[];
  88371. _resyncLightSources(): void;
  88372. _resyncLightSource(light: Light): void;
  88373. _removeLightSource(light: Light, dispose: boolean): void;
  88374. /**
  88375. * If the source mesh receives shadows
  88376. */
  88377. get receiveShadows(): boolean;
  88378. /**
  88379. * The material of the source mesh
  88380. */
  88381. get material(): Nullable<Material>;
  88382. /**
  88383. * Visibility of the source mesh
  88384. */
  88385. get visibility(): number;
  88386. /**
  88387. * Skeleton of the source mesh
  88388. */
  88389. get skeleton(): Nullable<Skeleton>;
  88390. /**
  88391. * Rendering ground id of the source mesh
  88392. */
  88393. get renderingGroupId(): number;
  88394. set renderingGroupId(value: number);
  88395. /**
  88396. * Returns the total number of vertices (integer).
  88397. */
  88398. getTotalVertices(): number;
  88399. /**
  88400. * Returns a positive integer : the total number of indices in this mesh geometry.
  88401. * @returns the numner of indices or zero if the mesh has no geometry.
  88402. */
  88403. getTotalIndices(): number;
  88404. /**
  88405. * The source mesh of the instance
  88406. */
  88407. get sourceMesh(): Mesh;
  88408. /**
  88409. * Is this node ready to be used/rendered
  88410. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  88411. * @return {boolean} is it ready
  88412. */
  88413. isReady(completeCheck?: boolean): boolean;
  88414. /**
  88415. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  88416. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  88417. * @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.
  88418. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  88419. */
  88420. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  88421. /**
  88422. * Sets the vertex data of the mesh geometry for the requested `kind`.
  88423. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  88424. * The `data` are either a numeric array either a Float32Array.
  88425. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  88426. * 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).
  88427. * Note that a new underlying VertexBuffer object is created each call.
  88428. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  88429. *
  88430. * Possible `kind` values :
  88431. * - VertexBuffer.PositionKind
  88432. * - VertexBuffer.UVKind
  88433. * - VertexBuffer.UV2Kind
  88434. * - VertexBuffer.UV3Kind
  88435. * - VertexBuffer.UV4Kind
  88436. * - VertexBuffer.UV5Kind
  88437. * - VertexBuffer.UV6Kind
  88438. * - VertexBuffer.ColorKind
  88439. * - VertexBuffer.MatricesIndicesKind
  88440. * - VertexBuffer.MatricesIndicesExtraKind
  88441. * - VertexBuffer.MatricesWeightsKind
  88442. * - VertexBuffer.MatricesWeightsExtraKind
  88443. *
  88444. * Returns the Mesh.
  88445. */
  88446. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  88447. /**
  88448. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  88449. * If the mesh has no geometry, it is simply returned as it is.
  88450. * The `data` are either a numeric array either a Float32Array.
  88451. * No new underlying VertexBuffer object is created.
  88452. * 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.
  88453. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  88454. *
  88455. * Possible `kind` values :
  88456. * - VertexBuffer.PositionKind
  88457. * - VertexBuffer.UVKind
  88458. * - VertexBuffer.UV2Kind
  88459. * - VertexBuffer.UV3Kind
  88460. * - VertexBuffer.UV4Kind
  88461. * - VertexBuffer.UV5Kind
  88462. * - VertexBuffer.UV6Kind
  88463. * - VertexBuffer.ColorKind
  88464. * - VertexBuffer.MatricesIndicesKind
  88465. * - VertexBuffer.MatricesIndicesExtraKind
  88466. * - VertexBuffer.MatricesWeightsKind
  88467. * - VertexBuffer.MatricesWeightsExtraKind
  88468. *
  88469. * Returns the Mesh.
  88470. */
  88471. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  88472. /**
  88473. * Sets the mesh indices.
  88474. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  88475. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  88476. * This method creates a new index buffer each call.
  88477. * Returns the Mesh.
  88478. */
  88479. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  88480. /**
  88481. * Boolean : True if the mesh owns the requested kind of data.
  88482. */
  88483. isVerticesDataPresent(kind: string): boolean;
  88484. /**
  88485. * Returns an array of indices (IndicesArray).
  88486. */
  88487. getIndices(): Nullable<IndicesArray>;
  88488. get _positions(): Nullable<Vector3[]>;
  88489. /**
  88490. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  88491. * This means the mesh underlying bounding box and sphere are recomputed.
  88492. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  88493. * @returns the current mesh
  88494. */
  88495. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  88496. /** @hidden */
  88497. _preActivate(): InstancedMesh;
  88498. /** @hidden */
  88499. _activate(renderId: number, intermediateRendering: boolean): boolean;
  88500. /** @hidden */
  88501. _postActivate(): void;
  88502. getWorldMatrix(): Matrix;
  88503. get isAnInstance(): boolean;
  88504. /**
  88505. * Returns the current associated LOD AbstractMesh.
  88506. */
  88507. getLOD(camera: Camera): AbstractMesh;
  88508. /** @hidden */
  88509. _syncSubMeshes(): InstancedMesh;
  88510. /** @hidden */
  88511. _generatePointsArray(): boolean;
  88512. /**
  88513. * Creates a new InstancedMesh from the current mesh.
  88514. * - name (string) : the cloned mesh name
  88515. * - newParent (optional Node) : the optional Node to parent the clone to.
  88516. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  88517. *
  88518. * Returns the clone.
  88519. */
  88520. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  88521. /**
  88522. * Disposes the InstancedMesh.
  88523. * Returns nothing.
  88524. */
  88525. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88526. }
  88527. interface Mesh {
  88528. /**
  88529. * Register a custom buffer that will be instanced
  88530. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88531. * @param kind defines the buffer kind
  88532. * @param stride defines the stride in floats
  88533. */
  88534. registerInstancedBuffer(kind: string, stride: number): void;
  88535. /** @hidden */
  88536. _userInstancedBuffersStorage: {
  88537. data: {
  88538. [key: string]: Float32Array;
  88539. };
  88540. sizes: {
  88541. [key: string]: number;
  88542. };
  88543. vertexBuffers: {
  88544. [key: string]: Nullable<VertexBuffer>;
  88545. };
  88546. strides: {
  88547. [key: string]: number;
  88548. };
  88549. };
  88550. }
  88551. interface AbstractMesh {
  88552. /**
  88553. * Object used to store instanced buffers defined by user
  88554. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88555. */
  88556. instancedBuffers: {
  88557. [key: string]: any;
  88558. };
  88559. }
  88560. }
  88561. declare module BABYLON {
  88562. /**
  88563. * Defines the options associated with the creation of a shader material.
  88564. */
  88565. export interface IShaderMaterialOptions {
  88566. /**
  88567. * Does the material work in alpha blend mode
  88568. */
  88569. needAlphaBlending: boolean;
  88570. /**
  88571. * Does the material work in alpha test mode
  88572. */
  88573. needAlphaTesting: boolean;
  88574. /**
  88575. * The list of attribute names used in the shader
  88576. */
  88577. attributes: string[];
  88578. /**
  88579. * The list of unifrom names used in the shader
  88580. */
  88581. uniforms: string[];
  88582. /**
  88583. * The list of UBO names used in the shader
  88584. */
  88585. uniformBuffers: string[];
  88586. /**
  88587. * The list of sampler names used in the shader
  88588. */
  88589. samplers: string[];
  88590. /**
  88591. * The list of defines used in the shader
  88592. */
  88593. defines: string[];
  88594. }
  88595. /**
  88596. * 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.
  88597. *
  88598. * This returned material effects how the mesh will look based on the code in the shaders.
  88599. *
  88600. * @see http://doc.babylonjs.com/how_to/shader_material
  88601. */
  88602. export class ShaderMaterial extends Material {
  88603. private _shaderPath;
  88604. private _options;
  88605. private _textures;
  88606. private _textureArrays;
  88607. private _floats;
  88608. private _ints;
  88609. private _floatsArrays;
  88610. private _colors3;
  88611. private _colors3Arrays;
  88612. private _colors4;
  88613. private _colors4Arrays;
  88614. private _vectors2;
  88615. private _vectors3;
  88616. private _vectors4;
  88617. private _matrices;
  88618. private _matrixArrays;
  88619. private _matrices3x3;
  88620. private _matrices2x2;
  88621. private _vectors2Arrays;
  88622. private _vectors3Arrays;
  88623. private _vectors4Arrays;
  88624. private _cachedWorldViewMatrix;
  88625. private _cachedWorldViewProjectionMatrix;
  88626. private _renderId;
  88627. private _multiview;
  88628. /**
  88629. * Instantiate a new shader material.
  88630. * 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.
  88631. * This returned material effects how the mesh will look based on the code in the shaders.
  88632. * @see http://doc.babylonjs.com/how_to/shader_material
  88633. * @param name Define the name of the material in the scene
  88634. * @param scene Define the scene the material belongs to
  88635. * @param shaderPath Defines the route to the shader code in one of three ways:
  88636. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  88637. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  88638. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  88639. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  88640. * @param options Define the options used to create the shader
  88641. */
  88642. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  88643. /**
  88644. * Gets the shader path used to define the shader code
  88645. * It can be modified to trigger a new compilation
  88646. */
  88647. get shaderPath(): any;
  88648. /**
  88649. * Sets the shader path used to define the shader code
  88650. * It can be modified to trigger a new compilation
  88651. */
  88652. set shaderPath(shaderPath: any);
  88653. /**
  88654. * Gets the options used to compile the shader.
  88655. * They can be modified to trigger a new compilation
  88656. */
  88657. get options(): IShaderMaterialOptions;
  88658. /**
  88659. * Gets the current class name of the material e.g. "ShaderMaterial"
  88660. * Mainly use in serialization.
  88661. * @returns the class name
  88662. */
  88663. getClassName(): string;
  88664. /**
  88665. * Specifies if the material will require alpha blending
  88666. * @returns a boolean specifying if alpha blending is needed
  88667. */
  88668. needAlphaBlending(): boolean;
  88669. /**
  88670. * Specifies if this material should be rendered in alpha test mode
  88671. * @returns a boolean specifying if an alpha test is needed.
  88672. */
  88673. needAlphaTesting(): boolean;
  88674. private _checkUniform;
  88675. /**
  88676. * Set a texture in the shader.
  88677. * @param name Define the name of the uniform samplers as defined in the shader
  88678. * @param texture Define the texture to bind to this sampler
  88679. * @return the material itself allowing "fluent" like uniform updates
  88680. */
  88681. setTexture(name: string, texture: Texture): ShaderMaterial;
  88682. /**
  88683. * Set a texture array in the shader.
  88684. * @param name Define the name of the uniform sampler array as defined in the shader
  88685. * @param textures Define the list of textures to bind to this sampler
  88686. * @return the material itself allowing "fluent" like uniform updates
  88687. */
  88688. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  88689. /**
  88690. * Set a float in the shader.
  88691. * @param name Define the name of the uniform as defined in the shader
  88692. * @param value Define the value to give to the uniform
  88693. * @return the material itself allowing "fluent" like uniform updates
  88694. */
  88695. setFloat(name: string, value: number): ShaderMaterial;
  88696. /**
  88697. * Set a int in the shader.
  88698. * @param name Define the name of the uniform as defined in the shader
  88699. * @param value Define the value to give to the uniform
  88700. * @return the material itself allowing "fluent" like uniform updates
  88701. */
  88702. setInt(name: string, value: number): ShaderMaterial;
  88703. /**
  88704. * Set an array of floats in the shader.
  88705. * @param name Define the name of the uniform as defined in the shader
  88706. * @param value Define the value to give to the uniform
  88707. * @return the material itself allowing "fluent" like uniform updates
  88708. */
  88709. setFloats(name: string, value: number[]): ShaderMaterial;
  88710. /**
  88711. * Set a vec3 in the shader from a Color3.
  88712. * @param name Define the name of the uniform as defined in the shader
  88713. * @param value Define the value to give to the uniform
  88714. * @return the material itself allowing "fluent" like uniform updates
  88715. */
  88716. setColor3(name: string, value: Color3): ShaderMaterial;
  88717. /**
  88718. * Set a vec3 array in the shader from a Color3 array.
  88719. * @param name Define the name of the uniform as defined in the shader
  88720. * @param value Define the value to give to the uniform
  88721. * @return the material itself allowing "fluent" like uniform updates
  88722. */
  88723. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  88724. /**
  88725. * Set a vec4 in the shader from a Color4.
  88726. * @param name Define the name of the uniform as defined in the shader
  88727. * @param value Define the value to give to the uniform
  88728. * @return the material itself allowing "fluent" like uniform updates
  88729. */
  88730. setColor4(name: string, value: Color4): ShaderMaterial;
  88731. /**
  88732. * Set a vec4 array in the shader from a Color4 array.
  88733. * @param name Define the name of the uniform as defined in the shader
  88734. * @param value Define the value to give to the uniform
  88735. * @return the material itself allowing "fluent" like uniform updates
  88736. */
  88737. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  88738. /**
  88739. * Set a vec2 in the shader from a Vector2.
  88740. * @param name Define the name of the uniform as defined in the shader
  88741. * @param value Define the value to give to the uniform
  88742. * @return the material itself allowing "fluent" like uniform updates
  88743. */
  88744. setVector2(name: string, value: Vector2): ShaderMaterial;
  88745. /**
  88746. * Set a vec3 in the shader from a Vector3.
  88747. * @param name Define the name of the uniform as defined in the shader
  88748. * @param value Define the value to give to the uniform
  88749. * @return the material itself allowing "fluent" like uniform updates
  88750. */
  88751. setVector3(name: string, value: Vector3): ShaderMaterial;
  88752. /**
  88753. * Set a vec4 in the shader from a Vector4.
  88754. * @param name Define the name of the uniform as defined in the shader
  88755. * @param value Define the value to give to the uniform
  88756. * @return the material itself allowing "fluent" like uniform updates
  88757. */
  88758. setVector4(name: string, value: Vector4): ShaderMaterial;
  88759. /**
  88760. * Set a mat4 in the shader from a Matrix.
  88761. * @param name Define the name of the uniform as defined in the shader
  88762. * @param value Define the value to give to the uniform
  88763. * @return the material itself allowing "fluent" like uniform updates
  88764. */
  88765. setMatrix(name: string, value: Matrix): ShaderMaterial;
  88766. /**
  88767. * Set a float32Array in the shader from a matrix array.
  88768. * @param name Define the name of the uniform as defined in the shader
  88769. * @param value Define the value to give to the uniform
  88770. * @return the material itself allowing "fluent" like uniform updates
  88771. */
  88772. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  88773. /**
  88774. * Set a mat3 in the shader from a Float32Array.
  88775. * @param name Define the name of the uniform as defined in the shader
  88776. * @param value Define the value to give to the uniform
  88777. * @return the material itself allowing "fluent" like uniform updates
  88778. */
  88779. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  88780. /**
  88781. * Set a mat2 in the shader from a Float32Array.
  88782. * @param name Define the name of the uniform as defined in the shader
  88783. * @param value Define the value to give to the uniform
  88784. * @return the material itself allowing "fluent" like uniform updates
  88785. */
  88786. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  88787. /**
  88788. * Set a vec2 array in the shader from a number array.
  88789. * @param name Define the name of the uniform as defined in the shader
  88790. * @param value Define the value to give to the uniform
  88791. * @return the material itself allowing "fluent" like uniform updates
  88792. */
  88793. setArray2(name: string, value: number[]): ShaderMaterial;
  88794. /**
  88795. * Set a vec3 array in the shader from a number array.
  88796. * @param name Define the name of the uniform as defined in the shader
  88797. * @param value Define the value to give to the uniform
  88798. * @return the material itself allowing "fluent" like uniform updates
  88799. */
  88800. setArray3(name: string, value: number[]): ShaderMaterial;
  88801. /**
  88802. * Set a vec4 array in the shader from a number array.
  88803. * @param name Define the name of the uniform as defined in the shader
  88804. * @param value Define the value to give to the uniform
  88805. * @return the material itself allowing "fluent" like uniform updates
  88806. */
  88807. setArray4(name: string, value: number[]): ShaderMaterial;
  88808. private _checkCache;
  88809. /**
  88810. * Specifies that the submesh is ready to be used
  88811. * @param mesh defines the mesh to check
  88812. * @param subMesh defines which submesh to check
  88813. * @param useInstances specifies that instances should be used
  88814. * @returns a boolean indicating that the submesh is ready or not
  88815. */
  88816. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  88817. /**
  88818. * Checks if the material is ready to render the requested mesh
  88819. * @param mesh Define the mesh to render
  88820. * @param useInstances Define whether or not the material is used with instances
  88821. * @returns true if ready, otherwise false
  88822. */
  88823. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  88824. /**
  88825. * Binds the world matrix to the material
  88826. * @param world defines the world transformation matrix
  88827. */
  88828. bindOnlyWorldMatrix(world: Matrix): void;
  88829. /**
  88830. * Binds the material to the mesh
  88831. * @param world defines the world transformation matrix
  88832. * @param mesh defines the mesh to bind the material to
  88833. */
  88834. bind(world: Matrix, mesh?: Mesh): void;
  88835. /**
  88836. * Gets the active textures from the material
  88837. * @returns an array of textures
  88838. */
  88839. getActiveTextures(): BaseTexture[];
  88840. /**
  88841. * Specifies if the material uses a texture
  88842. * @param texture defines the texture to check against the material
  88843. * @returns a boolean specifying if the material uses the texture
  88844. */
  88845. hasTexture(texture: BaseTexture): boolean;
  88846. /**
  88847. * Makes a duplicate of the material, and gives it a new name
  88848. * @param name defines the new name for the duplicated material
  88849. * @returns the cloned material
  88850. */
  88851. clone(name: string): ShaderMaterial;
  88852. /**
  88853. * Disposes the material
  88854. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  88855. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  88856. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  88857. */
  88858. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  88859. /**
  88860. * Serializes this material in a JSON representation
  88861. * @returns the serialized material object
  88862. */
  88863. serialize(): any;
  88864. /**
  88865. * Creates a shader material from parsed shader material data
  88866. * @param source defines the JSON represnetation of the material
  88867. * @param scene defines the hosting scene
  88868. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  88869. * @returns a new material
  88870. */
  88871. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  88872. }
  88873. }
  88874. declare module BABYLON {
  88875. /** @hidden */
  88876. export var colorPixelShader: {
  88877. name: string;
  88878. shader: string;
  88879. };
  88880. }
  88881. declare module BABYLON {
  88882. /** @hidden */
  88883. export var colorVertexShader: {
  88884. name: string;
  88885. shader: string;
  88886. };
  88887. }
  88888. declare module BABYLON {
  88889. /**
  88890. * Line mesh
  88891. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  88892. */
  88893. export class LinesMesh extends Mesh {
  88894. /**
  88895. * If vertex color should be applied to the mesh
  88896. */
  88897. readonly useVertexColor?: boolean | undefined;
  88898. /**
  88899. * If vertex alpha should be applied to the mesh
  88900. */
  88901. readonly useVertexAlpha?: boolean | undefined;
  88902. /**
  88903. * Color of the line (Default: White)
  88904. */
  88905. color: Color3;
  88906. /**
  88907. * Alpha of the line (Default: 1)
  88908. */
  88909. alpha: number;
  88910. /**
  88911. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  88912. * This margin is expressed in world space coordinates, so its value may vary.
  88913. * Default value is 0.1
  88914. */
  88915. intersectionThreshold: number;
  88916. private _colorShader;
  88917. private color4;
  88918. /**
  88919. * Creates a new LinesMesh
  88920. * @param name defines the name
  88921. * @param scene defines the hosting scene
  88922. * @param parent defines the parent mesh if any
  88923. * @param source defines the optional source LinesMesh used to clone data from
  88924. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  88925. * When false, achieved by calling a clone(), also passing False.
  88926. * This will make creation of children, recursive.
  88927. * @param useVertexColor defines if this LinesMesh supports vertex color
  88928. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  88929. */
  88930. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  88931. /**
  88932. * If vertex color should be applied to the mesh
  88933. */
  88934. useVertexColor?: boolean | undefined,
  88935. /**
  88936. * If vertex alpha should be applied to the mesh
  88937. */
  88938. useVertexAlpha?: boolean | undefined);
  88939. private _addClipPlaneDefine;
  88940. private _removeClipPlaneDefine;
  88941. isReady(): boolean;
  88942. /**
  88943. * Returns the string "LineMesh"
  88944. */
  88945. getClassName(): string;
  88946. /**
  88947. * @hidden
  88948. */
  88949. get material(): Material;
  88950. /**
  88951. * @hidden
  88952. */
  88953. set material(value: Material);
  88954. /**
  88955. * @hidden
  88956. */
  88957. get checkCollisions(): boolean;
  88958. /** @hidden */
  88959. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  88960. /** @hidden */
  88961. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  88962. /**
  88963. * Disposes of the line mesh
  88964. * @param doNotRecurse If children should be disposed
  88965. */
  88966. dispose(doNotRecurse?: boolean): void;
  88967. /**
  88968. * Returns a new LineMesh object cloned from the current one.
  88969. */
  88970. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  88971. /**
  88972. * Creates a new InstancedLinesMesh object from the mesh model.
  88973. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  88974. * @param name defines the name of the new instance
  88975. * @returns a new InstancedLinesMesh
  88976. */
  88977. createInstance(name: string): InstancedLinesMesh;
  88978. }
  88979. /**
  88980. * Creates an instance based on a source LinesMesh
  88981. */
  88982. export class InstancedLinesMesh extends InstancedMesh {
  88983. /**
  88984. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  88985. * This margin is expressed in world space coordinates, so its value may vary.
  88986. * Initilized with the intersectionThreshold value of the source LinesMesh
  88987. */
  88988. intersectionThreshold: number;
  88989. constructor(name: string, source: LinesMesh);
  88990. /**
  88991. * Returns the string "InstancedLinesMesh".
  88992. */
  88993. getClassName(): string;
  88994. }
  88995. }
  88996. declare module BABYLON {
  88997. /** @hidden */
  88998. export var linePixelShader: {
  88999. name: string;
  89000. shader: string;
  89001. };
  89002. }
  89003. declare module BABYLON {
  89004. /** @hidden */
  89005. export var lineVertexShader: {
  89006. name: string;
  89007. shader: string;
  89008. };
  89009. }
  89010. declare module BABYLON {
  89011. interface AbstractMesh {
  89012. /**
  89013. * Gets the edgesRenderer associated with the mesh
  89014. */
  89015. edgesRenderer: Nullable<EdgesRenderer>;
  89016. }
  89017. interface LinesMesh {
  89018. /**
  89019. * Enables the edge rendering mode on the mesh.
  89020. * This mode makes the mesh edges visible
  89021. * @param epsilon defines the maximal distance between two angles to detect a face
  89022. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  89023. * @returns the currentAbstractMesh
  89024. * @see https://www.babylonjs-playground.com/#19O9TU#0
  89025. */
  89026. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  89027. }
  89028. interface InstancedLinesMesh {
  89029. /**
  89030. * Enables the edge rendering mode on the mesh.
  89031. * This mode makes the mesh edges visible
  89032. * @param epsilon defines the maximal distance between two angles to detect a face
  89033. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  89034. * @returns the current InstancedLinesMesh
  89035. * @see https://www.babylonjs-playground.com/#19O9TU#0
  89036. */
  89037. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  89038. }
  89039. /**
  89040. * Defines the minimum contract an Edges renderer should follow.
  89041. */
  89042. export interface IEdgesRenderer extends IDisposable {
  89043. /**
  89044. * Gets or sets a boolean indicating if the edgesRenderer is active
  89045. */
  89046. isEnabled: boolean;
  89047. /**
  89048. * Renders the edges of the attached mesh,
  89049. */
  89050. render(): void;
  89051. /**
  89052. * Checks wether or not the edges renderer is ready to render.
  89053. * @return true if ready, otherwise false.
  89054. */
  89055. isReady(): boolean;
  89056. }
  89057. /**
  89058. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  89059. */
  89060. export class EdgesRenderer implements IEdgesRenderer {
  89061. /**
  89062. * Define the size of the edges with an orthographic camera
  89063. */
  89064. edgesWidthScalerForOrthographic: number;
  89065. /**
  89066. * Define the size of the edges with a perspective camera
  89067. */
  89068. edgesWidthScalerForPerspective: number;
  89069. protected _source: AbstractMesh;
  89070. protected _linesPositions: number[];
  89071. protected _linesNormals: number[];
  89072. protected _linesIndices: number[];
  89073. protected _epsilon: number;
  89074. protected _indicesCount: number;
  89075. protected _lineShader: ShaderMaterial;
  89076. protected _ib: DataBuffer;
  89077. protected _buffers: {
  89078. [key: string]: Nullable<VertexBuffer>;
  89079. };
  89080. protected _checkVerticesInsteadOfIndices: boolean;
  89081. private _meshRebuildObserver;
  89082. private _meshDisposeObserver;
  89083. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  89084. isEnabled: boolean;
  89085. /**
  89086. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  89087. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  89088. * @param source Mesh used to create edges
  89089. * @param epsilon sum of angles in adjacency to check for edge
  89090. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  89091. * @param generateEdgesLines - should generate Lines or only prepare resources.
  89092. */
  89093. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  89094. protected _prepareRessources(): void;
  89095. /** @hidden */
  89096. _rebuild(): void;
  89097. /**
  89098. * Releases the required resources for the edges renderer
  89099. */
  89100. dispose(): void;
  89101. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  89102. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  89103. /**
  89104. * Checks if the pair of p0 and p1 is en edge
  89105. * @param faceIndex
  89106. * @param edge
  89107. * @param faceNormals
  89108. * @param p0
  89109. * @param p1
  89110. * @private
  89111. */
  89112. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  89113. /**
  89114. * push line into the position, normal and index buffer
  89115. * @protected
  89116. */
  89117. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  89118. /**
  89119. * Generates lines edges from adjacencjes
  89120. * @private
  89121. */
  89122. _generateEdgesLines(): void;
  89123. /**
  89124. * Checks wether or not the edges renderer is ready to render.
  89125. * @return true if ready, otherwise false.
  89126. */
  89127. isReady(): boolean;
  89128. /**
  89129. * Renders the edges of the attached mesh,
  89130. */
  89131. render(): void;
  89132. }
  89133. /**
  89134. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  89135. */
  89136. export class LineEdgesRenderer extends EdgesRenderer {
  89137. /**
  89138. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  89139. * @param source LineMesh used to generate edges
  89140. * @param epsilon not important (specified angle for edge detection)
  89141. * @param checkVerticesInsteadOfIndices not important for LineMesh
  89142. */
  89143. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  89144. /**
  89145. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  89146. */
  89147. _generateEdgesLines(): void;
  89148. }
  89149. }
  89150. declare module BABYLON {
  89151. /**
  89152. * This represents the object necessary to create a rendering group.
  89153. * This is exclusively used and created by the rendering manager.
  89154. * To modify the behavior, you use the available helpers in your scene or meshes.
  89155. * @hidden
  89156. */
  89157. export class RenderingGroup {
  89158. index: number;
  89159. private static _zeroVector;
  89160. private _scene;
  89161. private _opaqueSubMeshes;
  89162. private _transparentSubMeshes;
  89163. private _alphaTestSubMeshes;
  89164. private _depthOnlySubMeshes;
  89165. private _particleSystems;
  89166. private _spriteManagers;
  89167. private _opaqueSortCompareFn;
  89168. private _alphaTestSortCompareFn;
  89169. private _transparentSortCompareFn;
  89170. private _renderOpaque;
  89171. private _renderAlphaTest;
  89172. private _renderTransparent;
  89173. /** @hidden */
  89174. _edgesRenderers: SmartArray<IEdgesRenderer>;
  89175. onBeforeTransparentRendering: () => void;
  89176. /**
  89177. * Set the opaque sort comparison function.
  89178. * If null the sub meshes will be render in the order they were created
  89179. */
  89180. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89181. /**
  89182. * Set the alpha test sort comparison function.
  89183. * If null the sub meshes will be render in the order they were created
  89184. */
  89185. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89186. /**
  89187. * Set the transparent sort comparison function.
  89188. * If null the sub meshes will be render in the order they were created
  89189. */
  89190. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89191. /**
  89192. * Creates a new rendering group.
  89193. * @param index The rendering group index
  89194. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  89195. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  89196. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  89197. */
  89198. 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>);
  89199. /**
  89200. * Render all the sub meshes contained in the group.
  89201. * @param customRenderFunction Used to override the default render behaviour of the group.
  89202. * @returns true if rendered some submeshes.
  89203. */
  89204. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  89205. /**
  89206. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  89207. * @param subMeshes The submeshes to render
  89208. */
  89209. private renderOpaqueSorted;
  89210. /**
  89211. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  89212. * @param subMeshes The submeshes to render
  89213. */
  89214. private renderAlphaTestSorted;
  89215. /**
  89216. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  89217. * @param subMeshes The submeshes to render
  89218. */
  89219. private renderTransparentSorted;
  89220. /**
  89221. * Renders the submeshes in a specified order.
  89222. * @param subMeshes The submeshes to sort before render
  89223. * @param sortCompareFn The comparison function use to sort
  89224. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  89225. * @param transparent Specifies to activate blending if true
  89226. */
  89227. private static renderSorted;
  89228. /**
  89229. * Renders the submeshes in the order they were dispatched (no sort applied).
  89230. * @param subMeshes The submeshes to render
  89231. */
  89232. private static renderUnsorted;
  89233. /**
  89234. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89235. * are rendered back to front if in the same alpha index.
  89236. *
  89237. * @param a The first submesh
  89238. * @param b The second submesh
  89239. * @returns The result of the comparison
  89240. */
  89241. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  89242. /**
  89243. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89244. * are rendered back to front.
  89245. *
  89246. * @param a The first submesh
  89247. * @param b The second submesh
  89248. * @returns The result of the comparison
  89249. */
  89250. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  89251. /**
  89252. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89253. * are rendered front to back (prevent overdraw).
  89254. *
  89255. * @param a The first submesh
  89256. * @param b The second submesh
  89257. * @returns The result of the comparison
  89258. */
  89259. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  89260. /**
  89261. * Resets the different lists of submeshes to prepare a new frame.
  89262. */
  89263. prepare(): void;
  89264. dispose(): void;
  89265. /**
  89266. * Inserts the submesh in its correct queue depending on its material.
  89267. * @param subMesh The submesh to dispatch
  89268. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  89269. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  89270. */
  89271. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  89272. dispatchSprites(spriteManager: ISpriteManager): void;
  89273. dispatchParticles(particleSystem: IParticleSystem): void;
  89274. private _renderParticles;
  89275. private _renderSprites;
  89276. }
  89277. }
  89278. declare module BABYLON {
  89279. /**
  89280. * Interface describing the different options available in the rendering manager
  89281. * regarding Auto Clear between groups.
  89282. */
  89283. export interface IRenderingManagerAutoClearSetup {
  89284. /**
  89285. * Defines whether or not autoclear is enable.
  89286. */
  89287. autoClear: boolean;
  89288. /**
  89289. * Defines whether or not to autoclear the depth buffer.
  89290. */
  89291. depth: boolean;
  89292. /**
  89293. * Defines whether or not to autoclear the stencil buffer.
  89294. */
  89295. stencil: boolean;
  89296. }
  89297. /**
  89298. * This class is used by the onRenderingGroupObservable
  89299. */
  89300. export class RenderingGroupInfo {
  89301. /**
  89302. * The Scene that being rendered
  89303. */
  89304. scene: Scene;
  89305. /**
  89306. * The camera currently used for the rendering pass
  89307. */
  89308. camera: Nullable<Camera>;
  89309. /**
  89310. * The ID of the renderingGroup being processed
  89311. */
  89312. renderingGroupId: number;
  89313. }
  89314. /**
  89315. * This is the manager responsible of all the rendering for meshes sprites and particles.
  89316. * It is enable to manage the different groups as well as the different necessary sort functions.
  89317. * This should not be used directly aside of the few static configurations
  89318. */
  89319. export class RenderingManager {
  89320. /**
  89321. * The max id used for rendering groups (not included)
  89322. */
  89323. static MAX_RENDERINGGROUPS: number;
  89324. /**
  89325. * The min id used for rendering groups (included)
  89326. */
  89327. static MIN_RENDERINGGROUPS: number;
  89328. /**
  89329. * Used to globally prevent autoclearing scenes.
  89330. */
  89331. static AUTOCLEAR: boolean;
  89332. /**
  89333. * @hidden
  89334. */
  89335. _useSceneAutoClearSetup: boolean;
  89336. private _scene;
  89337. private _renderingGroups;
  89338. private _depthStencilBufferAlreadyCleaned;
  89339. private _autoClearDepthStencil;
  89340. private _customOpaqueSortCompareFn;
  89341. private _customAlphaTestSortCompareFn;
  89342. private _customTransparentSortCompareFn;
  89343. private _renderingGroupInfo;
  89344. /**
  89345. * Instantiates a new rendering group for a particular scene
  89346. * @param scene Defines the scene the groups belongs to
  89347. */
  89348. constructor(scene: Scene);
  89349. private _clearDepthStencilBuffer;
  89350. /**
  89351. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  89352. * @hidden
  89353. */
  89354. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  89355. /**
  89356. * Resets the different information of the group to prepare a new frame
  89357. * @hidden
  89358. */
  89359. reset(): void;
  89360. /**
  89361. * Dispose and release the group and its associated resources.
  89362. * @hidden
  89363. */
  89364. dispose(): void;
  89365. /**
  89366. * Clear the info related to rendering groups preventing retention points during dispose.
  89367. */
  89368. freeRenderingGroups(): void;
  89369. private _prepareRenderingGroup;
  89370. /**
  89371. * Add a sprite manager to the rendering manager in order to render it this frame.
  89372. * @param spriteManager Define the sprite manager to render
  89373. */
  89374. dispatchSprites(spriteManager: ISpriteManager): void;
  89375. /**
  89376. * Add a particle system to the rendering manager in order to render it this frame.
  89377. * @param particleSystem Define the particle system to render
  89378. */
  89379. dispatchParticles(particleSystem: IParticleSystem): void;
  89380. /**
  89381. * Add a submesh to the manager in order to render it this frame
  89382. * @param subMesh The submesh to dispatch
  89383. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  89384. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  89385. */
  89386. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  89387. /**
  89388. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  89389. * This allowed control for front to back rendering or reversly depending of the special needs.
  89390. *
  89391. * @param renderingGroupId The rendering group id corresponding to its index
  89392. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  89393. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  89394. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  89395. */
  89396. 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;
  89397. /**
  89398. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  89399. *
  89400. * @param renderingGroupId The rendering group id corresponding to its index
  89401. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  89402. * @param depth Automatically clears depth between groups if true and autoClear is true.
  89403. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  89404. */
  89405. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  89406. /**
  89407. * Gets the current auto clear configuration for one rendering group of the rendering
  89408. * manager.
  89409. * @param index the rendering group index to get the information for
  89410. * @returns The auto clear setup for the requested rendering group
  89411. */
  89412. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  89413. }
  89414. }
  89415. declare module BABYLON {
  89416. /**
  89417. * Defines the options associated with the creation of a custom shader for a shadow generator.
  89418. */
  89419. export interface ICustomShaderOptions {
  89420. /**
  89421. * Gets or sets the custom shader name to use
  89422. */
  89423. shaderName: string;
  89424. /**
  89425. * The list of attribute names used in the shader
  89426. */
  89427. attributes?: string[];
  89428. /**
  89429. * The list of unifrom names used in the shader
  89430. */
  89431. uniforms?: string[];
  89432. /**
  89433. * The list of sampler names used in the shader
  89434. */
  89435. samplers?: string[];
  89436. /**
  89437. * The list of defines used in the shader
  89438. */
  89439. defines?: string[];
  89440. }
  89441. /**
  89442. * Interface to implement to create a shadow generator compatible with BJS.
  89443. */
  89444. export interface IShadowGenerator {
  89445. /**
  89446. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  89447. * @returns The render target texture if present otherwise, null
  89448. */
  89449. getShadowMap(): Nullable<RenderTargetTexture>;
  89450. /**
  89451. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  89452. * @param subMesh The submesh we want to render in the shadow map
  89453. * @param useInstances Defines wether will draw in the map using instances
  89454. * @returns true if ready otherwise, false
  89455. */
  89456. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  89457. /**
  89458. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  89459. * @param defines Defines of the material we want to update
  89460. * @param lightIndex Index of the light in the enabled light list of the material
  89461. */
  89462. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  89463. /**
  89464. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  89465. * defined in the generator but impacting the effect).
  89466. * It implies the unifroms available on the materials are the standard BJS ones.
  89467. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  89468. * @param effect The effect we are binfing the information for
  89469. */
  89470. bindShadowLight(lightIndex: string, effect: Effect): void;
  89471. /**
  89472. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  89473. * (eq to shadow prjection matrix * light transform matrix)
  89474. * @returns The transform matrix used to create the shadow map
  89475. */
  89476. getTransformMatrix(): Matrix;
  89477. /**
  89478. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  89479. * Cube and 2D textures for instance.
  89480. */
  89481. recreateShadowMap(): void;
  89482. /**
  89483. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89484. * @param onCompiled Callback triggered at the and of the effects compilation
  89485. * @param options Sets of optional options forcing the compilation with different modes
  89486. */
  89487. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  89488. useInstances: boolean;
  89489. }>): void;
  89490. /**
  89491. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89492. * @param options Sets of optional options forcing the compilation with different modes
  89493. * @returns A promise that resolves when the compilation completes
  89494. */
  89495. forceCompilationAsync(options?: Partial<{
  89496. useInstances: boolean;
  89497. }>): Promise<void>;
  89498. /**
  89499. * Serializes the shadow generator setup to a json object.
  89500. * @returns The serialized JSON object
  89501. */
  89502. serialize(): any;
  89503. /**
  89504. * Disposes the Shadow map and related Textures and effects.
  89505. */
  89506. dispose(): void;
  89507. }
  89508. /**
  89509. * Default implementation IShadowGenerator.
  89510. * This is the main object responsible of generating shadows in the framework.
  89511. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  89512. */
  89513. export class ShadowGenerator implements IShadowGenerator {
  89514. /**
  89515. * Name of the shadow generator class
  89516. */
  89517. static CLASSNAME: string;
  89518. /**
  89519. * Shadow generator mode None: no filtering applied.
  89520. */
  89521. static readonly FILTER_NONE: number;
  89522. /**
  89523. * Shadow generator mode ESM: Exponential Shadow Mapping.
  89524. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89525. */
  89526. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  89527. /**
  89528. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  89529. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  89530. */
  89531. static readonly FILTER_POISSONSAMPLING: number;
  89532. /**
  89533. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  89534. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89535. */
  89536. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  89537. /**
  89538. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  89539. * edge artifacts on steep falloff.
  89540. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89541. */
  89542. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  89543. /**
  89544. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  89545. * edge artifacts on steep falloff.
  89546. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89547. */
  89548. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  89549. /**
  89550. * Shadow generator mode PCF: Percentage Closer Filtering
  89551. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  89552. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  89553. */
  89554. static readonly FILTER_PCF: number;
  89555. /**
  89556. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  89557. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  89558. * Contact Hardening
  89559. */
  89560. static readonly FILTER_PCSS: number;
  89561. /**
  89562. * Reserved for PCF and PCSS
  89563. * Highest Quality.
  89564. *
  89565. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  89566. *
  89567. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  89568. */
  89569. static readonly QUALITY_HIGH: number;
  89570. /**
  89571. * Reserved for PCF and PCSS
  89572. * Good tradeoff for quality/perf cross devices
  89573. *
  89574. * Execute PCF on a 3*3 kernel.
  89575. *
  89576. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  89577. */
  89578. static readonly QUALITY_MEDIUM: number;
  89579. /**
  89580. * Reserved for PCF and PCSS
  89581. * The lowest quality but the fastest.
  89582. *
  89583. * Execute PCF on a 1*1 kernel.
  89584. *
  89585. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  89586. */
  89587. static readonly QUALITY_LOW: number;
  89588. /** Gets or sets the custom shader name to use */
  89589. customShaderOptions: ICustomShaderOptions;
  89590. /**
  89591. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  89592. */
  89593. onBeforeShadowMapRenderObservable: Observable<Effect>;
  89594. /**
  89595. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  89596. */
  89597. onAfterShadowMapRenderObservable: Observable<Effect>;
  89598. /**
  89599. * Observable triggered before a mesh is rendered in the shadow map.
  89600. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  89601. */
  89602. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  89603. /**
  89604. * Observable triggered after a mesh is rendered in the shadow map.
  89605. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  89606. */
  89607. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  89608. protected _bias: number;
  89609. /**
  89610. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  89611. */
  89612. get bias(): number;
  89613. /**
  89614. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  89615. */
  89616. set bias(bias: number);
  89617. protected _normalBias: number;
  89618. /**
  89619. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  89620. */
  89621. get normalBias(): number;
  89622. /**
  89623. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  89624. */
  89625. set normalBias(normalBias: number);
  89626. protected _blurBoxOffset: number;
  89627. /**
  89628. * Gets the blur box offset: offset applied during the blur pass.
  89629. * Only useful if useKernelBlur = false
  89630. */
  89631. get blurBoxOffset(): number;
  89632. /**
  89633. * Sets the blur box offset: offset applied during the blur pass.
  89634. * Only useful if useKernelBlur = false
  89635. */
  89636. set blurBoxOffset(value: number);
  89637. protected _blurScale: number;
  89638. /**
  89639. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  89640. * 2 means half of the size.
  89641. */
  89642. get blurScale(): number;
  89643. /**
  89644. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  89645. * 2 means half of the size.
  89646. */
  89647. set blurScale(value: number);
  89648. protected _blurKernel: number;
  89649. /**
  89650. * Gets the blur kernel: kernel size of the blur pass.
  89651. * Only useful if useKernelBlur = true
  89652. */
  89653. get blurKernel(): number;
  89654. /**
  89655. * Sets the blur kernel: kernel size of the blur pass.
  89656. * Only useful if useKernelBlur = true
  89657. */
  89658. set blurKernel(value: number);
  89659. protected _useKernelBlur: boolean;
  89660. /**
  89661. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  89662. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  89663. */
  89664. get useKernelBlur(): boolean;
  89665. /**
  89666. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  89667. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  89668. */
  89669. set useKernelBlur(value: boolean);
  89670. protected _depthScale: number;
  89671. /**
  89672. * Gets the depth scale used in ESM mode.
  89673. */
  89674. get depthScale(): number;
  89675. /**
  89676. * Sets the depth scale used in ESM mode.
  89677. * This can override the scale stored on the light.
  89678. */
  89679. set depthScale(value: number);
  89680. protected _validateFilter(filter: number): number;
  89681. protected _filter: number;
  89682. /**
  89683. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  89684. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  89685. */
  89686. get filter(): number;
  89687. /**
  89688. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  89689. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  89690. */
  89691. set filter(value: number);
  89692. /**
  89693. * Gets if the current filter is set to Poisson Sampling.
  89694. */
  89695. get usePoissonSampling(): boolean;
  89696. /**
  89697. * Sets the current filter to Poisson Sampling.
  89698. */
  89699. set usePoissonSampling(value: boolean);
  89700. /**
  89701. * Gets if the current filter is set to ESM.
  89702. */
  89703. get useExponentialShadowMap(): boolean;
  89704. /**
  89705. * Sets the current filter is to ESM.
  89706. */
  89707. set useExponentialShadowMap(value: boolean);
  89708. /**
  89709. * Gets if the current filter is set to filtered ESM.
  89710. */
  89711. get useBlurExponentialShadowMap(): boolean;
  89712. /**
  89713. * Gets if the current filter is set to filtered ESM.
  89714. */
  89715. set useBlurExponentialShadowMap(value: boolean);
  89716. /**
  89717. * Gets if the current filter is set to "close ESM" (using the inverse of the
  89718. * exponential to prevent steep falloff artifacts).
  89719. */
  89720. get useCloseExponentialShadowMap(): boolean;
  89721. /**
  89722. * Sets the current filter to "close ESM" (using the inverse of the
  89723. * exponential to prevent steep falloff artifacts).
  89724. */
  89725. set useCloseExponentialShadowMap(value: boolean);
  89726. /**
  89727. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  89728. * exponential to prevent steep falloff artifacts).
  89729. */
  89730. get useBlurCloseExponentialShadowMap(): boolean;
  89731. /**
  89732. * Sets the current filter to filtered "close ESM" (using the inverse of the
  89733. * exponential to prevent steep falloff artifacts).
  89734. */
  89735. set useBlurCloseExponentialShadowMap(value: boolean);
  89736. /**
  89737. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  89738. */
  89739. get usePercentageCloserFiltering(): boolean;
  89740. /**
  89741. * Sets the current filter to "PCF" (percentage closer filtering).
  89742. */
  89743. set usePercentageCloserFiltering(value: boolean);
  89744. protected _filteringQuality: number;
  89745. /**
  89746. * Gets the PCF or PCSS Quality.
  89747. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  89748. */
  89749. get filteringQuality(): number;
  89750. /**
  89751. * Sets the PCF or PCSS Quality.
  89752. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  89753. */
  89754. set filteringQuality(filteringQuality: number);
  89755. /**
  89756. * Gets if the current filter is set to "PCSS" (contact hardening).
  89757. */
  89758. get useContactHardeningShadow(): boolean;
  89759. /**
  89760. * Sets the current filter to "PCSS" (contact hardening).
  89761. */
  89762. set useContactHardeningShadow(value: boolean);
  89763. protected _contactHardeningLightSizeUVRatio: number;
  89764. /**
  89765. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  89766. * Using a ratio helps keeping shape stability independently of the map size.
  89767. *
  89768. * It does not account for the light projection as it was having too much
  89769. * instability during the light setup or during light position changes.
  89770. *
  89771. * Only valid if useContactHardeningShadow is true.
  89772. */
  89773. get contactHardeningLightSizeUVRatio(): number;
  89774. /**
  89775. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  89776. * Using a ratio helps keeping shape stability independently of the map size.
  89777. *
  89778. * It does not account for the light projection as it was having too much
  89779. * instability during the light setup or during light position changes.
  89780. *
  89781. * Only valid if useContactHardeningShadow is true.
  89782. */
  89783. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  89784. protected _darkness: number;
  89785. /** Gets or sets the actual darkness of a shadow */
  89786. get darkness(): number;
  89787. set darkness(value: number);
  89788. /**
  89789. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  89790. * 0 means strongest and 1 would means no shadow.
  89791. * @returns the darkness.
  89792. */
  89793. getDarkness(): number;
  89794. /**
  89795. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  89796. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  89797. * @returns the shadow generator allowing fluent coding.
  89798. */
  89799. setDarkness(darkness: number): ShadowGenerator;
  89800. protected _transparencyShadow: boolean;
  89801. /** Gets or sets the ability to have transparent shadow */
  89802. get transparencyShadow(): boolean;
  89803. set transparencyShadow(value: boolean);
  89804. /**
  89805. * Sets the ability to have transparent shadow (boolean).
  89806. * @param transparent True if transparent else False
  89807. * @returns the shadow generator allowing fluent coding
  89808. */
  89809. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  89810. protected _shadowMap: Nullable<RenderTargetTexture>;
  89811. protected _shadowMap2: Nullable<RenderTargetTexture>;
  89812. /**
  89813. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  89814. * @returns The render target texture if present otherwise, null
  89815. */
  89816. getShadowMap(): Nullable<RenderTargetTexture>;
  89817. /**
  89818. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  89819. * @returns The render target texture if the shadow map is present otherwise, null
  89820. */
  89821. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  89822. /**
  89823. * Gets the class name of that object
  89824. * @returns "ShadowGenerator"
  89825. */
  89826. getClassName(): string;
  89827. /**
  89828. * Helper function to add a mesh and its descendants to the list of shadow casters.
  89829. * @param mesh Mesh to add
  89830. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  89831. * @returns the Shadow Generator itself
  89832. */
  89833. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  89834. /**
  89835. * Helper function to remove a mesh and its descendants from the list of shadow casters
  89836. * @param mesh Mesh to remove
  89837. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  89838. * @returns the Shadow Generator itself
  89839. */
  89840. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  89841. /**
  89842. * Controls the extent to which the shadows fade out at the edge of the frustum
  89843. */
  89844. frustumEdgeFalloff: number;
  89845. protected _light: IShadowLight;
  89846. /**
  89847. * Returns the associated light object.
  89848. * @returns the light generating the shadow
  89849. */
  89850. getLight(): IShadowLight;
  89851. /**
  89852. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  89853. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  89854. * It might on the other hand introduce peter panning.
  89855. */
  89856. forceBackFacesOnly: boolean;
  89857. protected _scene: Scene;
  89858. protected _lightDirection: Vector3;
  89859. protected _effect: Effect;
  89860. protected _viewMatrix: Matrix;
  89861. protected _projectionMatrix: Matrix;
  89862. protected _transformMatrix: Matrix;
  89863. protected _cachedPosition: Vector3;
  89864. protected _cachedDirection: Vector3;
  89865. protected _cachedDefines: string;
  89866. protected _currentRenderID: number;
  89867. protected _boxBlurPostprocess: Nullable<PostProcess>;
  89868. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  89869. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  89870. protected _blurPostProcesses: PostProcess[];
  89871. protected _mapSize: number;
  89872. protected _currentFaceIndex: number;
  89873. protected _currentFaceIndexCache: number;
  89874. protected _textureType: number;
  89875. protected _defaultTextureMatrix: Matrix;
  89876. protected _storedUniqueId: Nullable<number>;
  89877. /** @hidden */
  89878. static _SceneComponentInitialization: (scene: Scene) => void;
  89879. /**
  89880. * Creates a ShadowGenerator object.
  89881. * A ShadowGenerator is the required tool to use the shadows.
  89882. * Each light casting shadows needs to use its own ShadowGenerator.
  89883. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  89884. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  89885. * @param light The light object generating the shadows.
  89886. * @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.
  89887. */
  89888. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  89889. protected _initializeGenerator(): void;
  89890. protected _createTargetRenderTexture(): void;
  89891. protected _initializeShadowMap(): void;
  89892. protected _initializeBlurRTTAndPostProcesses(): void;
  89893. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  89894. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  89895. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  89896. protected _applyFilterValues(): void;
  89897. /**
  89898. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89899. * @param onCompiled Callback triggered at the and of the effects compilation
  89900. * @param options Sets of optional options forcing the compilation with different modes
  89901. */
  89902. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  89903. useInstances: boolean;
  89904. }>): void;
  89905. /**
  89906. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89907. * @param options Sets of optional options forcing the compilation with different modes
  89908. * @returns A promise that resolves when the compilation completes
  89909. */
  89910. forceCompilationAsync(options?: Partial<{
  89911. useInstances: boolean;
  89912. }>): Promise<void>;
  89913. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  89914. /**
  89915. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  89916. * @param subMesh The submesh we want to render in the shadow map
  89917. * @param useInstances Defines wether will draw in the map using instances
  89918. * @returns true if ready otherwise, false
  89919. */
  89920. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  89921. /**
  89922. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  89923. * @param defines Defines of the material we want to update
  89924. * @param lightIndex Index of the light in the enabled light list of the material
  89925. */
  89926. prepareDefines(defines: any, lightIndex: number): void;
  89927. /**
  89928. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  89929. * defined in the generator but impacting the effect).
  89930. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  89931. * @param effect The effect we are binfing the information for
  89932. */
  89933. bindShadowLight(lightIndex: string, effect: Effect): void;
  89934. /**
  89935. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  89936. * (eq to shadow prjection matrix * light transform matrix)
  89937. * @returns The transform matrix used to create the shadow map
  89938. */
  89939. getTransformMatrix(): Matrix;
  89940. /**
  89941. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  89942. * Cube and 2D textures for instance.
  89943. */
  89944. recreateShadowMap(): void;
  89945. protected _disposeBlurPostProcesses(): void;
  89946. protected _disposeRTTandPostProcesses(): void;
  89947. /**
  89948. * Disposes the ShadowGenerator.
  89949. * Returns nothing.
  89950. */
  89951. dispose(): void;
  89952. /**
  89953. * Serializes the shadow generator setup to a json object.
  89954. * @returns The serialized JSON object
  89955. */
  89956. serialize(): any;
  89957. /**
  89958. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  89959. * @param parsedShadowGenerator The JSON object to parse
  89960. * @param scene The scene to create the shadow map for
  89961. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  89962. * @returns The parsed shadow generator
  89963. */
  89964. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  89965. }
  89966. }
  89967. declare module BABYLON {
  89968. /**
  89969. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  89970. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  89971. * 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.
  89972. */
  89973. export abstract class Light extends Node {
  89974. /**
  89975. * Falloff Default: light is falling off following the material specification:
  89976. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  89977. */
  89978. static readonly FALLOFF_DEFAULT: number;
  89979. /**
  89980. * Falloff Physical: light is falling off following the inverse squared distance law.
  89981. */
  89982. static readonly FALLOFF_PHYSICAL: number;
  89983. /**
  89984. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  89985. * to enhance interoperability with other engines.
  89986. */
  89987. static readonly FALLOFF_GLTF: number;
  89988. /**
  89989. * Falloff Standard: light is falling off like in the standard material
  89990. * to enhance interoperability with other materials.
  89991. */
  89992. static readonly FALLOFF_STANDARD: number;
  89993. /**
  89994. * If every light affecting the material is in this lightmapMode,
  89995. * material.lightmapTexture adds or multiplies
  89996. * (depends on material.useLightmapAsShadowmap)
  89997. * after every other light calculations.
  89998. */
  89999. static readonly LIGHTMAP_DEFAULT: number;
  90000. /**
  90001. * material.lightmapTexture as only diffuse lighting from this light
  90002. * adds only specular lighting from this light
  90003. * adds dynamic shadows
  90004. */
  90005. static readonly LIGHTMAP_SPECULAR: number;
  90006. /**
  90007. * material.lightmapTexture as only lighting
  90008. * no light calculation from this light
  90009. * only adds dynamic shadows from this light
  90010. */
  90011. static readonly LIGHTMAP_SHADOWSONLY: number;
  90012. /**
  90013. * Each light type uses the default quantity according to its type:
  90014. * point/spot lights use luminous intensity
  90015. * directional lights use illuminance
  90016. */
  90017. static readonly INTENSITYMODE_AUTOMATIC: number;
  90018. /**
  90019. * lumen (lm)
  90020. */
  90021. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  90022. /**
  90023. * candela (lm/sr)
  90024. */
  90025. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  90026. /**
  90027. * lux (lm/m^2)
  90028. */
  90029. static readonly INTENSITYMODE_ILLUMINANCE: number;
  90030. /**
  90031. * nit (cd/m^2)
  90032. */
  90033. static readonly INTENSITYMODE_LUMINANCE: number;
  90034. /**
  90035. * Light type const id of the point light.
  90036. */
  90037. static readonly LIGHTTYPEID_POINTLIGHT: number;
  90038. /**
  90039. * Light type const id of the directional light.
  90040. */
  90041. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  90042. /**
  90043. * Light type const id of the spot light.
  90044. */
  90045. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  90046. /**
  90047. * Light type const id of the hemispheric light.
  90048. */
  90049. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  90050. /**
  90051. * Diffuse gives the basic color to an object.
  90052. */
  90053. diffuse: Color3;
  90054. /**
  90055. * Specular produces a highlight color on an object.
  90056. * Note: This is note affecting PBR materials.
  90057. */
  90058. specular: Color3;
  90059. /**
  90060. * Defines the falloff type for this light. This lets overrriding how punctual light are
  90061. * falling off base on range or angle.
  90062. * This can be set to any values in Light.FALLOFF_x.
  90063. *
  90064. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  90065. * other types of materials.
  90066. */
  90067. falloffType: number;
  90068. /**
  90069. * Strength of the light.
  90070. * Note: By default it is define in the framework own unit.
  90071. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  90072. */
  90073. intensity: number;
  90074. private _range;
  90075. protected _inverseSquaredRange: number;
  90076. /**
  90077. * Defines how far from the source the light is impacting in scene units.
  90078. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  90079. */
  90080. get range(): number;
  90081. /**
  90082. * Defines how far from the source the light is impacting in scene units.
  90083. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  90084. */
  90085. set range(value: number);
  90086. /**
  90087. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  90088. * of light.
  90089. */
  90090. private _photometricScale;
  90091. private _intensityMode;
  90092. /**
  90093. * Gets the photometric scale used to interpret the intensity.
  90094. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  90095. */
  90096. get intensityMode(): number;
  90097. /**
  90098. * Sets the photometric scale used to interpret the intensity.
  90099. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  90100. */
  90101. set intensityMode(value: number);
  90102. private _radius;
  90103. /**
  90104. * Gets the light radius used by PBR Materials to simulate soft area lights.
  90105. */
  90106. get radius(): number;
  90107. /**
  90108. * sets the light radius used by PBR Materials to simulate soft area lights.
  90109. */
  90110. set radius(value: number);
  90111. private _renderPriority;
  90112. /**
  90113. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  90114. * exceeding the number allowed of the materials.
  90115. */
  90116. renderPriority: number;
  90117. private _shadowEnabled;
  90118. /**
  90119. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  90120. * the current shadow generator.
  90121. */
  90122. get shadowEnabled(): boolean;
  90123. /**
  90124. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  90125. * the current shadow generator.
  90126. */
  90127. set shadowEnabled(value: boolean);
  90128. private _includedOnlyMeshes;
  90129. /**
  90130. * Gets the only meshes impacted by this light.
  90131. */
  90132. get includedOnlyMeshes(): AbstractMesh[];
  90133. /**
  90134. * Sets the only meshes impacted by this light.
  90135. */
  90136. set includedOnlyMeshes(value: AbstractMesh[]);
  90137. private _excludedMeshes;
  90138. /**
  90139. * Gets the meshes not impacted by this light.
  90140. */
  90141. get excludedMeshes(): AbstractMesh[];
  90142. /**
  90143. * Sets the meshes not impacted by this light.
  90144. */
  90145. set excludedMeshes(value: AbstractMesh[]);
  90146. private _excludeWithLayerMask;
  90147. /**
  90148. * Gets the layer id use to find what meshes are not impacted by the light.
  90149. * Inactive if 0
  90150. */
  90151. get excludeWithLayerMask(): number;
  90152. /**
  90153. * Sets the layer id use to find what meshes are not impacted by the light.
  90154. * Inactive if 0
  90155. */
  90156. set excludeWithLayerMask(value: number);
  90157. private _includeOnlyWithLayerMask;
  90158. /**
  90159. * Gets the layer id use to find what meshes are impacted by the light.
  90160. * Inactive if 0
  90161. */
  90162. get includeOnlyWithLayerMask(): number;
  90163. /**
  90164. * Sets the layer id use to find what meshes are impacted by the light.
  90165. * Inactive if 0
  90166. */
  90167. set includeOnlyWithLayerMask(value: number);
  90168. private _lightmapMode;
  90169. /**
  90170. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  90171. */
  90172. get lightmapMode(): number;
  90173. /**
  90174. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  90175. */
  90176. set lightmapMode(value: number);
  90177. /**
  90178. * Shadow generator associted to the light.
  90179. * @hidden Internal use only.
  90180. */
  90181. _shadowGenerator: Nullable<IShadowGenerator>;
  90182. /**
  90183. * @hidden Internal use only.
  90184. */
  90185. _excludedMeshesIds: string[];
  90186. /**
  90187. * @hidden Internal use only.
  90188. */
  90189. _includedOnlyMeshesIds: string[];
  90190. /**
  90191. * The current light unifom buffer.
  90192. * @hidden Internal use only.
  90193. */
  90194. _uniformBuffer: UniformBuffer;
  90195. /** @hidden */
  90196. _renderId: number;
  90197. /**
  90198. * Creates a Light object in the scene.
  90199. * Documentation : https://doc.babylonjs.com/babylon101/lights
  90200. * @param name The firendly name of the light
  90201. * @param scene The scene the light belongs too
  90202. */
  90203. constructor(name: string, scene: Scene);
  90204. protected abstract _buildUniformLayout(): void;
  90205. /**
  90206. * Sets the passed Effect "effect" with the Light information.
  90207. * @param effect The effect to update
  90208. * @param lightIndex The index of the light in the effect to update
  90209. * @returns The light
  90210. */
  90211. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  90212. /**
  90213. * Sets the passed Effect "effect" with the Light textures.
  90214. * @param effect The effect to update
  90215. * @param lightIndex The index of the light in the effect to update
  90216. * @returns The light
  90217. */
  90218. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  90219. /**
  90220. * Binds the lights information from the scene to the effect for the given mesh.
  90221. * @param lightIndex Light index
  90222. * @param scene The scene where the light belongs to
  90223. * @param effect The effect we are binding the data to
  90224. * @param useSpecular Defines if specular is supported
  90225. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  90226. */
  90227. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  90228. /**
  90229. * Sets the passed Effect "effect" with the Light information.
  90230. * @param effect The effect to update
  90231. * @param lightDataUniformName The uniform used to store light data (position or direction)
  90232. * @returns The light
  90233. */
  90234. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  90235. /**
  90236. * Returns the string "Light".
  90237. * @returns the class name
  90238. */
  90239. getClassName(): string;
  90240. /** @hidden */
  90241. readonly _isLight: boolean;
  90242. /**
  90243. * Converts the light information to a readable string for debug purpose.
  90244. * @param fullDetails Supports for multiple levels of logging within scene loading
  90245. * @returns the human readable light info
  90246. */
  90247. toString(fullDetails?: boolean): string;
  90248. /** @hidden */
  90249. protected _syncParentEnabledState(): void;
  90250. /**
  90251. * Set the enabled state of this node.
  90252. * @param value - the new enabled state
  90253. */
  90254. setEnabled(value: boolean): void;
  90255. /**
  90256. * Returns the Light associated shadow generator if any.
  90257. * @return the associated shadow generator.
  90258. */
  90259. getShadowGenerator(): Nullable<IShadowGenerator>;
  90260. /**
  90261. * Returns a Vector3, the absolute light position in the World.
  90262. * @returns the world space position of the light
  90263. */
  90264. getAbsolutePosition(): Vector3;
  90265. /**
  90266. * Specifies if the light will affect the passed mesh.
  90267. * @param mesh The mesh to test against the light
  90268. * @return true the mesh is affected otherwise, false.
  90269. */
  90270. canAffectMesh(mesh: AbstractMesh): boolean;
  90271. /**
  90272. * Sort function to order lights for rendering.
  90273. * @param a First Light object to compare to second.
  90274. * @param b Second Light object to compare first.
  90275. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  90276. */
  90277. static CompareLightsPriority(a: Light, b: Light): number;
  90278. /**
  90279. * Releases resources associated with this node.
  90280. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90281. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90282. */
  90283. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90284. /**
  90285. * Returns the light type ID (integer).
  90286. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  90287. */
  90288. getTypeID(): number;
  90289. /**
  90290. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  90291. * @returns the scaled intensity in intensity mode unit
  90292. */
  90293. getScaledIntensity(): number;
  90294. /**
  90295. * Returns a new Light object, named "name", from the current one.
  90296. * @param name The name of the cloned light
  90297. * @returns the new created light
  90298. */
  90299. clone(name: string): Nullable<Light>;
  90300. /**
  90301. * Serializes the current light into a Serialization object.
  90302. * @returns the serialized object.
  90303. */
  90304. serialize(): any;
  90305. /**
  90306. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  90307. * This new light is named "name" and added to the passed scene.
  90308. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  90309. * @param name The friendly name of the light
  90310. * @param scene The scene the new light will belong to
  90311. * @returns the constructor function
  90312. */
  90313. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  90314. /**
  90315. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  90316. * @param parsedLight The JSON representation of the light
  90317. * @param scene The scene to create the parsed light in
  90318. * @returns the created light after parsing
  90319. */
  90320. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  90321. private _hookArrayForExcluded;
  90322. private _hookArrayForIncludedOnly;
  90323. private _resyncMeshes;
  90324. /**
  90325. * Forces the meshes to update their light related information in their rendering used effects
  90326. * @hidden Internal Use Only
  90327. */
  90328. _markMeshesAsLightDirty(): void;
  90329. /**
  90330. * Recomputes the cached photometric scale if needed.
  90331. */
  90332. private _computePhotometricScale;
  90333. /**
  90334. * Returns the Photometric Scale according to the light type and intensity mode.
  90335. */
  90336. private _getPhotometricScale;
  90337. /**
  90338. * Reorder the light in the scene according to their defined priority.
  90339. * @hidden Internal Use Only
  90340. */
  90341. _reorderLightsInScene(): void;
  90342. /**
  90343. * Prepares the list of defines specific to the light type.
  90344. * @param defines the list of defines
  90345. * @param lightIndex defines the index of the light for the effect
  90346. */
  90347. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  90348. }
  90349. }
  90350. declare module BABYLON {
  90351. /**
  90352. * Interface used to define Action
  90353. */
  90354. export interface IAction {
  90355. /**
  90356. * Trigger for the action
  90357. */
  90358. trigger: number;
  90359. /** Options of the trigger */
  90360. triggerOptions: any;
  90361. /**
  90362. * Gets the trigger parameters
  90363. * @returns the trigger parameters
  90364. */
  90365. getTriggerParameter(): any;
  90366. /**
  90367. * Internal only - executes current action event
  90368. * @hidden
  90369. */
  90370. _executeCurrent(evt?: ActionEvent): void;
  90371. /**
  90372. * Serialize placeholder for child classes
  90373. * @param parent of child
  90374. * @returns the serialized object
  90375. */
  90376. serialize(parent: any): any;
  90377. /**
  90378. * Internal only
  90379. * @hidden
  90380. */
  90381. _prepare(): void;
  90382. /**
  90383. * Internal only - manager for action
  90384. * @hidden
  90385. */
  90386. _actionManager: AbstractActionManager;
  90387. /**
  90388. * Adds action to chain of actions, may be a DoNothingAction
  90389. * @param action defines the next action to execute
  90390. * @returns The action passed in
  90391. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90392. */
  90393. then(action: IAction): IAction;
  90394. }
  90395. /**
  90396. * The action to be carried out following a trigger
  90397. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  90398. */
  90399. export class Action implements IAction {
  90400. /** the trigger, with or without parameters, for the action */
  90401. triggerOptions: any;
  90402. /**
  90403. * Trigger for the action
  90404. */
  90405. trigger: number;
  90406. /**
  90407. * Internal only - manager for action
  90408. * @hidden
  90409. */
  90410. _actionManager: ActionManager;
  90411. private _nextActiveAction;
  90412. private _child;
  90413. private _condition?;
  90414. private _triggerParameter;
  90415. /**
  90416. * An event triggered prior to action being executed.
  90417. */
  90418. onBeforeExecuteObservable: Observable<Action>;
  90419. /**
  90420. * Creates a new Action
  90421. * @param triggerOptions the trigger, with or without parameters, for the action
  90422. * @param condition an optional determinant of action
  90423. */
  90424. constructor(
  90425. /** the trigger, with or without parameters, for the action */
  90426. triggerOptions: any, condition?: Condition);
  90427. /**
  90428. * Internal only
  90429. * @hidden
  90430. */
  90431. _prepare(): void;
  90432. /**
  90433. * Gets the trigger parameters
  90434. * @returns the trigger parameters
  90435. */
  90436. getTriggerParameter(): any;
  90437. /**
  90438. * Internal only - executes current action event
  90439. * @hidden
  90440. */
  90441. _executeCurrent(evt?: ActionEvent): void;
  90442. /**
  90443. * Execute placeholder for child classes
  90444. * @param evt optional action event
  90445. */
  90446. execute(evt?: ActionEvent): void;
  90447. /**
  90448. * Skips to next active action
  90449. */
  90450. skipToNextActiveAction(): void;
  90451. /**
  90452. * Adds action to chain of actions, may be a DoNothingAction
  90453. * @param action defines the next action to execute
  90454. * @returns The action passed in
  90455. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90456. */
  90457. then(action: Action): Action;
  90458. /**
  90459. * Internal only
  90460. * @hidden
  90461. */
  90462. _getProperty(propertyPath: string): string;
  90463. /**
  90464. * Internal only
  90465. * @hidden
  90466. */
  90467. _getEffectiveTarget(target: any, propertyPath: string): any;
  90468. /**
  90469. * Serialize placeholder for child classes
  90470. * @param parent of child
  90471. * @returns the serialized object
  90472. */
  90473. serialize(parent: any): any;
  90474. /**
  90475. * Internal only called by serialize
  90476. * @hidden
  90477. */
  90478. protected _serialize(serializedAction: any, parent?: any): any;
  90479. /**
  90480. * Internal only
  90481. * @hidden
  90482. */
  90483. static _SerializeValueAsString: (value: any) => string;
  90484. /**
  90485. * Internal only
  90486. * @hidden
  90487. */
  90488. static _GetTargetProperty: (target: Node | Scene) => {
  90489. name: string;
  90490. targetType: string;
  90491. value: string;
  90492. };
  90493. }
  90494. }
  90495. declare module BABYLON {
  90496. /**
  90497. * A Condition applied to an Action
  90498. */
  90499. export class Condition {
  90500. /**
  90501. * Internal only - manager for action
  90502. * @hidden
  90503. */
  90504. _actionManager: ActionManager;
  90505. /**
  90506. * Internal only
  90507. * @hidden
  90508. */
  90509. _evaluationId: number;
  90510. /**
  90511. * Internal only
  90512. * @hidden
  90513. */
  90514. _currentResult: boolean;
  90515. /**
  90516. * Creates a new Condition
  90517. * @param actionManager the manager of the action the condition is applied to
  90518. */
  90519. constructor(actionManager: ActionManager);
  90520. /**
  90521. * Check if the current condition is valid
  90522. * @returns a boolean
  90523. */
  90524. isValid(): boolean;
  90525. /**
  90526. * Internal only
  90527. * @hidden
  90528. */
  90529. _getProperty(propertyPath: string): string;
  90530. /**
  90531. * Internal only
  90532. * @hidden
  90533. */
  90534. _getEffectiveTarget(target: any, propertyPath: string): any;
  90535. /**
  90536. * Serialize placeholder for child classes
  90537. * @returns the serialized object
  90538. */
  90539. serialize(): any;
  90540. /**
  90541. * Internal only
  90542. * @hidden
  90543. */
  90544. protected _serialize(serializedCondition: any): any;
  90545. }
  90546. /**
  90547. * Defines specific conditional operators as extensions of Condition
  90548. */
  90549. export class ValueCondition extends Condition {
  90550. /** path to specify the property of the target the conditional operator uses */
  90551. propertyPath: string;
  90552. /** the value compared by the conditional operator against the current value of the property */
  90553. value: any;
  90554. /** the conditional operator, default ValueCondition.IsEqual */
  90555. operator: number;
  90556. /**
  90557. * Internal only
  90558. * @hidden
  90559. */
  90560. private static _IsEqual;
  90561. /**
  90562. * Internal only
  90563. * @hidden
  90564. */
  90565. private static _IsDifferent;
  90566. /**
  90567. * Internal only
  90568. * @hidden
  90569. */
  90570. private static _IsGreater;
  90571. /**
  90572. * Internal only
  90573. * @hidden
  90574. */
  90575. private static _IsLesser;
  90576. /**
  90577. * returns the number for IsEqual
  90578. */
  90579. static get IsEqual(): number;
  90580. /**
  90581. * Returns the number for IsDifferent
  90582. */
  90583. static get IsDifferent(): number;
  90584. /**
  90585. * Returns the number for IsGreater
  90586. */
  90587. static get IsGreater(): number;
  90588. /**
  90589. * Returns the number for IsLesser
  90590. */
  90591. static get IsLesser(): number;
  90592. /**
  90593. * Internal only The action manager for the condition
  90594. * @hidden
  90595. */
  90596. _actionManager: ActionManager;
  90597. /**
  90598. * Internal only
  90599. * @hidden
  90600. */
  90601. private _target;
  90602. /**
  90603. * Internal only
  90604. * @hidden
  90605. */
  90606. private _effectiveTarget;
  90607. /**
  90608. * Internal only
  90609. * @hidden
  90610. */
  90611. private _property;
  90612. /**
  90613. * Creates a new ValueCondition
  90614. * @param actionManager manager for the action the condition applies to
  90615. * @param target for the action
  90616. * @param propertyPath path to specify the property of the target the conditional operator uses
  90617. * @param value the value compared by the conditional operator against the current value of the property
  90618. * @param operator the conditional operator, default ValueCondition.IsEqual
  90619. */
  90620. constructor(actionManager: ActionManager, target: any,
  90621. /** path to specify the property of the target the conditional operator uses */
  90622. propertyPath: string,
  90623. /** the value compared by the conditional operator against the current value of the property */
  90624. value: any,
  90625. /** the conditional operator, default ValueCondition.IsEqual */
  90626. operator?: number);
  90627. /**
  90628. * Compares the given value with the property value for the specified conditional operator
  90629. * @returns the result of the comparison
  90630. */
  90631. isValid(): boolean;
  90632. /**
  90633. * Serialize the ValueCondition into a JSON compatible object
  90634. * @returns serialization object
  90635. */
  90636. serialize(): any;
  90637. /**
  90638. * Gets the name of the conditional operator for the ValueCondition
  90639. * @param operator the conditional operator
  90640. * @returns the name
  90641. */
  90642. static GetOperatorName(operator: number): string;
  90643. }
  90644. /**
  90645. * Defines a predicate condition as an extension of Condition
  90646. */
  90647. export class PredicateCondition extends Condition {
  90648. /** defines the predicate function used to validate the condition */
  90649. predicate: () => boolean;
  90650. /**
  90651. * Internal only - manager for action
  90652. * @hidden
  90653. */
  90654. _actionManager: ActionManager;
  90655. /**
  90656. * Creates a new PredicateCondition
  90657. * @param actionManager manager for the action the condition applies to
  90658. * @param predicate defines the predicate function used to validate the condition
  90659. */
  90660. constructor(actionManager: ActionManager,
  90661. /** defines the predicate function used to validate the condition */
  90662. predicate: () => boolean);
  90663. /**
  90664. * @returns the validity of the predicate condition
  90665. */
  90666. isValid(): boolean;
  90667. }
  90668. /**
  90669. * Defines a state condition as an extension of Condition
  90670. */
  90671. export class StateCondition extends Condition {
  90672. /** Value to compare with target state */
  90673. value: string;
  90674. /**
  90675. * Internal only - manager for action
  90676. * @hidden
  90677. */
  90678. _actionManager: ActionManager;
  90679. /**
  90680. * Internal only
  90681. * @hidden
  90682. */
  90683. private _target;
  90684. /**
  90685. * Creates a new StateCondition
  90686. * @param actionManager manager for the action the condition applies to
  90687. * @param target of the condition
  90688. * @param value to compare with target state
  90689. */
  90690. constructor(actionManager: ActionManager, target: any,
  90691. /** Value to compare with target state */
  90692. value: string);
  90693. /**
  90694. * Gets a boolean indicating if the current condition is met
  90695. * @returns the validity of the state
  90696. */
  90697. isValid(): boolean;
  90698. /**
  90699. * Serialize the StateCondition into a JSON compatible object
  90700. * @returns serialization object
  90701. */
  90702. serialize(): any;
  90703. }
  90704. }
  90705. declare module BABYLON {
  90706. /**
  90707. * This defines an action responsible to toggle a boolean once triggered.
  90708. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90709. */
  90710. export class SwitchBooleanAction extends Action {
  90711. /**
  90712. * The path to the boolean property in the target object
  90713. */
  90714. propertyPath: string;
  90715. private _target;
  90716. private _effectiveTarget;
  90717. private _property;
  90718. /**
  90719. * Instantiate the action
  90720. * @param triggerOptions defines the trigger options
  90721. * @param target defines the object containing the boolean
  90722. * @param propertyPath defines the path to the boolean property in the target object
  90723. * @param condition defines the trigger related conditions
  90724. */
  90725. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  90726. /** @hidden */
  90727. _prepare(): void;
  90728. /**
  90729. * Execute the action toggle the boolean value.
  90730. */
  90731. execute(): void;
  90732. /**
  90733. * Serializes the actions and its related information.
  90734. * @param parent defines the object to serialize in
  90735. * @returns the serialized object
  90736. */
  90737. serialize(parent: any): any;
  90738. }
  90739. /**
  90740. * This defines an action responsible to set a the state field of the target
  90741. * to a desired value once triggered.
  90742. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90743. */
  90744. export class SetStateAction extends Action {
  90745. /**
  90746. * The value to store in the state field.
  90747. */
  90748. value: string;
  90749. private _target;
  90750. /**
  90751. * Instantiate the action
  90752. * @param triggerOptions defines the trigger options
  90753. * @param target defines the object containing the state property
  90754. * @param value defines the value to store in the state field
  90755. * @param condition defines the trigger related conditions
  90756. */
  90757. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  90758. /**
  90759. * Execute the action and store the value on the target state property.
  90760. */
  90761. execute(): void;
  90762. /**
  90763. * Serializes the actions and its related information.
  90764. * @param parent defines the object to serialize in
  90765. * @returns the serialized object
  90766. */
  90767. serialize(parent: any): any;
  90768. }
  90769. /**
  90770. * This defines an action responsible to set a property of the target
  90771. * to a desired value once triggered.
  90772. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90773. */
  90774. export class SetValueAction extends Action {
  90775. /**
  90776. * The path of the property to set in the target.
  90777. */
  90778. propertyPath: string;
  90779. /**
  90780. * The value to set in the property
  90781. */
  90782. value: any;
  90783. private _target;
  90784. private _effectiveTarget;
  90785. private _property;
  90786. /**
  90787. * Instantiate the action
  90788. * @param triggerOptions defines the trigger options
  90789. * @param target defines the object containing the property
  90790. * @param propertyPath defines the path of the property to set in the target
  90791. * @param value defines the value to set in the property
  90792. * @param condition defines the trigger related conditions
  90793. */
  90794. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90795. /** @hidden */
  90796. _prepare(): void;
  90797. /**
  90798. * Execute the action and set the targetted property to the desired value.
  90799. */
  90800. execute(): void;
  90801. /**
  90802. * Serializes the actions and its related information.
  90803. * @param parent defines the object to serialize in
  90804. * @returns the serialized object
  90805. */
  90806. serialize(parent: any): any;
  90807. }
  90808. /**
  90809. * This defines an action responsible to increment the target value
  90810. * to a desired value once triggered.
  90811. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90812. */
  90813. export class IncrementValueAction extends Action {
  90814. /**
  90815. * The path of the property to increment in the target.
  90816. */
  90817. propertyPath: string;
  90818. /**
  90819. * The value we should increment the property by.
  90820. */
  90821. value: any;
  90822. private _target;
  90823. private _effectiveTarget;
  90824. private _property;
  90825. /**
  90826. * Instantiate the action
  90827. * @param triggerOptions defines the trigger options
  90828. * @param target defines the object containing the property
  90829. * @param propertyPath defines the path of the property to increment in the target
  90830. * @param value defines the value value we should increment the property by
  90831. * @param condition defines the trigger related conditions
  90832. */
  90833. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90834. /** @hidden */
  90835. _prepare(): void;
  90836. /**
  90837. * Execute the action and increment the target of the value amount.
  90838. */
  90839. execute(): void;
  90840. /**
  90841. * Serializes the actions and its related information.
  90842. * @param parent defines the object to serialize in
  90843. * @returns the serialized object
  90844. */
  90845. serialize(parent: any): any;
  90846. }
  90847. /**
  90848. * This defines an action responsible to start an animation once triggered.
  90849. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90850. */
  90851. export class PlayAnimationAction extends Action {
  90852. /**
  90853. * Where the animation should start (animation frame)
  90854. */
  90855. from: number;
  90856. /**
  90857. * Where the animation should stop (animation frame)
  90858. */
  90859. to: number;
  90860. /**
  90861. * Define if the animation should loop or stop after the first play.
  90862. */
  90863. loop?: boolean;
  90864. private _target;
  90865. /**
  90866. * Instantiate the action
  90867. * @param triggerOptions defines the trigger options
  90868. * @param target defines the target animation or animation name
  90869. * @param from defines from where the animation should start (animation frame)
  90870. * @param end defines where the animation should stop (animation frame)
  90871. * @param loop defines if the animation should loop or stop after the first play
  90872. * @param condition defines the trigger related conditions
  90873. */
  90874. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  90875. /** @hidden */
  90876. _prepare(): void;
  90877. /**
  90878. * Execute the action and play the animation.
  90879. */
  90880. execute(): void;
  90881. /**
  90882. * Serializes the actions and its related information.
  90883. * @param parent defines the object to serialize in
  90884. * @returns the serialized object
  90885. */
  90886. serialize(parent: any): any;
  90887. }
  90888. /**
  90889. * This defines an action responsible to stop an animation once triggered.
  90890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90891. */
  90892. export class StopAnimationAction extends Action {
  90893. private _target;
  90894. /**
  90895. * Instantiate the action
  90896. * @param triggerOptions defines the trigger options
  90897. * @param target defines the target animation or animation name
  90898. * @param condition defines the trigger related conditions
  90899. */
  90900. constructor(triggerOptions: any, target: any, condition?: Condition);
  90901. /** @hidden */
  90902. _prepare(): void;
  90903. /**
  90904. * Execute the action and stop the animation.
  90905. */
  90906. execute(): void;
  90907. /**
  90908. * Serializes the actions and its related information.
  90909. * @param parent defines the object to serialize in
  90910. * @returns the serialized object
  90911. */
  90912. serialize(parent: any): any;
  90913. }
  90914. /**
  90915. * This defines an action responsible that does nothing once triggered.
  90916. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90917. */
  90918. export class DoNothingAction extends Action {
  90919. /**
  90920. * Instantiate the action
  90921. * @param triggerOptions defines the trigger options
  90922. * @param condition defines the trigger related conditions
  90923. */
  90924. constructor(triggerOptions?: any, condition?: Condition);
  90925. /**
  90926. * Execute the action and do nothing.
  90927. */
  90928. execute(): void;
  90929. /**
  90930. * Serializes the actions and its related information.
  90931. * @param parent defines the object to serialize in
  90932. * @returns the serialized object
  90933. */
  90934. serialize(parent: any): any;
  90935. }
  90936. /**
  90937. * This defines an action responsible to trigger several actions once triggered.
  90938. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90939. */
  90940. export class CombineAction extends Action {
  90941. /**
  90942. * The list of aggregated animations to run.
  90943. */
  90944. children: Action[];
  90945. /**
  90946. * Instantiate the action
  90947. * @param triggerOptions defines the trigger options
  90948. * @param children defines the list of aggregated animations to run
  90949. * @param condition defines the trigger related conditions
  90950. */
  90951. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  90952. /** @hidden */
  90953. _prepare(): void;
  90954. /**
  90955. * Execute the action and executes all the aggregated actions.
  90956. */
  90957. execute(evt: ActionEvent): void;
  90958. /**
  90959. * Serializes the actions and its related information.
  90960. * @param parent defines the object to serialize in
  90961. * @returns the serialized object
  90962. */
  90963. serialize(parent: any): any;
  90964. }
  90965. /**
  90966. * This defines an action responsible to run code (external event) once triggered.
  90967. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90968. */
  90969. export class ExecuteCodeAction extends Action {
  90970. /**
  90971. * The callback function to run.
  90972. */
  90973. func: (evt: ActionEvent) => void;
  90974. /**
  90975. * Instantiate the action
  90976. * @param triggerOptions defines the trigger options
  90977. * @param func defines the callback function to run
  90978. * @param condition defines the trigger related conditions
  90979. */
  90980. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  90981. /**
  90982. * Execute the action and run the attached code.
  90983. */
  90984. execute(evt: ActionEvent): void;
  90985. }
  90986. /**
  90987. * This defines an action responsible to set the parent property of the target once triggered.
  90988. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90989. */
  90990. export class SetParentAction extends Action {
  90991. private _parent;
  90992. private _target;
  90993. /**
  90994. * Instantiate the action
  90995. * @param triggerOptions defines the trigger options
  90996. * @param target defines the target containing the parent property
  90997. * @param parent defines from where the animation should start (animation frame)
  90998. * @param condition defines the trigger related conditions
  90999. */
  91000. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  91001. /** @hidden */
  91002. _prepare(): void;
  91003. /**
  91004. * Execute the action and set the parent property.
  91005. */
  91006. execute(): void;
  91007. /**
  91008. * Serializes the actions and its related information.
  91009. * @param parent defines the object to serialize in
  91010. * @returns the serialized object
  91011. */
  91012. serialize(parent: any): any;
  91013. }
  91014. }
  91015. declare module BABYLON {
  91016. /**
  91017. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  91018. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  91019. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91020. */
  91021. export class ActionManager extends AbstractActionManager {
  91022. /**
  91023. * Nothing
  91024. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91025. */
  91026. static readonly NothingTrigger: number;
  91027. /**
  91028. * On pick
  91029. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91030. */
  91031. static readonly OnPickTrigger: number;
  91032. /**
  91033. * On left pick
  91034. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91035. */
  91036. static readonly OnLeftPickTrigger: number;
  91037. /**
  91038. * On right pick
  91039. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91040. */
  91041. static readonly OnRightPickTrigger: number;
  91042. /**
  91043. * On center pick
  91044. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91045. */
  91046. static readonly OnCenterPickTrigger: number;
  91047. /**
  91048. * On pick down
  91049. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91050. */
  91051. static readonly OnPickDownTrigger: number;
  91052. /**
  91053. * On double pick
  91054. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91055. */
  91056. static readonly OnDoublePickTrigger: number;
  91057. /**
  91058. * On pick up
  91059. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91060. */
  91061. static readonly OnPickUpTrigger: number;
  91062. /**
  91063. * On pick out.
  91064. * This trigger will only be raised if you also declared a OnPickDown
  91065. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91066. */
  91067. static readonly OnPickOutTrigger: number;
  91068. /**
  91069. * On long press
  91070. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91071. */
  91072. static readonly OnLongPressTrigger: number;
  91073. /**
  91074. * On pointer over
  91075. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91076. */
  91077. static readonly OnPointerOverTrigger: number;
  91078. /**
  91079. * On pointer out
  91080. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91081. */
  91082. static readonly OnPointerOutTrigger: number;
  91083. /**
  91084. * On every frame
  91085. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91086. */
  91087. static readonly OnEveryFrameTrigger: number;
  91088. /**
  91089. * On intersection enter
  91090. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91091. */
  91092. static readonly OnIntersectionEnterTrigger: number;
  91093. /**
  91094. * On intersection exit
  91095. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91096. */
  91097. static readonly OnIntersectionExitTrigger: number;
  91098. /**
  91099. * On key down
  91100. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91101. */
  91102. static readonly OnKeyDownTrigger: number;
  91103. /**
  91104. * On key up
  91105. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91106. */
  91107. static readonly OnKeyUpTrigger: number;
  91108. private _scene;
  91109. /**
  91110. * Creates a new action manager
  91111. * @param scene defines the hosting scene
  91112. */
  91113. constructor(scene: Scene);
  91114. /**
  91115. * Releases all associated resources
  91116. */
  91117. dispose(): void;
  91118. /**
  91119. * Gets hosting scene
  91120. * @returns the hosting scene
  91121. */
  91122. getScene(): Scene;
  91123. /**
  91124. * Does this action manager handles actions of any of the given triggers
  91125. * @param triggers defines the triggers to be tested
  91126. * @return a boolean indicating whether one (or more) of the triggers is handled
  91127. */
  91128. hasSpecificTriggers(triggers: number[]): boolean;
  91129. /**
  91130. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  91131. * speed.
  91132. * @param triggerA defines the trigger to be tested
  91133. * @param triggerB defines the trigger to be tested
  91134. * @return a boolean indicating whether one (or more) of the triggers is handled
  91135. */
  91136. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  91137. /**
  91138. * Does this action manager handles actions of a given trigger
  91139. * @param trigger defines the trigger to be tested
  91140. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  91141. * @return whether the trigger is handled
  91142. */
  91143. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  91144. /**
  91145. * Does this action manager has pointer triggers
  91146. */
  91147. get hasPointerTriggers(): boolean;
  91148. /**
  91149. * Does this action manager has pick triggers
  91150. */
  91151. get hasPickTriggers(): boolean;
  91152. /**
  91153. * Registers an action to this action manager
  91154. * @param action defines the action to be registered
  91155. * @return the action amended (prepared) after registration
  91156. */
  91157. registerAction(action: IAction): Nullable<IAction>;
  91158. /**
  91159. * Unregisters an action to this action manager
  91160. * @param action defines the action to be unregistered
  91161. * @return a boolean indicating whether the action has been unregistered
  91162. */
  91163. unregisterAction(action: IAction): Boolean;
  91164. /**
  91165. * Process a specific trigger
  91166. * @param trigger defines the trigger to process
  91167. * @param evt defines the event details to be processed
  91168. */
  91169. processTrigger(trigger: number, evt?: IActionEvent): void;
  91170. /** @hidden */
  91171. _getEffectiveTarget(target: any, propertyPath: string): any;
  91172. /** @hidden */
  91173. _getProperty(propertyPath: string): string;
  91174. /**
  91175. * Serialize this manager to a JSON object
  91176. * @param name defines the property name to store this manager
  91177. * @returns a JSON representation of this manager
  91178. */
  91179. serialize(name: string): any;
  91180. /**
  91181. * Creates a new ActionManager from a JSON data
  91182. * @param parsedActions defines the JSON data to read from
  91183. * @param object defines the hosting mesh
  91184. * @param scene defines the hosting scene
  91185. */
  91186. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  91187. /**
  91188. * Get a trigger name by index
  91189. * @param trigger defines the trigger index
  91190. * @returns a trigger name
  91191. */
  91192. static GetTriggerName(trigger: number): string;
  91193. }
  91194. }
  91195. declare module BABYLON {
  91196. /**
  91197. * Class used to represent a sprite
  91198. * @see http://doc.babylonjs.com/babylon101/sprites
  91199. */
  91200. export class Sprite {
  91201. /** defines the name */
  91202. name: string;
  91203. /** Gets or sets the current world position */
  91204. position: Vector3;
  91205. /** Gets or sets the main color */
  91206. color: Color4;
  91207. /** Gets or sets the width */
  91208. width: number;
  91209. /** Gets or sets the height */
  91210. height: number;
  91211. /** Gets or sets rotation angle */
  91212. angle: number;
  91213. /** Gets or sets the cell index in the sprite sheet */
  91214. cellIndex: number;
  91215. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  91216. cellRef: string;
  91217. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  91218. invertU: number;
  91219. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  91220. invertV: number;
  91221. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  91222. disposeWhenFinishedAnimating: boolean;
  91223. /** Gets the list of attached animations */
  91224. animations: Animation[];
  91225. /** Gets or sets a boolean indicating if the sprite can be picked */
  91226. isPickable: boolean;
  91227. /**
  91228. * Gets or sets the associated action manager
  91229. */
  91230. actionManager: Nullable<ActionManager>;
  91231. private _animationStarted;
  91232. private _loopAnimation;
  91233. private _fromIndex;
  91234. private _toIndex;
  91235. private _delay;
  91236. private _direction;
  91237. private _manager;
  91238. private _time;
  91239. private _onAnimationEnd;
  91240. /**
  91241. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  91242. */
  91243. isVisible: boolean;
  91244. /**
  91245. * Gets or sets the sprite size
  91246. */
  91247. get size(): number;
  91248. set size(value: number);
  91249. /**
  91250. * Creates a new Sprite
  91251. * @param name defines the name
  91252. * @param manager defines the manager
  91253. */
  91254. constructor(
  91255. /** defines the name */
  91256. name: string, manager: ISpriteManager);
  91257. /**
  91258. * Starts an animation
  91259. * @param from defines the initial key
  91260. * @param to defines the end key
  91261. * @param loop defines if the animation must loop
  91262. * @param delay defines the start delay (in ms)
  91263. * @param onAnimationEnd defines a callback to call when animation ends
  91264. */
  91265. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  91266. /** Stops current animation (if any) */
  91267. stopAnimation(): void;
  91268. /** @hidden */
  91269. _animate(deltaTime: number): void;
  91270. /** Release associated resources */
  91271. dispose(): void;
  91272. }
  91273. }
  91274. declare module BABYLON {
  91275. /**
  91276. * Information about the result of picking within a scene
  91277. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  91278. */
  91279. export class PickingInfo {
  91280. /** @hidden */
  91281. _pickingUnavailable: boolean;
  91282. /**
  91283. * If the pick collided with an object
  91284. */
  91285. hit: boolean;
  91286. /**
  91287. * Distance away where the pick collided
  91288. */
  91289. distance: number;
  91290. /**
  91291. * The location of pick collision
  91292. */
  91293. pickedPoint: Nullable<Vector3>;
  91294. /**
  91295. * The mesh corresponding the the pick collision
  91296. */
  91297. pickedMesh: Nullable<AbstractMesh>;
  91298. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  91299. bu: number;
  91300. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  91301. bv: number;
  91302. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  91303. faceId: number;
  91304. /** Id of the the submesh that was picked */
  91305. subMeshId: number;
  91306. /** If a sprite was picked, this will be the sprite the pick collided with */
  91307. pickedSprite: Nullable<Sprite>;
  91308. /**
  91309. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  91310. */
  91311. originMesh: Nullable<AbstractMesh>;
  91312. /**
  91313. * The ray that was used to perform the picking.
  91314. */
  91315. ray: Nullable<Ray>;
  91316. /**
  91317. * Gets the normal correspodning to the face the pick collided with
  91318. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  91319. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  91320. * @returns The normal correspodning to the face the pick collided with
  91321. */
  91322. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  91323. /**
  91324. * Gets the texture coordinates of where the pick occured
  91325. * @returns the vector containing the coordnates of the texture
  91326. */
  91327. getTextureCoordinates(): Nullable<Vector2>;
  91328. }
  91329. }
  91330. declare module BABYLON {
  91331. /**
  91332. * Gather the list of pointer event types as constants.
  91333. */
  91334. export class PointerEventTypes {
  91335. /**
  91336. * 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.
  91337. */
  91338. static readonly POINTERDOWN: number;
  91339. /**
  91340. * The pointerup event is fired when a pointer is no longer active.
  91341. */
  91342. static readonly POINTERUP: number;
  91343. /**
  91344. * The pointermove event is fired when a pointer changes coordinates.
  91345. */
  91346. static readonly POINTERMOVE: number;
  91347. /**
  91348. * The pointerwheel event is fired when a mouse wheel has been rotated.
  91349. */
  91350. static readonly POINTERWHEEL: number;
  91351. /**
  91352. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  91353. */
  91354. static readonly POINTERPICK: number;
  91355. /**
  91356. * The pointertap event is fired when a the object has been touched and released without drag.
  91357. */
  91358. static readonly POINTERTAP: number;
  91359. /**
  91360. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  91361. */
  91362. static readonly POINTERDOUBLETAP: number;
  91363. }
  91364. /**
  91365. * Base class of pointer info types.
  91366. */
  91367. export class PointerInfoBase {
  91368. /**
  91369. * Defines the type of event (PointerEventTypes)
  91370. */
  91371. type: number;
  91372. /**
  91373. * Defines the related dom event
  91374. */
  91375. event: PointerEvent | MouseWheelEvent;
  91376. /**
  91377. * Instantiates the base class of pointers info.
  91378. * @param type Defines the type of event (PointerEventTypes)
  91379. * @param event Defines the related dom event
  91380. */
  91381. constructor(
  91382. /**
  91383. * Defines the type of event (PointerEventTypes)
  91384. */
  91385. type: number,
  91386. /**
  91387. * Defines the related dom event
  91388. */
  91389. event: PointerEvent | MouseWheelEvent);
  91390. }
  91391. /**
  91392. * This class is used to store pointer related info for the onPrePointerObservable event.
  91393. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  91394. */
  91395. export class PointerInfoPre extends PointerInfoBase {
  91396. /**
  91397. * Ray from a pointer if availible (eg. 6dof controller)
  91398. */
  91399. ray: Nullable<Ray>;
  91400. /**
  91401. * Defines the local position of the pointer on the canvas.
  91402. */
  91403. localPosition: Vector2;
  91404. /**
  91405. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  91406. */
  91407. skipOnPointerObservable: boolean;
  91408. /**
  91409. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  91410. * @param type Defines the type of event (PointerEventTypes)
  91411. * @param event Defines the related dom event
  91412. * @param localX Defines the local x coordinates of the pointer when the event occured
  91413. * @param localY Defines the local y coordinates of the pointer when the event occured
  91414. */
  91415. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  91416. }
  91417. /**
  91418. * This type contains all the data related to a pointer event in Babylon.js.
  91419. * 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.
  91420. */
  91421. export class PointerInfo extends PointerInfoBase {
  91422. /**
  91423. * Defines the picking info associated to the info (if any)\
  91424. */
  91425. pickInfo: Nullable<PickingInfo>;
  91426. /**
  91427. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  91428. * @param type Defines the type of event (PointerEventTypes)
  91429. * @param event Defines the related dom event
  91430. * @param pickInfo Defines the picking info associated to the info (if any)\
  91431. */
  91432. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  91433. /**
  91434. * Defines the picking info associated to the info (if any)\
  91435. */
  91436. pickInfo: Nullable<PickingInfo>);
  91437. }
  91438. /**
  91439. * Data relating to a touch event on the screen.
  91440. */
  91441. export interface PointerTouch {
  91442. /**
  91443. * X coordinate of touch.
  91444. */
  91445. x: number;
  91446. /**
  91447. * Y coordinate of touch.
  91448. */
  91449. y: number;
  91450. /**
  91451. * Id of touch. Unique for each finger.
  91452. */
  91453. pointerId: number;
  91454. /**
  91455. * Event type passed from DOM.
  91456. */
  91457. type: any;
  91458. }
  91459. }
  91460. declare module BABYLON {
  91461. /**
  91462. * Manage the mouse inputs to control the movement of a free camera.
  91463. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91464. */
  91465. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  91466. /**
  91467. * Define if touch is enabled in the mouse input
  91468. */
  91469. touchEnabled: boolean;
  91470. /**
  91471. * Defines the camera the input is attached to.
  91472. */
  91473. camera: FreeCamera;
  91474. /**
  91475. * Defines the buttons associated with the input to handle camera move.
  91476. */
  91477. buttons: number[];
  91478. /**
  91479. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  91480. */
  91481. angularSensibility: number;
  91482. private _pointerInput;
  91483. private _onMouseMove;
  91484. private _observer;
  91485. private previousPosition;
  91486. /**
  91487. * Observable for when a pointer move event occurs containing the move offset
  91488. */
  91489. onPointerMovedObservable: Observable<{
  91490. offsetX: number;
  91491. offsetY: number;
  91492. }>;
  91493. /**
  91494. * @hidden
  91495. * If the camera should be rotated automatically based on pointer movement
  91496. */
  91497. _allowCameraRotation: boolean;
  91498. /**
  91499. * Manage the mouse inputs to control the movement of a free camera.
  91500. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91501. * @param touchEnabled Defines if touch is enabled or not
  91502. */
  91503. constructor(
  91504. /**
  91505. * Define if touch is enabled in the mouse input
  91506. */
  91507. touchEnabled?: boolean);
  91508. /**
  91509. * Attach the input controls to a specific dom element to get the input from.
  91510. * @param element Defines the element the controls should be listened from
  91511. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91512. */
  91513. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91514. /**
  91515. * Called on JS contextmenu event.
  91516. * Override this method to provide functionality.
  91517. */
  91518. protected onContextMenu(evt: PointerEvent): void;
  91519. /**
  91520. * Detach the current controls from the specified dom element.
  91521. * @param element Defines the element to stop listening the inputs from
  91522. */
  91523. detachControl(element: Nullable<HTMLElement>): void;
  91524. /**
  91525. * Gets the class name of the current intput.
  91526. * @returns the class name
  91527. */
  91528. getClassName(): string;
  91529. /**
  91530. * Get the friendly name associated with the input class.
  91531. * @returns the input friendly name
  91532. */
  91533. getSimpleName(): string;
  91534. }
  91535. }
  91536. declare module BABYLON {
  91537. /**
  91538. * Manage the touch inputs to control the movement of a free camera.
  91539. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91540. */
  91541. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  91542. /**
  91543. * Defines the camera the input is attached to.
  91544. */
  91545. camera: FreeCamera;
  91546. /**
  91547. * Defines the touch sensibility for rotation.
  91548. * The higher the faster.
  91549. */
  91550. touchAngularSensibility: number;
  91551. /**
  91552. * Defines the touch sensibility for move.
  91553. * The higher the faster.
  91554. */
  91555. touchMoveSensibility: number;
  91556. private _offsetX;
  91557. private _offsetY;
  91558. private _pointerPressed;
  91559. private _pointerInput;
  91560. private _observer;
  91561. private _onLostFocus;
  91562. /**
  91563. * Attach the input controls to a specific dom element to get the input from.
  91564. * @param element Defines the element the controls should be listened from
  91565. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91566. */
  91567. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91568. /**
  91569. * Detach the current controls from the specified dom element.
  91570. * @param element Defines the element to stop listening the inputs from
  91571. */
  91572. detachControl(element: Nullable<HTMLElement>): void;
  91573. /**
  91574. * Update the current camera state depending on the inputs that have been used this frame.
  91575. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91576. */
  91577. checkInputs(): void;
  91578. /**
  91579. * Gets the class name of the current intput.
  91580. * @returns the class name
  91581. */
  91582. getClassName(): string;
  91583. /**
  91584. * Get the friendly name associated with the input class.
  91585. * @returns the input friendly name
  91586. */
  91587. getSimpleName(): string;
  91588. }
  91589. }
  91590. declare module BABYLON {
  91591. /**
  91592. * Default Inputs manager for the FreeCamera.
  91593. * It groups all the default supported inputs for ease of use.
  91594. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91595. */
  91596. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  91597. /**
  91598. * @hidden
  91599. */
  91600. _mouseInput: Nullable<FreeCameraMouseInput>;
  91601. /**
  91602. * Instantiates a new FreeCameraInputsManager.
  91603. * @param camera Defines the camera the inputs belong to
  91604. */
  91605. constructor(camera: FreeCamera);
  91606. /**
  91607. * Add keyboard input support to the input manager.
  91608. * @returns the current input manager
  91609. */
  91610. addKeyboard(): FreeCameraInputsManager;
  91611. /**
  91612. * Add mouse input support to the input manager.
  91613. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  91614. * @returns the current input manager
  91615. */
  91616. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  91617. /**
  91618. * Removes the mouse input support from the manager
  91619. * @returns the current input manager
  91620. */
  91621. removeMouse(): FreeCameraInputsManager;
  91622. /**
  91623. * Add touch input support to the input manager.
  91624. * @returns the current input manager
  91625. */
  91626. addTouch(): FreeCameraInputsManager;
  91627. /**
  91628. * Remove all attached input methods from a camera
  91629. */
  91630. clear(): void;
  91631. }
  91632. }
  91633. declare module BABYLON {
  91634. /**
  91635. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  91636. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  91637. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  91638. */
  91639. export class FreeCamera extends TargetCamera {
  91640. /**
  91641. * Define the collision ellipsoid of the camera.
  91642. * This is helpful to simulate a camera body like the player body around the camera
  91643. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  91644. */
  91645. ellipsoid: Vector3;
  91646. /**
  91647. * Define an offset for the position of the ellipsoid around the camera.
  91648. * This can be helpful to determine the center of the body near the gravity center of the body
  91649. * instead of its head.
  91650. */
  91651. ellipsoidOffset: Vector3;
  91652. /**
  91653. * Enable or disable collisions of the camera with the rest of the scene objects.
  91654. */
  91655. checkCollisions: boolean;
  91656. /**
  91657. * Enable or disable gravity on the camera.
  91658. */
  91659. applyGravity: boolean;
  91660. /**
  91661. * Define the input manager associated to the camera.
  91662. */
  91663. inputs: FreeCameraInputsManager;
  91664. /**
  91665. * Gets the input sensibility for a mouse input. (default is 2000.0)
  91666. * Higher values reduce sensitivity.
  91667. */
  91668. get angularSensibility(): number;
  91669. /**
  91670. * Sets the input sensibility for a mouse input. (default is 2000.0)
  91671. * Higher values reduce sensitivity.
  91672. */
  91673. set angularSensibility(value: number);
  91674. /**
  91675. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  91676. */
  91677. get keysUp(): number[];
  91678. set keysUp(value: number[]);
  91679. /**
  91680. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  91681. */
  91682. get keysDown(): number[];
  91683. set keysDown(value: number[]);
  91684. /**
  91685. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  91686. */
  91687. get keysLeft(): number[];
  91688. set keysLeft(value: number[]);
  91689. /**
  91690. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  91691. */
  91692. get keysRight(): number[];
  91693. set keysRight(value: number[]);
  91694. /**
  91695. * Event raised when the camera collide with a mesh in the scene.
  91696. */
  91697. onCollide: (collidedMesh: AbstractMesh) => void;
  91698. private _collider;
  91699. private _needMoveForGravity;
  91700. private _oldPosition;
  91701. private _diffPosition;
  91702. private _newPosition;
  91703. /** @hidden */
  91704. _localDirection: Vector3;
  91705. /** @hidden */
  91706. _transformedDirection: Vector3;
  91707. /**
  91708. * Instantiates a Free Camera.
  91709. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  91710. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  91711. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  91712. * @param name Define the name of the camera in the scene
  91713. * @param position Define the start position of the camera in the scene
  91714. * @param scene Define the scene the camera belongs to
  91715. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  91716. */
  91717. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  91718. /**
  91719. * Attached controls to the current camera.
  91720. * @param element Defines the element the controls should be listened from
  91721. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91722. */
  91723. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91724. /**
  91725. * Detach the current controls from the camera.
  91726. * The camera will stop reacting to inputs.
  91727. * @param element Defines the element to stop listening the inputs from
  91728. */
  91729. detachControl(element: HTMLElement): void;
  91730. private _collisionMask;
  91731. /**
  91732. * Define a collision mask to limit the list of object the camera can collide with
  91733. */
  91734. get collisionMask(): number;
  91735. set collisionMask(mask: number);
  91736. /** @hidden */
  91737. _collideWithWorld(displacement: Vector3): void;
  91738. private _onCollisionPositionChange;
  91739. /** @hidden */
  91740. _checkInputs(): void;
  91741. /** @hidden */
  91742. _decideIfNeedsToMove(): boolean;
  91743. /** @hidden */
  91744. _updatePosition(): void;
  91745. /**
  91746. * Destroy the camera and release the current resources hold by it.
  91747. */
  91748. dispose(): void;
  91749. /**
  91750. * Gets the current object class name.
  91751. * @return the class name
  91752. */
  91753. getClassName(): string;
  91754. }
  91755. }
  91756. declare module BABYLON {
  91757. /**
  91758. * Represents a gamepad control stick position
  91759. */
  91760. export class StickValues {
  91761. /**
  91762. * The x component of the control stick
  91763. */
  91764. x: number;
  91765. /**
  91766. * The y component of the control stick
  91767. */
  91768. y: number;
  91769. /**
  91770. * Initializes the gamepad x and y control stick values
  91771. * @param x The x component of the gamepad control stick value
  91772. * @param y The y component of the gamepad control stick value
  91773. */
  91774. constructor(
  91775. /**
  91776. * The x component of the control stick
  91777. */
  91778. x: number,
  91779. /**
  91780. * The y component of the control stick
  91781. */
  91782. y: number);
  91783. }
  91784. /**
  91785. * An interface which manages callbacks for gamepad button changes
  91786. */
  91787. export interface GamepadButtonChanges {
  91788. /**
  91789. * Called when a gamepad has been changed
  91790. */
  91791. changed: boolean;
  91792. /**
  91793. * Called when a gamepad press event has been triggered
  91794. */
  91795. pressChanged: boolean;
  91796. /**
  91797. * Called when a touch event has been triggered
  91798. */
  91799. touchChanged: boolean;
  91800. /**
  91801. * Called when a value has changed
  91802. */
  91803. valueChanged: boolean;
  91804. }
  91805. /**
  91806. * Represents a gamepad
  91807. */
  91808. export class Gamepad {
  91809. /**
  91810. * The id of the gamepad
  91811. */
  91812. id: string;
  91813. /**
  91814. * The index of the gamepad
  91815. */
  91816. index: number;
  91817. /**
  91818. * The browser gamepad
  91819. */
  91820. browserGamepad: any;
  91821. /**
  91822. * Specifies what type of gamepad this represents
  91823. */
  91824. type: number;
  91825. private _leftStick;
  91826. private _rightStick;
  91827. /** @hidden */
  91828. _isConnected: boolean;
  91829. private _leftStickAxisX;
  91830. private _leftStickAxisY;
  91831. private _rightStickAxisX;
  91832. private _rightStickAxisY;
  91833. /**
  91834. * Triggered when the left control stick has been changed
  91835. */
  91836. private _onleftstickchanged;
  91837. /**
  91838. * Triggered when the right control stick has been changed
  91839. */
  91840. private _onrightstickchanged;
  91841. /**
  91842. * Represents a gamepad controller
  91843. */
  91844. static GAMEPAD: number;
  91845. /**
  91846. * Represents a generic controller
  91847. */
  91848. static GENERIC: number;
  91849. /**
  91850. * Represents an XBox controller
  91851. */
  91852. static XBOX: number;
  91853. /**
  91854. * Represents a pose-enabled controller
  91855. */
  91856. static POSE_ENABLED: number;
  91857. /**
  91858. * Represents an Dual Shock controller
  91859. */
  91860. static DUALSHOCK: number;
  91861. /**
  91862. * Specifies whether the left control stick should be Y-inverted
  91863. */
  91864. protected _invertLeftStickY: boolean;
  91865. /**
  91866. * Specifies if the gamepad has been connected
  91867. */
  91868. get isConnected(): boolean;
  91869. /**
  91870. * Initializes the gamepad
  91871. * @param id The id of the gamepad
  91872. * @param index The index of the gamepad
  91873. * @param browserGamepad The browser gamepad
  91874. * @param leftStickX The x component of the left joystick
  91875. * @param leftStickY The y component of the left joystick
  91876. * @param rightStickX The x component of the right joystick
  91877. * @param rightStickY The y component of the right joystick
  91878. */
  91879. constructor(
  91880. /**
  91881. * The id of the gamepad
  91882. */
  91883. id: string,
  91884. /**
  91885. * The index of the gamepad
  91886. */
  91887. index: number,
  91888. /**
  91889. * The browser gamepad
  91890. */
  91891. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  91892. /**
  91893. * Callback triggered when the left joystick has changed
  91894. * @param callback
  91895. */
  91896. onleftstickchanged(callback: (values: StickValues) => void): void;
  91897. /**
  91898. * Callback triggered when the right joystick has changed
  91899. * @param callback
  91900. */
  91901. onrightstickchanged(callback: (values: StickValues) => void): void;
  91902. /**
  91903. * Gets the left joystick
  91904. */
  91905. get leftStick(): StickValues;
  91906. /**
  91907. * Sets the left joystick values
  91908. */
  91909. set leftStick(newValues: StickValues);
  91910. /**
  91911. * Gets the right joystick
  91912. */
  91913. get rightStick(): StickValues;
  91914. /**
  91915. * Sets the right joystick value
  91916. */
  91917. set rightStick(newValues: StickValues);
  91918. /**
  91919. * Updates the gamepad joystick positions
  91920. */
  91921. update(): void;
  91922. /**
  91923. * Disposes the gamepad
  91924. */
  91925. dispose(): void;
  91926. }
  91927. /**
  91928. * Represents a generic gamepad
  91929. */
  91930. export class GenericPad extends Gamepad {
  91931. private _buttons;
  91932. private _onbuttondown;
  91933. private _onbuttonup;
  91934. /**
  91935. * Observable triggered when a button has been pressed
  91936. */
  91937. onButtonDownObservable: Observable<number>;
  91938. /**
  91939. * Observable triggered when a button has been released
  91940. */
  91941. onButtonUpObservable: Observable<number>;
  91942. /**
  91943. * Callback triggered when a button has been pressed
  91944. * @param callback Called when a button has been pressed
  91945. */
  91946. onbuttondown(callback: (buttonPressed: number) => void): void;
  91947. /**
  91948. * Callback triggered when a button has been released
  91949. * @param callback Called when a button has been released
  91950. */
  91951. onbuttonup(callback: (buttonReleased: number) => void): void;
  91952. /**
  91953. * Initializes the generic gamepad
  91954. * @param id The id of the generic gamepad
  91955. * @param index The index of the generic gamepad
  91956. * @param browserGamepad The browser gamepad
  91957. */
  91958. constructor(id: string, index: number, browserGamepad: any);
  91959. private _setButtonValue;
  91960. /**
  91961. * Updates the generic gamepad
  91962. */
  91963. update(): void;
  91964. /**
  91965. * Disposes the generic gamepad
  91966. */
  91967. dispose(): void;
  91968. }
  91969. }
  91970. declare module BABYLON {
  91971. /**
  91972. * Defines the types of pose enabled controllers that are supported
  91973. */
  91974. export enum PoseEnabledControllerType {
  91975. /**
  91976. * HTC Vive
  91977. */
  91978. VIVE = 0,
  91979. /**
  91980. * Oculus Rift
  91981. */
  91982. OCULUS = 1,
  91983. /**
  91984. * Windows mixed reality
  91985. */
  91986. WINDOWS = 2,
  91987. /**
  91988. * Samsung gear VR
  91989. */
  91990. GEAR_VR = 3,
  91991. /**
  91992. * Google Daydream
  91993. */
  91994. DAYDREAM = 4,
  91995. /**
  91996. * Generic
  91997. */
  91998. GENERIC = 5
  91999. }
  92000. /**
  92001. * Defines the MutableGamepadButton interface for the state of a gamepad button
  92002. */
  92003. export interface MutableGamepadButton {
  92004. /**
  92005. * Value of the button/trigger
  92006. */
  92007. value: number;
  92008. /**
  92009. * If the button/trigger is currently touched
  92010. */
  92011. touched: boolean;
  92012. /**
  92013. * If the button/trigger is currently pressed
  92014. */
  92015. pressed: boolean;
  92016. }
  92017. /**
  92018. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  92019. * @hidden
  92020. */
  92021. export interface ExtendedGamepadButton extends GamepadButton {
  92022. /**
  92023. * If the button/trigger is currently pressed
  92024. */
  92025. readonly pressed: boolean;
  92026. /**
  92027. * If the button/trigger is currently touched
  92028. */
  92029. readonly touched: boolean;
  92030. /**
  92031. * Value of the button/trigger
  92032. */
  92033. readonly value: number;
  92034. }
  92035. /** @hidden */
  92036. export interface _GamePadFactory {
  92037. /**
  92038. * Returns whether or not the current gamepad can be created for this type of controller.
  92039. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  92040. * @returns true if it can be created, otherwise false
  92041. */
  92042. canCreate(gamepadInfo: any): boolean;
  92043. /**
  92044. * Creates a new instance of the Gamepad.
  92045. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  92046. * @returns the new gamepad instance
  92047. */
  92048. create(gamepadInfo: any): Gamepad;
  92049. }
  92050. /**
  92051. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  92052. */
  92053. export class PoseEnabledControllerHelper {
  92054. /** @hidden */
  92055. static _ControllerFactories: _GamePadFactory[];
  92056. /** @hidden */
  92057. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  92058. /**
  92059. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  92060. * @param vrGamepad the gamepad to initialized
  92061. * @returns a vr controller of the type the gamepad identified as
  92062. */
  92063. static InitiateController(vrGamepad: any): Gamepad;
  92064. }
  92065. /**
  92066. * Defines the PoseEnabledController object that contains state of a vr capable controller
  92067. */
  92068. export class PoseEnabledController extends Gamepad implements PoseControlled {
  92069. /**
  92070. * If the controller is used in a webXR session
  92071. */
  92072. isXR: boolean;
  92073. private _deviceRoomPosition;
  92074. private _deviceRoomRotationQuaternion;
  92075. /**
  92076. * The device position in babylon space
  92077. */
  92078. devicePosition: Vector3;
  92079. /**
  92080. * The device rotation in babylon space
  92081. */
  92082. deviceRotationQuaternion: Quaternion;
  92083. /**
  92084. * The scale factor of the device in babylon space
  92085. */
  92086. deviceScaleFactor: number;
  92087. /**
  92088. * (Likely devicePosition should be used instead) The device position in its room space
  92089. */
  92090. position: Vector3;
  92091. /**
  92092. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  92093. */
  92094. rotationQuaternion: Quaternion;
  92095. /**
  92096. * The type of controller (Eg. Windows mixed reality)
  92097. */
  92098. controllerType: PoseEnabledControllerType;
  92099. protected _calculatedPosition: Vector3;
  92100. private _calculatedRotation;
  92101. /**
  92102. * The raw pose from the device
  92103. */
  92104. rawPose: DevicePose;
  92105. private _trackPosition;
  92106. private _maxRotationDistFromHeadset;
  92107. private _draggedRoomRotation;
  92108. /**
  92109. * @hidden
  92110. */
  92111. _disableTrackPosition(fixedPosition: Vector3): void;
  92112. /**
  92113. * Internal, the mesh attached to the controller
  92114. * @hidden
  92115. */
  92116. _mesh: Nullable<AbstractMesh>;
  92117. private _poseControlledCamera;
  92118. private _leftHandSystemQuaternion;
  92119. /**
  92120. * Internal, matrix used to convert room space to babylon space
  92121. * @hidden
  92122. */
  92123. _deviceToWorld: Matrix;
  92124. /**
  92125. * Node to be used when casting a ray from the controller
  92126. * @hidden
  92127. */
  92128. _pointingPoseNode: Nullable<TransformNode>;
  92129. /**
  92130. * Name of the child mesh that can be used to cast a ray from the controller
  92131. */
  92132. static readonly POINTING_POSE: string;
  92133. /**
  92134. * Creates a new PoseEnabledController from a gamepad
  92135. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  92136. */
  92137. constructor(browserGamepad: any);
  92138. private _workingMatrix;
  92139. /**
  92140. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  92141. */
  92142. update(): void;
  92143. /**
  92144. * Updates only the pose device and mesh without doing any button event checking
  92145. */
  92146. protected _updatePoseAndMesh(): void;
  92147. /**
  92148. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  92149. * @param poseData raw pose fromthe device
  92150. */
  92151. updateFromDevice(poseData: DevicePose): void;
  92152. /**
  92153. * @hidden
  92154. */
  92155. _meshAttachedObservable: Observable<AbstractMesh>;
  92156. /**
  92157. * Attaches a mesh to the controller
  92158. * @param mesh the mesh to be attached
  92159. */
  92160. attachToMesh(mesh: AbstractMesh): void;
  92161. /**
  92162. * Attaches the controllers mesh to a camera
  92163. * @param camera the camera the mesh should be attached to
  92164. */
  92165. attachToPoseControlledCamera(camera: TargetCamera): void;
  92166. /**
  92167. * Disposes of the controller
  92168. */
  92169. dispose(): void;
  92170. /**
  92171. * The mesh that is attached to the controller
  92172. */
  92173. get mesh(): Nullable<AbstractMesh>;
  92174. /**
  92175. * Gets the ray of the controller in the direction the controller is pointing
  92176. * @param length the length the resulting ray should be
  92177. * @returns a ray in the direction the controller is pointing
  92178. */
  92179. getForwardRay(length?: number): Ray;
  92180. }
  92181. }
  92182. declare module BABYLON {
  92183. /**
  92184. * Defines the WebVRController object that represents controllers tracked in 3D space
  92185. */
  92186. export abstract class WebVRController extends PoseEnabledController {
  92187. /**
  92188. * Internal, the default controller model for the controller
  92189. */
  92190. protected _defaultModel: Nullable<AbstractMesh>;
  92191. /**
  92192. * Fired when the trigger state has changed
  92193. */
  92194. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  92195. /**
  92196. * Fired when the main button state has changed
  92197. */
  92198. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  92199. /**
  92200. * Fired when the secondary button state has changed
  92201. */
  92202. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  92203. /**
  92204. * Fired when the pad state has changed
  92205. */
  92206. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  92207. /**
  92208. * Fired when controllers stick values have changed
  92209. */
  92210. onPadValuesChangedObservable: Observable<StickValues>;
  92211. /**
  92212. * Array of button availible on the controller
  92213. */
  92214. protected _buttons: Array<MutableGamepadButton>;
  92215. private _onButtonStateChange;
  92216. /**
  92217. * Fired when a controller button's state has changed
  92218. * @param callback the callback containing the button that was modified
  92219. */
  92220. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  92221. /**
  92222. * X and Y axis corresponding to the controllers joystick
  92223. */
  92224. pad: StickValues;
  92225. /**
  92226. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  92227. */
  92228. hand: string;
  92229. /**
  92230. * The default controller model for the controller
  92231. */
  92232. get defaultModel(): Nullable<AbstractMesh>;
  92233. /**
  92234. * Creates a new WebVRController from a gamepad
  92235. * @param vrGamepad the gamepad that the WebVRController should be created from
  92236. */
  92237. constructor(vrGamepad: any);
  92238. /**
  92239. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  92240. */
  92241. update(): void;
  92242. /**
  92243. * Function to be called when a button is modified
  92244. */
  92245. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  92246. /**
  92247. * Loads a mesh and attaches it to the controller
  92248. * @param scene the scene the mesh should be added to
  92249. * @param meshLoaded callback for when the mesh has been loaded
  92250. */
  92251. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  92252. private _setButtonValue;
  92253. private _changes;
  92254. private _checkChanges;
  92255. /**
  92256. * Disposes of th webVRCOntroller
  92257. */
  92258. dispose(): void;
  92259. }
  92260. }
  92261. declare module BABYLON {
  92262. /**
  92263. * The HemisphericLight simulates the ambient environment light,
  92264. * so the passed direction is the light reflection direction, not the incoming direction.
  92265. */
  92266. export class HemisphericLight extends Light {
  92267. /**
  92268. * The groundColor is the light in the opposite direction to the one specified during creation.
  92269. * 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.
  92270. */
  92271. groundColor: Color3;
  92272. /**
  92273. * The light reflection direction, not the incoming direction.
  92274. */
  92275. direction: Vector3;
  92276. /**
  92277. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  92278. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  92279. * The HemisphericLight can't cast shadows.
  92280. * Documentation : https://doc.babylonjs.com/babylon101/lights
  92281. * @param name The friendly name of the light
  92282. * @param direction The direction of the light reflection
  92283. * @param scene The scene the light belongs to
  92284. */
  92285. constructor(name: string, direction: Vector3, scene: Scene);
  92286. protected _buildUniformLayout(): void;
  92287. /**
  92288. * Returns the string "HemisphericLight".
  92289. * @return The class name
  92290. */
  92291. getClassName(): string;
  92292. /**
  92293. * Sets the HemisphericLight direction towards the passed target (Vector3).
  92294. * Returns the updated direction.
  92295. * @param target The target the direction should point to
  92296. * @return The computed direction
  92297. */
  92298. setDirectionToTarget(target: Vector3): Vector3;
  92299. /**
  92300. * Returns the shadow generator associated to the light.
  92301. * @returns Always null for hemispheric lights because it does not support shadows.
  92302. */
  92303. getShadowGenerator(): Nullable<IShadowGenerator>;
  92304. /**
  92305. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  92306. * @param effect The effect to update
  92307. * @param lightIndex The index of the light in the effect to update
  92308. * @returns The hemispheric light
  92309. */
  92310. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  92311. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  92312. /**
  92313. * Computes the world matrix of the node
  92314. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  92315. * @param useWasUpdatedFlag defines a reserved property
  92316. * @returns the world matrix
  92317. */
  92318. computeWorldMatrix(): Matrix;
  92319. /**
  92320. * Returns the integer 3.
  92321. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  92322. */
  92323. getTypeID(): number;
  92324. /**
  92325. * Prepares the list of defines specific to the light type.
  92326. * @param defines the list of defines
  92327. * @param lightIndex defines the index of the light for the effect
  92328. */
  92329. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  92330. }
  92331. }
  92332. declare module BABYLON {
  92333. /** @hidden */
  92334. export var vrMultiviewToSingleviewPixelShader: {
  92335. name: string;
  92336. shader: string;
  92337. };
  92338. }
  92339. declare module BABYLON {
  92340. /**
  92341. * Renders to multiple views with a single draw call
  92342. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  92343. */
  92344. export class MultiviewRenderTarget extends RenderTargetTexture {
  92345. /**
  92346. * Creates a multiview render target
  92347. * @param scene scene used with the render target
  92348. * @param size the size of the render target (used for each view)
  92349. */
  92350. constructor(scene: Scene, size?: number | {
  92351. width: number;
  92352. height: number;
  92353. } | {
  92354. ratio: number;
  92355. });
  92356. /**
  92357. * @hidden
  92358. * @param faceIndex the face index, if its a cube texture
  92359. */
  92360. _bindFrameBuffer(faceIndex?: number): void;
  92361. /**
  92362. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  92363. * @returns the view count
  92364. */
  92365. getViewCount(): number;
  92366. }
  92367. }
  92368. declare module BABYLON {
  92369. /**
  92370. * Represents a camera frustum
  92371. */
  92372. export class Frustum {
  92373. /**
  92374. * Gets the planes representing the frustum
  92375. * @param transform matrix to be applied to the returned planes
  92376. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  92377. */
  92378. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  92379. /**
  92380. * Gets the near frustum plane transformed by the transform matrix
  92381. * @param transform transformation matrix to be applied to the resulting frustum plane
  92382. * @param frustumPlane the resuling frustum plane
  92383. */
  92384. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92385. /**
  92386. * Gets the far frustum plane transformed by the transform matrix
  92387. * @param transform transformation matrix to be applied to the resulting frustum plane
  92388. * @param frustumPlane the resuling frustum plane
  92389. */
  92390. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92391. /**
  92392. * Gets the left frustum plane transformed by the transform matrix
  92393. * @param transform transformation matrix to be applied to the resulting frustum plane
  92394. * @param frustumPlane the resuling frustum plane
  92395. */
  92396. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92397. /**
  92398. * Gets the right frustum plane transformed by the transform matrix
  92399. * @param transform transformation matrix to be applied to the resulting frustum plane
  92400. * @param frustumPlane the resuling frustum plane
  92401. */
  92402. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92403. /**
  92404. * Gets the top frustum plane transformed by the transform matrix
  92405. * @param transform transformation matrix to be applied to the resulting frustum plane
  92406. * @param frustumPlane the resuling frustum plane
  92407. */
  92408. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92409. /**
  92410. * Gets the bottom frustum plane transformed by the transform matrix
  92411. * @param transform transformation matrix to be applied to the resulting frustum plane
  92412. * @param frustumPlane the resuling frustum plane
  92413. */
  92414. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92415. /**
  92416. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  92417. * @param transform transformation matrix to be applied to the resulting frustum planes
  92418. * @param frustumPlanes the resuling frustum planes
  92419. */
  92420. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  92421. }
  92422. }
  92423. declare module BABYLON {
  92424. interface Engine {
  92425. /**
  92426. * Creates a new multiview render target
  92427. * @param width defines the width of the texture
  92428. * @param height defines the height of the texture
  92429. * @returns the created multiview texture
  92430. */
  92431. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  92432. /**
  92433. * Binds a multiview framebuffer to be drawn to
  92434. * @param multiviewTexture texture to bind
  92435. */
  92436. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  92437. }
  92438. interface Camera {
  92439. /**
  92440. * @hidden
  92441. * 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)
  92442. */
  92443. _useMultiviewToSingleView: boolean;
  92444. /**
  92445. * @hidden
  92446. * 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)
  92447. */
  92448. _multiviewTexture: Nullable<RenderTargetTexture>;
  92449. /**
  92450. * @hidden
  92451. * ensures the multiview texture of the camera exists and has the specified width/height
  92452. * @param width height to set on the multiview texture
  92453. * @param height width to set on the multiview texture
  92454. */
  92455. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  92456. }
  92457. interface Scene {
  92458. /** @hidden */
  92459. _transformMatrixR: Matrix;
  92460. /** @hidden */
  92461. _multiviewSceneUbo: Nullable<UniformBuffer>;
  92462. /** @hidden */
  92463. _createMultiviewUbo(): void;
  92464. /** @hidden */
  92465. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  92466. /** @hidden */
  92467. _renderMultiviewToSingleView(camera: Camera): void;
  92468. }
  92469. }
  92470. declare module BABYLON {
  92471. /**
  92472. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  92473. * This will not be used for webXR as it supports displaying texture arrays directly
  92474. */
  92475. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  92476. /**
  92477. * Initializes a VRMultiviewToSingleview
  92478. * @param name name of the post process
  92479. * @param camera camera to be applied to
  92480. * @param scaleFactor scaling factor to the size of the output texture
  92481. */
  92482. constructor(name: string, camera: Camera, scaleFactor: number);
  92483. }
  92484. }
  92485. declare module BABYLON {
  92486. /**
  92487. * Interface used to define additional presentation attributes
  92488. */
  92489. export interface IVRPresentationAttributes {
  92490. /**
  92491. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  92492. */
  92493. highRefreshRate: boolean;
  92494. /**
  92495. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  92496. */
  92497. foveationLevel: number;
  92498. }
  92499. interface Engine {
  92500. /** @hidden */
  92501. _vrDisplay: any;
  92502. /** @hidden */
  92503. _vrSupported: boolean;
  92504. /** @hidden */
  92505. _oldSize: Size;
  92506. /** @hidden */
  92507. _oldHardwareScaleFactor: number;
  92508. /** @hidden */
  92509. _vrExclusivePointerMode: boolean;
  92510. /** @hidden */
  92511. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  92512. /** @hidden */
  92513. _onVRDisplayPointerRestricted: () => void;
  92514. /** @hidden */
  92515. _onVRDisplayPointerUnrestricted: () => void;
  92516. /** @hidden */
  92517. _onVrDisplayConnect: Nullable<(display: any) => void>;
  92518. /** @hidden */
  92519. _onVrDisplayDisconnect: Nullable<() => void>;
  92520. /** @hidden */
  92521. _onVrDisplayPresentChange: Nullable<() => void>;
  92522. /**
  92523. * Observable signaled when VR display mode changes
  92524. */
  92525. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  92526. /**
  92527. * Observable signaled when VR request present is complete
  92528. */
  92529. onVRRequestPresentComplete: Observable<boolean>;
  92530. /**
  92531. * Observable signaled when VR request present starts
  92532. */
  92533. onVRRequestPresentStart: Observable<Engine>;
  92534. /**
  92535. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  92536. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  92537. */
  92538. isInVRExclusivePointerMode: boolean;
  92539. /**
  92540. * Gets a boolean indicating if a webVR device was detected
  92541. * @returns true if a webVR device was detected
  92542. */
  92543. isVRDevicePresent(): boolean;
  92544. /**
  92545. * Gets the current webVR device
  92546. * @returns the current webVR device (or null)
  92547. */
  92548. getVRDevice(): any;
  92549. /**
  92550. * Initializes a webVR display and starts listening to display change events
  92551. * The onVRDisplayChangedObservable will be notified upon these changes
  92552. * @returns A promise containing a VRDisplay and if vr is supported
  92553. */
  92554. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  92555. /** @hidden */
  92556. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  92557. /**
  92558. * Gets or sets the presentation attributes used to configure VR rendering
  92559. */
  92560. vrPresentationAttributes?: IVRPresentationAttributes;
  92561. /**
  92562. * Call this function to switch to webVR mode
  92563. * Will do nothing if webVR is not supported or if there is no webVR device
  92564. * @param options the webvr options provided to the camera. mainly used for multiview
  92565. * @see http://doc.babylonjs.com/how_to/webvr_camera
  92566. */
  92567. enableVR(options: WebVROptions): void;
  92568. /** @hidden */
  92569. _onVRFullScreenTriggered(): void;
  92570. }
  92571. }
  92572. declare module BABYLON {
  92573. /**
  92574. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  92575. * IMPORTANT!! The data is right-hand data.
  92576. * @export
  92577. * @interface DevicePose
  92578. */
  92579. export interface DevicePose {
  92580. /**
  92581. * The position of the device, values in array are [x,y,z].
  92582. */
  92583. readonly position: Nullable<Float32Array>;
  92584. /**
  92585. * The linearVelocity of the device, values in array are [x,y,z].
  92586. */
  92587. readonly linearVelocity: Nullable<Float32Array>;
  92588. /**
  92589. * The linearAcceleration of the device, values in array are [x,y,z].
  92590. */
  92591. readonly linearAcceleration: Nullable<Float32Array>;
  92592. /**
  92593. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  92594. */
  92595. readonly orientation: Nullable<Float32Array>;
  92596. /**
  92597. * The angularVelocity of the device, values in array are [x,y,z].
  92598. */
  92599. readonly angularVelocity: Nullable<Float32Array>;
  92600. /**
  92601. * The angularAcceleration of the device, values in array are [x,y,z].
  92602. */
  92603. readonly angularAcceleration: Nullable<Float32Array>;
  92604. }
  92605. /**
  92606. * Interface representing a pose controlled object in Babylon.
  92607. * A pose controlled object has both regular pose values as well as pose values
  92608. * from an external device such as a VR head mounted display
  92609. */
  92610. export interface PoseControlled {
  92611. /**
  92612. * The position of the object in babylon space.
  92613. */
  92614. position: Vector3;
  92615. /**
  92616. * The rotation quaternion of the object in babylon space.
  92617. */
  92618. rotationQuaternion: Quaternion;
  92619. /**
  92620. * The position of the device in babylon space.
  92621. */
  92622. devicePosition?: Vector3;
  92623. /**
  92624. * The rotation quaternion of the device in babylon space.
  92625. */
  92626. deviceRotationQuaternion: Quaternion;
  92627. /**
  92628. * The raw pose coming from the device.
  92629. */
  92630. rawPose: Nullable<DevicePose>;
  92631. /**
  92632. * The scale of the device to be used when translating from device space to babylon space.
  92633. */
  92634. deviceScaleFactor: number;
  92635. /**
  92636. * Updates the poseControlled values based on the input device pose.
  92637. * @param poseData the pose data to update the object with
  92638. */
  92639. updateFromDevice(poseData: DevicePose): void;
  92640. }
  92641. /**
  92642. * Set of options to customize the webVRCamera
  92643. */
  92644. export interface WebVROptions {
  92645. /**
  92646. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  92647. */
  92648. trackPosition?: boolean;
  92649. /**
  92650. * Sets the scale of the vrDevice in babylon space. (default: 1)
  92651. */
  92652. positionScale?: number;
  92653. /**
  92654. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  92655. */
  92656. displayName?: string;
  92657. /**
  92658. * Should the native controller meshes be initialized. (default: true)
  92659. */
  92660. controllerMeshes?: boolean;
  92661. /**
  92662. * Creating a default HemiLight only on controllers. (default: true)
  92663. */
  92664. defaultLightingOnControllers?: boolean;
  92665. /**
  92666. * If you don't want to use the default VR button of the helper. (default: false)
  92667. */
  92668. useCustomVRButton?: boolean;
  92669. /**
  92670. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  92671. */
  92672. customVRButton?: HTMLButtonElement;
  92673. /**
  92674. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  92675. */
  92676. rayLength?: number;
  92677. /**
  92678. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  92679. */
  92680. defaultHeight?: number;
  92681. /**
  92682. * If multiview should be used if availible (default: false)
  92683. */
  92684. useMultiview?: boolean;
  92685. }
  92686. /**
  92687. * This represents a WebVR camera.
  92688. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  92689. * @example http://doc.babylonjs.com/how_to/webvr_camera
  92690. */
  92691. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  92692. private webVROptions;
  92693. /**
  92694. * @hidden
  92695. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  92696. */
  92697. _vrDevice: any;
  92698. /**
  92699. * The rawPose of the vrDevice.
  92700. */
  92701. rawPose: Nullable<DevicePose>;
  92702. private _onVREnabled;
  92703. private _specsVersion;
  92704. private _attached;
  92705. private _frameData;
  92706. protected _descendants: Array<Node>;
  92707. private _deviceRoomPosition;
  92708. /** @hidden */
  92709. _deviceRoomRotationQuaternion: Quaternion;
  92710. private _standingMatrix;
  92711. /**
  92712. * Represents device position in babylon space.
  92713. */
  92714. devicePosition: Vector3;
  92715. /**
  92716. * Represents device rotation in babylon space.
  92717. */
  92718. deviceRotationQuaternion: Quaternion;
  92719. /**
  92720. * The scale of the device to be used when translating from device space to babylon space.
  92721. */
  92722. deviceScaleFactor: number;
  92723. private _deviceToWorld;
  92724. private _worldToDevice;
  92725. /**
  92726. * References to the webVR controllers for the vrDevice.
  92727. */
  92728. controllers: Array<WebVRController>;
  92729. /**
  92730. * Emits an event when a controller is attached.
  92731. */
  92732. onControllersAttachedObservable: Observable<WebVRController[]>;
  92733. /**
  92734. * Emits an event when a controller's mesh has been loaded;
  92735. */
  92736. onControllerMeshLoadedObservable: Observable<WebVRController>;
  92737. /**
  92738. * Emits an event when the HMD's pose has been updated.
  92739. */
  92740. onPoseUpdatedFromDeviceObservable: Observable<any>;
  92741. private _poseSet;
  92742. /**
  92743. * If the rig cameras be used as parent instead of this camera.
  92744. */
  92745. rigParenting: boolean;
  92746. private _lightOnControllers;
  92747. private _defaultHeight?;
  92748. /**
  92749. * Instantiates a WebVRFreeCamera.
  92750. * @param name The name of the WebVRFreeCamera
  92751. * @param position The starting anchor position for the camera
  92752. * @param scene The scene the camera belongs to
  92753. * @param webVROptions a set of customizable options for the webVRCamera
  92754. */
  92755. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  92756. /**
  92757. * Gets the device distance from the ground in meters.
  92758. * @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.
  92759. */
  92760. deviceDistanceToRoomGround(): number;
  92761. /**
  92762. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  92763. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  92764. */
  92765. useStandingMatrix(callback?: (bool: boolean) => void): void;
  92766. /**
  92767. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  92768. * @returns A promise with a boolean set to if the standing matrix is supported.
  92769. */
  92770. useStandingMatrixAsync(): Promise<boolean>;
  92771. /**
  92772. * Disposes the camera
  92773. */
  92774. dispose(): void;
  92775. /**
  92776. * Gets a vrController by name.
  92777. * @param name The name of the controller to retreive
  92778. * @returns the controller matching the name specified or null if not found
  92779. */
  92780. getControllerByName(name: string): Nullable<WebVRController>;
  92781. private _leftController;
  92782. /**
  92783. * The controller corresponding to the users left hand.
  92784. */
  92785. get leftController(): Nullable<WebVRController>;
  92786. private _rightController;
  92787. /**
  92788. * The controller corresponding to the users right hand.
  92789. */
  92790. get rightController(): Nullable<WebVRController>;
  92791. /**
  92792. * Casts a ray forward from the vrCamera's gaze.
  92793. * @param length Length of the ray (default: 100)
  92794. * @returns the ray corresponding to the gaze
  92795. */
  92796. getForwardRay(length?: number): Ray;
  92797. /**
  92798. * @hidden
  92799. * Updates the camera based on device's frame data
  92800. */
  92801. _checkInputs(): void;
  92802. /**
  92803. * Updates the poseControlled values based on the input device pose.
  92804. * @param poseData Pose coming from the device
  92805. */
  92806. updateFromDevice(poseData: DevicePose): void;
  92807. private _htmlElementAttached;
  92808. private _detachIfAttached;
  92809. /**
  92810. * WebVR's attach control will start broadcasting frames to the device.
  92811. * Note that in certain browsers (chrome for example) this function must be called
  92812. * within a user-interaction callback. Example:
  92813. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  92814. *
  92815. * @param element html element to attach the vrDevice to
  92816. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  92817. */
  92818. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92819. /**
  92820. * Detaches the camera from the html element and disables VR
  92821. *
  92822. * @param element html element to detach from
  92823. */
  92824. detachControl(element: HTMLElement): void;
  92825. /**
  92826. * @returns the name of this class
  92827. */
  92828. getClassName(): string;
  92829. /**
  92830. * Calls resetPose on the vrDisplay
  92831. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  92832. */
  92833. resetToCurrentRotation(): void;
  92834. /**
  92835. * @hidden
  92836. * Updates the rig cameras (left and right eye)
  92837. */
  92838. _updateRigCameras(): void;
  92839. private _workingVector;
  92840. private _oneVector;
  92841. private _workingMatrix;
  92842. private updateCacheCalled;
  92843. private _correctPositionIfNotTrackPosition;
  92844. /**
  92845. * @hidden
  92846. * Updates the cached values of the camera
  92847. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  92848. */
  92849. _updateCache(ignoreParentClass?: boolean): void;
  92850. /**
  92851. * @hidden
  92852. * Get current device position in babylon world
  92853. */
  92854. _computeDevicePosition(): void;
  92855. /**
  92856. * Updates the current device position and rotation in the babylon world
  92857. */
  92858. update(): void;
  92859. /**
  92860. * @hidden
  92861. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  92862. * @returns an identity matrix
  92863. */
  92864. _getViewMatrix(): Matrix;
  92865. private _tmpMatrix;
  92866. /**
  92867. * This function is called by the two RIG cameras.
  92868. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  92869. * @hidden
  92870. */
  92871. _getWebVRViewMatrix(): Matrix;
  92872. /** @hidden */
  92873. _getWebVRProjectionMatrix(): Matrix;
  92874. private _onGamepadConnectedObserver;
  92875. private _onGamepadDisconnectedObserver;
  92876. private _updateCacheWhenTrackingDisabledObserver;
  92877. /**
  92878. * Initializes the controllers and their meshes
  92879. */
  92880. initControllers(): void;
  92881. }
  92882. }
  92883. declare module BABYLON {
  92884. /**
  92885. * Size options for a post process
  92886. */
  92887. export type PostProcessOptions = {
  92888. width: number;
  92889. height: number;
  92890. };
  92891. /**
  92892. * PostProcess can be used to apply a shader to a texture after it has been rendered
  92893. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  92894. */
  92895. export class PostProcess {
  92896. /** Name of the PostProcess. */
  92897. name: string;
  92898. /**
  92899. * Gets or sets the unique id of the post process
  92900. */
  92901. uniqueId: number;
  92902. /**
  92903. * Width of the texture to apply the post process on
  92904. */
  92905. width: number;
  92906. /**
  92907. * Height of the texture to apply the post process on
  92908. */
  92909. height: number;
  92910. /**
  92911. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  92912. * @hidden
  92913. */
  92914. _outputTexture: Nullable<InternalTexture>;
  92915. /**
  92916. * Sampling mode used by the shader
  92917. * See https://doc.babylonjs.com/classes/3.1/texture
  92918. */
  92919. renderTargetSamplingMode: number;
  92920. /**
  92921. * Clear color to use when screen clearing
  92922. */
  92923. clearColor: Color4;
  92924. /**
  92925. * If the buffer needs to be cleared before applying the post process. (default: true)
  92926. * Should be set to false if shader will overwrite all previous pixels.
  92927. */
  92928. autoClear: boolean;
  92929. /**
  92930. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  92931. */
  92932. alphaMode: number;
  92933. /**
  92934. * Sets the setAlphaBlendConstants of the babylon engine
  92935. */
  92936. alphaConstants: Color4;
  92937. /**
  92938. * Animations to be used for the post processing
  92939. */
  92940. animations: Animation[];
  92941. /**
  92942. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  92943. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  92944. */
  92945. enablePixelPerfectMode: boolean;
  92946. /**
  92947. * Force the postprocess to be applied without taking in account viewport
  92948. */
  92949. forceFullscreenViewport: boolean;
  92950. /**
  92951. * List of inspectable custom properties (used by the Inspector)
  92952. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  92953. */
  92954. inspectableCustomProperties: IInspectable[];
  92955. /**
  92956. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  92957. *
  92958. * | Value | Type | Description |
  92959. * | ----- | ----------------------------------- | ----------- |
  92960. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  92961. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  92962. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  92963. *
  92964. */
  92965. scaleMode: number;
  92966. /**
  92967. * Force textures to be a power of two (default: false)
  92968. */
  92969. alwaysForcePOT: boolean;
  92970. private _samples;
  92971. /**
  92972. * Number of sample textures (default: 1)
  92973. */
  92974. get samples(): number;
  92975. set samples(n: number);
  92976. /**
  92977. * Modify the scale of the post process to be the same as the viewport (default: false)
  92978. */
  92979. adaptScaleToCurrentViewport: boolean;
  92980. private _camera;
  92981. private _scene;
  92982. private _engine;
  92983. private _options;
  92984. private _reusable;
  92985. private _textureType;
  92986. private _textureFormat;
  92987. /**
  92988. * Smart array of input and output textures for the post process.
  92989. * @hidden
  92990. */
  92991. _textures: SmartArray<InternalTexture>;
  92992. /**
  92993. * The index in _textures that corresponds to the output texture.
  92994. * @hidden
  92995. */
  92996. _currentRenderTextureInd: number;
  92997. private _effect;
  92998. private _samplers;
  92999. private _fragmentUrl;
  93000. private _vertexUrl;
  93001. private _parameters;
  93002. private _scaleRatio;
  93003. protected _indexParameters: any;
  93004. private _shareOutputWithPostProcess;
  93005. private _texelSize;
  93006. private _forcedOutputTexture;
  93007. /**
  93008. * Returns the fragment url or shader name used in the post process.
  93009. * @returns the fragment url or name in the shader store.
  93010. */
  93011. getEffectName(): string;
  93012. /**
  93013. * An event triggered when the postprocess is activated.
  93014. */
  93015. onActivateObservable: Observable<Camera>;
  93016. private _onActivateObserver;
  93017. /**
  93018. * A function that is added to the onActivateObservable
  93019. */
  93020. set onActivate(callback: Nullable<(camera: Camera) => void>);
  93021. /**
  93022. * An event triggered when the postprocess changes its size.
  93023. */
  93024. onSizeChangedObservable: Observable<PostProcess>;
  93025. private _onSizeChangedObserver;
  93026. /**
  93027. * A function that is added to the onSizeChangedObservable
  93028. */
  93029. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  93030. /**
  93031. * An event triggered when the postprocess applies its effect.
  93032. */
  93033. onApplyObservable: Observable<Effect>;
  93034. private _onApplyObserver;
  93035. /**
  93036. * A function that is added to the onApplyObservable
  93037. */
  93038. set onApply(callback: (effect: Effect) => void);
  93039. /**
  93040. * An event triggered before rendering the postprocess
  93041. */
  93042. onBeforeRenderObservable: Observable<Effect>;
  93043. private _onBeforeRenderObserver;
  93044. /**
  93045. * A function that is added to the onBeforeRenderObservable
  93046. */
  93047. set onBeforeRender(callback: (effect: Effect) => void);
  93048. /**
  93049. * An event triggered after rendering the postprocess
  93050. */
  93051. onAfterRenderObservable: Observable<Effect>;
  93052. private _onAfterRenderObserver;
  93053. /**
  93054. * A function that is added to the onAfterRenderObservable
  93055. */
  93056. set onAfterRender(callback: (efect: Effect) => void);
  93057. /**
  93058. * 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
  93059. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  93060. */
  93061. get inputTexture(): InternalTexture;
  93062. set inputTexture(value: InternalTexture);
  93063. /**
  93064. * Gets the camera which post process is applied to.
  93065. * @returns The camera the post process is applied to.
  93066. */
  93067. getCamera(): Camera;
  93068. /**
  93069. * Gets the texel size of the postprocess.
  93070. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  93071. */
  93072. get texelSize(): Vector2;
  93073. /**
  93074. * Creates a new instance PostProcess
  93075. * @param name The name of the PostProcess.
  93076. * @param fragmentUrl The url of the fragment shader to be used.
  93077. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  93078. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  93079. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  93080. * @param camera The camera to apply the render pass to.
  93081. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  93082. * @param engine The engine which the post process will be applied. (default: current engine)
  93083. * @param reusable If the post process can be reused on the same frame. (default: false)
  93084. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  93085. * @param textureType Type of textures used when performing the post process. (default: 0)
  93086. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  93087. * @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
  93088. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  93089. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  93090. */
  93091. constructor(
  93092. /** Name of the PostProcess. */
  93093. 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);
  93094. /**
  93095. * Gets a string idenfifying the name of the class
  93096. * @returns "PostProcess" string
  93097. */
  93098. getClassName(): string;
  93099. /**
  93100. * Gets the engine which this post process belongs to.
  93101. * @returns The engine the post process was enabled with.
  93102. */
  93103. getEngine(): Engine;
  93104. /**
  93105. * The effect that is created when initializing the post process.
  93106. * @returns The created effect corresponding the the postprocess.
  93107. */
  93108. getEffect(): Effect;
  93109. /**
  93110. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  93111. * @param postProcess The post process to share the output with.
  93112. * @returns This post process.
  93113. */
  93114. shareOutputWith(postProcess: PostProcess): PostProcess;
  93115. /**
  93116. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  93117. * This should be called if the post process that shares output with this post process is disabled/disposed.
  93118. */
  93119. useOwnOutput(): void;
  93120. /**
  93121. * Updates the effect with the current post process compile time values and recompiles the shader.
  93122. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  93123. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  93124. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  93125. * @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
  93126. * @param onCompiled Called when the shader has been compiled.
  93127. * @param onError Called if there is an error when compiling a shader.
  93128. */
  93129. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93130. /**
  93131. * The post process is reusable if it can be used multiple times within one frame.
  93132. * @returns If the post process is reusable
  93133. */
  93134. isReusable(): boolean;
  93135. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  93136. markTextureDirty(): void;
  93137. /**
  93138. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  93139. * 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.
  93140. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  93141. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  93142. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  93143. * @returns The target texture that was bound to be written to.
  93144. */
  93145. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  93146. /**
  93147. * If the post process is supported.
  93148. */
  93149. get isSupported(): boolean;
  93150. /**
  93151. * The aspect ratio of the output texture.
  93152. */
  93153. get aspectRatio(): number;
  93154. /**
  93155. * Get a value indicating if the post-process is ready to be used
  93156. * @returns true if the post-process is ready (shader is compiled)
  93157. */
  93158. isReady(): boolean;
  93159. /**
  93160. * Binds all textures and uniforms to the shader, this will be run on every pass.
  93161. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  93162. */
  93163. apply(): Nullable<Effect>;
  93164. private _disposeTextures;
  93165. /**
  93166. * Disposes the post process.
  93167. * @param camera The camera to dispose the post process on.
  93168. */
  93169. dispose(camera?: Camera): void;
  93170. }
  93171. }
  93172. declare module BABYLON {
  93173. /** @hidden */
  93174. export var kernelBlurVaryingDeclaration: {
  93175. name: string;
  93176. shader: string;
  93177. };
  93178. }
  93179. declare module BABYLON {
  93180. /** @hidden */
  93181. export var kernelBlurFragment: {
  93182. name: string;
  93183. shader: string;
  93184. };
  93185. }
  93186. declare module BABYLON {
  93187. /** @hidden */
  93188. export var kernelBlurFragment2: {
  93189. name: string;
  93190. shader: string;
  93191. };
  93192. }
  93193. declare module BABYLON {
  93194. /** @hidden */
  93195. export var kernelBlurPixelShader: {
  93196. name: string;
  93197. shader: string;
  93198. };
  93199. }
  93200. declare module BABYLON {
  93201. /** @hidden */
  93202. export var kernelBlurVertex: {
  93203. name: string;
  93204. shader: string;
  93205. };
  93206. }
  93207. declare module BABYLON {
  93208. /** @hidden */
  93209. export var kernelBlurVertexShader: {
  93210. name: string;
  93211. shader: string;
  93212. };
  93213. }
  93214. declare module BABYLON {
  93215. /**
  93216. * The Blur Post Process which blurs an image based on a kernel and direction.
  93217. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  93218. */
  93219. export class BlurPostProcess extends PostProcess {
  93220. /** The direction in which to blur the image. */
  93221. direction: Vector2;
  93222. private blockCompilation;
  93223. protected _kernel: number;
  93224. protected _idealKernel: number;
  93225. protected _packedFloat: boolean;
  93226. private _staticDefines;
  93227. /**
  93228. * Sets the length in pixels of the blur sample region
  93229. */
  93230. set kernel(v: number);
  93231. /**
  93232. * Gets the length in pixels of the blur sample region
  93233. */
  93234. get kernel(): number;
  93235. /**
  93236. * Sets wether or not the blur needs to unpack/repack floats
  93237. */
  93238. set packedFloat(v: boolean);
  93239. /**
  93240. * Gets wether or not the blur is unpacking/repacking floats
  93241. */
  93242. get packedFloat(): boolean;
  93243. /**
  93244. * Creates a new instance BlurPostProcess
  93245. * @param name The name of the effect.
  93246. * @param direction The direction in which to blur the image.
  93247. * @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.
  93248. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  93249. * @param camera The camera to apply the render pass to.
  93250. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  93251. * @param engine The engine which the post process will be applied. (default: current engine)
  93252. * @param reusable If the post process can be reused on the same frame. (default: false)
  93253. * @param textureType Type of textures used when performing the post process. (default: 0)
  93254. * @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)
  93255. */
  93256. constructor(name: string,
  93257. /** The direction in which to blur the image. */
  93258. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  93259. /**
  93260. * Updates the effect with the current post process compile time values and recompiles the shader.
  93261. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  93262. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  93263. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  93264. * @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
  93265. * @param onCompiled Called when the shader has been compiled.
  93266. * @param onError Called if there is an error when compiling a shader.
  93267. */
  93268. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93269. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93270. /**
  93271. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  93272. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  93273. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  93274. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  93275. * The gaps between physical kernels are compensated for in the weighting of the samples
  93276. * @param idealKernel Ideal blur kernel.
  93277. * @return Nearest best kernel.
  93278. */
  93279. protected _nearestBestKernel(idealKernel: number): number;
  93280. /**
  93281. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  93282. * @param x The point on the Gaussian distribution to sample.
  93283. * @return the value of the Gaussian function at x.
  93284. */
  93285. protected _gaussianWeight(x: number): number;
  93286. /**
  93287. * Generates a string that can be used as a floating point number in GLSL.
  93288. * @param x Value to print.
  93289. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  93290. * @return GLSL float string.
  93291. */
  93292. protected _glslFloat(x: number, decimalFigures?: number): string;
  93293. }
  93294. }
  93295. declare module BABYLON {
  93296. /**
  93297. * Mirror texture can be used to simulate the view from a mirror in a scene.
  93298. * It will dynamically be rendered every frame to adapt to the camera point of view.
  93299. * You can then easily use it as a reflectionTexture on a flat surface.
  93300. * In case the surface is not a plane, please consider relying on reflection probes.
  93301. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93302. */
  93303. export class MirrorTexture extends RenderTargetTexture {
  93304. private scene;
  93305. /**
  93306. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  93307. * 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.
  93308. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93309. */
  93310. mirrorPlane: Plane;
  93311. /**
  93312. * Define the blur ratio used to blur the reflection if needed.
  93313. */
  93314. set blurRatio(value: number);
  93315. get blurRatio(): number;
  93316. /**
  93317. * Define the adaptive blur kernel used to blur the reflection if needed.
  93318. * This will autocompute the closest best match for the `blurKernel`
  93319. */
  93320. set adaptiveBlurKernel(value: number);
  93321. /**
  93322. * Define the blur kernel used to blur the reflection if needed.
  93323. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93324. */
  93325. set blurKernel(value: number);
  93326. /**
  93327. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  93328. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93329. */
  93330. set blurKernelX(value: number);
  93331. get blurKernelX(): number;
  93332. /**
  93333. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  93334. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93335. */
  93336. set blurKernelY(value: number);
  93337. get blurKernelY(): number;
  93338. private _autoComputeBlurKernel;
  93339. protected _onRatioRescale(): void;
  93340. private _updateGammaSpace;
  93341. private _imageProcessingConfigChangeObserver;
  93342. private _transformMatrix;
  93343. private _mirrorMatrix;
  93344. private _savedViewMatrix;
  93345. private _blurX;
  93346. private _blurY;
  93347. private _adaptiveBlurKernel;
  93348. private _blurKernelX;
  93349. private _blurKernelY;
  93350. private _blurRatio;
  93351. /**
  93352. * Instantiates a Mirror Texture.
  93353. * Mirror texture can be used to simulate the view from a mirror in a scene.
  93354. * It will dynamically be rendered every frame to adapt to the camera point of view.
  93355. * You can then easily use it as a reflectionTexture on a flat surface.
  93356. * In case the surface is not a plane, please consider relying on reflection probes.
  93357. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93358. * @param name
  93359. * @param size
  93360. * @param scene
  93361. * @param generateMipMaps
  93362. * @param type
  93363. * @param samplingMode
  93364. * @param generateDepthBuffer
  93365. */
  93366. constructor(name: string, size: number | {
  93367. width: number;
  93368. height: number;
  93369. } | {
  93370. ratio: number;
  93371. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  93372. private _preparePostProcesses;
  93373. /**
  93374. * Clone the mirror texture.
  93375. * @returns the cloned texture
  93376. */
  93377. clone(): MirrorTexture;
  93378. /**
  93379. * Serialize the texture to a JSON representation you could use in Parse later on
  93380. * @returns the serialized JSON representation
  93381. */
  93382. serialize(): any;
  93383. /**
  93384. * Dispose the texture and release its associated resources.
  93385. */
  93386. dispose(): void;
  93387. }
  93388. }
  93389. declare module BABYLON {
  93390. /**
  93391. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  93392. * @see http://doc.babylonjs.com/babylon101/materials#texture
  93393. */
  93394. export class Texture extends BaseTexture {
  93395. /**
  93396. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  93397. */
  93398. static SerializeBuffers: boolean;
  93399. /** @hidden */
  93400. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  93401. /** @hidden */
  93402. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  93403. /** @hidden */
  93404. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  93405. /** nearest is mag = nearest and min = nearest and mip = linear */
  93406. static readonly NEAREST_SAMPLINGMODE: number;
  93407. /** nearest is mag = nearest and min = nearest and mip = linear */
  93408. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  93409. /** Bilinear is mag = linear and min = linear and mip = nearest */
  93410. static readonly BILINEAR_SAMPLINGMODE: number;
  93411. /** Bilinear is mag = linear and min = linear and mip = nearest */
  93412. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  93413. /** Trilinear is mag = linear and min = linear and mip = linear */
  93414. static readonly TRILINEAR_SAMPLINGMODE: number;
  93415. /** Trilinear is mag = linear and min = linear and mip = linear */
  93416. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  93417. /** mag = nearest and min = nearest and mip = nearest */
  93418. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  93419. /** mag = nearest and min = linear and mip = nearest */
  93420. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  93421. /** mag = nearest and min = linear and mip = linear */
  93422. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  93423. /** mag = nearest and min = linear and mip = none */
  93424. static readonly NEAREST_LINEAR: number;
  93425. /** mag = nearest and min = nearest and mip = none */
  93426. static readonly NEAREST_NEAREST: number;
  93427. /** mag = linear and min = nearest and mip = nearest */
  93428. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  93429. /** mag = linear and min = nearest and mip = linear */
  93430. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  93431. /** mag = linear and min = linear and mip = none */
  93432. static readonly LINEAR_LINEAR: number;
  93433. /** mag = linear and min = nearest and mip = none */
  93434. static readonly LINEAR_NEAREST: number;
  93435. /** Explicit coordinates mode */
  93436. static readonly EXPLICIT_MODE: number;
  93437. /** Spherical coordinates mode */
  93438. static readonly SPHERICAL_MODE: number;
  93439. /** Planar coordinates mode */
  93440. static readonly PLANAR_MODE: number;
  93441. /** Cubic coordinates mode */
  93442. static readonly CUBIC_MODE: number;
  93443. /** Projection coordinates mode */
  93444. static readonly PROJECTION_MODE: number;
  93445. /** Inverse Cubic coordinates mode */
  93446. static readonly SKYBOX_MODE: number;
  93447. /** Inverse Cubic coordinates mode */
  93448. static readonly INVCUBIC_MODE: number;
  93449. /** Equirectangular coordinates mode */
  93450. static readonly EQUIRECTANGULAR_MODE: number;
  93451. /** Equirectangular Fixed coordinates mode */
  93452. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  93453. /** Equirectangular Fixed Mirrored coordinates mode */
  93454. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  93455. /** Texture is not repeating outside of 0..1 UVs */
  93456. static readonly CLAMP_ADDRESSMODE: number;
  93457. /** Texture is repeating outside of 0..1 UVs */
  93458. static readonly WRAP_ADDRESSMODE: number;
  93459. /** Texture is repeating and mirrored */
  93460. static readonly MIRROR_ADDRESSMODE: number;
  93461. /**
  93462. * 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
  93463. */
  93464. static UseSerializedUrlIfAny: boolean;
  93465. /**
  93466. * Define the url of the texture.
  93467. */
  93468. url: Nullable<string>;
  93469. /**
  93470. * Define an offset on the texture to offset the u coordinates of the UVs
  93471. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  93472. */
  93473. uOffset: number;
  93474. /**
  93475. * Define an offset on the texture to offset the v coordinates of the UVs
  93476. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  93477. */
  93478. vOffset: number;
  93479. /**
  93480. * Define an offset on the texture to scale the u coordinates of the UVs
  93481. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  93482. */
  93483. uScale: number;
  93484. /**
  93485. * Define an offset on the texture to scale the v coordinates of the UVs
  93486. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  93487. */
  93488. vScale: number;
  93489. /**
  93490. * Define an offset on the texture to rotate around the u coordinates of the UVs
  93491. * @see http://doc.babylonjs.com/how_to/more_materials
  93492. */
  93493. uAng: number;
  93494. /**
  93495. * Define an offset on the texture to rotate around the v coordinates of the UVs
  93496. * @see http://doc.babylonjs.com/how_to/more_materials
  93497. */
  93498. vAng: number;
  93499. /**
  93500. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  93501. * @see http://doc.babylonjs.com/how_to/more_materials
  93502. */
  93503. wAng: number;
  93504. /**
  93505. * Defines the center of rotation (U)
  93506. */
  93507. uRotationCenter: number;
  93508. /**
  93509. * Defines the center of rotation (V)
  93510. */
  93511. vRotationCenter: number;
  93512. /**
  93513. * Defines the center of rotation (W)
  93514. */
  93515. wRotationCenter: number;
  93516. /**
  93517. * Are mip maps generated for this texture or not.
  93518. */
  93519. get noMipmap(): boolean;
  93520. /**
  93521. * List of inspectable custom properties (used by the Inspector)
  93522. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93523. */
  93524. inspectableCustomProperties: Nullable<IInspectable[]>;
  93525. private _noMipmap;
  93526. /** @hidden */
  93527. _invertY: boolean;
  93528. private _rowGenerationMatrix;
  93529. private _cachedTextureMatrix;
  93530. private _projectionModeMatrix;
  93531. private _t0;
  93532. private _t1;
  93533. private _t2;
  93534. private _cachedUOffset;
  93535. private _cachedVOffset;
  93536. private _cachedUScale;
  93537. private _cachedVScale;
  93538. private _cachedUAng;
  93539. private _cachedVAng;
  93540. private _cachedWAng;
  93541. private _cachedProjectionMatrixId;
  93542. private _cachedCoordinatesMode;
  93543. /** @hidden */
  93544. protected _initialSamplingMode: number;
  93545. /** @hidden */
  93546. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  93547. private _deleteBuffer;
  93548. protected _format: Nullable<number>;
  93549. private _delayedOnLoad;
  93550. private _delayedOnError;
  93551. private _mimeType?;
  93552. /**
  93553. * Observable triggered once the texture has been loaded.
  93554. */
  93555. onLoadObservable: Observable<Texture>;
  93556. protected _isBlocking: boolean;
  93557. /**
  93558. * Is the texture preventing material to render while loading.
  93559. * If false, a default texture will be used instead of the loading one during the preparation step.
  93560. */
  93561. set isBlocking(value: boolean);
  93562. get isBlocking(): boolean;
  93563. /**
  93564. * Get the current sampling mode associated with the texture.
  93565. */
  93566. get samplingMode(): number;
  93567. /**
  93568. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  93569. */
  93570. get invertY(): boolean;
  93571. /**
  93572. * Instantiates a new texture.
  93573. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  93574. * @see http://doc.babylonjs.com/babylon101/materials#texture
  93575. * @param url defines the url of the picture to load as a texture
  93576. * @param scene defines the scene or engine the texture will belong to
  93577. * @param noMipmap defines if the texture will require mip maps or not
  93578. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  93579. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93580. * @param onLoad defines a callback triggered when the texture has been loaded
  93581. * @param onError defines a callback triggered when an error occurred during the loading session
  93582. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  93583. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  93584. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93585. * @param mimeType defines an optional mime type information
  93586. */
  93587. 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);
  93588. /**
  93589. * Update the url (and optional buffer) of this texture if url was null during construction.
  93590. * @param url the url of the texture
  93591. * @param buffer the buffer of the texture (defaults to null)
  93592. * @param onLoad callback called when the texture is loaded (defaults to null)
  93593. */
  93594. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  93595. /**
  93596. * Finish the loading sequence of a texture flagged as delayed load.
  93597. * @hidden
  93598. */
  93599. delayLoad(): void;
  93600. private _prepareRowForTextureGeneration;
  93601. /**
  93602. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  93603. * @returns the transform matrix of the texture.
  93604. */
  93605. getTextureMatrix(uBase?: number): Matrix;
  93606. /**
  93607. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  93608. * @returns The reflection texture transform
  93609. */
  93610. getReflectionTextureMatrix(): Matrix;
  93611. /**
  93612. * Clones the texture.
  93613. * @returns the cloned texture
  93614. */
  93615. clone(): Texture;
  93616. /**
  93617. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  93618. * @returns The JSON representation of the texture
  93619. */
  93620. serialize(): any;
  93621. /**
  93622. * Get the current class name of the texture useful for serialization or dynamic coding.
  93623. * @returns "Texture"
  93624. */
  93625. getClassName(): string;
  93626. /**
  93627. * Dispose the texture and release its associated resources.
  93628. */
  93629. dispose(): void;
  93630. /**
  93631. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  93632. * @param parsedTexture Define the JSON representation of the texture
  93633. * @param scene Define the scene the parsed texture should be instantiated in
  93634. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  93635. * @returns The parsed texture if successful
  93636. */
  93637. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  93638. /**
  93639. * Creates a texture from its base 64 representation.
  93640. * @param data Define the base64 payload without the data: prefix
  93641. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  93642. * @param scene Define the scene the texture should belong to
  93643. * @param noMipmap Forces the texture to not create mip map information if true
  93644. * @param invertY define if the texture needs to be inverted on the y axis during loading
  93645. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93646. * @param onLoad define a callback triggered when the texture has been loaded
  93647. * @param onError define a callback triggered when an error occurred during the loading session
  93648. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93649. * @returns the created texture
  93650. */
  93651. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  93652. /**
  93653. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  93654. * @param data Define the base64 payload without the data: prefix
  93655. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  93656. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  93657. * @param scene Define the scene the texture should belong to
  93658. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  93659. * @param noMipmap Forces the texture to not create mip map information if true
  93660. * @param invertY define if the texture needs to be inverted on the y axis during loading
  93661. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93662. * @param onLoad define a callback triggered when the texture has been loaded
  93663. * @param onError define a callback triggered when an error occurred during the loading session
  93664. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93665. * @returns the created texture
  93666. */
  93667. 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;
  93668. }
  93669. }
  93670. declare module BABYLON {
  93671. /**
  93672. * PostProcessManager is used to manage one or more post processes or post process pipelines
  93673. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  93674. */
  93675. export class PostProcessManager {
  93676. private _scene;
  93677. private _indexBuffer;
  93678. private _vertexBuffers;
  93679. /**
  93680. * Creates a new instance PostProcess
  93681. * @param scene The scene that the post process is associated with.
  93682. */
  93683. constructor(scene: Scene);
  93684. private _prepareBuffers;
  93685. private _buildIndexBuffer;
  93686. /**
  93687. * Rebuilds the vertex buffers of the manager.
  93688. * @hidden
  93689. */
  93690. _rebuild(): void;
  93691. /**
  93692. * Prepares a frame to be run through a post process.
  93693. * @param sourceTexture The input texture to the post procesess. (default: null)
  93694. * @param postProcesses An array of post processes to be run. (default: null)
  93695. * @returns True if the post processes were able to be run.
  93696. * @hidden
  93697. */
  93698. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  93699. /**
  93700. * Manually render a set of post processes to a texture.
  93701. * @param postProcesses An array of post processes to be run.
  93702. * @param targetTexture The target texture to render to.
  93703. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  93704. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  93705. * @param lodLevel defines which lod of the texture to render to
  93706. */
  93707. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  93708. /**
  93709. * Finalize the result of the output of the postprocesses.
  93710. * @param doNotPresent If true the result will not be displayed to the screen.
  93711. * @param targetTexture The target texture to render to.
  93712. * @param faceIndex The index of the face to bind the target texture to.
  93713. * @param postProcesses The array of post processes to render.
  93714. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  93715. * @hidden
  93716. */
  93717. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  93718. /**
  93719. * Disposes of the post process manager.
  93720. */
  93721. dispose(): void;
  93722. }
  93723. }
  93724. declare module BABYLON {
  93725. /**
  93726. * This Helps creating a texture that will be created from a camera in your scene.
  93727. * It is basically a dynamic texture that could be used to create special effects for instance.
  93728. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  93729. */
  93730. export class RenderTargetTexture extends Texture {
  93731. isCube: boolean;
  93732. /**
  93733. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  93734. */
  93735. static readonly REFRESHRATE_RENDER_ONCE: number;
  93736. /**
  93737. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  93738. */
  93739. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  93740. /**
  93741. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  93742. * the central point of your effect and can save a lot of performances.
  93743. */
  93744. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  93745. /**
  93746. * Use this predicate to dynamically define the list of mesh you want to render.
  93747. * If set, the renderList property will be overwritten.
  93748. */
  93749. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  93750. private _renderList;
  93751. /**
  93752. * Use this list to define the list of mesh you want to render.
  93753. */
  93754. get renderList(): Nullable<Array<AbstractMesh>>;
  93755. set renderList(value: Nullable<Array<AbstractMesh>>);
  93756. /**
  93757. * Use this function to overload the renderList array at rendering time.
  93758. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  93759. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  93760. * the cube (if the RTT is a cube, else layerOrFace=0).
  93761. * The renderList passed to the function is the current render list (the one that will be used if the function returns null)
  93762. */
  93763. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>) => Nullable<Array<AbstractMesh>>;
  93764. private _hookArray;
  93765. /**
  93766. * Define if particles should be rendered in your texture.
  93767. */
  93768. renderParticles: boolean;
  93769. /**
  93770. * Define if sprites should be rendered in your texture.
  93771. */
  93772. renderSprites: boolean;
  93773. /**
  93774. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  93775. */
  93776. coordinatesMode: number;
  93777. /**
  93778. * Define the camera used to render the texture.
  93779. */
  93780. activeCamera: Nullable<Camera>;
  93781. /**
  93782. * Override the render function of the texture with your own one.
  93783. */
  93784. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  93785. /**
  93786. * Define if camera post processes should be use while rendering the texture.
  93787. */
  93788. useCameraPostProcesses: boolean;
  93789. /**
  93790. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  93791. */
  93792. ignoreCameraViewport: boolean;
  93793. private _postProcessManager;
  93794. private _postProcesses;
  93795. private _resizeObserver;
  93796. /**
  93797. * An event triggered when the texture is unbind.
  93798. */
  93799. onBeforeBindObservable: Observable<RenderTargetTexture>;
  93800. /**
  93801. * An event triggered when the texture is unbind.
  93802. */
  93803. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  93804. private _onAfterUnbindObserver;
  93805. /**
  93806. * Set a after unbind callback in the texture.
  93807. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  93808. */
  93809. set onAfterUnbind(callback: () => void);
  93810. /**
  93811. * An event triggered before rendering the texture
  93812. */
  93813. onBeforeRenderObservable: Observable<number>;
  93814. private _onBeforeRenderObserver;
  93815. /**
  93816. * Set a before render callback in the texture.
  93817. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  93818. */
  93819. set onBeforeRender(callback: (faceIndex: number) => void);
  93820. /**
  93821. * An event triggered after rendering the texture
  93822. */
  93823. onAfterRenderObservable: Observable<number>;
  93824. private _onAfterRenderObserver;
  93825. /**
  93826. * Set a after render callback in the texture.
  93827. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  93828. */
  93829. set onAfterRender(callback: (faceIndex: number) => void);
  93830. /**
  93831. * An event triggered after the texture clear
  93832. */
  93833. onClearObservable: Observable<Engine>;
  93834. private _onClearObserver;
  93835. /**
  93836. * Set a clear callback in the texture.
  93837. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  93838. */
  93839. set onClear(callback: (Engine: Engine) => void);
  93840. /**
  93841. * An event triggered when the texture is resized.
  93842. */
  93843. onResizeObservable: Observable<RenderTargetTexture>;
  93844. /**
  93845. * Define the clear color of the Render Target if it should be different from the scene.
  93846. */
  93847. clearColor: Color4;
  93848. protected _size: number | {
  93849. width: number;
  93850. height: number;
  93851. layers?: number;
  93852. };
  93853. protected _initialSizeParameter: number | {
  93854. width: number;
  93855. height: number;
  93856. } | {
  93857. ratio: number;
  93858. };
  93859. protected _sizeRatio: Nullable<number>;
  93860. /** @hidden */
  93861. _generateMipMaps: boolean;
  93862. protected _renderingManager: RenderingManager;
  93863. /** @hidden */
  93864. _waitingRenderList: string[];
  93865. protected _doNotChangeAspectRatio: boolean;
  93866. protected _currentRefreshId: number;
  93867. protected _refreshRate: number;
  93868. protected _textureMatrix: Matrix;
  93869. protected _samples: number;
  93870. protected _renderTargetOptions: RenderTargetCreationOptions;
  93871. /**
  93872. * Gets render target creation options that were used.
  93873. */
  93874. get renderTargetOptions(): RenderTargetCreationOptions;
  93875. protected _engine: Engine;
  93876. protected _onRatioRescale(): void;
  93877. /**
  93878. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  93879. * It must define where the camera used to render the texture is set
  93880. */
  93881. boundingBoxPosition: Vector3;
  93882. private _boundingBoxSize;
  93883. /**
  93884. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  93885. * When defined, the cubemap will switch to local mode
  93886. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  93887. * @example https://www.babylonjs-playground.com/#RNASML
  93888. */
  93889. set boundingBoxSize(value: Vector3);
  93890. get boundingBoxSize(): Vector3;
  93891. /**
  93892. * In case the RTT has been created with a depth texture, get the associated
  93893. * depth texture.
  93894. * Otherwise, return null.
  93895. */
  93896. get depthStencilTexture(): Nullable<InternalTexture>;
  93897. /**
  93898. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  93899. * or used a shadow, depth texture...
  93900. * @param name The friendly name of the texture
  93901. * @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)
  93902. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  93903. * @param generateMipMaps True if mip maps need to be generated after render.
  93904. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  93905. * @param type The type of the buffer in the RTT (int, half float, float...)
  93906. * @param isCube True if a cube texture needs to be created
  93907. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  93908. * @param generateDepthBuffer True to generate a depth buffer
  93909. * @param generateStencilBuffer True to generate a stencil buffer
  93910. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  93911. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  93912. * @param delayAllocation if the texture allocation should be delayed (default: false)
  93913. */
  93914. constructor(name: string, size: number | {
  93915. width: number;
  93916. height: number;
  93917. layers?: number;
  93918. } | {
  93919. ratio: number;
  93920. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  93921. /**
  93922. * Creates a depth stencil texture.
  93923. * This is only available in WebGL 2 or with the depth texture extension available.
  93924. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  93925. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  93926. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  93927. */
  93928. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  93929. private _processSizeParameter;
  93930. /**
  93931. * Define the number of samples to use in case of MSAA.
  93932. * It defaults to one meaning no MSAA has been enabled.
  93933. */
  93934. get samples(): number;
  93935. set samples(value: number);
  93936. /**
  93937. * Resets the refresh counter of the texture and start bak from scratch.
  93938. * Could be useful to regenerate the texture if it is setup to render only once.
  93939. */
  93940. resetRefreshCounter(): void;
  93941. /**
  93942. * Define the refresh rate of the texture or the rendering frequency.
  93943. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  93944. */
  93945. get refreshRate(): number;
  93946. set refreshRate(value: number);
  93947. /**
  93948. * Adds a post process to the render target rendering passes.
  93949. * @param postProcess define the post process to add
  93950. */
  93951. addPostProcess(postProcess: PostProcess): void;
  93952. /**
  93953. * Clear all the post processes attached to the render target
  93954. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  93955. */
  93956. clearPostProcesses(dispose?: boolean): void;
  93957. /**
  93958. * Remove one of the post process from the list of attached post processes to the texture
  93959. * @param postProcess define the post process to remove from the list
  93960. */
  93961. removePostProcess(postProcess: PostProcess): void;
  93962. /** @hidden */
  93963. _shouldRender(): boolean;
  93964. /**
  93965. * Gets the actual render size of the texture.
  93966. * @returns the width of the render size
  93967. */
  93968. getRenderSize(): number;
  93969. /**
  93970. * Gets the actual render width of the texture.
  93971. * @returns the width of the render size
  93972. */
  93973. getRenderWidth(): number;
  93974. /**
  93975. * Gets the actual render height of the texture.
  93976. * @returns the height of the render size
  93977. */
  93978. getRenderHeight(): number;
  93979. /**
  93980. * Gets the actual number of layers of the texture.
  93981. * @returns the number of layers
  93982. */
  93983. getRenderLayers(): number;
  93984. /**
  93985. * Get if the texture can be rescaled or not.
  93986. */
  93987. get canRescale(): boolean;
  93988. /**
  93989. * Resize the texture using a ratio.
  93990. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  93991. */
  93992. scale(ratio: number): void;
  93993. /**
  93994. * Get the texture reflection matrix used to rotate/transform the reflection.
  93995. * @returns the reflection matrix
  93996. */
  93997. getReflectionTextureMatrix(): Matrix;
  93998. /**
  93999. * Resize the texture to a new desired size.
  94000. * Be carrefull as it will recreate all the data in the new texture.
  94001. * @param size Define the new size. It can be:
  94002. * - a number for squared texture,
  94003. * - an object containing { width: number, height: number }
  94004. * - or an object containing a ratio { ratio: number }
  94005. */
  94006. resize(size: number | {
  94007. width: number;
  94008. height: number;
  94009. } | {
  94010. ratio: number;
  94011. }): void;
  94012. private _defaultRenderListPrepared;
  94013. /**
  94014. * Renders all the objects from the render list into the texture.
  94015. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  94016. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  94017. */
  94018. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  94019. private _bestReflectionRenderTargetDimension;
  94020. private _prepareRenderingManager;
  94021. /**
  94022. * @hidden
  94023. * @param faceIndex face index to bind to if this is a cubetexture
  94024. * @param layer defines the index of the texture to bind in the array
  94025. */
  94026. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  94027. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  94028. private renderToTarget;
  94029. /**
  94030. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  94031. * This allowed control for front to back rendering or reversly depending of the special needs.
  94032. *
  94033. * @param renderingGroupId The rendering group id corresponding to its index
  94034. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  94035. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  94036. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  94037. */
  94038. 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;
  94039. /**
  94040. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  94041. *
  94042. * @param renderingGroupId The rendering group id corresponding to its index
  94043. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  94044. */
  94045. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  94046. /**
  94047. * Clones the texture.
  94048. * @returns the cloned texture
  94049. */
  94050. clone(): RenderTargetTexture;
  94051. /**
  94052. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  94053. * @returns The JSON representation of the texture
  94054. */
  94055. serialize(): any;
  94056. /**
  94057. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  94058. */
  94059. disposeFramebufferObjects(): void;
  94060. /**
  94061. * Dispose the texture and release its associated resources.
  94062. */
  94063. dispose(): void;
  94064. /** @hidden */
  94065. _rebuild(): void;
  94066. /**
  94067. * Clear the info related to rendering groups preventing retention point in material dispose.
  94068. */
  94069. freeRenderingGroups(): void;
  94070. /**
  94071. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  94072. * @returns the view count
  94073. */
  94074. getViewCount(): number;
  94075. }
  94076. }
  94077. declare module BABYLON {
  94078. /**
  94079. * Options for compiling materials.
  94080. */
  94081. export interface IMaterialCompilationOptions {
  94082. /**
  94083. * Defines whether clip planes are enabled.
  94084. */
  94085. clipPlane: boolean;
  94086. /**
  94087. * Defines whether instances are enabled.
  94088. */
  94089. useInstances: boolean;
  94090. }
  94091. /**
  94092. * Base class for the main features of a material in Babylon.js
  94093. */
  94094. export class Material implements IAnimatable {
  94095. /**
  94096. * Returns the triangle fill mode
  94097. */
  94098. static readonly TriangleFillMode: number;
  94099. /**
  94100. * Returns the wireframe mode
  94101. */
  94102. static readonly WireFrameFillMode: number;
  94103. /**
  94104. * Returns the point fill mode
  94105. */
  94106. static readonly PointFillMode: number;
  94107. /**
  94108. * Returns the point list draw mode
  94109. */
  94110. static readonly PointListDrawMode: number;
  94111. /**
  94112. * Returns the line list draw mode
  94113. */
  94114. static readonly LineListDrawMode: number;
  94115. /**
  94116. * Returns the line loop draw mode
  94117. */
  94118. static readonly LineLoopDrawMode: number;
  94119. /**
  94120. * Returns the line strip draw mode
  94121. */
  94122. static readonly LineStripDrawMode: number;
  94123. /**
  94124. * Returns the triangle strip draw mode
  94125. */
  94126. static readonly TriangleStripDrawMode: number;
  94127. /**
  94128. * Returns the triangle fan draw mode
  94129. */
  94130. static readonly TriangleFanDrawMode: number;
  94131. /**
  94132. * Stores the clock-wise side orientation
  94133. */
  94134. static readonly ClockWiseSideOrientation: number;
  94135. /**
  94136. * Stores the counter clock-wise side orientation
  94137. */
  94138. static readonly CounterClockWiseSideOrientation: number;
  94139. /**
  94140. * The dirty texture flag value
  94141. */
  94142. static readonly TextureDirtyFlag: number;
  94143. /**
  94144. * The dirty light flag value
  94145. */
  94146. static readonly LightDirtyFlag: number;
  94147. /**
  94148. * The dirty fresnel flag value
  94149. */
  94150. static readonly FresnelDirtyFlag: number;
  94151. /**
  94152. * The dirty attribute flag value
  94153. */
  94154. static readonly AttributesDirtyFlag: number;
  94155. /**
  94156. * The dirty misc flag value
  94157. */
  94158. static readonly MiscDirtyFlag: number;
  94159. /**
  94160. * The all dirty flag value
  94161. */
  94162. static readonly AllDirtyFlag: number;
  94163. /**
  94164. * The ID of the material
  94165. */
  94166. id: string;
  94167. /**
  94168. * Gets or sets the unique id of the material
  94169. */
  94170. uniqueId: number;
  94171. /**
  94172. * The name of the material
  94173. */
  94174. name: string;
  94175. /**
  94176. * Gets or sets user defined metadata
  94177. */
  94178. metadata: any;
  94179. /**
  94180. * For internal use only. Please do not use.
  94181. */
  94182. reservedDataStore: any;
  94183. /**
  94184. * Specifies if the ready state should be checked on each call
  94185. */
  94186. checkReadyOnEveryCall: boolean;
  94187. /**
  94188. * Specifies if the ready state should be checked once
  94189. */
  94190. checkReadyOnlyOnce: boolean;
  94191. /**
  94192. * The state of the material
  94193. */
  94194. state: string;
  94195. /**
  94196. * The alpha value of the material
  94197. */
  94198. protected _alpha: number;
  94199. /**
  94200. * List of inspectable custom properties (used by the Inspector)
  94201. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94202. */
  94203. inspectableCustomProperties: IInspectable[];
  94204. /**
  94205. * Sets the alpha value of the material
  94206. */
  94207. set alpha(value: number);
  94208. /**
  94209. * Gets the alpha value of the material
  94210. */
  94211. get alpha(): number;
  94212. /**
  94213. * Specifies if back face culling is enabled
  94214. */
  94215. protected _backFaceCulling: boolean;
  94216. /**
  94217. * Sets the back-face culling state
  94218. */
  94219. set backFaceCulling(value: boolean);
  94220. /**
  94221. * Gets the back-face culling state
  94222. */
  94223. get backFaceCulling(): boolean;
  94224. /**
  94225. * Stores the value for side orientation
  94226. */
  94227. sideOrientation: number;
  94228. /**
  94229. * Callback triggered when the material is compiled
  94230. */
  94231. onCompiled: Nullable<(effect: Effect) => void>;
  94232. /**
  94233. * Callback triggered when an error occurs
  94234. */
  94235. onError: Nullable<(effect: Effect, errors: string) => void>;
  94236. /**
  94237. * Callback triggered to get the render target textures
  94238. */
  94239. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  94240. /**
  94241. * Gets a boolean indicating that current material needs to register RTT
  94242. */
  94243. get hasRenderTargetTextures(): boolean;
  94244. /**
  94245. * Specifies if the material should be serialized
  94246. */
  94247. doNotSerialize: boolean;
  94248. /**
  94249. * @hidden
  94250. */
  94251. _storeEffectOnSubMeshes: boolean;
  94252. /**
  94253. * Stores the animations for the material
  94254. */
  94255. animations: Nullable<Array<Animation>>;
  94256. /**
  94257. * An event triggered when the material is disposed
  94258. */
  94259. onDisposeObservable: Observable<Material>;
  94260. /**
  94261. * An observer which watches for dispose events
  94262. */
  94263. private _onDisposeObserver;
  94264. private _onUnBindObservable;
  94265. /**
  94266. * Called during a dispose event
  94267. */
  94268. set onDispose(callback: () => void);
  94269. private _onBindObservable;
  94270. /**
  94271. * An event triggered when the material is bound
  94272. */
  94273. get onBindObservable(): Observable<AbstractMesh>;
  94274. /**
  94275. * An observer which watches for bind events
  94276. */
  94277. private _onBindObserver;
  94278. /**
  94279. * Called during a bind event
  94280. */
  94281. set onBind(callback: (Mesh: AbstractMesh) => void);
  94282. /**
  94283. * An event triggered when the material is unbound
  94284. */
  94285. get onUnBindObservable(): Observable<Material>;
  94286. /**
  94287. * Stores the value of the alpha mode
  94288. */
  94289. private _alphaMode;
  94290. /**
  94291. * Sets the value of the alpha mode.
  94292. *
  94293. * | Value | Type | Description |
  94294. * | --- | --- | --- |
  94295. * | 0 | ALPHA_DISABLE | |
  94296. * | 1 | ALPHA_ADD | |
  94297. * | 2 | ALPHA_COMBINE | |
  94298. * | 3 | ALPHA_SUBTRACT | |
  94299. * | 4 | ALPHA_MULTIPLY | |
  94300. * | 5 | ALPHA_MAXIMIZED | |
  94301. * | 6 | ALPHA_ONEONE | |
  94302. * | 7 | ALPHA_PREMULTIPLIED | |
  94303. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  94304. * | 9 | ALPHA_INTERPOLATE | |
  94305. * | 10 | ALPHA_SCREENMODE | |
  94306. *
  94307. */
  94308. set alphaMode(value: number);
  94309. /**
  94310. * Gets the value of the alpha mode
  94311. */
  94312. get alphaMode(): number;
  94313. /**
  94314. * Stores the state of the need depth pre-pass value
  94315. */
  94316. private _needDepthPrePass;
  94317. /**
  94318. * Sets the need depth pre-pass value
  94319. */
  94320. set needDepthPrePass(value: boolean);
  94321. /**
  94322. * Gets the depth pre-pass value
  94323. */
  94324. get needDepthPrePass(): boolean;
  94325. /**
  94326. * Specifies if depth writing should be disabled
  94327. */
  94328. disableDepthWrite: boolean;
  94329. /**
  94330. * Specifies if depth writing should be forced
  94331. */
  94332. forceDepthWrite: boolean;
  94333. /**
  94334. * Specifies the depth function that should be used. 0 means the default engine function
  94335. */
  94336. depthFunction: number;
  94337. /**
  94338. * Specifies if there should be a separate pass for culling
  94339. */
  94340. separateCullingPass: boolean;
  94341. /**
  94342. * Stores the state specifing if fog should be enabled
  94343. */
  94344. private _fogEnabled;
  94345. /**
  94346. * Sets the state for enabling fog
  94347. */
  94348. set fogEnabled(value: boolean);
  94349. /**
  94350. * Gets the value of the fog enabled state
  94351. */
  94352. get fogEnabled(): boolean;
  94353. /**
  94354. * Stores the size of points
  94355. */
  94356. pointSize: number;
  94357. /**
  94358. * Stores the z offset value
  94359. */
  94360. zOffset: number;
  94361. /**
  94362. * Gets a value specifying if wireframe mode is enabled
  94363. */
  94364. get wireframe(): boolean;
  94365. /**
  94366. * Sets the state of wireframe mode
  94367. */
  94368. set wireframe(value: boolean);
  94369. /**
  94370. * Gets the value specifying if point clouds are enabled
  94371. */
  94372. get pointsCloud(): boolean;
  94373. /**
  94374. * Sets the state of point cloud mode
  94375. */
  94376. set pointsCloud(value: boolean);
  94377. /**
  94378. * Gets the material fill mode
  94379. */
  94380. get fillMode(): number;
  94381. /**
  94382. * Sets the material fill mode
  94383. */
  94384. set fillMode(value: number);
  94385. /**
  94386. * @hidden
  94387. * Stores the effects for the material
  94388. */
  94389. _effect: Nullable<Effect>;
  94390. /**
  94391. * Specifies if uniform buffers should be used
  94392. */
  94393. private _useUBO;
  94394. /**
  94395. * Stores a reference to the scene
  94396. */
  94397. private _scene;
  94398. /**
  94399. * Stores the fill mode state
  94400. */
  94401. private _fillMode;
  94402. /**
  94403. * Specifies if the depth write state should be cached
  94404. */
  94405. private _cachedDepthWriteState;
  94406. /**
  94407. * Specifies if the depth function state should be cached
  94408. */
  94409. private _cachedDepthFunctionState;
  94410. /**
  94411. * Stores the uniform buffer
  94412. */
  94413. protected _uniformBuffer: UniformBuffer;
  94414. /** @hidden */
  94415. _indexInSceneMaterialArray: number;
  94416. /** @hidden */
  94417. meshMap: Nullable<{
  94418. [id: string]: AbstractMesh | undefined;
  94419. }>;
  94420. /**
  94421. * Creates a material instance
  94422. * @param name defines the name of the material
  94423. * @param scene defines the scene to reference
  94424. * @param doNotAdd specifies if the material should be added to the scene
  94425. */
  94426. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  94427. /**
  94428. * Returns a string representation of the current material
  94429. * @param fullDetails defines a boolean indicating which levels of logging is desired
  94430. * @returns a string with material information
  94431. */
  94432. toString(fullDetails?: boolean): string;
  94433. /**
  94434. * Gets the class name of the material
  94435. * @returns a string with the class name of the material
  94436. */
  94437. getClassName(): string;
  94438. /**
  94439. * Specifies if updates for the material been locked
  94440. */
  94441. get isFrozen(): boolean;
  94442. /**
  94443. * Locks updates for the material
  94444. */
  94445. freeze(): void;
  94446. /**
  94447. * Unlocks updates for the material
  94448. */
  94449. unfreeze(): void;
  94450. /**
  94451. * Specifies if the material is ready to be used
  94452. * @param mesh defines the mesh to check
  94453. * @param useInstances specifies if instances should be used
  94454. * @returns a boolean indicating if the material is ready to be used
  94455. */
  94456. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94457. /**
  94458. * Specifies that the submesh is ready to be used
  94459. * @param mesh defines the mesh to check
  94460. * @param subMesh defines which submesh to check
  94461. * @param useInstances specifies that instances should be used
  94462. * @returns a boolean indicating that the submesh is ready or not
  94463. */
  94464. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  94465. /**
  94466. * Returns the material effect
  94467. * @returns the effect associated with the material
  94468. */
  94469. getEffect(): Nullable<Effect>;
  94470. /**
  94471. * Returns the current scene
  94472. * @returns a Scene
  94473. */
  94474. getScene(): Scene;
  94475. /**
  94476. * Specifies if the material will require alpha blending
  94477. * @returns a boolean specifying if alpha blending is needed
  94478. */
  94479. needAlphaBlending(): boolean;
  94480. /**
  94481. * Specifies if the mesh will require alpha blending
  94482. * @param mesh defines the mesh to check
  94483. * @returns a boolean specifying if alpha blending is needed for the mesh
  94484. */
  94485. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  94486. /**
  94487. * Specifies if this material should be rendered in alpha test mode
  94488. * @returns a boolean specifying if an alpha test is needed.
  94489. */
  94490. needAlphaTesting(): boolean;
  94491. /**
  94492. * Gets the texture used for the alpha test
  94493. * @returns the texture to use for alpha testing
  94494. */
  94495. getAlphaTestTexture(): Nullable<BaseTexture>;
  94496. /**
  94497. * Marks the material to indicate that it needs to be re-calculated
  94498. */
  94499. markDirty(): void;
  94500. /** @hidden */
  94501. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  94502. /**
  94503. * Binds the material to the mesh
  94504. * @param world defines the world transformation matrix
  94505. * @param mesh defines the mesh to bind the material to
  94506. */
  94507. bind(world: Matrix, mesh?: Mesh): void;
  94508. /**
  94509. * Binds the submesh to the material
  94510. * @param world defines the world transformation matrix
  94511. * @param mesh defines the mesh containing the submesh
  94512. * @param subMesh defines the submesh to bind the material to
  94513. */
  94514. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  94515. /**
  94516. * Binds the world matrix to the material
  94517. * @param world defines the world transformation matrix
  94518. */
  94519. bindOnlyWorldMatrix(world: Matrix): void;
  94520. /**
  94521. * Binds the scene's uniform buffer to the effect.
  94522. * @param effect defines the effect to bind to the scene uniform buffer
  94523. * @param sceneUbo defines the uniform buffer storing scene data
  94524. */
  94525. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  94526. /**
  94527. * Binds the view matrix to the effect
  94528. * @param effect defines the effect to bind the view matrix to
  94529. */
  94530. bindView(effect: Effect): void;
  94531. /**
  94532. * Binds the view projection matrix to the effect
  94533. * @param effect defines the effect to bind the view projection matrix to
  94534. */
  94535. bindViewProjection(effect: Effect): void;
  94536. /**
  94537. * Specifies if material alpha testing should be turned on for the mesh
  94538. * @param mesh defines the mesh to check
  94539. */
  94540. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  94541. /**
  94542. * Processes to execute after binding the material to a mesh
  94543. * @param mesh defines the rendered mesh
  94544. */
  94545. protected _afterBind(mesh?: Mesh): void;
  94546. /**
  94547. * Unbinds the material from the mesh
  94548. */
  94549. unbind(): void;
  94550. /**
  94551. * Gets the active textures from the material
  94552. * @returns an array of textures
  94553. */
  94554. getActiveTextures(): BaseTexture[];
  94555. /**
  94556. * Specifies if the material uses a texture
  94557. * @param texture defines the texture to check against the material
  94558. * @returns a boolean specifying if the material uses the texture
  94559. */
  94560. hasTexture(texture: BaseTexture): boolean;
  94561. /**
  94562. * Makes a duplicate of the material, and gives it a new name
  94563. * @param name defines the new name for the duplicated material
  94564. * @returns the cloned material
  94565. */
  94566. clone(name: string): Nullable<Material>;
  94567. /**
  94568. * Gets the meshes bound to the material
  94569. * @returns an array of meshes bound to the material
  94570. */
  94571. getBindedMeshes(): AbstractMesh[];
  94572. /**
  94573. * Force shader compilation
  94574. * @param mesh defines the mesh associated with this material
  94575. * @param onCompiled defines a function to execute once the material is compiled
  94576. * @param options defines the options to configure the compilation
  94577. * @param onError defines a function to execute if the material fails compiling
  94578. */
  94579. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  94580. /**
  94581. * Force shader compilation
  94582. * @param mesh defines the mesh that will use this material
  94583. * @param options defines additional options for compiling the shaders
  94584. * @returns a promise that resolves when the compilation completes
  94585. */
  94586. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  94587. private static readonly _AllDirtyCallBack;
  94588. private static readonly _ImageProcessingDirtyCallBack;
  94589. private static readonly _TextureDirtyCallBack;
  94590. private static readonly _FresnelDirtyCallBack;
  94591. private static readonly _MiscDirtyCallBack;
  94592. private static readonly _LightsDirtyCallBack;
  94593. private static readonly _AttributeDirtyCallBack;
  94594. private static _FresnelAndMiscDirtyCallBack;
  94595. private static _TextureAndMiscDirtyCallBack;
  94596. private static readonly _DirtyCallbackArray;
  94597. private static readonly _RunDirtyCallBacks;
  94598. /**
  94599. * Marks a define in the material to indicate that it needs to be re-computed
  94600. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  94601. */
  94602. markAsDirty(flag: number): void;
  94603. /**
  94604. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  94605. * @param func defines a function which checks material defines against the submeshes
  94606. */
  94607. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  94608. /**
  94609. * Indicates that we need to re-calculated for all submeshes
  94610. */
  94611. protected _markAllSubMeshesAsAllDirty(): void;
  94612. /**
  94613. * Indicates that image processing needs to be re-calculated for all submeshes
  94614. */
  94615. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  94616. /**
  94617. * Indicates that textures need to be re-calculated for all submeshes
  94618. */
  94619. protected _markAllSubMeshesAsTexturesDirty(): void;
  94620. /**
  94621. * Indicates that fresnel needs to be re-calculated for all submeshes
  94622. */
  94623. protected _markAllSubMeshesAsFresnelDirty(): void;
  94624. /**
  94625. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  94626. */
  94627. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  94628. /**
  94629. * Indicates that lights need to be re-calculated for all submeshes
  94630. */
  94631. protected _markAllSubMeshesAsLightsDirty(): void;
  94632. /**
  94633. * Indicates that attributes need to be re-calculated for all submeshes
  94634. */
  94635. protected _markAllSubMeshesAsAttributesDirty(): void;
  94636. /**
  94637. * Indicates that misc needs to be re-calculated for all submeshes
  94638. */
  94639. protected _markAllSubMeshesAsMiscDirty(): void;
  94640. /**
  94641. * Indicates that textures and misc need to be re-calculated for all submeshes
  94642. */
  94643. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  94644. /**
  94645. * Disposes the material
  94646. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  94647. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  94648. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  94649. */
  94650. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  94651. /** @hidden */
  94652. private releaseVertexArrayObject;
  94653. /**
  94654. * Serializes this material
  94655. * @returns the serialized material object
  94656. */
  94657. serialize(): any;
  94658. /**
  94659. * Creates a material from parsed material data
  94660. * @param parsedMaterial defines parsed material data
  94661. * @param scene defines the hosting scene
  94662. * @param rootUrl defines the root URL to use to load textures
  94663. * @returns a new material
  94664. */
  94665. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  94666. }
  94667. }
  94668. declare module BABYLON {
  94669. /**
  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. */
  94674. export class MultiMaterial extends Material {
  94675. private _subMaterials;
  94676. /**
  94677. * Gets or Sets the list of Materials used within the multi material.
  94678. * They need to be ordered according to the submeshes order in the associated mesh
  94679. */
  94680. get subMaterials(): Nullable<Material>[];
  94681. set subMaterials(value: Nullable<Material>[]);
  94682. /**
  94683. * Function used to align with Node.getChildren()
  94684. * @returns the list of Materials used within the multi material
  94685. */
  94686. getChildren(): Nullable<Material>[];
  94687. /**
  94688. * Instantiates a new Multi Material
  94689. * A multi-material is used to apply different materials to different parts of the same object without the need of
  94690. * separate meshes. This can be use to improve performances.
  94691. * @see http://doc.babylonjs.com/how_to/multi_materials
  94692. * @param name Define the name in the scene
  94693. * @param scene Define the scene the material belongs to
  94694. */
  94695. constructor(name: string, scene: Scene);
  94696. private _hookArray;
  94697. /**
  94698. * Get one of the submaterial by its index in the submaterials array
  94699. * @param index The index to look the sub material at
  94700. * @returns The Material if the index has been defined
  94701. */
  94702. getSubMaterial(index: number): Nullable<Material>;
  94703. /**
  94704. * Get the list of active textures for the whole sub materials list.
  94705. * @returns All the textures that will be used during the rendering
  94706. */
  94707. getActiveTextures(): BaseTexture[];
  94708. /**
  94709. * Gets the current class name of the material e.g. "MultiMaterial"
  94710. * Mainly use in serialization.
  94711. * @returns the class name
  94712. */
  94713. getClassName(): string;
  94714. /**
  94715. * Checks if the material is ready to render the requested sub mesh
  94716. * @param mesh Define the mesh the submesh belongs to
  94717. * @param subMesh Define the sub mesh to look readyness for
  94718. * @param useInstances Define whether or not the material is used with instances
  94719. * @returns true if ready, otherwise false
  94720. */
  94721. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  94722. /**
  94723. * Clones the current material and its related sub materials
  94724. * @param name Define the name of the newly cloned material
  94725. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  94726. * @returns the cloned material
  94727. */
  94728. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  94729. /**
  94730. * Serializes the materials into a JSON representation.
  94731. * @returns the JSON representation
  94732. */
  94733. serialize(): any;
  94734. /**
  94735. * Dispose the material and release its associated resources
  94736. * @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)
  94737. * @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)
  94738. * @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)
  94739. */
  94740. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  94741. /**
  94742. * Creates a MultiMaterial from parsed MultiMaterial data.
  94743. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  94744. * @param scene defines the hosting scene
  94745. * @returns a new MultiMaterial
  94746. */
  94747. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  94748. }
  94749. }
  94750. declare module BABYLON {
  94751. /**
  94752. * Base class for submeshes
  94753. */
  94754. export class BaseSubMesh {
  94755. /** @hidden */
  94756. _materialDefines: Nullable<MaterialDefines>;
  94757. /** @hidden */
  94758. _materialEffect: Nullable<Effect>;
  94759. /**
  94760. * Gets material defines used by the effect associated to the sub mesh
  94761. */
  94762. get materialDefines(): Nullable<MaterialDefines>;
  94763. /**
  94764. * Sets material defines used by the effect associated to the sub mesh
  94765. */
  94766. set materialDefines(defines: Nullable<MaterialDefines>);
  94767. /**
  94768. * Gets associated effect
  94769. */
  94770. get effect(): Nullable<Effect>;
  94771. /**
  94772. * Sets associated effect (effect used to render this submesh)
  94773. * @param effect defines the effect to associate with
  94774. * @param defines defines the set of defines used to compile this effect
  94775. */
  94776. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  94777. }
  94778. /**
  94779. * Defines a subdivision inside a mesh
  94780. */
  94781. export class SubMesh extends BaseSubMesh implements ICullable {
  94782. /** the material index to use */
  94783. materialIndex: number;
  94784. /** vertex index start */
  94785. verticesStart: number;
  94786. /** vertices count */
  94787. verticesCount: number;
  94788. /** index start */
  94789. indexStart: number;
  94790. /** indices count */
  94791. indexCount: number;
  94792. /** @hidden */
  94793. _linesIndexCount: number;
  94794. private _mesh;
  94795. private _renderingMesh;
  94796. private _boundingInfo;
  94797. private _linesIndexBuffer;
  94798. /** @hidden */
  94799. _lastColliderWorldVertices: Nullable<Vector3[]>;
  94800. /** @hidden */
  94801. _trianglePlanes: Plane[];
  94802. /** @hidden */
  94803. _lastColliderTransformMatrix: Nullable<Matrix>;
  94804. /** @hidden */
  94805. _renderId: number;
  94806. /** @hidden */
  94807. _alphaIndex: number;
  94808. /** @hidden */
  94809. _distanceToCamera: number;
  94810. /** @hidden */
  94811. _id: number;
  94812. private _currentMaterial;
  94813. /**
  94814. * Add a new submesh to a mesh
  94815. * @param materialIndex defines the material index to use
  94816. * @param verticesStart defines vertex index start
  94817. * @param verticesCount defines vertices count
  94818. * @param indexStart defines index start
  94819. * @param indexCount defines indices count
  94820. * @param mesh defines the parent mesh
  94821. * @param renderingMesh defines an optional rendering mesh
  94822. * @param createBoundingBox defines if bounding box should be created for this submesh
  94823. * @returns the new submesh
  94824. */
  94825. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  94826. /**
  94827. * Creates a new submesh
  94828. * @param materialIndex defines the material index to use
  94829. * @param verticesStart defines vertex index start
  94830. * @param verticesCount defines vertices count
  94831. * @param indexStart defines index start
  94832. * @param indexCount defines indices count
  94833. * @param mesh defines the parent mesh
  94834. * @param renderingMesh defines an optional rendering mesh
  94835. * @param createBoundingBox defines if bounding box should be created for this submesh
  94836. */
  94837. constructor(
  94838. /** the material index to use */
  94839. materialIndex: number,
  94840. /** vertex index start */
  94841. verticesStart: number,
  94842. /** vertices count */
  94843. verticesCount: number,
  94844. /** index start */
  94845. indexStart: number,
  94846. /** indices count */
  94847. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  94848. /**
  94849. * Returns true if this submesh covers the entire parent mesh
  94850. * @ignorenaming
  94851. */
  94852. get IsGlobal(): boolean;
  94853. /**
  94854. * Returns the submesh BoudingInfo object
  94855. * @returns current bounding info (or mesh's one if the submesh is global)
  94856. */
  94857. getBoundingInfo(): BoundingInfo;
  94858. /**
  94859. * Sets the submesh BoundingInfo
  94860. * @param boundingInfo defines the new bounding info to use
  94861. * @returns the SubMesh
  94862. */
  94863. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  94864. /**
  94865. * Returns the mesh of the current submesh
  94866. * @return the parent mesh
  94867. */
  94868. getMesh(): AbstractMesh;
  94869. /**
  94870. * Returns the rendering mesh of the submesh
  94871. * @returns the rendering mesh (could be different from parent mesh)
  94872. */
  94873. getRenderingMesh(): Mesh;
  94874. /**
  94875. * Returns the submesh material
  94876. * @returns null or the current material
  94877. */
  94878. getMaterial(): Nullable<Material>;
  94879. /**
  94880. * Sets a new updated BoundingInfo object to the submesh
  94881. * @param data defines an optional position array to use to determine the bounding info
  94882. * @returns the SubMesh
  94883. */
  94884. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  94885. /** @hidden */
  94886. _checkCollision(collider: Collider): boolean;
  94887. /**
  94888. * Updates the submesh BoundingInfo
  94889. * @param world defines the world matrix to use to update the bounding info
  94890. * @returns the submesh
  94891. */
  94892. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  94893. /**
  94894. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  94895. * @param frustumPlanes defines the frustum planes
  94896. * @returns true if the submesh is intersecting with the frustum
  94897. */
  94898. isInFrustum(frustumPlanes: Plane[]): boolean;
  94899. /**
  94900. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  94901. * @param frustumPlanes defines the frustum planes
  94902. * @returns true if the submesh is inside the frustum
  94903. */
  94904. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  94905. /**
  94906. * Renders the submesh
  94907. * @param enableAlphaMode defines if alpha needs to be used
  94908. * @returns the submesh
  94909. */
  94910. render(enableAlphaMode: boolean): SubMesh;
  94911. /**
  94912. * @hidden
  94913. */
  94914. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  94915. /**
  94916. * Checks if the submesh intersects with a ray
  94917. * @param ray defines the ray to test
  94918. * @returns true is the passed ray intersects the submesh bounding box
  94919. */
  94920. canIntersects(ray: Ray): boolean;
  94921. /**
  94922. * Intersects current submesh with a ray
  94923. * @param ray defines the ray to test
  94924. * @param positions defines mesh's positions array
  94925. * @param indices defines mesh's indices array
  94926. * @param fastCheck defines if only bounding info should be used
  94927. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  94928. * @returns intersection info or null if no intersection
  94929. */
  94930. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  94931. /** @hidden */
  94932. private _intersectLines;
  94933. /** @hidden */
  94934. private _intersectUnIndexedLines;
  94935. /** @hidden */
  94936. private _intersectTriangles;
  94937. /** @hidden */
  94938. private _intersectUnIndexedTriangles;
  94939. /** @hidden */
  94940. _rebuild(): void;
  94941. /**
  94942. * Creates a new submesh from the passed mesh
  94943. * @param newMesh defines the new hosting mesh
  94944. * @param newRenderingMesh defines an optional rendering mesh
  94945. * @returns the new submesh
  94946. */
  94947. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  94948. /**
  94949. * Release associated resources
  94950. */
  94951. dispose(): void;
  94952. /**
  94953. * Gets the class name
  94954. * @returns the string "SubMesh".
  94955. */
  94956. getClassName(): string;
  94957. /**
  94958. * Creates a new submesh from indices data
  94959. * @param materialIndex the index of the main mesh material
  94960. * @param startIndex the index where to start the copy in the mesh indices array
  94961. * @param indexCount the number of indices to copy then from the startIndex
  94962. * @param mesh the main mesh to create the submesh from
  94963. * @param renderingMesh the optional rendering mesh
  94964. * @returns a new submesh
  94965. */
  94966. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  94967. }
  94968. }
  94969. declare module BABYLON {
  94970. /**
  94971. * Class used to represent data loading progression
  94972. */
  94973. export class SceneLoaderFlags {
  94974. private static _ForceFullSceneLoadingForIncremental;
  94975. private static _ShowLoadingScreen;
  94976. private static _CleanBoneMatrixWeights;
  94977. private static _loggingLevel;
  94978. /**
  94979. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  94980. */
  94981. static get ForceFullSceneLoadingForIncremental(): boolean;
  94982. static set ForceFullSceneLoadingForIncremental(value: boolean);
  94983. /**
  94984. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  94985. */
  94986. static get ShowLoadingScreen(): boolean;
  94987. static set ShowLoadingScreen(value: boolean);
  94988. /**
  94989. * Defines the current logging level (while loading the scene)
  94990. * @ignorenaming
  94991. */
  94992. static get loggingLevel(): number;
  94993. static set loggingLevel(value: number);
  94994. /**
  94995. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  94996. */
  94997. static get CleanBoneMatrixWeights(): boolean;
  94998. static set CleanBoneMatrixWeights(value: boolean);
  94999. }
  95000. }
  95001. declare module BABYLON {
  95002. /**
  95003. * Class used to store geometry data (vertex buffers + index buffer)
  95004. */
  95005. export class Geometry implements IGetSetVerticesData {
  95006. /**
  95007. * Gets or sets the ID of the geometry
  95008. */
  95009. id: string;
  95010. /**
  95011. * Gets or sets the unique ID of the geometry
  95012. */
  95013. uniqueId: number;
  95014. /**
  95015. * Gets the delay loading state of the geometry (none by default which means not delayed)
  95016. */
  95017. delayLoadState: number;
  95018. /**
  95019. * Gets the file containing the data to load when running in delay load state
  95020. */
  95021. delayLoadingFile: Nullable<string>;
  95022. /**
  95023. * Callback called when the geometry is updated
  95024. */
  95025. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  95026. private _scene;
  95027. private _engine;
  95028. private _meshes;
  95029. private _totalVertices;
  95030. /** @hidden */
  95031. _indices: IndicesArray;
  95032. /** @hidden */
  95033. _vertexBuffers: {
  95034. [key: string]: VertexBuffer;
  95035. };
  95036. private _isDisposed;
  95037. private _extend;
  95038. private _boundingBias;
  95039. /** @hidden */
  95040. _delayInfo: Array<string>;
  95041. private _indexBuffer;
  95042. private _indexBufferIsUpdatable;
  95043. /** @hidden */
  95044. _boundingInfo: Nullable<BoundingInfo>;
  95045. /** @hidden */
  95046. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  95047. /** @hidden */
  95048. _softwareSkinningFrameId: number;
  95049. private _vertexArrayObjects;
  95050. private _updatable;
  95051. /** @hidden */
  95052. _positions: Nullable<Vector3[]>;
  95053. /**
  95054. * 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
  95055. */
  95056. get boundingBias(): Vector2;
  95057. /**
  95058. * 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
  95059. */
  95060. set boundingBias(value: Vector2);
  95061. /**
  95062. * Static function used to attach a new empty geometry to a mesh
  95063. * @param mesh defines the mesh to attach the geometry to
  95064. * @returns the new Geometry
  95065. */
  95066. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  95067. /**
  95068. * Creates a new geometry
  95069. * @param id defines the unique ID
  95070. * @param scene defines the hosting scene
  95071. * @param vertexData defines the VertexData used to get geometry data
  95072. * @param updatable defines if geometry must be updatable (false by default)
  95073. * @param mesh defines the mesh that will be associated with the geometry
  95074. */
  95075. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  95076. /**
  95077. * Gets the current extend of the geometry
  95078. */
  95079. get extend(): {
  95080. minimum: Vector3;
  95081. maximum: Vector3;
  95082. };
  95083. /**
  95084. * Gets the hosting scene
  95085. * @returns the hosting Scene
  95086. */
  95087. getScene(): Scene;
  95088. /**
  95089. * Gets the hosting engine
  95090. * @returns the hosting Engine
  95091. */
  95092. getEngine(): Engine;
  95093. /**
  95094. * Defines if the geometry is ready to use
  95095. * @returns true if the geometry is ready to be used
  95096. */
  95097. isReady(): boolean;
  95098. /**
  95099. * Gets a value indicating that the geometry should not be serialized
  95100. */
  95101. get doNotSerialize(): boolean;
  95102. /** @hidden */
  95103. _rebuild(): void;
  95104. /**
  95105. * Affects all geometry data in one call
  95106. * @param vertexData defines the geometry data
  95107. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  95108. */
  95109. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  95110. /**
  95111. * Set specific vertex data
  95112. * @param kind defines the data kind (Position, normal, etc...)
  95113. * @param data defines the vertex data to use
  95114. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  95115. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  95116. */
  95117. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  95118. /**
  95119. * Removes a specific vertex data
  95120. * @param kind defines the data kind (Position, normal, etc...)
  95121. */
  95122. removeVerticesData(kind: string): void;
  95123. /**
  95124. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  95125. * @param buffer defines the vertex buffer to use
  95126. * @param totalVertices defines the total number of vertices for position kind (could be null)
  95127. */
  95128. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  95129. /**
  95130. * Update a specific vertex buffer
  95131. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  95132. * It will do nothing if the buffer is not updatable
  95133. * @param kind defines the data kind (Position, normal, etc...)
  95134. * @param data defines the data to use
  95135. * @param offset defines the offset in the target buffer where to store the data
  95136. * @param useBytes set to true if the offset is in bytes
  95137. */
  95138. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  95139. /**
  95140. * Update a specific vertex buffer
  95141. * This function will create a new buffer if the current one is not updatable
  95142. * @param kind defines the data kind (Position, normal, etc...)
  95143. * @param data defines the data to use
  95144. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  95145. */
  95146. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  95147. private _updateBoundingInfo;
  95148. /** @hidden */
  95149. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  95150. /**
  95151. * Gets total number of vertices
  95152. * @returns the total number of vertices
  95153. */
  95154. getTotalVertices(): number;
  95155. /**
  95156. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  95157. * @param kind defines the data kind (Position, normal, etc...)
  95158. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95159. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95160. * @returns a float array containing vertex data
  95161. */
  95162. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  95163. /**
  95164. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  95165. * @param kind defines the data kind (Position, normal, etc...)
  95166. * @returns true if the vertex buffer with the specified kind is updatable
  95167. */
  95168. isVertexBufferUpdatable(kind: string): boolean;
  95169. /**
  95170. * Gets a specific vertex buffer
  95171. * @param kind defines the data kind (Position, normal, etc...)
  95172. * @returns a VertexBuffer
  95173. */
  95174. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  95175. /**
  95176. * Returns all vertex buffers
  95177. * @return an object holding all vertex buffers indexed by kind
  95178. */
  95179. getVertexBuffers(): Nullable<{
  95180. [key: string]: VertexBuffer;
  95181. }>;
  95182. /**
  95183. * Gets a boolean indicating if specific vertex buffer is present
  95184. * @param kind defines the data kind (Position, normal, etc...)
  95185. * @returns true if data is present
  95186. */
  95187. isVerticesDataPresent(kind: string): boolean;
  95188. /**
  95189. * Gets a list of all attached data kinds (Position, normal, etc...)
  95190. * @returns a list of string containing all kinds
  95191. */
  95192. getVerticesDataKinds(): string[];
  95193. /**
  95194. * Update index buffer
  95195. * @param indices defines the indices to store in the index buffer
  95196. * @param offset defines the offset in the target buffer where to store the data
  95197. * @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)
  95198. */
  95199. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  95200. /**
  95201. * Creates a new index buffer
  95202. * @param indices defines the indices to store in the index buffer
  95203. * @param totalVertices defines the total number of vertices (could be null)
  95204. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  95205. */
  95206. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  95207. /**
  95208. * Return the total number of indices
  95209. * @returns the total number of indices
  95210. */
  95211. getTotalIndices(): number;
  95212. /**
  95213. * Gets the index buffer array
  95214. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95215. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95216. * @returns the index buffer array
  95217. */
  95218. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  95219. /**
  95220. * Gets the index buffer
  95221. * @return the index buffer
  95222. */
  95223. getIndexBuffer(): Nullable<DataBuffer>;
  95224. /** @hidden */
  95225. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  95226. /**
  95227. * Release the associated resources for a specific mesh
  95228. * @param mesh defines the source mesh
  95229. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  95230. */
  95231. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  95232. /**
  95233. * Apply current geometry to a given mesh
  95234. * @param mesh defines the mesh to apply geometry to
  95235. */
  95236. applyToMesh(mesh: Mesh): void;
  95237. private _updateExtend;
  95238. private _applyToMesh;
  95239. private notifyUpdate;
  95240. /**
  95241. * Load the geometry if it was flagged as delay loaded
  95242. * @param scene defines the hosting scene
  95243. * @param onLoaded defines a callback called when the geometry is loaded
  95244. */
  95245. load(scene: Scene, onLoaded?: () => void): void;
  95246. private _queueLoad;
  95247. /**
  95248. * Invert the geometry to move from a right handed system to a left handed one.
  95249. */
  95250. toLeftHanded(): void;
  95251. /** @hidden */
  95252. _resetPointsArrayCache(): void;
  95253. /** @hidden */
  95254. _generatePointsArray(): boolean;
  95255. /**
  95256. * Gets a value indicating if the geometry is disposed
  95257. * @returns true if the geometry was disposed
  95258. */
  95259. isDisposed(): boolean;
  95260. private _disposeVertexArrayObjects;
  95261. /**
  95262. * Free all associated resources
  95263. */
  95264. dispose(): void;
  95265. /**
  95266. * Clone the current geometry into a new geometry
  95267. * @param id defines the unique ID of the new geometry
  95268. * @returns a new geometry object
  95269. */
  95270. copy(id: string): Geometry;
  95271. /**
  95272. * Serialize the current geometry info (and not the vertices data) into a JSON object
  95273. * @return a JSON representation of the current geometry data (without the vertices data)
  95274. */
  95275. serialize(): any;
  95276. private toNumberArray;
  95277. /**
  95278. * Serialize all vertices data into a JSON oject
  95279. * @returns a JSON representation of the current geometry data
  95280. */
  95281. serializeVerticeData(): any;
  95282. /**
  95283. * Extracts a clone of a mesh geometry
  95284. * @param mesh defines the source mesh
  95285. * @param id defines the unique ID of the new geometry object
  95286. * @returns the new geometry object
  95287. */
  95288. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  95289. /**
  95290. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  95291. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  95292. * Be aware Math.random() could cause collisions, but:
  95293. * "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"
  95294. * @returns a string containing a new GUID
  95295. */
  95296. static RandomId(): string;
  95297. /** @hidden */
  95298. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  95299. private static _CleanMatricesWeights;
  95300. /**
  95301. * Create a new geometry from persisted data (Using .babylon file format)
  95302. * @param parsedVertexData defines the persisted data
  95303. * @param scene defines the hosting scene
  95304. * @param rootUrl defines the root url to use to load assets (like delayed data)
  95305. * @returns the new geometry object
  95306. */
  95307. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  95308. }
  95309. }
  95310. declare module BABYLON {
  95311. /**
  95312. * Define an interface for all classes that will get and set the data on vertices
  95313. */
  95314. export interface IGetSetVerticesData {
  95315. /**
  95316. * Gets a boolean indicating if specific vertex data is present
  95317. * @param kind defines the vertex data kind to use
  95318. * @returns true is data kind is present
  95319. */
  95320. isVerticesDataPresent(kind: string): boolean;
  95321. /**
  95322. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  95323. * @param kind defines the data kind (Position, normal, etc...)
  95324. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95325. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95326. * @returns a float array containing vertex data
  95327. */
  95328. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  95329. /**
  95330. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  95331. * @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.
  95332. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95333. * @returns the indices array or an empty array if the mesh has no geometry
  95334. */
  95335. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  95336. /**
  95337. * Set specific vertex data
  95338. * @param kind defines the data kind (Position, normal, etc...)
  95339. * @param data defines the vertex data to use
  95340. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  95341. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  95342. */
  95343. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  95344. /**
  95345. * Update a specific associated vertex buffer
  95346. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  95347. * - VertexBuffer.PositionKind
  95348. * - VertexBuffer.UVKind
  95349. * - VertexBuffer.UV2Kind
  95350. * - VertexBuffer.UV3Kind
  95351. * - VertexBuffer.UV4Kind
  95352. * - VertexBuffer.UV5Kind
  95353. * - VertexBuffer.UV6Kind
  95354. * - VertexBuffer.ColorKind
  95355. * - VertexBuffer.MatricesIndicesKind
  95356. * - VertexBuffer.MatricesIndicesExtraKind
  95357. * - VertexBuffer.MatricesWeightsKind
  95358. * - VertexBuffer.MatricesWeightsExtraKind
  95359. * @param data defines the data source
  95360. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  95361. * @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)
  95362. */
  95363. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  95364. /**
  95365. * Creates a new index buffer
  95366. * @param indices defines the indices to store in the index buffer
  95367. * @param totalVertices defines the total number of vertices (could be null)
  95368. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  95369. */
  95370. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  95371. }
  95372. /**
  95373. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  95374. */
  95375. export class VertexData {
  95376. /**
  95377. * Mesh side orientation : usually the external or front surface
  95378. */
  95379. static readonly FRONTSIDE: number;
  95380. /**
  95381. * Mesh side orientation : usually the internal or back surface
  95382. */
  95383. static readonly BACKSIDE: number;
  95384. /**
  95385. * Mesh side orientation : both internal and external or front and back surfaces
  95386. */
  95387. static readonly DOUBLESIDE: number;
  95388. /**
  95389. * Mesh side orientation : by default, `FRONTSIDE`
  95390. */
  95391. static readonly DEFAULTSIDE: number;
  95392. /**
  95393. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  95394. */
  95395. positions: Nullable<FloatArray>;
  95396. /**
  95397. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  95398. */
  95399. normals: Nullable<FloatArray>;
  95400. /**
  95401. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  95402. */
  95403. tangents: Nullable<FloatArray>;
  95404. /**
  95405. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95406. */
  95407. uvs: Nullable<FloatArray>;
  95408. /**
  95409. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95410. */
  95411. uvs2: Nullable<FloatArray>;
  95412. /**
  95413. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95414. */
  95415. uvs3: Nullable<FloatArray>;
  95416. /**
  95417. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95418. */
  95419. uvs4: Nullable<FloatArray>;
  95420. /**
  95421. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95422. */
  95423. uvs5: Nullable<FloatArray>;
  95424. /**
  95425. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95426. */
  95427. uvs6: Nullable<FloatArray>;
  95428. /**
  95429. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  95430. */
  95431. colors: Nullable<FloatArray>;
  95432. /**
  95433. * 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).
  95434. */
  95435. matricesIndices: Nullable<FloatArray>;
  95436. /**
  95437. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  95438. */
  95439. matricesWeights: Nullable<FloatArray>;
  95440. /**
  95441. * An array extending the number of possible indices
  95442. */
  95443. matricesIndicesExtra: Nullable<FloatArray>;
  95444. /**
  95445. * An array extending the number of possible weights when the number of indices is extended
  95446. */
  95447. matricesWeightsExtra: Nullable<FloatArray>;
  95448. /**
  95449. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  95450. */
  95451. indices: Nullable<IndicesArray>;
  95452. /**
  95453. * Uses the passed data array to set the set the values for the specified kind of data
  95454. * @param data a linear array of floating numbers
  95455. * @param kind the type of data that is being set, eg positions, colors etc
  95456. */
  95457. set(data: FloatArray, kind: string): void;
  95458. /**
  95459. * Associates the vertexData to the passed Mesh.
  95460. * Sets it as updatable or not (default `false`)
  95461. * @param mesh the mesh the vertexData is applied to
  95462. * @param updatable when used and having the value true allows new data to update the vertexData
  95463. * @returns the VertexData
  95464. */
  95465. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  95466. /**
  95467. * Associates the vertexData to the passed Geometry.
  95468. * Sets it as updatable or not (default `false`)
  95469. * @param geometry the geometry the vertexData is applied to
  95470. * @param updatable when used and having the value true allows new data to update the vertexData
  95471. * @returns VertexData
  95472. */
  95473. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  95474. /**
  95475. * Updates the associated mesh
  95476. * @param mesh the mesh to be updated
  95477. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  95478. * @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
  95479. * @returns VertexData
  95480. */
  95481. updateMesh(mesh: Mesh): VertexData;
  95482. /**
  95483. * Updates the associated geometry
  95484. * @param geometry the geometry to be updated
  95485. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  95486. * @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
  95487. * @returns VertexData.
  95488. */
  95489. updateGeometry(geometry: Geometry): VertexData;
  95490. private _applyTo;
  95491. private _update;
  95492. /**
  95493. * Transforms each position and each normal of the vertexData according to the passed Matrix
  95494. * @param matrix the transforming matrix
  95495. * @returns the VertexData
  95496. */
  95497. transform(matrix: Matrix): VertexData;
  95498. /**
  95499. * Merges the passed VertexData into the current one
  95500. * @param other the VertexData to be merged into the current one
  95501. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  95502. * @returns the modified VertexData
  95503. */
  95504. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  95505. private _mergeElement;
  95506. private _validate;
  95507. /**
  95508. * Serializes the VertexData
  95509. * @returns a serialized object
  95510. */
  95511. serialize(): any;
  95512. /**
  95513. * Extracts the vertexData from a mesh
  95514. * @param mesh the mesh from which to extract the VertexData
  95515. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  95516. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  95517. * @returns the object VertexData associated to the passed mesh
  95518. */
  95519. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  95520. /**
  95521. * Extracts the vertexData from the geometry
  95522. * @param geometry the geometry from which to extract the VertexData
  95523. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  95524. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  95525. * @returns the object VertexData associated to the passed mesh
  95526. */
  95527. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  95528. private static _ExtractFrom;
  95529. /**
  95530. * Creates the VertexData for a Ribbon
  95531. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  95532. * * pathArray array of paths, each of which an array of successive Vector3
  95533. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  95534. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  95535. * * 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
  95536. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95537. * * 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)
  95538. * * 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)
  95539. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  95540. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  95541. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  95542. * @returns the VertexData of the ribbon
  95543. */
  95544. static CreateRibbon(options: {
  95545. pathArray: Vector3[][];
  95546. closeArray?: boolean;
  95547. closePath?: boolean;
  95548. offset?: number;
  95549. sideOrientation?: number;
  95550. frontUVs?: Vector4;
  95551. backUVs?: Vector4;
  95552. invertUV?: boolean;
  95553. uvs?: Vector2[];
  95554. colors?: Color4[];
  95555. }): VertexData;
  95556. /**
  95557. * Creates the VertexData for a box
  95558. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95559. * * size sets the width, height and depth of the box to the value of size, optional default 1
  95560. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  95561. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  95562. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  95563. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  95564. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  95565. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95566. * * 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)
  95567. * * 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)
  95568. * @returns the VertexData of the box
  95569. */
  95570. static CreateBox(options: {
  95571. size?: number;
  95572. width?: number;
  95573. height?: number;
  95574. depth?: number;
  95575. faceUV?: Vector4[];
  95576. faceColors?: Color4[];
  95577. sideOrientation?: number;
  95578. frontUVs?: Vector4;
  95579. backUVs?: Vector4;
  95580. }): VertexData;
  95581. /**
  95582. * Creates the VertexData for a tiled box
  95583. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95584. * * faceTiles sets the pattern, tile size and number of tiles for a face
  95585. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  95586. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  95587. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95588. * @returns the VertexData of the box
  95589. */
  95590. static CreateTiledBox(options: {
  95591. pattern?: number;
  95592. width?: number;
  95593. height?: number;
  95594. depth?: number;
  95595. tileSize?: number;
  95596. tileWidth?: number;
  95597. tileHeight?: number;
  95598. alignHorizontal?: number;
  95599. alignVertical?: number;
  95600. faceUV?: Vector4[];
  95601. faceColors?: Color4[];
  95602. sideOrientation?: number;
  95603. }): VertexData;
  95604. /**
  95605. * Creates the VertexData for a tiled plane
  95606. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95607. * * pattern a limited pattern arrangement depending on the number
  95608. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  95609. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  95610. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  95611. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95612. * * 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)
  95613. * * 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)
  95614. * @returns the VertexData of the tiled plane
  95615. */
  95616. static CreateTiledPlane(options: {
  95617. pattern?: number;
  95618. tileSize?: number;
  95619. tileWidth?: number;
  95620. tileHeight?: number;
  95621. size?: number;
  95622. width?: number;
  95623. height?: number;
  95624. alignHorizontal?: number;
  95625. alignVertical?: number;
  95626. sideOrientation?: number;
  95627. frontUVs?: Vector4;
  95628. backUVs?: Vector4;
  95629. }): VertexData;
  95630. /**
  95631. * Creates the VertexData for an ellipsoid, defaults to a sphere
  95632. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95633. * * segments sets the number of horizontal strips optional, default 32
  95634. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  95635. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  95636. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  95637. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  95638. * * 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
  95639. * * 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
  95640. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95641. * * 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)
  95642. * * 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)
  95643. * @returns the VertexData of the ellipsoid
  95644. */
  95645. static CreateSphere(options: {
  95646. segments?: number;
  95647. diameter?: number;
  95648. diameterX?: number;
  95649. diameterY?: number;
  95650. diameterZ?: number;
  95651. arc?: number;
  95652. slice?: number;
  95653. sideOrientation?: number;
  95654. frontUVs?: Vector4;
  95655. backUVs?: Vector4;
  95656. }): VertexData;
  95657. /**
  95658. * Creates the VertexData for a cylinder, cone or prism
  95659. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95660. * * height sets the height (y direction) of the cylinder, optional, default 2
  95661. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  95662. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  95663. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  95664. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  95665. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  95666. * * 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
  95667. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95668. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95669. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  95670. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  95671. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95672. * * 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)
  95673. * * 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)
  95674. * @returns the VertexData of the cylinder, cone or prism
  95675. */
  95676. static CreateCylinder(options: {
  95677. height?: number;
  95678. diameterTop?: number;
  95679. diameterBottom?: number;
  95680. diameter?: number;
  95681. tessellation?: number;
  95682. subdivisions?: number;
  95683. arc?: number;
  95684. faceColors?: Color4[];
  95685. faceUV?: Vector4[];
  95686. hasRings?: boolean;
  95687. enclose?: boolean;
  95688. sideOrientation?: number;
  95689. frontUVs?: Vector4;
  95690. backUVs?: Vector4;
  95691. }): VertexData;
  95692. /**
  95693. * Creates the VertexData for a torus
  95694. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95695. * * diameter the diameter of the torus, optional default 1
  95696. * * thickness the diameter of the tube forming the torus, optional default 0.5
  95697. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  95698. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95699. * * 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)
  95700. * * 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)
  95701. * @returns the VertexData of the torus
  95702. */
  95703. static CreateTorus(options: {
  95704. diameter?: number;
  95705. thickness?: number;
  95706. tessellation?: number;
  95707. sideOrientation?: number;
  95708. frontUVs?: Vector4;
  95709. backUVs?: Vector4;
  95710. }): VertexData;
  95711. /**
  95712. * Creates the VertexData of the LineSystem
  95713. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  95714. * - lines an array of lines, each line being an array of successive Vector3
  95715. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  95716. * @returns the VertexData of the LineSystem
  95717. */
  95718. static CreateLineSystem(options: {
  95719. lines: Vector3[][];
  95720. colors?: Nullable<Color4[][]>;
  95721. }): VertexData;
  95722. /**
  95723. * Create the VertexData for a DashedLines
  95724. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  95725. * - points an array successive Vector3
  95726. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  95727. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  95728. * - dashNb the intended total number of dashes, optional, default 200
  95729. * @returns the VertexData for the DashedLines
  95730. */
  95731. static CreateDashedLines(options: {
  95732. points: Vector3[];
  95733. dashSize?: number;
  95734. gapSize?: number;
  95735. dashNb?: number;
  95736. }): VertexData;
  95737. /**
  95738. * Creates the VertexData for a Ground
  95739. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  95740. * - width the width (x direction) of the ground, optional, default 1
  95741. * - height the height (z direction) of the ground, optional, default 1
  95742. * - subdivisions the number of subdivisions per side, optional, default 1
  95743. * @returns the VertexData of the Ground
  95744. */
  95745. static CreateGround(options: {
  95746. width?: number;
  95747. height?: number;
  95748. subdivisions?: number;
  95749. subdivisionsX?: number;
  95750. subdivisionsY?: number;
  95751. }): VertexData;
  95752. /**
  95753. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  95754. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  95755. * * xmin the ground minimum X coordinate, optional, default -1
  95756. * * zmin the ground minimum Z coordinate, optional, default -1
  95757. * * xmax the ground maximum X coordinate, optional, default 1
  95758. * * zmax the ground maximum Z coordinate, optional, default 1
  95759. * * 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}
  95760. * * 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}
  95761. * @returns the VertexData of the TiledGround
  95762. */
  95763. static CreateTiledGround(options: {
  95764. xmin: number;
  95765. zmin: number;
  95766. xmax: number;
  95767. zmax: number;
  95768. subdivisions?: {
  95769. w: number;
  95770. h: number;
  95771. };
  95772. precision?: {
  95773. w: number;
  95774. h: number;
  95775. };
  95776. }): VertexData;
  95777. /**
  95778. * Creates the VertexData of the Ground designed from a heightmap
  95779. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  95780. * * width the width (x direction) of the ground
  95781. * * height the height (z direction) of the ground
  95782. * * subdivisions the number of subdivisions per side
  95783. * * minHeight the minimum altitude on the ground, optional, default 0
  95784. * * maxHeight the maximum altitude on the ground, optional default 1
  95785. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  95786. * * buffer the array holding the image color data
  95787. * * bufferWidth the width of image
  95788. * * bufferHeight the height of image
  95789. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  95790. * @returns the VertexData of the Ground designed from a heightmap
  95791. */
  95792. static CreateGroundFromHeightMap(options: {
  95793. width: number;
  95794. height: number;
  95795. subdivisions: number;
  95796. minHeight: number;
  95797. maxHeight: number;
  95798. colorFilter: Color3;
  95799. buffer: Uint8Array;
  95800. bufferWidth: number;
  95801. bufferHeight: number;
  95802. alphaFilter: number;
  95803. }): VertexData;
  95804. /**
  95805. * Creates the VertexData for a Plane
  95806. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  95807. * * size sets the width and height of the plane to the value of size, optional default 1
  95808. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  95809. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  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 CreatePlane(options: {
  95816. size?: number;
  95817. width?: number;
  95818. height?: number;
  95819. sideOrientation?: number;
  95820. frontUVs?: Vector4;
  95821. backUVs?: Vector4;
  95822. }): VertexData;
  95823. /**
  95824. * Creates the VertexData of the Disc or regular Polygon
  95825. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  95826. * * radius the radius of the disc, optional default 0.5
  95827. * * tessellation the number of polygon sides, optional, default 64
  95828. * * 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
  95829. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95830. * * 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. * * 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 box
  95833. */
  95834. static CreateDisc(options: {
  95835. radius?: number;
  95836. tessellation?: number;
  95837. arc?: number;
  95838. sideOrientation?: number;
  95839. frontUVs?: Vector4;
  95840. backUVs?: Vector4;
  95841. }): VertexData;
  95842. /**
  95843. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  95844. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  95845. * @param polygon a mesh built from polygonTriangulation.build()
  95846. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95847. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95848. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95849. * @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)
  95850. * @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)
  95851. * @returns the VertexData of the Polygon
  95852. */
  95853. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  95854. /**
  95855. * Creates the VertexData of the IcoSphere
  95856. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  95857. * * radius the radius of the IcoSphere, optional default 1
  95858. * * radiusX allows stretching in the x direction, optional, default radius
  95859. * * radiusY allows stretching in the y direction, optional, default radius
  95860. * * radiusZ allows stretching in the z direction, optional, default radius
  95861. * * flat when true creates a flat shaded mesh, optional, default true
  95862. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  95863. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95864. * * 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)
  95865. * * 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)
  95866. * @returns the VertexData of the IcoSphere
  95867. */
  95868. static CreateIcoSphere(options: {
  95869. radius?: number;
  95870. radiusX?: number;
  95871. radiusY?: number;
  95872. radiusZ?: number;
  95873. flat?: boolean;
  95874. subdivisions?: number;
  95875. sideOrientation?: number;
  95876. frontUVs?: Vector4;
  95877. backUVs?: Vector4;
  95878. }): VertexData;
  95879. /**
  95880. * Creates the VertexData for a Polyhedron
  95881. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  95882. * * type provided types are:
  95883. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  95884. * * 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)
  95885. * * size the size of the IcoSphere, optional default 1
  95886. * * sizeX allows stretching in the x direction, optional, default size
  95887. * * sizeY allows stretching in the y direction, optional, default size
  95888. * * sizeZ allows stretching in the z direction, optional, default size
  95889. * * 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
  95890. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95891. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95892. * * flat when true creates a flat shaded mesh, optional, default true
  95893. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  95894. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95895. * * 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)
  95896. * * 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)
  95897. * @returns the VertexData of the Polyhedron
  95898. */
  95899. static CreatePolyhedron(options: {
  95900. type?: number;
  95901. size?: number;
  95902. sizeX?: number;
  95903. sizeY?: number;
  95904. sizeZ?: number;
  95905. custom?: any;
  95906. faceUV?: Vector4[];
  95907. faceColors?: Color4[];
  95908. flat?: boolean;
  95909. sideOrientation?: number;
  95910. frontUVs?: Vector4;
  95911. backUVs?: Vector4;
  95912. }): VertexData;
  95913. /**
  95914. * Creates the VertexData for a TorusKnot
  95915. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  95916. * * radius the radius of the torus knot, optional, default 2
  95917. * * tube the thickness of the tube, optional, default 0.5
  95918. * * radialSegments the number of sides on each tube segments, optional, default 32
  95919. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  95920. * * p the number of windings around the z axis, optional, default 2
  95921. * * q the number of windings around the x axis, optional, default 3
  95922. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95923. * * 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)
  95924. * * 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)
  95925. * @returns the VertexData of the Torus Knot
  95926. */
  95927. static CreateTorusKnot(options: {
  95928. radius?: number;
  95929. tube?: number;
  95930. radialSegments?: number;
  95931. tubularSegments?: number;
  95932. p?: number;
  95933. q?: number;
  95934. sideOrientation?: number;
  95935. frontUVs?: Vector4;
  95936. backUVs?: Vector4;
  95937. }): VertexData;
  95938. /**
  95939. * Compute normals for given positions and indices
  95940. * @param positions an array of vertex positions, [...., x, y, z, ......]
  95941. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  95942. * @param normals an array of vertex normals, [...., x, y, z, ......]
  95943. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  95944. * * facetNormals : optional array of facet normals (vector3)
  95945. * * facetPositions : optional array of facet positions (vector3)
  95946. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  95947. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  95948. * * bInfo : optional bounding info, required for facetPartitioning computation
  95949. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  95950. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  95951. * * useRightHandedSystem: optional boolean to for right handed system computation
  95952. * * depthSort : optional boolean to enable the facet depth sort computation
  95953. * * distanceTo : optional Vector3 to compute the facet depth from this location
  95954. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  95955. */
  95956. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  95957. facetNormals?: any;
  95958. facetPositions?: any;
  95959. facetPartitioning?: any;
  95960. ratio?: number;
  95961. bInfo?: any;
  95962. bbSize?: Vector3;
  95963. subDiv?: any;
  95964. useRightHandedSystem?: boolean;
  95965. depthSort?: boolean;
  95966. distanceTo?: Vector3;
  95967. depthSortedFacets?: any;
  95968. }): void;
  95969. /** @hidden */
  95970. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  95971. /**
  95972. * Applies VertexData created from the imported parameters to the geometry
  95973. * @param parsedVertexData the parsed data from an imported file
  95974. * @param geometry the geometry to apply the VertexData to
  95975. */
  95976. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  95977. }
  95978. }
  95979. declare module BABYLON {
  95980. /**
  95981. * Defines a target to use with MorphTargetManager
  95982. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  95983. */
  95984. export class MorphTarget implements IAnimatable {
  95985. /** defines the name of the target */
  95986. name: string;
  95987. /**
  95988. * Gets or sets the list of animations
  95989. */
  95990. animations: Animation[];
  95991. private _scene;
  95992. private _positions;
  95993. private _normals;
  95994. private _tangents;
  95995. private _uvs;
  95996. private _influence;
  95997. private _uniqueId;
  95998. /**
  95999. * Observable raised when the influence changes
  96000. */
  96001. onInfluenceChanged: Observable<boolean>;
  96002. /** @hidden */
  96003. _onDataLayoutChanged: Observable<void>;
  96004. /**
  96005. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  96006. */
  96007. get influence(): number;
  96008. set influence(influence: number);
  96009. /**
  96010. * Gets or sets the id of the morph Target
  96011. */
  96012. id: string;
  96013. private _animationPropertiesOverride;
  96014. /**
  96015. * Gets or sets the animation properties override
  96016. */
  96017. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  96018. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  96019. /**
  96020. * Creates a new MorphTarget
  96021. * @param name defines the name of the target
  96022. * @param influence defines the influence to use
  96023. * @param scene defines the scene the morphtarget belongs to
  96024. */
  96025. constructor(
  96026. /** defines the name of the target */
  96027. name: string, influence?: number, scene?: Nullable<Scene>);
  96028. /**
  96029. * Gets the unique ID of this manager
  96030. */
  96031. get uniqueId(): number;
  96032. /**
  96033. * Gets a boolean defining if the target contains position data
  96034. */
  96035. get hasPositions(): boolean;
  96036. /**
  96037. * Gets a boolean defining if the target contains normal data
  96038. */
  96039. get hasNormals(): boolean;
  96040. /**
  96041. * Gets a boolean defining if the target contains tangent data
  96042. */
  96043. get hasTangents(): boolean;
  96044. /**
  96045. * Gets a boolean defining if the target contains texture coordinates data
  96046. */
  96047. get hasUVs(): boolean;
  96048. /**
  96049. * Affects position data to this target
  96050. * @param data defines the position data to use
  96051. */
  96052. setPositions(data: Nullable<FloatArray>): void;
  96053. /**
  96054. * Gets the position data stored in this target
  96055. * @returns a FloatArray containing the position data (or null if not present)
  96056. */
  96057. getPositions(): Nullable<FloatArray>;
  96058. /**
  96059. * Affects normal data to this target
  96060. * @param data defines the normal data to use
  96061. */
  96062. setNormals(data: Nullable<FloatArray>): void;
  96063. /**
  96064. * Gets the normal data stored in this target
  96065. * @returns a FloatArray containing the normal data (or null if not present)
  96066. */
  96067. getNormals(): Nullable<FloatArray>;
  96068. /**
  96069. * Affects tangent data to this target
  96070. * @param data defines the tangent data to use
  96071. */
  96072. setTangents(data: Nullable<FloatArray>): void;
  96073. /**
  96074. * Gets the tangent data stored in this target
  96075. * @returns a FloatArray containing the tangent data (or null if not present)
  96076. */
  96077. getTangents(): Nullable<FloatArray>;
  96078. /**
  96079. * Affects texture coordinates data to this target
  96080. * @param data defines the texture coordinates data to use
  96081. */
  96082. setUVs(data: Nullable<FloatArray>): void;
  96083. /**
  96084. * Gets the texture coordinates data stored in this target
  96085. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  96086. */
  96087. getUVs(): Nullable<FloatArray>;
  96088. /**
  96089. * Clone the current target
  96090. * @returns a new MorphTarget
  96091. */
  96092. clone(): MorphTarget;
  96093. /**
  96094. * Serializes the current target into a Serialization object
  96095. * @returns the serialized object
  96096. */
  96097. serialize(): any;
  96098. /**
  96099. * Returns the string "MorphTarget"
  96100. * @returns "MorphTarget"
  96101. */
  96102. getClassName(): string;
  96103. /**
  96104. * Creates a new target from serialized data
  96105. * @param serializationObject defines the serialized data to use
  96106. * @returns a new MorphTarget
  96107. */
  96108. static Parse(serializationObject: any): MorphTarget;
  96109. /**
  96110. * Creates a MorphTarget from mesh data
  96111. * @param mesh defines the source mesh
  96112. * @param name defines the name to use for the new target
  96113. * @param influence defines the influence to attach to the target
  96114. * @returns a new MorphTarget
  96115. */
  96116. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  96117. }
  96118. }
  96119. declare module BABYLON {
  96120. /**
  96121. * This class is used to deform meshes using morphing between different targets
  96122. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  96123. */
  96124. export class MorphTargetManager {
  96125. private _targets;
  96126. private _targetInfluenceChangedObservers;
  96127. private _targetDataLayoutChangedObservers;
  96128. private _activeTargets;
  96129. private _scene;
  96130. private _influences;
  96131. private _supportsNormals;
  96132. private _supportsTangents;
  96133. private _supportsUVs;
  96134. private _vertexCount;
  96135. private _uniqueId;
  96136. private _tempInfluences;
  96137. /**
  96138. * Gets or sets a boolean indicating if normals must be morphed
  96139. */
  96140. enableNormalMorphing: boolean;
  96141. /**
  96142. * Gets or sets a boolean indicating if tangents must be morphed
  96143. */
  96144. enableTangentMorphing: boolean;
  96145. /**
  96146. * Gets or sets a boolean indicating if UV must be morphed
  96147. */
  96148. enableUVMorphing: boolean;
  96149. /**
  96150. * Creates a new MorphTargetManager
  96151. * @param scene defines the current scene
  96152. */
  96153. constructor(scene?: Nullable<Scene>);
  96154. /**
  96155. * Gets the unique ID of this manager
  96156. */
  96157. get uniqueId(): number;
  96158. /**
  96159. * Gets the number of vertices handled by this manager
  96160. */
  96161. get vertexCount(): number;
  96162. /**
  96163. * Gets a boolean indicating if this manager supports morphing of normals
  96164. */
  96165. get supportsNormals(): boolean;
  96166. /**
  96167. * Gets a boolean indicating if this manager supports morphing of tangents
  96168. */
  96169. get supportsTangents(): boolean;
  96170. /**
  96171. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  96172. */
  96173. get supportsUVs(): boolean;
  96174. /**
  96175. * Gets the number of targets stored in this manager
  96176. */
  96177. get numTargets(): number;
  96178. /**
  96179. * Gets the number of influencers (ie. the number of targets with influences > 0)
  96180. */
  96181. get numInfluencers(): number;
  96182. /**
  96183. * Gets the list of influences (one per target)
  96184. */
  96185. get influences(): Float32Array;
  96186. /**
  96187. * Gets the active target at specified index. An active target is a target with an influence > 0
  96188. * @param index defines the index to check
  96189. * @returns the requested target
  96190. */
  96191. getActiveTarget(index: number): MorphTarget;
  96192. /**
  96193. * Gets the target at specified index
  96194. * @param index defines the index to check
  96195. * @returns the requested target
  96196. */
  96197. getTarget(index: number): MorphTarget;
  96198. /**
  96199. * Add a new target to this manager
  96200. * @param target defines the target to add
  96201. */
  96202. addTarget(target: MorphTarget): void;
  96203. /**
  96204. * Removes a target from the manager
  96205. * @param target defines the target to remove
  96206. */
  96207. removeTarget(target: MorphTarget): void;
  96208. /**
  96209. * Clone the current manager
  96210. * @returns a new MorphTargetManager
  96211. */
  96212. clone(): MorphTargetManager;
  96213. /**
  96214. * Serializes the current manager into a Serialization object
  96215. * @returns the serialized object
  96216. */
  96217. serialize(): any;
  96218. private _syncActiveTargets;
  96219. /**
  96220. * Syncrhonize the targets with all the meshes using this morph target manager
  96221. */
  96222. synchronize(): void;
  96223. /**
  96224. * Creates a new MorphTargetManager from serialized data
  96225. * @param serializationObject defines the serialized data
  96226. * @param scene defines the hosting scene
  96227. * @returns the new MorphTargetManager
  96228. */
  96229. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  96230. }
  96231. }
  96232. declare module BABYLON {
  96233. /**
  96234. * Class used to represent a specific level of detail of a mesh
  96235. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  96236. */
  96237. export class MeshLODLevel {
  96238. /** Defines the distance where this level should start being displayed */
  96239. distance: number;
  96240. /** Defines the mesh to use to render this level */
  96241. mesh: Nullable<Mesh>;
  96242. /**
  96243. * Creates a new LOD level
  96244. * @param distance defines the distance where this level should star being displayed
  96245. * @param mesh defines the mesh to use to render this level
  96246. */
  96247. constructor(
  96248. /** Defines the distance where this level should start being displayed */
  96249. distance: number,
  96250. /** Defines the mesh to use to render this level */
  96251. mesh: Nullable<Mesh>);
  96252. }
  96253. }
  96254. declare module BABYLON {
  96255. /**
  96256. * Mesh representing the gorund
  96257. */
  96258. export class GroundMesh extends Mesh {
  96259. /** If octree should be generated */
  96260. generateOctree: boolean;
  96261. private _heightQuads;
  96262. /** @hidden */
  96263. _subdivisionsX: number;
  96264. /** @hidden */
  96265. _subdivisionsY: number;
  96266. /** @hidden */
  96267. _width: number;
  96268. /** @hidden */
  96269. _height: number;
  96270. /** @hidden */
  96271. _minX: number;
  96272. /** @hidden */
  96273. _maxX: number;
  96274. /** @hidden */
  96275. _minZ: number;
  96276. /** @hidden */
  96277. _maxZ: number;
  96278. constructor(name: string, scene: Scene);
  96279. /**
  96280. * "GroundMesh"
  96281. * @returns "GroundMesh"
  96282. */
  96283. getClassName(): string;
  96284. /**
  96285. * The minimum of x and y subdivisions
  96286. */
  96287. get subdivisions(): number;
  96288. /**
  96289. * X subdivisions
  96290. */
  96291. get subdivisionsX(): number;
  96292. /**
  96293. * Y subdivisions
  96294. */
  96295. get subdivisionsY(): number;
  96296. /**
  96297. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  96298. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  96299. * @param chunksCount the number of subdivisions for x and y
  96300. * @param octreeBlocksSize (Default: 32)
  96301. */
  96302. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  96303. /**
  96304. * Returns a height (y) value in the Worl system :
  96305. * the ground altitude at the coordinates (x, z) expressed in the World system.
  96306. * @param x x coordinate
  96307. * @param z z coordinate
  96308. * @returns the ground y position if (x, z) are outside the ground surface.
  96309. */
  96310. getHeightAtCoordinates(x: number, z: number): number;
  96311. /**
  96312. * Returns a normalized vector (Vector3) orthogonal to the ground
  96313. * at the ground coordinates (x, z) expressed in the World system.
  96314. * @param x x coordinate
  96315. * @param z z coordinate
  96316. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  96317. */
  96318. getNormalAtCoordinates(x: number, z: number): Vector3;
  96319. /**
  96320. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  96321. * at the ground coordinates (x, z) expressed in the World system.
  96322. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  96323. * @param x x coordinate
  96324. * @param z z coordinate
  96325. * @param ref vector to store the result
  96326. * @returns the GroundMesh.
  96327. */
  96328. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  96329. /**
  96330. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  96331. * if the ground has been updated.
  96332. * This can be used in the render loop.
  96333. * @returns the GroundMesh.
  96334. */
  96335. updateCoordinateHeights(): GroundMesh;
  96336. private _getFacetAt;
  96337. private _initHeightQuads;
  96338. private _computeHeightQuads;
  96339. /**
  96340. * Serializes this ground mesh
  96341. * @param serializationObject object to write serialization to
  96342. */
  96343. serialize(serializationObject: any): void;
  96344. /**
  96345. * Parses a serialized ground mesh
  96346. * @param parsedMesh the serialized mesh
  96347. * @param scene the scene to create the ground mesh in
  96348. * @returns the created ground mesh
  96349. */
  96350. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  96351. }
  96352. }
  96353. declare module BABYLON {
  96354. /**
  96355. * Interface for Physics-Joint data
  96356. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96357. */
  96358. export interface PhysicsJointData {
  96359. /**
  96360. * The main pivot of the joint
  96361. */
  96362. mainPivot?: Vector3;
  96363. /**
  96364. * The connected pivot of the joint
  96365. */
  96366. connectedPivot?: Vector3;
  96367. /**
  96368. * The main axis of the joint
  96369. */
  96370. mainAxis?: Vector3;
  96371. /**
  96372. * The connected axis of the joint
  96373. */
  96374. connectedAxis?: Vector3;
  96375. /**
  96376. * The collision of the joint
  96377. */
  96378. collision?: boolean;
  96379. /**
  96380. * Native Oimo/Cannon/Energy data
  96381. */
  96382. nativeParams?: any;
  96383. }
  96384. /**
  96385. * This is a holder class for the physics joint created by the physics plugin
  96386. * It holds a set of functions to control the underlying joint
  96387. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96388. */
  96389. export class PhysicsJoint {
  96390. /**
  96391. * The type of the physics joint
  96392. */
  96393. type: number;
  96394. /**
  96395. * The data for the physics joint
  96396. */
  96397. jointData: PhysicsJointData;
  96398. private _physicsJoint;
  96399. protected _physicsPlugin: IPhysicsEnginePlugin;
  96400. /**
  96401. * Initializes the physics joint
  96402. * @param type The type of the physics joint
  96403. * @param jointData The data for the physics joint
  96404. */
  96405. constructor(
  96406. /**
  96407. * The type of the physics joint
  96408. */
  96409. type: number,
  96410. /**
  96411. * The data for the physics joint
  96412. */
  96413. jointData: PhysicsJointData);
  96414. /**
  96415. * Gets the physics joint
  96416. */
  96417. get physicsJoint(): any;
  96418. /**
  96419. * Sets the physics joint
  96420. */
  96421. set physicsJoint(newJoint: any);
  96422. /**
  96423. * Sets the physics plugin
  96424. */
  96425. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  96426. /**
  96427. * Execute a function that is physics-plugin specific.
  96428. * @param {Function} func the function that will be executed.
  96429. * It accepts two parameters: the physics world and the physics joint
  96430. */
  96431. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  96432. /**
  96433. * Distance-Joint type
  96434. */
  96435. static DistanceJoint: number;
  96436. /**
  96437. * Hinge-Joint type
  96438. */
  96439. static HingeJoint: number;
  96440. /**
  96441. * Ball-and-Socket joint type
  96442. */
  96443. static BallAndSocketJoint: number;
  96444. /**
  96445. * Wheel-Joint type
  96446. */
  96447. static WheelJoint: number;
  96448. /**
  96449. * Slider-Joint type
  96450. */
  96451. static SliderJoint: number;
  96452. /**
  96453. * Prismatic-Joint type
  96454. */
  96455. static PrismaticJoint: number;
  96456. /**
  96457. * Universal-Joint type
  96458. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  96459. */
  96460. static UniversalJoint: number;
  96461. /**
  96462. * Hinge-Joint 2 type
  96463. */
  96464. static Hinge2Joint: number;
  96465. /**
  96466. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  96467. */
  96468. static PointToPointJoint: number;
  96469. /**
  96470. * Spring-Joint type
  96471. */
  96472. static SpringJoint: number;
  96473. /**
  96474. * Lock-Joint type
  96475. */
  96476. static LockJoint: number;
  96477. }
  96478. /**
  96479. * A class representing a physics distance joint
  96480. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96481. */
  96482. export class DistanceJoint extends PhysicsJoint {
  96483. /**
  96484. *
  96485. * @param jointData The data for the Distance-Joint
  96486. */
  96487. constructor(jointData: DistanceJointData);
  96488. /**
  96489. * Update the predefined distance.
  96490. * @param maxDistance The maximum preferred distance
  96491. * @param minDistance The minimum preferred distance
  96492. */
  96493. updateDistance(maxDistance: number, minDistance?: number): void;
  96494. }
  96495. /**
  96496. * Represents a Motor-Enabled Joint
  96497. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96498. */
  96499. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  96500. /**
  96501. * Initializes the Motor-Enabled Joint
  96502. * @param type The type of the joint
  96503. * @param jointData The physica joint data for the joint
  96504. */
  96505. constructor(type: number, jointData: PhysicsJointData);
  96506. /**
  96507. * Set the motor values.
  96508. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96509. * @param force the force to apply
  96510. * @param maxForce max force for this motor.
  96511. */
  96512. setMotor(force?: number, maxForce?: number): void;
  96513. /**
  96514. * Set the motor's limits.
  96515. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96516. * @param upperLimit The upper limit of the motor
  96517. * @param lowerLimit The lower limit of the motor
  96518. */
  96519. setLimit(upperLimit: number, lowerLimit?: number): void;
  96520. }
  96521. /**
  96522. * This class represents a single physics Hinge-Joint
  96523. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96524. */
  96525. export class HingeJoint extends MotorEnabledJoint {
  96526. /**
  96527. * Initializes the Hinge-Joint
  96528. * @param jointData The joint data for the Hinge-Joint
  96529. */
  96530. constructor(jointData: PhysicsJointData);
  96531. /**
  96532. * Set the motor values.
  96533. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96534. * @param {number} force the force to apply
  96535. * @param {number} maxForce max force for this motor.
  96536. */
  96537. setMotor(force?: number, maxForce?: number): void;
  96538. /**
  96539. * Set the motor's limits.
  96540. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96541. * @param upperLimit The upper limit of the motor
  96542. * @param lowerLimit The lower limit of the motor
  96543. */
  96544. setLimit(upperLimit: number, lowerLimit?: number): void;
  96545. }
  96546. /**
  96547. * This class represents a dual hinge physics joint (same as wheel joint)
  96548. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96549. */
  96550. export class Hinge2Joint extends MotorEnabledJoint {
  96551. /**
  96552. * Initializes the Hinge2-Joint
  96553. * @param jointData The joint data for the Hinge2-Joint
  96554. */
  96555. constructor(jointData: PhysicsJointData);
  96556. /**
  96557. * Set the motor values.
  96558. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96559. * @param {number} targetSpeed the speed the motor is to reach
  96560. * @param {number} maxForce max force for this motor.
  96561. * @param {motorIndex} the motor's index, 0 or 1.
  96562. */
  96563. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  96564. /**
  96565. * Set the motor limits.
  96566. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96567. * @param {number} upperLimit the upper limit
  96568. * @param {number} lowerLimit lower limit
  96569. * @param {motorIndex} the motor's index, 0 or 1.
  96570. */
  96571. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96572. }
  96573. /**
  96574. * Interface for a motor enabled joint
  96575. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96576. */
  96577. export interface IMotorEnabledJoint {
  96578. /**
  96579. * Physics joint
  96580. */
  96581. physicsJoint: any;
  96582. /**
  96583. * Sets the motor of the motor-enabled joint
  96584. * @param force The force of the motor
  96585. * @param maxForce The maximum force of the motor
  96586. * @param motorIndex The index of the motor
  96587. */
  96588. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  96589. /**
  96590. * Sets the limit of the motor
  96591. * @param upperLimit The upper limit of the motor
  96592. * @param lowerLimit The lower limit of the motor
  96593. * @param motorIndex The index of the motor
  96594. */
  96595. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96596. }
  96597. /**
  96598. * Joint data for a Distance-Joint
  96599. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96600. */
  96601. export interface DistanceJointData extends PhysicsJointData {
  96602. /**
  96603. * Max distance the 2 joint objects can be apart
  96604. */
  96605. maxDistance: number;
  96606. }
  96607. /**
  96608. * Joint data from a spring joint
  96609. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96610. */
  96611. export interface SpringJointData extends PhysicsJointData {
  96612. /**
  96613. * Length of the spring
  96614. */
  96615. length: number;
  96616. /**
  96617. * Stiffness of the spring
  96618. */
  96619. stiffness: number;
  96620. /**
  96621. * Damping of the spring
  96622. */
  96623. damping: number;
  96624. /** this callback will be called when applying the force to the impostors. */
  96625. forceApplicationCallback: () => void;
  96626. }
  96627. }
  96628. declare module BABYLON {
  96629. /**
  96630. * Holds the data for the raycast result
  96631. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96632. */
  96633. export class PhysicsRaycastResult {
  96634. private _hasHit;
  96635. private _hitDistance;
  96636. private _hitNormalWorld;
  96637. private _hitPointWorld;
  96638. private _rayFromWorld;
  96639. private _rayToWorld;
  96640. /**
  96641. * Gets if there was a hit
  96642. */
  96643. get hasHit(): boolean;
  96644. /**
  96645. * Gets the distance from the hit
  96646. */
  96647. get hitDistance(): number;
  96648. /**
  96649. * Gets the hit normal/direction in the world
  96650. */
  96651. get hitNormalWorld(): Vector3;
  96652. /**
  96653. * Gets the hit point in the world
  96654. */
  96655. get hitPointWorld(): Vector3;
  96656. /**
  96657. * Gets the ray "start point" of the ray in the world
  96658. */
  96659. get rayFromWorld(): Vector3;
  96660. /**
  96661. * Gets the ray "end point" of the ray in the world
  96662. */
  96663. get rayToWorld(): Vector3;
  96664. /**
  96665. * Sets the hit data (normal & point in world space)
  96666. * @param hitNormalWorld defines the normal in world space
  96667. * @param hitPointWorld defines the point in world space
  96668. */
  96669. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  96670. /**
  96671. * Sets the distance from the start point to the hit point
  96672. * @param distance
  96673. */
  96674. setHitDistance(distance: number): void;
  96675. /**
  96676. * Calculates the distance manually
  96677. */
  96678. calculateHitDistance(): void;
  96679. /**
  96680. * Resets all the values to default
  96681. * @param from The from point on world space
  96682. * @param to The to point on world space
  96683. */
  96684. reset(from?: Vector3, to?: Vector3): void;
  96685. }
  96686. /**
  96687. * Interface for the size containing width and height
  96688. */
  96689. interface IXYZ {
  96690. /**
  96691. * X
  96692. */
  96693. x: number;
  96694. /**
  96695. * Y
  96696. */
  96697. y: number;
  96698. /**
  96699. * Z
  96700. */
  96701. z: number;
  96702. }
  96703. }
  96704. declare module BABYLON {
  96705. /**
  96706. * Interface used to describe a physics joint
  96707. */
  96708. export interface PhysicsImpostorJoint {
  96709. /** Defines the main impostor to which the joint is linked */
  96710. mainImpostor: PhysicsImpostor;
  96711. /** Defines the impostor that is connected to the main impostor using this joint */
  96712. connectedImpostor: PhysicsImpostor;
  96713. /** Defines the joint itself */
  96714. joint: PhysicsJoint;
  96715. }
  96716. /** @hidden */
  96717. export interface IPhysicsEnginePlugin {
  96718. world: any;
  96719. name: string;
  96720. setGravity(gravity: Vector3): void;
  96721. setTimeStep(timeStep: number): void;
  96722. getTimeStep(): number;
  96723. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  96724. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  96725. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  96726. generatePhysicsBody(impostor: PhysicsImpostor): void;
  96727. removePhysicsBody(impostor: PhysicsImpostor): void;
  96728. generateJoint(joint: PhysicsImpostorJoint): void;
  96729. removeJoint(joint: PhysicsImpostorJoint): void;
  96730. isSupported(): boolean;
  96731. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  96732. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  96733. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  96734. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  96735. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  96736. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  96737. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  96738. getBodyMass(impostor: PhysicsImpostor): number;
  96739. getBodyFriction(impostor: PhysicsImpostor): number;
  96740. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  96741. getBodyRestitution(impostor: PhysicsImpostor): number;
  96742. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  96743. getBodyPressure?(impostor: PhysicsImpostor): number;
  96744. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  96745. getBodyStiffness?(impostor: PhysicsImpostor): number;
  96746. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  96747. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  96748. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  96749. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  96750. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  96751. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  96752. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  96753. sleepBody(impostor: PhysicsImpostor): void;
  96754. wakeUpBody(impostor: PhysicsImpostor): void;
  96755. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  96756. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  96757. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  96758. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96759. getRadius(impostor: PhysicsImpostor): number;
  96760. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  96761. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  96762. dispose(): void;
  96763. }
  96764. /**
  96765. * Interface used to define a physics engine
  96766. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  96767. */
  96768. export interface IPhysicsEngine {
  96769. /**
  96770. * Gets the gravity vector used by the simulation
  96771. */
  96772. gravity: Vector3;
  96773. /**
  96774. * Sets the gravity vector used by the simulation
  96775. * @param gravity defines the gravity vector to use
  96776. */
  96777. setGravity(gravity: Vector3): void;
  96778. /**
  96779. * Set the time step of the physics engine.
  96780. * Default is 1/60.
  96781. * To slow it down, enter 1/600 for example.
  96782. * To speed it up, 1/30
  96783. * @param newTimeStep the new timestep to apply to this world.
  96784. */
  96785. setTimeStep(newTimeStep: number): void;
  96786. /**
  96787. * Get the time step of the physics engine.
  96788. * @returns the current time step
  96789. */
  96790. getTimeStep(): number;
  96791. /**
  96792. * Set the sub time step of the physics engine.
  96793. * Default is 0 meaning there is no sub steps
  96794. * To increase physics resolution precision, set a small value (like 1 ms)
  96795. * @param subTimeStep defines the new sub timestep used for physics resolution.
  96796. */
  96797. setSubTimeStep(subTimeStep: number): void;
  96798. /**
  96799. * Get the sub time step of the physics engine.
  96800. * @returns the current sub time step
  96801. */
  96802. getSubTimeStep(): number;
  96803. /**
  96804. * Release all resources
  96805. */
  96806. dispose(): void;
  96807. /**
  96808. * Gets the name of the current physics plugin
  96809. * @returns the name of the plugin
  96810. */
  96811. getPhysicsPluginName(): string;
  96812. /**
  96813. * Adding a new impostor for the impostor tracking.
  96814. * This will be done by the impostor itself.
  96815. * @param impostor the impostor to add
  96816. */
  96817. addImpostor(impostor: PhysicsImpostor): void;
  96818. /**
  96819. * Remove an impostor from the engine.
  96820. * This impostor and its mesh will not longer be updated by the physics engine.
  96821. * @param impostor the impostor to remove
  96822. */
  96823. removeImpostor(impostor: PhysicsImpostor): void;
  96824. /**
  96825. * Add a joint to the physics engine
  96826. * @param mainImpostor defines the main impostor to which the joint is added.
  96827. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  96828. * @param joint defines the joint that will connect both impostors.
  96829. */
  96830. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  96831. /**
  96832. * Removes a joint from the simulation
  96833. * @param mainImpostor defines the impostor used with the joint
  96834. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  96835. * @param joint defines the joint to remove
  96836. */
  96837. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  96838. /**
  96839. * Gets the current plugin used to run the simulation
  96840. * @returns current plugin
  96841. */
  96842. getPhysicsPlugin(): IPhysicsEnginePlugin;
  96843. /**
  96844. * Gets the list of physic impostors
  96845. * @returns an array of PhysicsImpostor
  96846. */
  96847. getImpostors(): Array<PhysicsImpostor>;
  96848. /**
  96849. * Gets the impostor for a physics enabled object
  96850. * @param object defines the object impersonated by the impostor
  96851. * @returns the PhysicsImpostor or null if not found
  96852. */
  96853. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  96854. /**
  96855. * Gets the impostor for a physics body object
  96856. * @param body defines physics body used by the impostor
  96857. * @returns the PhysicsImpostor or null if not found
  96858. */
  96859. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  96860. /**
  96861. * Does a raycast in the physics world
  96862. * @param from when should the ray start?
  96863. * @param to when should the ray end?
  96864. * @returns PhysicsRaycastResult
  96865. */
  96866. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  96867. /**
  96868. * Called by the scene. No need to call it.
  96869. * @param delta defines the timespam between frames
  96870. */
  96871. _step(delta: number): void;
  96872. }
  96873. }
  96874. declare module BABYLON {
  96875. /**
  96876. * The interface for the physics imposter parameters
  96877. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96878. */
  96879. export interface PhysicsImpostorParameters {
  96880. /**
  96881. * The mass of the physics imposter
  96882. */
  96883. mass: number;
  96884. /**
  96885. * The friction of the physics imposter
  96886. */
  96887. friction?: number;
  96888. /**
  96889. * The coefficient of restitution of the physics imposter
  96890. */
  96891. restitution?: number;
  96892. /**
  96893. * The native options of the physics imposter
  96894. */
  96895. nativeOptions?: any;
  96896. /**
  96897. * Specifies if the parent should be ignored
  96898. */
  96899. ignoreParent?: boolean;
  96900. /**
  96901. * Specifies if bi-directional transformations should be disabled
  96902. */
  96903. disableBidirectionalTransformation?: boolean;
  96904. /**
  96905. * The pressure inside the physics imposter, soft object only
  96906. */
  96907. pressure?: number;
  96908. /**
  96909. * The stiffness the physics imposter, soft object only
  96910. */
  96911. stiffness?: number;
  96912. /**
  96913. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  96914. */
  96915. velocityIterations?: number;
  96916. /**
  96917. * The number of iterations used in maintaining consistent vertex positions, soft object only
  96918. */
  96919. positionIterations?: number;
  96920. /**
  96921. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  96922. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  96923. * Add to fix multiple points
  96924. */
  96925. fixedPoints?: number;
  96926. /**
  96927. * The collision margin around a soft object
  96928. */
  96929. margin?: number;
  96930. /**
  96931. * The collision margin around a soft object
  96932. */
  96933. damping?: number;
  96934. /**
  96935. * The path for a rope based on an extrusion
  96936. */
  96937. path?: any;
  96938. /**
  96939. * The shape of an extrusion used for a rope based on an extrusion
  96940. */
  96941. shape?: any;
  96942. }
  96943. /**
  96944. * Interface for a physics-enabled object
  96945. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96946. */
  96947. export interface IPhysicsEnabledObject {
  96948. /**
  96949. * The position of the physics-enabled object
  96950. */
  96951. position: Vector3;
  96952. /**
  96953. * The rotation of the physics-enabled object
  96954. */
  96955. rotationQuaternion: Nullable<Quaternion>;
  96956. /**
  96957. * The scale of the physics-enabled object
  96958. */
  96959. scaling: Vector3;
  96960. /**
  96961. * The rotation of the physics-enabled object
  96962. */
  96963. rotation?: Vector3;
  96964. /**
  96965. * The parent of the physics-enabled object
  96966. */
  96967. parent?: any;
  96968. /**
  96969. * The bounding info of the physics-enabled object
  96970. * @returns The bounding info of the physics-enabled object
  96971. */
  96972. getBoundingInfo(): BoundingInfo;
  96973. /**
  96974. * Computes the world matrix
  96975. * @param force Specifies if the world matrix should be computed by force
  96976. * @returns A world matrix
  96977. */
  96978. computeWorldMatrix(force: boolean): Matrix;
  96979. /**
  96980. * Gets the world matrix
  96981. * @returns A world matrix
  96982. */
  96983. getWorldMatrix?(): Matrix;
  96984. /**
  96985. * Gets the child meshes
  96986. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  96987. * @returns An array of abstract meshes
  96988. */
  96989. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  96990. /**
  96991. * Gets the vertex data
  96992. * @param kind The type of vertex data
  96993. * @returns A nullable array of numbers, or a float32 array
  96994. */
  96995. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  96996. /**
  96997. * Gets the indices from the mesh
  96998. * @returns A nullable array of index arrays
  96999. */
  97000. getIndices?(): Nullable<IndicesArray>;
  97001. /**
  97002. * Gets the scene from the mesh
  97003. * @returns the indices array or null
  97004. */
  97005. getScene?(): Scene;
  97006. /**
  97007. * Gets the absolute position from the mesh
  97008. * @returns the absolute position
  97009. */
  97010. getAbsolutePosition(): Vector3;
  97011. /**
  97012. * Gets the absolute pivot point from the mesh
  97013. * @returns the absolute pivot point
  97014. */
  97015. getAbsolutePivotPoint(): Vector3;
  97016. /**
  97017. * Rotates the mesh
  97018. * @param axis The axis of rotation
  97019. * @param amount The amount of rotation
  97020. * @param space The space of the rotation
  97021. * @returns The rotation transform node
  97022. */
  97023. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  97024. /**
  97025. * Translates the mesh
  97026. * @param axis The axis of translation
  97027. * @param distance The distance of translation
  97028. * @param space The space of the translation
  97029. * @returns The transform node
  97030. */
  97031. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  97032. /**
  97033. * Sets the absolute position of the mesh
  97034. * @param absolutePosition The absolute position of the mesh
  97035. * @returns The transform node
  97036. */
  97037. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  97038. /**
  97039. * Gets the class name of the mesh
  97040. * @returns The class name
  97041. */
  97042. getClassName(): string;
  97043. }
  97044. /**
  97045. * Represents a physics imposter
  97046. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97047. */
  97048. export class PhysicsImpostor {
  97049. /**
  97050. * The physics-enabled object used as the physics imposter
  97051. */
  97052. object: IPhysicsEnabledObject;
  97053. /**
  97054. * The type of the physics imposter
  97055. */
  97056. type: number;
  97057. private _options;
  97058. private _scene?;
  97059. /**
  97060. * The default object size of the imposter
  97061. */
  97062. static DEFAULT_OBJECT_SIZE: Vector3;
  97063. /**
  97064. * The identity quaternion of the imposter
  97065. */
  97066. static IDENTITY_QUATERNION: Quaternion;
  97067. /** @hidden */
  97068. _pluginData: any;
  97069. private _physicsEngine;
  97070. private _physicsBody;
  97071. private _bodyUpdateRequired;
  97072. private _onBeforePhysicsStepCallbacks;
  97073. private _onAfterPhysicsStepCallbacks;
  97074. /** @hidden */
  97075. _onPhysicsCollideCallbacks: Array<{
  97076. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  97077. otherImpostors: Array<PhysicsImpostor>;
  97078. }>;
  97079. private _deltaPosition;
  97080. private _deltaRotation;
  97081. private _deltaRotationConjugated;
  97082. /** @hidden */
  97083. _isFromLine: boolean;
  97084. private _parent;
  97085. private _isDisposed;
  97086. private static _tmpVecs;
  97087. private static _tmpQuat;
  97088. /**
  97089. * Specifies if the physics imposter is disposed
  97090. */
  97091. get isDisposed(): boolean;
  97092. /**
  97093. * Gets the mass of the physics imposter
  97094. */
  97095. get mass(): number;
  97096. set mass(value: number);
  97097. /**
  97098. * Gets the coefficient of friction
  97099. */
  97100. get friction(): number;
  97101. /**
  97102. * Sets the coefficient of friction
  97103. */
  97104. set friction(value: number);
  97105. /**
  97106. * Gets the coefficient of restitution
  97107. */
  97108. get restitution(): number;
  97109. /**
  97110. * Sets the coefficient of restitution
  97111. */
  97112. set restitution(value: number);
  97113. /**
  97114. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  97115. */
  97116. get pressure(): number;
  97117. /**
  97118. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  97119. */
  97120. set pressure(value: number);
  97121. /**
  97122. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  97123. */
  97124. get stiffness(): number;
  97125. /**
  97126. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  97127. */
  97128. set stiffness(value: number);
  97129. /**
  97130. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  97131. */
  97132. get velocityIterations(): number;
  97133. /**
  97134. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  97135. */
  97136. set velocityIterations(value: number);
  97137. /**
  97138. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  97139. */
  97140. get positionIterations(): number;
  97141. /**
  97142. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  97143. */
  97144. set positionIterations(value: number);
  97145. /**
  97146. * The unique id of the physics imposter
  97147. * set by the physics engine when adding this impostor to the array
  97148. */
  97149. uniqueId: number;
  97150. /**
  97151. * @hidden
  97152. */
  97153. soft: boolean;
  97154. /**
  97155. * @hidden
  97156. */
  97157. segments: number;
  97158. private _joints;
  97159. /**
  97160. * Initializes the physics imposter
  97161. * @param object The physics-enabled object used as the physics imposter
  97162. * @param type The type of the physics imposter
  97163. * @param _options The options for the physics imposter
  97164. * @param _scene The Babylon scene
  97165. */
  97166. constructor(
  97167. /**
  97168. * The physics-enabled object used as the physics imposter
  97169. */
  97170. object: IPhysicsEnabledObject,
  97171. /**
  97172. * The type of the physics imposter
  97173. */
  97174. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  97175. /**
  97176. * This function will completly initialize this impostor.
  97177. * It will create a new body - but only if this mesh has no parent.
  97178. * If it has, this impostor will not be used other than to define the impostor
  97179. * of the child mesh.
  97180. * @hidden
  97181. */
  97182. _init(): void;
  97183. private _getPhysicsParent;
  97184. /**
  97185. * Should a new body be generated.
  97186. * @returns boolean specifying if body initialization is required
  97187. */
  97188. isBodyInitRequired(): boolean;
  97189. /**
  97190. * Sets the updated scaling
  97191. * @param updated Specifies if the scaling is updated
  97192. */
  97193. setScalingUpdated(): void;
  97194. /**
  97195. * Force a regeneration of this or the parent's impostor's body.
  97196. * Use under cautious - This will remove all joints already implemented.
  97197. */
  97198. forceUpdate(): void;
  97199. /**
  97200. * Gets the body that holds this impostor. Either its own, or its parent.
  97201. */
  97202. get physicsBody(): any;
  97203. /**
  97204. * Get the parent of the physics imposter
  97205. * @returns Physics imposter or null
  97206. */
  97207. get parent(): Nullable<PhysicsImpostor>;
  97208. /**
  97209. * Sets the parent of the physics imposter
  97210. */
  97211. set parent(value: Nullable<PhysicsImpostor>);
  97212. /**
  97213. * Set the physics body. Used mainly by the physics engine/plugin
  97214. */
  97215. set physicsBody(physicsBody: any);
  97216. /**
  97217. * Resets the update flags
  97218. */
  97219. resetUpdateFlags(): void;
  97220. /**
  97221. * Gets the object extend size
  97222. * @returns the object extend size
  97223. */
  97224. getObjectExtendSize(): Vector3;
  97225. /**
  97226. * Gets the object center
  97227. * @returns The object center
  97228. */
  97229. getObjectCenter(): Vector3;
  97230. /**
  97231. * Get a specific parameter from the options parameters
  97232. * @param paramName The object parameter name
  97233. * @returns The object parameter
  97234. */
  97235. getParam(paramName: string): any;
  97236. /**
  97237. * Sets a specific parameter in the options given to the physics plugin
  97238. * @param paramName The parameter name
  97239. * @param value The value of the parameter
  97240. */
  97241. setParam(paramName: string, value: number): void;
  97242. /**
  97243. * Specifically change the body's mass option. Won't recreate the physics body object
  97244. * @param mass The mass of the physics imposter
  97245. */
  97246. setMass(mass: number): void;
  97247. /**
  97248. * Gets the linear velocity
  97249. * @returns linear velocity or null
  97250. */
  97251. getLinearVelocity(): Nullable<Vector3>;
  97252. /**
  97253. * Sets the linear velocity
  97254. * @param velocity linear velocity or null
  97255. */
  97256. setLinearVelocity(velocity: Nullable<Vector3>): void;
  97257. /**
  97258. * Gets the angular velocity
  97259. * @returns angular velocity or null
  97260. */
  97261. getAngularVelocity(): Nullable<Vector3>;
  97262. /**
  97263. * Sets the angular velocity
  97264. * @param velocity The velocity or null
  97265. */
  97266. setAngularVelocity(velocity: Nullable<Vector3>): void;
  97267. /**
  97268. * Execute a function with the physics plugin native code
  97269. * Provide a function the will have two variables - the world object and the physics body object
  97270. * @param func The function to execute with the physics plugin native code
  97271. */
  97272. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  97273. /**
  97274. * Register a function that will be executed before the physics world is stepping forward
  97275. * @param func The function to execute before the physics world is stepped forward
  97276. */
  97277. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97278. /**
  97279. * Unregister a function that will be executed before the physics world is stepping forward
  97280. * @param func The function to execute before the physics world is stepped forward
  97281. */
  97282. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97283. /**
  97284. * Register a function that will be executed after the physics step
  97285. * @param func The function to execute after physics step
  97286. */
  97287. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97288. /**
  97289. * Unregisters a function that will be executed after the physics step
  97290. * @param func The function to execute after physics step
  97291. */
  97292. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97293. /**
  97294. * register a function that will be executed when this impostor collides against a different body
  97295. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  97296. * @param func Callback that is executed on collision
  97297. */
  97298. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  97299. /**
  97300. * Unregisters the physics imposter on contact
  97301. * @param collideAgainst The physics object to collide against
  97302. * @param func Callback to execute on collision
  97303. */
  97304. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  97305. private _tmpQuat;
  97306. private _tmpQuat2;
  97307. /**
  97308. * Get the parent rotation
  97309. * @returns The parent rotation
  97310. */
  97311. getParentsRotation(): Quaternion;
  97312. /**
  97313. * this function is executed by the physics engine.
  97314. */
  97315. beforeStep: () => void;
  97316. /**
  97317. * this function is executed by the physics engine
  97318. */
  97319. afterStep: () => void;
  97320. /**
  97321. * Legacy collision detection event support
  97322. */
  97323. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  97324. /**
  97325. * event and body object due to cannon's event-based architecture.
  97326. */
  97327. onCollide: (e: {
  97328. body: any;
  97329. }) => void;
  97330. /**
  97331. * Apply a force
  97332. * @param force The force to apply
  97333. * @param contactPoint The contact point for the force
  97334. * @returns The physics imposter
  97335. */
  97336. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  97337. /**
  97338. * Apply an impulse
  97339. * @param force The impulse force
  97340. * @param contactPoint The contact point for the impulse force
  97341. * @returns The physics imposter
  97342. */
  97343. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  97344. /**
  97345. * A help function to create a joint
  97346. * @param otherImpostor A physics imposter used to create a joint
  97347. * @param jointType The type of joint
  97348. * @param jointData The data for the joint
  97349. * @returns The physics imposter
  97350. */
  97351. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  97352. /**
  97353. * Add a joint to this impostor with a different impostor
  97354. * @param otherImpostor A physics imposter used to add a joint
  97355. * @param joint The joint to add
  97356. * @returns The physics imposter
  97357. */
  97358. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  97359. /**
  97360. * Add an anchor to a cloth impostor
  97361. * @param otherImpostor rigid impostor to anchor to
  97362. * @param width ratio across width from 0 to 1
  97363. * @param height ratio up height from 0 to 1
  97364. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  97365. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  97366. * @returns impostor the soft imposter
  97367. */
  97368. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  97369. /**
  97370. * Add a hook to a rope impostor
  97371. * @param otherImpostor rigid impostor to anchor to
  97372. * @param length ratio across rope from 0 to 1
  97373. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  97374. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  97375. * @returns impostor the rope imposter
  97376. */
  97377. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  97378. /**
  97379. * Will keep this body still, in a sleep mode.
  97380. * @returns the physics imposter
  97381. */
  97382. sleep(): PhysicsImpostor;
  97383. /**
  97384. * Wake the body up.
  97385. * @returns The physics imposter
  97386. */
  97387. wakeUp(): PhysicsImpostor;
  97388. /**
  97389. * Clones the physics imposter
  97390. * @param newObject The physics imposter clones to this physics-enabled object
  97391. * @returns A nullable physics imposter
  97392. */
  97393. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  97394. /**
  97395. * Disposes the physics imposter
  97396. */
  97397. dispose(): void;
  97398. /**
  97399. * Sets the delta position
  97400. * @param position The delta position amount
  97401. */
  97402. setDeltaPosition(position: Vector3): void;
  97403. /**
  97404. * Sets the delta rotation
  97405. * @param rotation The delta rotation amount
  97406. */
  97407. setDeltaRotation(rotation: Quaternion): void;
  97408. /**
  97409. * Gets the box size of the physics imposter and stores the result in the input parameter
  97410. * @param result Stores the box size
  97411. * @returns The physics imposter
  97412. */
  97413. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  97414. /**
  97415. * Gets the radius of the physics imposter
  97416. * @returns Radius of the physics imposter
  97417. */
  97418. getRadius(): number;
  97419. /**
  97420. * Sync a bone with this impostor
  97421. * @param bone The bone to sync to the impostor.
  97422. * @param boneMesh The mesh that the bone is influencing.
  97423. * @param jointPivot The pivot of the joint / bone in local space.
  97424. * @param distToJoint Optional distance from the impostor to the joint.
  97425. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  97426. */
  97427. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  97428. /**
  97429. * Sync impostor to a bone
  97430. * @param bone The bone that the impostor will be synced to.
  97431. * @param boneMesh The mesh that the bone is influencing.
  97432. * @param jointPivot The pivot of the joint / bone in local space.
  97433. * @param distToJoint Optional distance from the impostor to the joint.
  97434. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  97435. * @param boneAxis Optional vector3 axis the bone is aligned with
  97436. */
  97437. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  97438. /**
  97439. * No-Imposter type
  97440. */
  97441. static NoImpostor: number;
  97442. /**
  97443. * Sphere-Imposter type
  97444. */
  97445. static SphereImpostor: number;
  97446. /**
  97447. * Box-Imposter type
  97448. */
  97449. static BoxImpostor: number;
  97450. /**
  97451. * Plane-Imposter type
  97452. */
  97453. static PlaneImpostor: number;
  97454. /**
  97455. * Mesh-imposter type
  97456. */
  97457. static MeshImpostor: number;
  97458. /**
  97459. * Capsule-Impostor type (Ammo.js plugin only)
  97460. */
  97461. static CapsuleImpostor: number;
  97462. /**
  97463. * Cylinder-Imposter type
  97464. */
  97465. static CylinderImpostor: number;
  97466. /**
  97467. * Particle-Imposter type
  97468. */
  97469. static ParticleImpostor: number;
  97470. /**
  97471. * Heightmap-Imposter type
  97472. */
  97473. static HeightmapImpostor: number;
  97474. /**
  97475. * ConvexHull-Impostor type (Ammo.js plugin only)
  97476. */
  97477. static ConvexHullImpostor: number;
  97478. /**
  97479. * Custom-Imposter type (Ammo.js plugin only)
  97480. */
  97481. static CustomImpostor: number;
  97482. /**
  97483. * Rope-Imposter type
  97484. */
  97485. static RopeImpostor: number;
  97486. /**
  97487. * Cloth-Imposter type
  97488. */
  97489. static ClothImpostor: number;
  97490. /**
  97491. * Softbody-Imposter type
  97492. */
  97493. static SoftbodyImpostor: number;
  97494. }
  97495. }
  97496. declare module BABYLON {
  97497. /**
  97498. * @hidden
  97499. **/
  97500. export class _CreationDataStorage {
  97501. closePath?: boolean;
  97502. closeArray?: boolean;
  97503. idx: number[];
  97504. dashSize: number;
  97505. gapSize: number;
  97506. path3D: Path3D;
  97507. pathArray: Vector3[][];
  97508. arc: number;
  97509. radius: number;
  97510. cap: number;
  97511. tessellation: number;
  97512. }
  97513. /**
  97514. * @hidden
  97515. **/
  97516. class _InstanceDataStorage {
  97517. visibleInstances: any;
  97518. batchCache: _InstancesBatch;
  97519. instancesBufferSize: number;
  97520. instancesBuffer: Nullable<Buffer>;
  97521. instancesData: Float32Array;
  97522. overridenInstanceCount: number;
  97523. isFrozen: boolean;
  97524. previousBatch: Nullable<_InstancesBatch>;
  97525. hardwareInstancedRendering: boolean;
  97526. sideOrientation: number;
  97527. manualUpdate: boolean;
  97528. }
  97529. /**
  97530. * @hidden
  97531. **/
  97532. export class _InstancesBatch {
  97533. mustReturn: boolean;
  97534. visibleInstances: Nullable<InstancedMesh[]>[];
  97535. renderSelf: boolean[];
  97536. hardwareInstancedRendering: boolean[];
  97537. }
  97538. /**
  97539. * Class used to represent renderable models
  97540. */
  97541. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  97542. /**
  97543. * Mesh side orientation : usually the external or front surface
  97544. */
  97545. static readonly FRONTSIDE: number;
  97546. /**
  97547. * Mesh side orientation : usually the internal or back surface
  97548. */
  97549. static readonly BACKSIDE: number;
  97550. /**
  97551. * Mesh side orientation : both internal and external or front and back surfaces
  97552. */
  97553. static readonly DOUBLESIDE: number;
  97554. /**
  97555. * Mesh side orientation : by default, `FRONTSIDE`
  97556. */
  97557. static readonly DEFAULTSIDE: number;
  97558. /**
  97559. * Mesh cap setting : no cap
  97560. */
  97561. static readonly NO_CAP: number;
  97562. /**
  97563. * Mesh cap setting : one cap at the beginning of the mesh
  97564. */
  97565. static readonly CAP_START: number;
  97566. /**
  97567. * Mesh cap setting : one cap at the end of the mesh
  97568. */
  97569. static readonly CAP_END: number;
  97570. /**
  97571. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  97572. */
  97573. static readonly CAP_ALL: number;
  97574. /**
  97575. * Mesh pattern setting : no flip or rotate
  97576. */
  97577. static readonly NO_FLIP: number;
  97578. /**
  97579. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  97580. */
  97581. static readonly FLIP_TILE: number;
  97582. /**
  97583. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  97584. */
  97585. static readonly ROTATE_TILE: number;
  97586. /**
  97587. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  97588. */
  97589. static readonly FLIP_ROW: number;
  97590. /**
  97591. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  97592. */
  97593. static readonly ROTATE_ROW: number;
  97594. /**
  97595. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  97596. */
  97597. static readonly FLIP_N_ROTATE_TILE: number;
  97598. /**
  97599. * Mesh pattern setting : rotate pattern and rotate
  97600. */
  97601. static readonly FLIP_N_ROTATE_ROW: number;
  97602. /**
  97603. * Mesh tile positioning : part tiles same on left/right or top/bottom
  97604. */
  97605. static readonly CENTER: number;
  97606. /**
  97607. * Mesh tile positioning : part tiles on left
  97608. */
  97609. static readonly LEFT: number;
  97610. /**
  97611. * Mesh tile positioning : part tiles on right
  97612. */
  97613. static readonly RIGHT: number;
  97614. /**
  97615. * Mesh tile positioning : part tiles on top
  97616. */
  97617. static readonly TOP: number;
  97618. /**
  97619. * Mesh tile positioning : part tiles on bottom
  97620. */
  97621. static readonly BOTTOM: number;
  97622. /**
  97623. * Gets the default side orientation.
  97624. * @param orientation the orientation to value to attempt to get
  97625. * @returns the default orientation
  97626. * @hidden
  97627. */
  97628. static _GetDefaultSideOrientation(orientation?: number): number;
  97629. private _internalMeshDataInfo;
  97630. /**
  97631. * An event triggered before rendering the mesh
  97632. */
  97633. get onBeforeRenderObservable(): Observable<Mesh>;
  97634. /**
  97635. * An event triggered before binding the mesh
  97636. */
  97637. get onBeforeBindObservable(): Observable<Mesh>;
  97638. /**
  97639. * An event triggered after rendering the mesh
  97640. */
  97641. get onAfterRenderObservable(): Observable<Mesh>;
  97642. /**
  97643. * An event triggered before drawing the mesh
  97644. */
  97645. get onBeforeDrawObservable(): Observable<Mesh>;
  97646. private _onBeforeDrawObserver;
  97647. /**
  97648. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  97649. */
  97650. set onBeforeDraw(callback: () => void);
  97651. get hasInstances(): boolean;
  97652. /**
  97653. * Gets the delay loading state of the mesh (when delay loading is turned on)
  97654. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  97655. */
  97656. delayLoadState: number;
  97657. /**
  97658. * Gets the list of instances created from this mesh
  97659. * it is not supposed to be modified manually.
  97660. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  97661. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  97662. */
  97663. instances: InstancedMesh[];
  97664. /**
  97665. * Gets the file containing delay loading data for this mesh
  97666. */
  97667. delayLoadingFile: string;
  97668. /** @hidden */
  97669. _binaryInfo: any;
  97670. /**
  97671. * User defined function used to change how LOD level selection is done
  97672. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  97673. */
  97674. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  97675. /**
  97676. * Gets or sets the morph target manager
  97677. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  97678. */
  97679. get morphTargetManager(): Nullable<MorphTargetManager>;
  97680. set morphTargetManager(value: Nullable<MorphTargetManager>);
  97681. /** @hidden */
  97682. _creationDataStorage: Nullable<_CreationDataStorage>;
  97683. /** @hidden */
  97684. _geometry: Nullable<Geometry>;
  97685. /** @hidden */
  97686. _delayInfo: Array<string>;
  97687. /** @hidden */
  97688. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  97689. /** @hidden */
  97690. _instanceDataStorage: _InstanceDataStorage;
  97691. private _effectiveMaterial;
  97692. /** @hidden */
  97693. _shouldGenerateFlatShading: boolean;
  97694. /** @hidden */
  97695. _originalBuilderSideOrientation: number;
  97696. /**
  97697. * Use this property to change the original side orientation defined at construction time
  97698. */
  97699. overrideMaterialSideOrientation: Nullable<number>;
  97700. /**
  97701. * Gets the source mesh (the one used to clone this one from)
  97702. */
  97703. get source(): Nullable<Mesh>;
  97704. /**
  97705. * Gets or sets a boolean indicating that this mesh does not use index buffer
  97706. */
  97707. get isUnIndexed(): boolean;
  97708. set isUnIndexed(value: boolean);
  97709. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  97710. get worldMatrixInstancedBuffer(): Float32Array;
  97711. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  97712. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  97713. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  97714. /**
  97715. * @constructor
  97716. * @param name The value used by scene.getMeshByName() to do a lookup.
  97717. * @param scene The scene to add this mesh to.
  97718. * @param parent The parent of this mesh, if it has one
  97719. * @param source An optional Mesh from which geometry is shared, cloned.
  97720. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  97721. * When false, achieved by calling a clone(), also passing False.
  97722. * This will make creation of children, recursive.
  97723. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  97724. */
  97725. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  97726. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  97727. doNotInstantiate: boolean;
  97728. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  97729. /**
  97730. * Gets the class name
  97731. * @returns the string "Mesh".
  97732. */
  97733. getClassName(): string;
  97734. /** @hidden */
  97735. get _isMesh(): boolean;
  97736. /**
  97737. * Returns a description of this mesh
  97738. * @param fullDetails define if full details about this mesh must be used
  97739. * @returns a descriptive string representing this mesh
  97740. */
  97741. toString(fullDetails?: boolean): string;
  97742. /** @hidden */
  97743. _unBindEffect(): void;
  97744. /**
  97745. * Gets a boolean indicating if this mesh has LOD
  97746. */
  97747. get hasLODLevels(): boolean;
  97748. /**
  97749. * Gets the list of MeshLODLevel associated with the current mesh
  97750. * @returns an array of MeshLODLevel
  97751. */
  97752. getLODLevels(): MeshLODLevel[];
  97753. private _sortLODLevels;
  97754. /**
  97755. * Add a mesh as LOD level triggered at the given distance.
  97756. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97757. * @param distance The distance from the center of the object to show this level
  97758. * @param mesh The mesh to be added as LOD level (can be null)
  97759. * @return This mesh (for chaining)
  97760. */
  97761. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  97762. /**
  97763. * Returns the LOD level mesh at the passed distance or null if not found.
  97764. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97765. * @param distance The distance from the center of the object to show this level
  97766. * @returns a Mesh or `null`
  97767. */
  97768. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  97769. /**
  97770. * Remove a mesh from the LOD array
  97771. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97772. * @param mesh defines the mesh to be removed
  97773. * @return This mesh (for chaining)
  97774. */
  97775. removeLODLevel(mesh: Mesh): Mesh;
  97776. /**
  97777. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  97778. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97779. * @param camera defines the camera to use to compute distance
  97780. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  97781. * @return This mesh (for chaining)
  97782. */
  97783. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  97784. /**
  97785. * Gets the mesh internal Geometry object
  97786. */
  97787. get geometry(): Nullable<Geometry>;
  97788. /**
  97789. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  97790. * @returns the total number of vertices
  97791. */
  97792. getTotalVertices(): number;
  97793. /**
  97794. * Returns the content of an associated vertex buffer
  97795. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97796. * - VertexBuffer.PositionKind
  97797. * - VertexBuffer.UVKind
  97798. * - VertexBuffer.UV2Kind
  97799. * - VertexBuffer.UV3Kind
  97800. * - VertexBuffer.UV4Kind
  97801. * - VertexBuffer.UV5Kind
  97802. * - VertexBuffer.UV6Kind
  97803. * - VertexBuffer.ColorKind
  97804. * - VertexBuffer.MatricesIndicesKind
  97805. * - VertexBuffer.MatricesIndicesExtraKind
  97806. * - VertexBuffer.MatricesWeightsKind
  97807. * - VertexBuffer.MatricesWeightsExtraKind
  97808. * @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
  97809. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  97810. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  97811. */
  97812. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  97813. /**
  97814. * Returns the mesh VertexBuffer object from the requested `kind`
  97815. * @param kind defines which buffer to read from (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 FloatArray or null if the mesh has no vertex buffer for this kind.
  97830. */
  97831. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  97832. /**
  97833. * Tests if a specific vertex buffer is associated with this mesh
  97834. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  97835. * - VertexBuffer.PositionKind
  97836. * - VertexBuffer.NormalKind
  97837. * - VertexBuffer.UVKind
  97838. * - VertexBuffer.UV2Kind
  97839. * - VertexBuffer.UV3Kind
  97840. * - VertexBuffer.UV4Kind
  97841. * - VertexBuffer.UV5Kind
  97842. * - VertexBuffer.UV6Kind
  97843. * - VertexBuffer.ColorKind
  97844. * - VertexBuffer.MatricesIndicesKind
  97845. * - VertexBuffer.MatricesIndicesExtraKind
  97846. * - VertexBuffer.MatricesWeightsKind
  97847. * - VertexBuffer.MatricesWeightsExtraKind
  97848. * @returns a boolean
  97849. */
  97850. isVerticesDataPresent(kind: string): boolean;
  97851. /**
  97852. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  97853. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  97854. * - VertexBuffer.PositionKind
  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 a boolean
  97867. */
  97868. isVertexBufferUpdatable(kind: string): boolean;
  97869. /**
  97870. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  97871. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97872. * - VertexBuffer.PositionKind
  97873. * - VertexBuffer.NormalKind
  97874. * - VertexBuffer.UVKind
  97875. * - VertexBuffer.UV2Kind
  97876. * - VertexBuffer.UV3Kind
  97877. * - VertexBuffer.UV4Kind
  97878. * - VertexBuffer.UV5Kind
  97879. * - VertexBuffer.UV6Kind
  97880. * - VertexBuffer.ColorKind
  97881. * - VertexBuffer.MatricesIndicesKind
  97882. * - VertexBuffer.MatricesIndicesExtraKind
  97883. * - VertexBuffer.MatricesWeightsKind
  97884. * - VertexBuffer.MatricesWeightsExtraKind
  97885. * @returns an array of strings
  97886. */
  97887. getVerticesDataKinds(): string[];
  97888. /**
  97889. * Returns a positive integer : the total number of indices in this mesh geometry.
  97890. * @returns the numner of indices or zero if the mesh has no geometry.
  97891. */
  97892. getTotalIndices(): number;
  97893. /**
  97894. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  97895. * @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.
  97896. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  97897. * @returns the indices array or an empty array if the mesh has no geometry
  97898. */
  97899. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  97900. get isBlocked(): boolean;
  97901. /**
  97902. * Determine if the current mesh is ready to be rendered
  97903. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  97904. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  97905. * @returns true if all associated assets are ready (material, textures, shaders)
  97906. */
  97907. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  97908. /**
  97909. * 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.
  97910. */
  97911. get areNormalsFrozen(): boolean;
  97912. /**
  97913. * 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.
  97914. * @returns the current mesh
  97915. */
  97916. freezeNormals(): Mesh;
  97917. /**
  97918. * 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
  97919. * @returns the current mesh
  97920. */
  97921. unfreezeNormals(): Mesh;
  97922. /**
  97923. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  97924. */
  97925. set overridenInstanceCount(count: number);
  97926. /** @hidden */
  97927. _preActivate(): Mesh;
  97928. /** @hidden */
  97929. _preActivateForIntermediateRendering(renderId: number): Mesh;
  97930. /** @hidden */
  97931. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  97932. /**
  97933. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  97934. * This means the mesh underlying bounding box and sphere are recomputed.
  97935. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  97936. * @returns the current mesh
  97937. */
  97938. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  97939. /** @hidden */
  97940. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  97941. /**
  97942. * This function will subdivide the mesh into multiple submeshes
  97943. * @param count defines the expected number of submeshes
  97944. */
  97945. subdivide(count: number): void;
  97946. /**
  97947. * Copy a FloatArray into a specific associated vertex buffer
  97948. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  97949. * - VertexBuffer.PositionKind
  97950. * - VertexBuffer.UVKind
  97951. * - VertexBuffer.UV2Kind
  97952. * - VertexBuffer.UV3Kind
  97953. * - VertexBuffer.UV4Kind
  97954. * - VertexBuffer.UV5Kind
  97955. * - VertexBuffer.UV6Kind
  97956. * - VertexBuffer.ColorKind
  97957. * - VertexBuffer.MatricesIndicesKind
  97958. * - VertexBuffer.MatricesIndicesExtraKind
  97959. * - VertexBuffer.MatricesWeightsKind
  97960. * - VertexBuffer.MatricesWeightsExtraKind
  97961. * @param data defines the data source
  97962. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  97963. * @param stride defines the data stride size (can be null)
  97964. * @returns the current mesh
  97965. */
  97966. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  97967. /**
  97968. * Delete a vertex buffer associated with this mesh
  97969. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  97970. * - VertexBuffer.PositionKind
  97971. * - VertexBuffer.UVKind
  97972. * - VertexBuffer.UV2Kind
  97973. * - VertexBuffer.UV3Kind
  97974. * - VertexBuffer.UV4Kind
  97975. * - VertexBuffer.UV5Kind
  97976. * - VertexBuffer.UV6Kind
  97977. * - VertexBuffer.ColorKind
  97978. * - VertexBuffer.MatricesIndicesKind
  97979. * - VertexBuffer.MatricesIndicesExtraKind
  97980. * - VertexBuffer.MatricesWeightsKind
  97981. * - VertexBuffer.MatricesWeightsExtraKind
  97982. */
  97983. removeVerticesData(kind: string): void;
  97984. /**
  97985. * Flags an associated vertex buffer as updatable
  97986. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  97987. * - VertexBuffer.PositionKind
  97988. * - VertexBuffer.UVKind
  97989. * - VertexBuffer.UV2Kind
  97990. * - VertexBuffer.UV3Kind
  97991. * - VertexBuffer.UV4Kind
  97992. * - VertexBuffer.UV5Kind
  97993. * - VertexBuffer.UV6Kind
  97994. * - VertexBuffer.ColorKind
  97995. * - VertexBuffer.MatricesIndicesKind
  97996. * - VertexBuffer.MatricesIndicesExtraKind
  97997. * - VertexBuffer.MatricesWeightsKind
  97998. * - VertexBuffer.MatricesWeightsExtraKind
  97999. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  98000. */
  98001. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  98002. /**
  98003. * Sets the mesh global Vertex Buffer
  98004. * @param buffer defines the buffer to use
  98005. * @returns the current mesh
  98006. */
  98007. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  98008. /**
  98009. * Update a specific associated vertex buffer
  98010. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  98011. * - VertexBuffer.PositionKind
  98012. * - VertexBuffer.UVKind
  98013. * - VertexBuffer.UV2Kind
  98014. * - VertexBuffer.UV3Kind
  98015. * - VertexBuffer.UV4Kind
  98016. * - VertexBuffer.UV5Kind
  98017. * - VertexBuffer.UV6Kind
  98018. * - VertexBuffer.ColorKind
  98019. * - VertexBuffer.MatricesIndicesKind
  98020. * - VertexBuffer.MatricesIndicesExtraKind
  98021. * - VertexBuffer.MatricesWeightsKind
  98022. * - VertexBuffer.MatricesWeightsExtraKind
  98023. * @param data defines the data source
  98024. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  98025. * @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)
  98026. * @returns the current mesh
  98027. */
  98028. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  98029. /**
  98030. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  98031. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  98032. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  98033. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  98034. * @returns the current mesh
  98035. */
  98036. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  98037. /**
  98038. * Creates a un-shared specific occurence of the geometry for the mesh.
  98039. * @returns the current mesh
  98040. */
  98041. makeGeometryUnique(): Mesh;
  98042. /**
  98043. * Set the index buffer of this mesh
  98044. * @param indices defines the source data
  98045. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  98046. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  98047. * @returns the current mesh
  98048. */
  98049. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  98050. /**
  98051. * Update the current index buffer
  98052. * @param indices defines the source data
  98053. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  98054. * @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)
  98055. * @returns the current mesh
  98056. */
  98057. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  98058. /**
  98059. * Invert the geometry to move from a right handed system to a left handed one.
  98060. * @returns the current mesh
  98061. */
  98062. toLeftHanded(): Mesh;
  98063. /** @hidden */
  98064. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  98065. /** @hidden */
  98066. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  98067. /**
  98068. * Registers for this mesh a javascript function called just before the rendering process
  98069. * @param func defines the function to call before rendering this mesh
  98070. * @returns the current mesh
  98071. */
  98072. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  98073. /**
  98074. * Disposes a previously registered javascript function called before the rendering
  98075. * @param func defines the function to remove
  98076. * @returns the current mesh
  98077. */
  98078. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  98079. /**
  98080. * Registers for this mesh a javascript function called just after the rendering is complete
  98081. * @param func defines the function to call after rendering this mesh
  98082. * @returns the current mesh
  98083. */
  98084. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  98085. /**
  98086. * Disposes a previously registered javascript function called after the rendering.
  98087. * @param func defines the function to remove
  98088. * @returns the current mesh
  98089. */
  98090. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  98091. /** @hidden */
  98092. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  98093. /** @hidden */
  98094. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  98095. /** @hidden */
  98096. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  98097. /** @hidden */
  98098. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  98099. /** @hidden */
  98100. _rebuild(): void;
  98101. /** @hidden */
  98102. _freeze(): void;
  98103. /** @hidden */
  98104. _unFreeze(): void;
  98105. /**
  98106. * 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
  98107. * @param subMesh defines the subMesh to render
  98108. * @param enableAlphaMode defines if alpha mode can be changed
  98109. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  98110. * @returns the current mesh
  98111. */
  98112. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  98113. private _onBeforeDraw;
  98114. /**
  98115. * Renormalize the mesh and patch it up if there are no weights
  98116. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  98117. * However in the case of zero weights then we set just a single influence to 1.
  98118. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  98119. */
  98120. cleanMatrixWeights(): void;
  98121. private normalizeSkinFourWeights;
  98122. private normalizeSkinWeightsAndExtra;
  98123. /**
  98124. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  98125. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  98126. * the user know there was an issue with importing the mesh
  98127. * @returns a validation object with skinned, valid and report string
  98128. */
  98129. validateSkinning(): {
  98130. skinned: boolean;
  98131. valid: boolean;
  98132. report: string;
  98133. };
  98134. /** @hidden */
  98135. _checkDelayState(): Mesh;
  98136. private _queueLoad;
  98137. /**
  98138. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  98139. * A mesh is in the frustum if its bounding box intersects the frustum
  98140. * @param frustumPlanes defines the frustum to test
  98141. * @returns true if the mesh is in the frustum planes
  98142. */
  98143. isInFrustum(frustumPlanes: Plane[]): boolean;
  98144. /**
  98145. * Sets the mesh material by the material or multiMaterial `id` property
  98146. * @param id is a string identifying the material or the multiMaterial
  98147. * @returns the current mesh
  98148. */
  98149. setMaterialByID(id: string): Mesh;
  98150. /**
  98151. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  98152. * @returns an array of IAnimatable
  98153. */
  98154. getAnimatables(): IAnimatable[];
  98155. /**
  98156. * Modifies the mesh geometry according to the passed transformation matrix.
  98157. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  98158. * The mesh normals are modified using the same transformation.
  98159. * Note that, under the hood, this method sets a new VertexBuffer each call.
  98160. * @param transform defines the transform matrix to use
  98161. * @see http://doc.babylonjs.com/resources/baking_transformations
  98162. * @returns the current mesh
  98163. */
  98164. bakeTransformIntoVertices(transform: Matrix): Mesh;
  98165. /**
  98166. * Modifies the mesh geometry according to its own current World Matrix.
  98167. * The mesh World Matrix is then reset.
  98168. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  98169. * Note that, under the hood, this method sets a new VertexBuffer each call.
  98170. * @see http://doc.babylonjs.com/resources/baking_transformations
  98171. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  98172. * @returns the current mesh
  98173. */
  98174. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  98175. /** @hidden */
  98176. get _positions(): Nullable<Vector3[]>;
  98177. /** @hidden */
  98178. _resetPointsArrayCache(): Mesh;
  98179. /** @hidden */
  98180. _generatePointsArray(): boolean;
  98181. /**
  98182. * Returns a new Mesh object generated from the current mesh properties.
  98183. * This method must not get confused with createInstance()
  98184. * @param name is a string, the name given to the new mesh
  98185. * @param newParent can be any Node object (default `null`)
  98186. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  98187. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  98188. * @returns a new mesh
  98189. */
  98190. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  98191. /**
  98192. * Releases resources associated with this mesh.
  98193. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98194. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98195. */
  98196. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98197. /** @hidden */
  98198. _disposeInstanceSpecificData(): void;
  98199. /**
  98200. * Modifies the mesh geometry according to a displacement map.
  98201. * 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.
  98202. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  98203. * @param url is a string, the URL from the image file is to be downloaded.
  98204. * @param minHeight is the lower limit of the displacement.
  98205. * @param maxHeight is the upper limit of the displacement.
  98206. * @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.
  98207. * @param uvOffset is an optional vector2 used to offset UV.
  98208. * @param uvScale is an optional vector2 used to scale UV.
  98209. * @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.
  98210. * @returns the Mesh.
  98211. */
  98212. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  98213. /**
  98214. * Modifies the mesh geometry according to a displacementMap buffer.
  98215. * 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.
  98216. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  98217. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  98218. * @param heightMapWidth is the width of the buffer image.
  98219. * @param heightMapHeight is the height of the buffer image.
  98220. * @param minHeight is the lower limit of the displacement.
  98221. * @param maxHeight is the upper limit of the displacement.
  98222. * @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.
  98223. * @param uvOffset is an optional vector2 used to offset UV.
  98224. * @param uvScale is an optional vector2 used to scale UV.
  98225. * @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.
  98226. * @returns the Mesh.
  98227. */
  98228. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  98229. /**
  98230. * Modify the mesh to get a flat shading rendering.
  98231. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  98232. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  98233. * @returns current mesh
  98234. */
  98235. convertToFlatShadedMesh(): Mesh;
  98236. /**
  98237. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  98238. * In other words, more vertices, no more indices and a single bigger VBO.
  98239. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  98240. * @returns current mesh
  98241. */
  98242. convertToUnIndexedMesh(): Mesh;
  98243. /**
  98244. * Inverses facet orientations.
  98245. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98246. * @param flipNormals will also inverts the normals
  98247. * @returns current mesh
  98248. */
  98249. flipFaces(flipNormals?: boolean): Mesh;
  98250. /**
  98251. * Increase the number of facets and hence vertices in a mesh
  98252. * Vertex normals are interpolated from existing vertex normals
  98253. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98254. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  98255. */
  98256. increaseVertices(numberPerEdge: number): void;
  98257. /**
  98258. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  98259. * This will undo any application of covertToFlatShadedMesh
  98260. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98261. */
  98262. forceSharedVertices(): void;
  98263. /** @hidden */
  98264. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  98265. /** @hidden */
  98266. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  98267. /**
  98268. * Creates a new InstancedMesh object from the mesh model.
  98269. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  98270. * @param name defines the name of the new instance
  98271. * @returns a new InstancedMesh
  98272. */
  98273. createInstance(name: string): InstancedMesh;
  98274. /**
  98275. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  98276. * After this call, all the mesh instances have the same submeshes than the current mesh.
  98277. * @returns the current mesh
  98278. */
  98279. synchronizeInstances(): Mesh;
  98280. /**
  98281. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  98282. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  98283. * This should be used together with the simplification to avoid disappearing triangles.
  98284. * @param successCallback an optional success callback to be called after the optimization finished.
  98285. * @returns the current mesh
  98286. */
  98287. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  98288. /**
  98289. * Serialize current mesh
  98290. * @param serializationObject defines the object which will receive the serialization data
  98291. */
  98292. serialize(serializationObject: any): void;
  98293. /** @hidden */
  98294. _syncGeometryWithMorphTargetManager(): void;
  98295. /** @hidden */
  98296. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  98297. /**
  98298. * Returns a new Mesh object parsed from the source provided.
  98299. * @param parsedMesh is the source
  98300. * @param scene defines the hosting scene
  98301. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  98302. * @returns a new Mesh
  98303. */
  98304. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  98305. /**
  98306. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  98307. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98308. * @param name defines the name of the mesh to create
  98309. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  98310. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  98311. * @param closePath creates a seam between the first and the last points of each path of the path array
  98312. * @param offset is taken in account only if the `pathArray` is containing a single path
  98313. * @param scene defines the hosting scene
  98314. * @param updatable defines if the mesh must be flagged as updatable
  98315. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98316. * @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)
  98317. * @returns a new Mesh
  98318. */
  98319. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98320. /**
  98321. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  98322. * @param name defines the name of the mesh to create
  98323. * @param radius sets the radius size (float) of the polygon (default 0.5)
  98324. * @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
  98325. * @param scene defines the hosting scene
  98326. * @param updatable defines if the mesh must be flagged as updatable
  98327. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98328. * @returns a new Mesh
  98329. */
  98330. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  98331. /**
  98332. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  98333. * @param name defines the name of the mesh to create
  98334. * @param size sets the size (float) of each box side (default 1)
  98335. * @param scene defines the hosting scene
  98336. * @param updatable defines if the mesh must be flagged as updatable
  98337. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98338. * @returns a new Mesh
  98339. */
  98340. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  98341. /**
  98342. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  98343. * @param name defines the name of the mesh to create
  98344. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  98345. * @param diameter sets the diameter size (float) of the sphere (default 1)
  98346. * @param scene defines the hosting scene
  98347. * @param updatable defines if the mesh must be flagged as updatable
  98348. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98349. * @returns a new Mesh
  98350. */
  98351. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98352. /**
  98353. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  98354. * @param name defines the name of the mesh to create
  98355. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  98356. * @param diameter sets the diameter size (float) of the sphere (default 1)
  98357. * @param scene defines the hosting scene
  98358. * @returns a new Mesh
  98359. */
  98360. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  98361. /**
  98362. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  98363. * @param name defines the name of the mesh to create
  98364. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  98365. * @param diameterTop set the top cap diameter (floats, default 1)
  98366. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  98367. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  98368. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  98369. * @param scene defines the hosting scene
  98370. * @param updatable defines if the mesh must be flagged as updatable
  98371. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98372. * @returns a new Mesh
  98373. */
  98374. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  98375. /**
  98376. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  98377. * @param name defines the name of the mesh to create
  98378. * @param diameter sets the diameter size (float) of the torus (default 1)
  98379. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  98380. * @param tessellation sets the number of torus sides (postive integer, default 16)
  98381. * @param scene defines the hosting scene
  98382. * @param updatable defines if the mesh must be flagged as updatable
  98383. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98384. * @returns a new Mesh
  98385. */
  98386. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98387. /**
  98388. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  98389. * @param name defines the name of the mesh to create
  98390. * @param radius sets the global radius size (float) of the torus knot (default 2)
  98391. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  98392. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  98393. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  98394. * @param p the number of windings on X axis (positive integers, default 2)
  98395. * @param q the number of windings on Y axis (positive integers, default 3)
  98396. * @param scene defines the hosting scene
  98397. * @param updatable defines if the mesh must be flagged as updatable
  98398. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98399. * @returns a new Mesh
  98400. */
  98401. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98402. /**
  98403. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  98404. * @param name defines the name of the mesh to create
  98405. * @param points is an array successive Vector3
  98406. * @param scene defines the hosting scene
  98407. * @param updatable defines if the mesh must be flagged as updatable
  98408. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines).
  98409. * @returns a new Mesh
  98410. */
  98411. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  98412. /**
  98413. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  98414. * @param name defines the name of the mesh to create
  98415. * @param points is an array successive Vector3
  98416. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  98417. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  98418. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  98419. * @param scene defines the hosting scene
  98420. * @param updatable defines if the mesh must be flagged as updatable
  98421. * @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)
  98422. * @returns a new Mesh
  98423. */
  98424. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  98425. /**
  98426. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  98427. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  98428. * 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.
  98429. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98430. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98431. * Remember you can only change the shape positions, not their number when updating a polygon.
  98432. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  98433. * @param name defines the name of the mesh to create
  98434. * @param shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  98435. * @param scene defines the hosting scene
  98436. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  98437. * @param updatable defines if the mesh must be flagged as updatable
  98438. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98439. * @param earcutInjection can be used to inject your own earcut reference
  98440. * @returns a new Mesh
  98441. */
  98442. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  98443. /**
  98444. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  98445. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  98446. * @param name defines the name of the mesh to create
  98447. * @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
  98448. * @param depth defines the height of extrusion
  98449. * @param scene defines the hosting scene
  98450. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  98451. * @param updatable defines if the mesh must be flagged as updatable
  98452. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98453. * @param earcutInjection can be used to inject your own earcut reference
  98454. * @returns a new Mesh
  98455. */
  98456. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  98457. /**
  98458. * Creates an extruded shape mesh.
  98459. * 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
  98460. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  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 scale is the value to scale the shape
  98466. * @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
  98467. * @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
  98468. * @param scene defines the hosting scene
  98469. * @param updatable defines if the mesh must be flagged as updatable
  98470. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98471. * @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)
  98472. * @returns a new Mesh
  98473. */
  98474. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98475. /**
  98476. * Creates an custom extruded shape mesh.
  98477. * The custom extrusion is a parametric shape.
  98478. * It has no predefined shape. Its final shape will depend on the input parameters.
  98479. * Please consider using the same method from the MeshBuilder class instead
  98480. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  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 extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
  98483. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  98484. * @param scaleFunction is a custom Javascript function called on each path point
  98485. * @param rotationFunction is a custom Javascript function called on each path point
  98486. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  98487. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  98488. * @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
  98489. * @param scene defines the hosting scene
  98490. * @param updatable defines if the mesh must be flagged as updatable
  98491. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98492. * @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)
  98493. * @returns a new Mesh
  98494. */
  98495. 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;
  98496. /**
  98497. * Creates lathe mesh.
  98498. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  98499. * Please consider using the same method from the MeshBuilder class instead
  98500. * @param name defines the name of the mesh to create
  98501. * @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
  98502. * @param radius is the radius value of the lathe
  98503. * @param tessellation is the side number of the lathe.
  98504. * @param scene defines the hosting scene
  98505. * @param updatable defines if the mesh must be flagged as updatable
  98506. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98507. * @returns a new Mesh
  98508. */
  98509. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98510. /**
  98511. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  98512. * @param name defines the name of the mesh to create
  98513. * @param size sets the size (float) of both sides of the plane at once (default 1)
  98514. * @param scene defines the hosting scene
  98515. * @param updatable defines if the mesh must be flagged as updatable
  98516. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98517. * @returns a new Mesh
  98518. */
  98519. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98520. /**
  98521. * Creates a ground mesh.
  98522. * Please consider using the same method from the MeshBuilder class instead
  98523. * @param name defines the name of the mesh to create
  98524. * @param width set the width of the ground
  98525. * @param height set the height of the ground
  98526. * @param subdivisions sets the number of subdivisions per side
  98527. * @param scene defines the hosting scene
  98528. * @param updatable defines if the mesh must be flagged as updatable
  98529. * @returns a new Mesh
  98530. */
  98531. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  98532. /**
  98533. * Creates a tiled ground mesh.
  98534. * Please consider using the same method from the MeshBuilder class instead
  98535. * @param name defines the name of the mesh to create
  98536. * @param xmin set the ground minimum X coordinate
  98537. * @param zmin set the ground minimum Y coordinate
  98538. * @param xmax set the ground maximum X coordinate
  98539. * @param zmax set the ground maximum Z coordinate
  98540. * @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
  98541. * @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
  98542. * @param scene defines the hosting scene
  98543. * @param updatable defines if the mesh must be flagged as updatable
  98544. * @returns a new Mesh
  98545. */
  98546. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  98547. w: number;
  98548. h: number;
  98549. }, precision: {
  98550. w: number;
  98551. h: number;
  98552. }, scene: Scene, updatable?: boolean): Mesh;
  98553. /**
  98554. * Creates a ground mesh from a height map.
  98555. * Please consider using the same method from the MeshBuilder class instead
  98556. * @see http://doc.babylonjs.com/babylon101/height_map
  98557. * @param name defines the name of the mesh to create
  98558. * @param url sets the URL of the height map image resource
  98559. * @param width set the ground width size
  98560. * @param height set the ground height size
  98561. * @param subdivisions sets the number of subdivision per side
  98562. * @param minHeight is the minimum altitude on the ground
  98563. * @param maxHeight is the maximum altitude on the ground
  98564. * @param scene defines the hosting scene
  98565. * @param updatable defines if the mesh must be flagged as updatable
  98566. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  98567. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  98568. * @returns a new Mesh
  98569. */
  98570. 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;
  98571. /**
  98572. * Creates a tube mesh.
  98573. * The tube is a parametric shape.
  98574. * It has no predefined shape. Its final shape will depend on the input parameters.
  98575. * Please consider using the same method from the MeshBuilder class instead
  98576. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98577. * @param name defines the name of the mesh to create
  98578. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  98579. * @param radius sets the tube radius size
  98580. * @param tessellation is the number of sides on the tubular surface
  98581. * @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
  98582. * @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
  98583. * @param scene defines the hosting scene
  98584. * @param updatable defines if the mesh must be flagged as updatable
  98585. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98586. * @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)
  98587. * @returns a new Mesh
  98588. */
  98589. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  98590. (i: number, distance: number): number;
  98591. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98592. /**
  98593. * Creates a polyhedron mesh.
  98594. * Please consider using the same method from the MeshBuilder class instead.
  98595. * * 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
  98596. * * The parameter `size` (positive float, default 1) sets the polygon size
  98597. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  98598. * * 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`
  98599. * * 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
  98600. * * 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)`)
  98601. * * 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
  98602. * * 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
  98603. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98604. * * If you create a double-sided mesh, you can choose what parts of 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
  98605. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98606. * @param name defines the name of the mesh to create
  98607. * @param options defines the options used to create the mesh
  98608. * @param scene defines the hosting scene
  98609. * @returns a new Mesh
  98610. */
  98611. static CreatePolyhedron(name: string, options: {
  98612. type?: number;
  98613. size?: number;
  98614. sizeX?: number;
  98615. sizeY?: number;
  98616. sizeZ?: number;
  98617. custom?: any;
  98618. faceUV?: Vector4[];
  98619. faceColors?: Color4[];
  98620. updatable?: boolean;
  98621. sideOrientation?: number;
  98622. }, scene: Scene): Mesh;
  98623. /**
  98624. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  98625. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  98626. * * 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`)
  98627. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  98628. * * 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
  98629. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98630. * * If you create a double-sided mesh, you can choose what parts of 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
  98631. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98632. * @param name defines the name of the mesh
  98633. * @param options defines the options used to create the mesh
  98634. * @param scene defines the hosting scene
  98635. * @returns a new Mesh
  98636. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  98637. */
  98638. static CreateIcoSphere(name: string, options: {
  98639. radius?: number;
  98640. flat?: boolean;
  98641. subdivisions?: number;
  98642. sideOrientation?: number;
  98643. updatable?: boolean;
  98644. }, scene: Scene): Mesh;
  98645. /**
  98646. * Creates a decal mesh.
  98647. * Please consider using the same method from the MeshBuilder class instead.
  98648. * A decal is a mesh usually applied as a model onto the surface of another mesh
  98649. * @param name defines the name of the mesh
  98650. * @param sourceMesh defines the mesh receiving the decal
  98651. * @param position sets the position of the decal in world coordinates
  98652. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  98653. * @param size sets the decal scaling
  98654. * @param angle sets the angle to rotate the decal
  98655. * @returns a new Mesh
  98656. */
  98657. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  98658. /**
  98659. * Prepare internal position array for software CPU skinning
  98660. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  98661. */
  98662. setPositionsForCPUSkinning(): Float32Array;
  98663. /**
  98664. * Prepare internal normal array for software CPU skinning
  98665. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  98666. */
  98667. setNormalsForCPUSkinning(): Float32Array;
  98668. /**
  98669. * Updates the vertex buffer by applying transformation from the bones
  98670. * @param skeleton defines the skeleton to apply to current mesh
  98671. * @returns the current mesh
  98672. */
  98673. applySkeleton(skeleton: Skeleton): Mesh;
  98674. /**
  98675. * 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
  98676. * @param meshes defines the list of meshes to scan
  98677. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  98678. */
  98679. static MinMax(meshes: AbstractMesh[]): {
  98680. min: Vector3;
  98681. max: Vector3;
  98682. };
  98683. /**
  98684. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  98685. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  98686. * @returns a vector3
  98687. */
  98688. static Center(meshesOrMinMaxVector: {
  98689. min: Vector3;
  98690. max: Vector3;
  98691. } | AbstractMesh[]): Vector3;
  98692. /**
  98693. * Merge the array of meshes into a single mesh for performance reasons.
  98694. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  98695. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  98696. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  98697. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  98698. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  98699. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  98700. * @returns a new mesh
  98701. */
  98702. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  98703. /** @hidden */
  98704. addInstance(instance: InstancedMesh): void;
  98705. /** @hidden */
  98706. removeInstance(instance: InstancedMesh): void;
  98707. }
  98708. }
  98709. declare module BABYLON {
  98710. /**
  98711. * This is the base class of all the camera used in the application.
  98712. * @see http://doc.babylonjs.com/features/cameras
  98713. */
  98714. export class Camera extends Node {
  98715. /** @hidden */
  98716. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  98717. /**
  98718. * This is the default projection mode used by the cameras.
  98719. * It helps recreating a feeling of perspective and better appreciate depth.
  98720. * This is the best way to simulate real life cameras.
  98721. */
  98722. static readonly PERSPECTIVE_CAMERA: number;
  98723. /**
  98724. * This helps creating camera with an orthographic mode.
  98725. * 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.
  98726. */
  98727. static readonly ORTHOGRAPHIC_CAMERA: number;
  98728. /**
  98729. * This is the default FOV mode for perspective cameras.
  98730. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  98731. */
  98732. static readonly FOVMODE_VERTICAL_FIXED: number;
  98733. /**
  98734. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  98735. */
  98736. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  98737. /**
  98738. * This specifies ther is no need for a camera rig.
  98739. * Basically only one eye is rendered corresponding to the camera.
  98740. */
  98741. static readonly RIG_MODE_NONE: number;
  98742. /**
  98743. * Simulates a camera Rig with one blue eye and one red eye.
  98744. * This can be use with 3d blue and red glasses.
  98745. */
  98746. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  98747. /**
  98748. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  98749. */
  98750. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  98751. /**
  98752. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  98753. */
  98754. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  98755. /**
  98756. * Defines that both eyes of the camera will be rendered over under each other.
  98757. */
  98758. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  98759. /**
  98760. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  98761. */
  98762. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  98763. /**
  98764. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  98765. */
  98766. static readonly RIG_MODE_VR: number;
  98767. /**
  98768. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  98769. */
  98770. static readonly RIG_MODE_WEBVR: number;
  98771. /**
  98772. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  98773. */
  98774. static readonly RIG_MODE_CUSTOM: number;
  98775. /**
  98776. * Defines if by default attaching controls should prevent the default javascript event to continue.
  98777. */
  98778. static ForceAttachControlToAlwaysPreventDefault: boolean;
  98779. /**
  98780. * Define the input manager associated with the camera.
  98781. */
  98782. inputs: CameraInputsManager<Camera>;
  98783. /** @hidden */
  98784. _position: Vector3;
  98785. /**
  98786. * Define the current local position of the camera in the scene
  98787. */
  98788. get position(): Vector3;
  98789. set position(newPosition: Vector3);
  98790. /**
  98791. * The vector the camera should consider as up.
  98792. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  98793. */
  98794. upVector: Vector3;
  98795. /**
  98796. * Define the current limit on the left side for an orthographic camera
  98797. * In scene unit
  98798. */
  98799. orthoLeft: Nullable<number>;
  98800. /**
  98801. * Define the current limit on the right side for an orthographic camera
  98802. * In scene unit
  98803. */
  98804. orthoRight: Nullable<number>;
  98805. /**
  98806. * Define the current limit on the bottom side for an orthographic camera
  98807. * In scene unit
  98808. */
  98809. orthoBottom: Nullable<number>;
  98810. /**
  98811. * Define the current limit on the top side for an orthographic camera
  98812. * In scene unit
  98813. */
  98814. orthoTop: Nullable<number>;
  98815. /**
  98816. * Field Of View is set in Radians. (default is 0.8)
  98817. */
  98818. fov: number;
  98819. /**
  98820. * Define the minimum distance the camera can see from.
  98821. * This is important to note that the depth buffer are not infinite and the closer it starts
  98822. * the more your scene might encounter depth fighting issue.
  98823. */
  98824. minZ: number;
  98825. /**
  98826. * Define the maximum distance the camera can see to.
  98827. * This is important to note that the depth buffer are not infinite and the further it end
  98828. * the more your scene might encounter depth fighting issue.
  98829. */
  98830. maxZ: number;
  98831. /**
  98832. * Define the default inertia of the camera.
  98833. * This helps giving a smooth feeling to the camera movement.
  98834. */
  98835. inertia: number;
  98836. /**
  98837. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  98838. */
  98839. mode: number;
  98840. /**
  98841. * Define whether the camera is intermediate.
  98842. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  98843. */
  98844. isIntermediate: boolean;
  98845. /**
  98846. * Define the viewport of the camera.
  98847. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  98848. */
  98849. viewport: Viewport;
  98850. /**
  98851. * Restricts the camera to viewing objects with the same layerMask.
  98852. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  98853. */
  98854. layerMask: number;
  98855. /**
  98856. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  98857. */
  98858. fovMode: number;
  98859. /**
  98860. * Rig mode of the camera.
  98861. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  98862. * This is normally controlled byt the camera themselves as internal use.
  98863. */
  98864. cameraRigMode: number;
  98865. /**
  98866. * Defines the distance between both "eyes" in case of a RIG
  98867. */
  98868. interaxialDistance: number;
  98869. /**
  98870. * Defines if stereoscopic rendering is done side by side or over under.
  98871. */
  98872. isStereoscopicSideBySide: boolean;
  98873. /**
  98874. * 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
  98875. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  98876. * else in the scene. (Eg. security camera)
  98877. *
  98878. * 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)
  98879. */
  98880. customRenderTargets: RenderTargetTexture[];
  98881. /**
  98882. * When set, the camera will render to this render target instead of the default canvas
  98883. *
  98884. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  98885. */
  98886. outputRenderTarget: Nullable<RenderTargetTexture>;
  98887. /**
  98888. * Observable triggered when the camera view matrix has changed.
  98889. */
  98890. onViewMatrixChangedObservable: Observable<Camera>;
  98891. /**
  98892. * Observable triggered when the camera Projection matrix has changed.
  98893. */
  98894. onProjectionMatrixChangedObservable: Observable<Camera>;
  98895. /**
  98896. * Observable triggered when the inputs have been processed.
  98897. */
  98898. onAfterCheckInputsObservable: Observable<Camera>;
  98899. /**
  98900. * Observable triggered when reset has been called and applied to the camera.
  98901. */
  98902. onRestoreStateObservable: Observable<Camera>;
  98903. /**
  98904. * Is this camera a part of a rig system?
  98905. */
  98906. isRigCamera: boolean;
  98907. /**
  98908. * If isRigCamera set to true this will be set with the parent camera.
  98909. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  98910. */
  98911. rigParent?: Camera;
  98912. /** @hidden */
  98913. _cameraRigParams: any;
  98914. /** @hidden */
  98915. _rigCameras: Camera[];
  98916. /** @hidden */
  98917. _rigPostProcess: Nullable<PostProcess>;
  98918. protected _webvrViewMatrix: Matrix;
  98919. /** @hidden */
  98920. _skipRendering: boolean;
  98921. /** @hidden */
  98922. _projectionMatrix: Matrix;
  98923. /** @hidden */
  98924. _postProcesses: Nullable<PostProcess>[];
  98925. /** @hidden */
  98926. _activeMeshes: SmartArray<AbstractMesh>;
  98927. protected _globalPosition: Vector3;
  98928. /** @hidden */
  98929. _computedViewMatrix: Matrix;
  98930. private _doNotComputeProjectionMatrix;
  98931. private _transformMatrix;
  98932. private _frustumPlanes;
  98933. private _refreshFrustumPlanes;
  98934. private _storedFov;
  98935. private _stateStored;
  98936. /**
  98937. * Instantiates a new camera object.
  98938. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  98939. * @see http://doc.babylonjs.com/features/cameras
  98940. * @param name Defines the name of the camera in the scene
  98941. * @param position Defines the position of the camera
  98942. * @param scene Defines the scene the camera belongs too
  98943. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  98944. */
  98945. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98946. /**
  98947. * Store current camera state (fov, position, etc..)
  98948. * @returns the camera
  98949. */
  98950. storeState(): Camera;
  98951. /**
  98952. * Restores the camera state values if it has been stored. You must call storeState() first
  98953. */
  98954. protected _restoreStateValues(): boolean;
  98955. /**
  98956. * Restored camera state. You must call storeState() first.
  98957. * @returns true if restored and false otherwise
  98958. */
  98959. restoreState(): boolean;
  98960. /**
  98961. * Gets the class name of the camera.
  98962. * @returns the class name
  98963. */
  98964. getClassName(): string;
  98965. /** @hidden */
  98966. readonly _isCamera: boolean;
  98967. /**
  98968. * Gets a string representation of the camera useful for debug purpose.
  98969. * @param fullDetails Defines that a more verboe level of logging is required
  98970. * @returns the string representation
  98971. */
  98972. toString(fullDetails?: boolean): string;
  98973. /**
  98974. * Gets the current world space position of the camera.
  98975. */
  98976. get globalPosition(): Vector3;
  98977. /**
  98978. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  98979. * @returns the active meshe list
  98980. */
  98981. getActiveMeshes(): SmartArray<AbstractMesh>;
  98982. /**
  98983. * Check whether a mesh is part of the current active mesh list of the camera
  98984. * @param mesh Defines the mesh to check
  98985. * @returns true if active, false otherwise
  98986. */
  98987. isActiveMesh(mesh: Mesh): boolean;
  98988. /**
  98989. * Is this camera ready to be used/rendered
  98990. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  98991. * @return true if the camera is ready
  98992. */
  98993. isReady(completeCheck?: boolean): boolean;
  98994. /** @hidden */
  98995. _initCache(): void;
  98996. /** @hidden */
  98997. _updateCache(ignoreParentClass?: boolean): void;
  98998. /** @hidden */
  98999. _isSynchronized(): boolean;
  99000. /** @hidden */
  99001. _isSynchronizedViewMatrix(): boolean;
  99002. /** @hidden */
  99003. _isSynchronizedProjectionMatrix(): boolean;
  99004. /**
  99005. * Attach the input controls to a specific dom element to get the input from.
  99006. * @param element Defines the element the controls should be listened from
  99007. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99008. */
  99009. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99010. /**
  99011. * Detach the current controls from the specified dom element.
  99012. * @param element Defines the element to stop listening the inputs from
  99013. */
  99014. detachControl(element: HTMLElement): void;
  99015. /**
  99016. * Update the camera state according to the different inputs gathered during the frame.
  99017. */
  99018. update(): void;
  99019. /** @hidden */
  99020. _checkInputs(): void;
  99021. /** @hidden */
  99022. get rigCameras(): Camera[];
  99023. /**
  99024. * Gets the post process used by the rig cameras
  99025. */
  99026. get rigPostProcess(): Nullable<PostProcess>;
  99027. /**
  99028. * Internal, gets the first post proces.
  99029. * @returns the first post process to be run on this camera.
  99030. */
  99031. _getFirstPostProcess(): Nullable<PostProcess>;
  99032. private _cascadePostProcessesToRigCams;
  99033. /**
  99034. * Attach a post process to the camera.
  99035. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  99036. * @param postProcess The post process to attach to the camera
  99037. * @param insertAt The position of the post process in case several of them are in use in the scene
  99038. * @returns the position the post process has been inserted at
  99039. */
  99040. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  99041. /**
  99042. * Detach a post process to the camera.
  99043. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  99044. * @param postProcess The post process to detach from the camera
  99045. */
  99046. detachPostProcess(postProcess: PostProcess): void;
  99047. /**
  99048. * Gets the current world matrix of the camera
  99049. */
  99050. getWorldMatrix(): Matrix;
  99051. /** @hidden */
  99052. _getViewMatrix(): Matrix;
  99053. /**
  99054. * Gets the current view matrix of the camera.
  99055. * @param force forces the camera to recompute the matrix without looking at the cached state
  99056. * @returns the view matrix
  99057. */
  99058. getViewMatrix(force?: boolean): Matrix;
  99059. /**
  99060. * Freeze the projection matrix.
  99061. * It will prevent the cache check of the camera projection compute and can speed up perf
  99062. * if no parameter of the camera are meant to change
  99063. * @param projection Defines manually a projection if necessary
  99064. */
  99065. freezeProjectionMatrix(projection?: Matrix): void;
  99066. /**
  99067. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  99068. */
  99069. unfreezeProjectionMatrix(): void;
  99070. /**
  99071. * Gets the current projection matrix of the camera.
  99072. * @param force forces the camera to recompute the matrix without looking at the cached state
  99073. * @returns the projection matrix
  99074. */
  99075. getProjectionMatrix(force?: boolean): Matrix;
  99076. /**
  99077. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  99078. * @returns a Matrix
  99079. */
  99080. getTransformationMatrix(): Matrix;
  99081. private _updateFrustumPlanes;
  99082. /**
  99083. * Checks if a cullable object (mesh...) is in the camera frustum
  99084. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  99085. * @param target The object to check
  99086. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  99087. * @returns true if the object is in frustum otherwise false
  99088. */
  99089. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  99090. /**
  99091. * Checks if a cullable object (mesh...) is in the camera frustum
  99092. * Unlike isInFrustum this cheks the full bounding box
  99093. * @param target The object to check
  99094. * @returns true if the object is in frustum otherwise false
  99095. */
  99096. isCompletelyInFrustum(target: ICullable): boolean;
  99097. /**
  99098. * Gets a ray in the forward direction from the camera.
  99099. * @param length Defines the length of the ray to create
  99100. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  99101. * @param origin Defines the start point of the ray which defaults to the camera position
  99102. * @returns the forward ray
  99103. */
  99104. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  99105. /**
  99106. * Releases resources associated with this node.
  99107. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99108. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99109. */
  99110. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99111. /** @hidden */
  99112. _isLeftCamera: boolean;
  99113. /**
  99114. * Gets the left camera of a rig setup in case of Rigged Camera
  99115. */
  99116. get isLeftCamera(): boolean;
  99117. /** @hidden */
  99118. _isRightCamera: boolean;
  99119. /**
  99120. * Gets the right camera of a rig setup in case of Rigged Camera
  99121. */
  99122. get isRightCamera(): boolean;
  99123. /**
  99124. * Gets the left camera of a rig setup in case of Rigged Camera
  99125. */
  99126. get leftCamera(): Nullable<FreeCamera>;
  99127. /**
  99128. * Gets the right camera of a rig setup in case of Rigged Camera
  99129. */
  99130. get rightCamera(): Nullable<FreeCamera>;
  99131. /**
  99132. * Gets the left camera target of a rig setup in case of Rigged Camera
  99133. * @returns the target position
  99134. */
  99135. getLeftTarget(): Nullable<Vector3>;
  99136. /**
  99137. * Gets the right camera target of a rig setup in case of Rigged Camera
  99138. * @returns the target position
  99139. */
  99140. getRightTarget(): Nullable<Vector3>;
  99141. /**
  99142. * @hidden
  99143. */
  99144. setCameraRigMode(mode: number, rigParams: any): void;
  99145. /** @hidden */
  99146. static _setStereoscopicRigMode(camera: Camera): void;
  99147. /** @hidden */
  99148. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  99149. /** @hidden */
  99150. static _setVRRigMode(camera: Camera, rigParams: any): void;
  99151. /** @hidden */
  99152. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  99153. /** @hidden */
  99154. _getVRProjectionMatrix(): Matrix;
  99155. protected _updateCameraRotationMatrix(): void;
  99156. protected _updateWebVRCameraRotationMatrix(): void;
  99157. /**
  99158. * This function MUST be overwritten by the different WebVR cameras available.
  99159. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  99160. * @hidden
  99161. */
  99162. _getWebVRProjectionMatrix(): Matrix;
  99163. /**
  99164. * This function MUST be overwritten by the different WebVR cameras available.
  99165. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  99166. * @hidden
  99167. */
  99168. _getWebVRViewMatrix(): Matrix;
  99169. /** @hidden */
  99170. setCameraRigParameter(name: string, value: any): void;
  99171. /**
  99172. * needs to be overridden by children so sub has required properties to be copied
  99173. * @hidden
  99174. */
  99175. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  99176. /**
  99177. * May need to be overridden by children
  99178. * @hidden
  99179. */
  99180. _updateRigCameras(): void;
  99181. /** @hidden */
  99182. _setupInputs(): void;
  99183. /**
  99184. * Serialiaze the camera setup to a json represention
  99185. * @returns the JSON representation
  99186. */
  99187. serialize(): any;
  99188. /**
  99189. * Clones the current camera.
  99190. * @param name The cloned camera name
  99191. * @returns the cloned camera
  99192. */
  99193. clone(name: string): Camera;
  99194. /**
  99195. * Gets the direction of the camera relative to a given local axis.
  99196. * @param localAxis Defines the reference axis to provide a relative direction.
  99197. * @return the direction
  99198. */
  99199. getDirection(localAxis: Vector3): Vector3;
  99200. /**
  99201. * Returns the current camera absolute rotation
  99202. */
  99203. get absoluteRotation(): Quaternion;
  99204. /**
  99205. * Gets the direction of the camera relative to a given local axis into a passed vector.
  99206. * @param localAxis Defines the reference axis to provide a relative direction.
  99207. * @param result Defines the vector to store the result in
  99208. */
  99209. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  99210. /**
  99211. * Gets a camera constructor for a given camera type
  99212. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  99213. * @param name The name of the camera the result will be able to instantiate
  99214. * @param scene The scene the result will construct the camera in
  99215. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  99216. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  99217. * @returns a factory method to construc the camera
  99218. */
  99219. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  99220. /**
  99221. * Compute the world matrix of the camera.
  99222. * @returns the camera world matrix
  99223. */
  99224. computeWorldMatrix(): Matrix;
  99225. /**
  99226. * Parse a JSON and creates the camera from the parsed information
  99227. * @param parsedCamera The JSON to parse
  99228. * @param scene The scene to instantiate the camera in
  99229. * @returns the newly constructed camera
  99230. */
  99231. static Parse(parsedCamera: any, scene: Scene): Camera;
  99232. }
  99233. }
  99234. declare module BABYLON {
  99235. /**
  99236. * Class containing static functions to help procedurally build meshes
  99237. */
  99238. export class DiscBuilder {
  99239. /**
  99240. * Creates a plane polygonal mesh. By default, this is a disc
  99241. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  99242. * * 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
  99243. * * 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
  99244. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99245. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99246. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99247. * @param name defines the name of the mesh
  99248. * @param options defines the options used to create the mesh
  99249. * @param scene defines the hosting scene
  99250. * @returns the plane polygonal mesh
  99251. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  99252. */
  99253. static CreateDisc(name: string, options: {
  99254. radius?: number;
  99255. tessellation?: number;
  99256. arc?: number;
  99257. updatable?: boolean;
  99258. sideOrientation?: number;
  99259. frontUVs?: Vector4;
  99260. backUVs?: Vector4;
  99261. }, scene?: Nullable<Scene>): Mesh;
  99262. }
  99263. }
  99264. declare module BABYLON {
  99265. /**
  99266. * This represents all the required information to add a fresnel effect on a material:
  99267. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99268. */
  99269. export class FresnelParameters {
  99270. private _isEnabled;
  99271. /**
  99272. * Define if the fresnel effect is enable or not.
  99273. */
  99274. get isEnabled(): boolean;
  99275. set isEnabled(value: boolean);
  99276. /**
  99277. * Define the color used on edges (grazing angle)
  99278. */
  99279. leftColor: Color3;
  99280. /**
  99281. * Define the color used on center
  99282. */
  99283. rightColor: Color3;
  99284. /**
  99285. * Define bias applied to computed fresnel term
  99286. */
  99287. bias: number;
  99288. /**
  99289. * Defined the power exponent applied to fresnel term
  99290. */
  99291. power: number;
  99292. /**
  99293. * Clones the current fresnel and its valuues
  99294. * @returns a clone fresnel configuration
  99295. */
  99296. clone(): FresnelParameters;
  99297. /**
  99298. * Serializes the current fresnel parameters to a JSON representation.
  99299. * @return the JSON serialization
  99300. */
  99301. serialize(): any;
  99302. /**
  99303. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  99304. * @param parsedFresnelParameters Define the JSON representation
  99305. * @returns the parsed parameters
  99306. */
  99307. static Parse(parsedFresnelParameters: any): FresnelParameters;
  99308. }
  99309. }
  99310. declare module BABYLON {
  99311. /**
  99312. * Base class of materials working in push mode in babylon JS
  99313. * @hidden
  99314. */
  99315. export class PushMaterial extends Material {
  99316. protected _activeEffect: Effect;
  99317. protected _normalMatrix: Matrix;
  99318. /**
  99319. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  99320. * This means that the material can keep using a previous shader while a new one is being compiled.
  99321. * This is mostly used when shader parallel compilation is supported (true by default)
  99322. */
  99323. allowShaderHotSwapping: boolean;
  99324. constructor(name: string, scene: Scene);
  99325. getEffect(): Effect;
  99326. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  99327. /**
  99328. * Binds the given world matrix to the active effect
  99329. *
  99330. * @param world the matrix to bind
  99331. */
  99332. bindOnlyWorldMatrix(world: Matrix): void;
  99333. /**
  99334. * Binds the given normal matrix to the active effect
  99335. *
  99336. * @param normalMatrix the matrix to bind
  99337. */
  99338. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  99339. bind(world: Matrix, mesh?: Mesh): void;
  99340. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  99341. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  99342. }
  99343. }
  99344. declare module BABYLON {
  99345. /**
  99346. * This groups all the flags used to control the materials channel.
  99347. */
  99348. export class MaterialFlags {
  99349. private static _DiffuseTextureEnabled;
  99350. /**
  99351. * Are diffuse textures enabled in the application.
  99352. */
  99353. static get DiffuseTextureEnabled(): boolean;
  99354. static set DiffuseTextureEnabled(value: boolean);
  99355. private static _AmbientTextureEnabled;
  99356. /**
  99357. * Are ambient textures enabled in the application.
  99358. */
  99359. static get AmbientTextureEnabled(): boolean;
  99360. static set AmbientTextureEnabled(value: boolean);
  99361. private static _OpacityTextureEnabled;
  99362. /**
  99363. * Are opacity textures enabled in the application.
  99364. */
  99365. static get OpacityTextureEnabled(): boolean;
  99366. static set OpacityTextureEnabled(value: boolean);
  99367. private static _ReflectionTextureEnabled;
  99368. /**
  99369. * Are reflection textures enabled in the application.
  99370. */
  99371. static get ReflectionTextureEnabled(): boolean;
  99372. static set ReflectionTextureEnabled(value: boolean);
  99373. private static _EmissiveTextureEnabled;
  99374. /**
  99375. * Are emissive textures enabled in the application.
  99376. */
  99377. static get EmissiveTextureEnabled(): boolean;
  99378. static set EmissiveTextureEnabled(value: boolean);
  99379. private static _SpecularTextureEnabled;
  99380. /**
  99381. * Are specular textures enabled in the application.
  99382. */
  99383. static get SpecularTextureEnabled(): boolean;
  99384. static set SpecularTextureEnabled(value: boolean);
  99385. private static _BumpTextureEnabled;
  99386. /**
  99387. * Are bump textures enabled in the application.
  99388. */
  99389. static get BumpTextureEnabled(): boolean;
  99390. static set BumpTextureEnabled(value: boolean);
  99391. private static _LightmapTextureEnabled;
  99392. /**
  99393. * Are lightmap textures enabled in the application.
  99394. */
  99395. static get LightmapTextureEnabled(): boolean;
  99396. static set LightmapTextureEnabled(value: boolean);
  99397. private static _RefractionTextureEnabled;
  99398. /**
  99399. * Are refraction textures enabled in the application.
  99400. */
  99401. static get RefractionTextureEnabled(): boolean;
  99402. static set RefractionTextureEnabled(value: boolean);
  99403. private static _ColorGradingTextureEnabled;
  99404. /**
  99405. * Are color grading textures enabled in the application.
  99406. */
  99407. static get ColorGradingTextureEnabled(): boolean;
  99408. static set ColorGradingTextureEnabled(value: boolean);
  99409. private static _FresnelEnabled;
  99410. /**
  99411. * Are fresnels enabled in the application.
  99412. */
  99413. static get FresnelEnabled(): boolean;
  99414. static set FresnelEnabled(value: boolean);
  99415. private static _ClearCoatTextureEnabled;
  99416. /**
  99417. * Are clear coat textures enabled in the application.
  99418. */
  99419. static get ClearCoatTextureEnabled(): boolean;
  99420. static set ClearCoatTextureEnabled(value: boolean);
  99421. private static _ClearCoatBumpTextureEnabled;
  99422. /**
  99423. * Are clear coat bump textures enabled in the application.
  99424. */
  99425. static get ClearCoatBumpTextureEnabled(): boolean;
  99426. static set ClearCoatBumpTextureEnabled(value: boolean);
  99427. private static _ClearCoatTintTextureEnabled;
  99428. /**
  99429. * Are clear coat tint textures enabled in the application.
  99430. */
  99431. static get ClearCoatTintTextureEnabled(): boolean;
  99432. static set ClearCoatTintTextureEnabled(value: boolean);
  99433. private static _SheenTextureEnabled;
  99434. /**
  99435. * Are sheen textures enabled in the application.
  99436. */
  99437. static get SheenTextureEnabled(): boolean;
  99438. static set SheenTextureEnabled(value: boolean);
  99439. private static _AnisotropicTextureEnabled;
  99440. /**
  99441. * Are anisotropic textures enabled in the application.
  99442. */
  99443. static get AnisotropicTextureEnabled(): boolean;
  99444. static set AnisotropicTextureEnabled(value: boolean);
  99445. private static _ThicknessTextureEnabled;
  99446. /**
  99447. * Are thickness textures enabled in the application.
  99448. */
  99449. static get ThicknessTextureEnabled(): boolean;
  99450. static set ThicknessTextureEnabled(value: boolean);
  99451. }
  99452. }
  99453. declare module BABYLON {
  99454. /** @hidden */
  99455. export var defaultFragmentDeclaration: {
  99456. name: string;
  99457. shader: string;
  99458. };
  99459. }
  99460. declare module BABYLON {
  99461. /** @hidden */
  99462. export var defaultUboDeclaration: {
  99463. name: string;
  99464. shader: string;
  99465. };
  99466. }
  99467. declare module BABYLON {
  99468. /** @hidden */
  99469. export var lightFragmentDeclaration: {
  99470. name: string;
  99471. shader: string;
  99472. };
  99473. }
  99474. declare module BABYLON {
  99475. /** @hidden */
  99476. export var lightUboDeclaration: {
  99477. name: string;
  99478. shader: string;
  99479. };
  99480. }
  99481. declare module BABYLON {
  99482. /** @hidden */
  99483. export var lightsFragmentFunctions: {
  99484. name: string;
  99485. shader: string;
  99486. };
  99487. }
  99488. declare module BABYLON {
  99489. /** @hidden */
  99490. export var shadowsFragmentFunctions: {
  99491. name: string;
  99492. shader: string;
  99493. };
  99494. }
  99495. declare module BABYLON {
  99496. /** @hidden */
  99497. export var fresnelFunction: {
  99498. name: string;
  99499. shader: string;
  99500. };
  99501. }
  99502. declare module BABYLON {
  99503. /** @hidden */
  99504. export var reflectionFunction: {
  99505. name: string;
  99506. shader: string;
  99507. };
  99508. }
  99509. declare module BABYLON {
  99510. /** @hidden */
  99511. export var bumpFragmentFunctions: {
  99512. name: string;
  99513. shader: string;
  99514. };
  99515. }
  99516. declare module BABYLON {
  99517. /** @hidden */
  99518. export var logDepthDeclaration: {
  99519. name: string;
  99520. shader: string;
  99521. };
  99522. }
  99523. declare module BABYLON {
  99524. /** @hidden */
  99525. export var bumpFragment: {
  99526. name: string;
  99527. shader: string;
  99528. };
  99529. }
  99530. declare module BABYLON {
  99531. /** @hidden */
  99532. export var depthPrePass: {
  99533. name: string;
  99534. shader: string;
  99535. };
  99536. }
  99537. declare module BABYLON {
  99538. /** @hidden */
  99539. export var lightFragment: {
  99540. name: string;
  99541. shader: string;
  99542. };
  99543. }
  99544. declare module BABYLON {
  99545. /** @hidden */
  99546. export var logDepthFragment: {
  99547. name: string;
  99548. shader: string;
  99549. };
  99550. }
  99551. declare module BABYLON {
  99552. /** @hidden */
  99553. export var defaultPixelShader: {
  99554. name: string;
  99555. shader: string;
  99556. };
  99557. }
  99558. declare module BABYLON {
  99559. /** @hidden */
  99560. export var defaultVertexDeclaration: {
  99561. name: string;
  99562. shader: string;
  99563. };
  99564. }
  99565. declare module BABYLON {
  99566. /** @hidden */
  99567. export var bumpVertexDeclaration: {
  99568. name: string;
  99569. shader: string;
  99570. };
  99571. }
  99572. declare module BABYLON {
  99573. /** @hidden */
  99574. export var bumpVertex: {
  99575. name: string;
  99576. shader: string;
  99577. };
  99578. }
  99579. declare module BABYLON {
  99580. /** @hidden */
  99581. export var fogVertex: {
  99582. name: string;
  99583. shader: string;
  99584. };
  99585. }
  99586. declare module BABYLON {
  99587. /** @hidden */
  99588. export var shadowsVertex: {
  99589. name: string;
  99590. shader: string;
  99591. };
  99592. }
  99593. declare module BABYLON {
  99594. /** @hidden */
  99595. export var pointCloudVertex: {
  99596. name: string;
  99597. shader: string;
  99598. };
  99599. }
  99600. declare module BABYLON {
  99601. /** @hidden */
  99602. export var logDepthVertex: {
  99603. name: string;
  99604. shader: string;
  99605. };
  99606. }
  99607. declare module BABYLON {
  99608. /** @hidden */
  99609. export var defaultVertexShader: {
  99610. name: string;
  99611. shader: string;
  99612. };
  99613. }
  99614. declare module BABYLON {
  99615. /** @hidden */
  99616. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  99617. MAINUV1: boolean;
  99618. MAINUV2: boolean;
  99619. DIFFUSE: boolean;
  99620. DIFFUSEDIRECTUV: number;
  99621. AMBIENT: boolean;
  99622. AMBIENTDIRECTUV: number;
  99623. OPACITY: boolean;
  99624. OPACITYDIRECTUV: number;
  99625. OPACITYRGB: boolean;
  99626. REFLECTION: boolean;
  99627. EMISSIVE: boolean;
  99628. EMISSIVEDIRECTUV: number;
  99629. SPECULAR: boolean;
  99630. SPECULARDIRECTUV: number;
  99631. BUMP: boolean;
  99632. BUMPDIRECTUV: number;
  99633. PARALLAX: boolean;
  99634. PARALLAXOCCLUSION: boolean;
  99635. SPECULAROVERALPHA: boolean;
  99636. CLIPPLANE: boolean;
  99637. CLIPPLANE2: boolean;
  99638. CLIPPLANE3: boolean;
  99639. CLIPPLANE4: boolean;
  99640. CLIPPLANE5: boolean;
  99641. CLIPPLANE6: boolean;
  99642. ALPHATEST: boolean;
  99643. DEPTHPREPASS: boolean;
  99644. ALPHAFROMDIFFUSE: boolean;
  99645. POINTSIZE: boolean;
  99646. FOG: boolean;
  99647. SPECULARTERM: boolean;
  99648. DIFFUSEFRESNEL: boolean;
  99649. OPACITYFRESNEL: boolean;
  99650. REFLECTIONFRESNEL: boolean;
  99651. REFRACTIONFRESNEL: boolean;
  99652. EMISSIVEFRESNEL: boolean;
  99653. FRESNEL: boolean;
  99654. NORMAL: boolean;
  99655. UV1: boolean;
  99656. UV2: boolean;
  99657. VERTEXCOLOR: boolean;
  99658. VERTEXALPHA: boolean;
  99659. NUM_BONE_INFLUENCERS: number;
  99660. BonesPerMesh: number;
  99661. BONETEXTURE: boolean;
  99662. INSTANCES: boolean;
  99663. GLOSSINESS: boolean;
  99664. ROUGHNESS: boolean;
  99665. EMISSIVEASILLUMINATION: boolean;
  99666. LINKEMISSIVEWITHDIFFUSE: boolean;
  99667. REFLECTIONFRESNELFROMSPECULAR: boolean;
  99668. LIGHTMAP: boolean;
  99669. LIGHTMAPDIRECTUV: number;
  99670. OBJECTSPACE_NORMALMAP: boolean;
  99671. USELIGHTMAPASSHADOWMAP: boolean;
  99672. REFLECTIONMAP_3D: boolean;
  99673. REFLECTIONMAP_SPHERICAL: boolean;
  99674. REFLECTIONMAP_PLANAR: boolean;
  99675. REFLECTIONMAP_CUBIC: boolean;
  99676. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  99677. REFLECTIONMAP_PROJECTION: boolean;
  99678. REFLECTIONMAP_SKYBOX: boolean;
  99679. REFLECTIONMAP_EXPLICIT: boolean;
  99680. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  99681. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  99682. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  99683. INVERTCUBICMAP: boolean;
  99684. LOGARITHMICDEPTH: boolean;
  99685. REFRACTION: boolean;
  99686. REFRACTIONMAP_3D: boolean;
  99687. REFLECTIONOVERALPHA: boolean;
  99688. TWOSIDEDLIGHTING: boolean;
  99689. SHADOWFLOAT: boolean;
  99690. MORPHTARGETS: boolean;
  99691. MORPHTARGETS_NORMAL: boolean;
  99692. MORPHTARGETS_TANGENT: boolean;
  99693. MORPHTARGETS_UV: boolean;
  99694. NUM_MORPH_INFLUENCERS: number;
  99695. NONUNIFORMSCALING: boolean;
  99696. PREMULTIPLYALPHA: boolean;
  99697. IMAGEPROCESSING: boolean;
  99698. VIGNETTE: boolean;
  99699. VIGNETTEBLENDMODEMULTIPLY: boolean;
  99700. VIGNETTEBLENDMODEOPAQUE: boolean;
  99701. TONEMAPPING: boolean;
  99702. TONEMAPPING_ACES: boolean;
  99703. CONTRAST: boolean;
  99704. COLORCURVES: boolean;
  99705. COLORGRADING: boolean;
  99706. COLORGRADING3D: boolean;
  99707. SAMPLER3DGREENDEPTH: boolean;
  99708. SAMPLER3DBGRMAP: boolean;
  99709. IMAGEPROCESSINGPOSTPROCESS: boolean;
  99710. MULTIVIEW: boolean;
  99711. /**
  99712. * If the reflection texture on this material is in linear color space
  99713. * @hidden
  99714. */
  99715. IS_REFLECTION_LINEAR: boolean;
  99716. /**
  99717. * If the refraction texture on this material is in linear color space
  99718. * @hidden
  99719. */
  99720. IS_REFRACTION_LINEAR: boolean;
  99721. EXPOSURE: boolean;
  99722. constructor();
  99723. setReflectionMode(modeToEnable: string): void;
  99724. }
  99725. /**
  99726. * This is the default material used in Babylon. It is the best trade off between quality
  99727. * and performances.
  99728. * @see http://doc.babylonjs.com/babylon101/materials
  99729. */
  99730. export class StandardMaterial extends PushMaterial {
  99731. private _diffuseTexture;
  99732. /**
  99733. * The basic texture of the material as viewed under a light.
  99734. */
  99735. diffuseTexture: Nullable<BaseTexture>;
  99736. private _ambientTexture;
  99737. /**
  99738. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  99739. */
  99740. ambientTexture: Nullable<BaseTexture>;
  99741. private _opacityTexture;
  99742. /**
  99743. * Define the transparency of the material from a texture.
  99744. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  99745. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  99746. */
  99747. opacityTexture: Nullable<BaseTexture>;
  99748. private _reflectionTexture;
  99749. /**
  99750. * Define the texture used to display the reflection.
  99751. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99752. */
  99753. reflectionTexture: Nullable<BaseTexture>;
  99754. private _emissiveTexture;
  99755. /**
  99756. * Define texture of the material as if self lit.
  99757. * This will be mixed in the final result even in the absence of light.
  99758. */
  99759. emissiveTexture: Nullable<BaseTexture>;
  99760. private _specularTexture;
  99761. /**
  99762. * Define how the color and intensity of the highlight given by the light in the material.
  99763. */
  99764. specularTexture: Nullable<BaseTexture>;
  99765. private _bumpTexture;
  99766. /**
  99767. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  99768. * 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.
  99769. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  99770. */
  99771. bumpTexture: Nullable<BaseTexture>;
  99772. private _lightmapTexture;
  99773. /**
  99774. * Complex lighting can be computationally expensive to compute at runtime.
  99775. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  99776. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  99777. */
  99778. lightmapTexture: Nullable<BaseTexture>;
  99779. private _refractionTexture;
  99780. /**
  99781. * Define the texture used to display the refraction.
  99782. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99783. */
  99784. refractionTexture: Nullable<BaseTexture>;
  99785. /**
  99786. * The color of the material lit by the environmental background lighting.
  99787. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  99788. */
  99789. ambientColor: Color3;
  99790. /**
  99791. * The basic color of the material as viewed under a light.
  99792. */
  99793. diffuseColor: Color3;
  99794. /**
  99795. * Define how the color and intensity of the highlight given by the light in the material.
  99796. */
  99797. specularColor: Color3;
  99798. /**
  99799. * Define the color of the material as if self lit.
  99800. * This will be mixed in the final result even in the absence of light.
  99801. */
  99802. emissiveColor: Color3;
  99803. /**
  99804. * Defines how sharp are the highlights in the material.
  99805. * The bigger the value the sharper giving a more glossy feeling to the result.
  99806. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  99807. */
  99808. specularPower: number;
  99809. private _useAlphaFromDiffuseTexture;
  99810. /**
  99811. * Does the transparency come from the diffuse texture alpha channel.
  99812. */
  99813. useAlphaFromDiffuseTexture: boolean;
  99814. private _useEmissiveAsIllumination;
  99815. /**
  99816. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  99817. */
  99818. useEmissiveAsIllumination: boolean;
  99819. private _linkEmissiveWithDiffuse;
  99820. /**
  99821. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  99822. * the emissive level when the final color is close to one.
  99823. */
  99824. linkEmissiveWithDiffuse: boolean;
  99825. private _useSpecularOverAlpha;
  99826. /**
  99827. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  99828. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  99829. */
  99830. useSpecularOverAlpha: boolean;
  99831. private _useReflectionOverAlpha;
  99832. /**
  99833. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  99834. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  99835. */
  99836. useReflectionOverAlpha: boolean;
  99837. private _disableLighting;
  99838. /**
  99839. * Does lights from the scene impacts this material.
  99840. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  99841. */
  99842. disableLighting: boolean;
  99843. private _useObjectSpaceNormalMap;
  99844. /**
  99845. * Allows using an object space normal map (instead of tangent space).
  99846. */
  99847. useObjectSpaceNormalMap: boolean;
  99848. private _useParallax;
  99849. /**
  99850. * Is parallax enabled or not.
  99851. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  99852. */
  99853. useParallax: boolean;
  99854. private _useParallaxOcclusion;
  99855. /**
  99856. * Is parallax occlusion enabled or not.
  99857. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  99858. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  99859. */
  99860. useParallaxOcclusion: boolean;
  99861. /**
  99862. * 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.
  99863. */
  99864. parallaxScaleBias: number;
  99865. private _roughness;
  99866. /**
  99867. * Helps to define how blurry the reflections should appears in the material.
  99868. */
  99869. roughness: number;
  99870. /**
  99871. * In case of refraction, define the value of the index of refraction.
  99872. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99873. */
  99874. indexOfRefraction: number;
  99875. /**
  99876. * Invert the refraction texture alongside the y axis.
  99877. * It can be useful with procedural textures or probe for instance.
  99878. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99879. */
  99880. invertRefractionY: boolean;
  99881. /**
  99882. * Defines the alpha limits in alpha test mode.
  99883. */
  99884. alphaCutOff: number;
  99885. private _useLightmapAsShadowmap;
  99886. /**
  99887. * In case of light mapping, define whether the map contains light or shadow informations.
  99888. */
  99889. useLightmapAsShadowmap: boolean;
  99890. private _diffuseFresnelParameters;
  99891. /**
  99892. * Define the diffuse fresnel parameters of the material.
  99893. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99894. */
  99895. diffuseFresnelParameters: FresnelParameters;
  99896. private _opacityFresnelParameters;
  99897. /**
  99898. * Define the opacity fresnel parameters of the material.
  99899. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99900. */
  99901. opacityFresnelParameters: FresnelParameters;
  99902. private _reflectionFresnelParameters;
  99903. /**
  99904. * Define the reflection fresnel parameters of the material.
  99905. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99906. */
  99907. reflectionFresnelParameters: FresnelParameters;
  99908. private _refractionFresnelParameters;
  99909. /**
  99910. * Define the refraction fresnel parameters of the material.
  99911. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99912. */
  99913. refractionFresnelParameters: FresnelParameters;
  99914. private _emissiveFresnelParameters;
  99915. /**
  99916. * Define the emissive fresnel parameters of the material.
  99917. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99918. */
  99919. emissiveFresnelParameters: FresnelParameters;
  99920. private _useReflectionFresnelFromSpecular;
  99921. /**
  99922. * If true automatically deducts the fresnels values from the material specularity.
  99923. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99924. */
  99925. useReflectionFresnelFromSpecular: boolean;
  99926. private _useGlossinessFromSpecularMapAlpha;
  99927. /**
  99928. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  99929. */
  99930. useGlossinessFromSpecularMapAlpha: boolean;
  99931. private _maxSimultaneousLights;
  99932. /**
  99933. * Defines the maximum number of lights that can be used in the material
  99934. */
  99935. maxSimultaneousLights: number;
  99936. private _invertNormalMapX;
  99937. /**
  99938. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  99939. */
  99940. invertNormalMapX: boolean;
  99941. private _invertNormalMapY;
  99942. /**
  99943. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  99944. */
  99945. invertNormalMapY: boolean;
  99946. private _twoSidedLighting;
  99947. /**
  99948. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  99949. */
  99950. twoSidedLighting: boolean;
  99951. /**
  99952. * Default configuration related to image processing available in the standard Material.
  99953. */
  99954. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99955. /**
  99956. * Gets the image processing configuration used either in this material.
  99957. */
  99958. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  99959. /**
  99960. * Sets the Default image processing configuration used either in the this material.
  99961. *
  99962. * If sets to null, the scene one is in use.
  99963. */
  99964. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  99965. /**
  99966. * Keep track of the image processing observer to allow dispose and replace.
  99967. */
  99968. private _imageProcessingObserver;
  99969. /**
  99970. * Attaches a new image processing configuration to the Standard Material.
  99971. * @param configuration
  99972. */
  99973. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  99974. /**
  99975. * Gets wether the color curves effect is enabled.
  99976. */
  99977. get cameraColorCurvesEnabled(): boolean;
  99978. /**
  99979. * Sets wether the color curves effect is enabled.
  99980. */
  99981. set cameraColorCurvesEnabled(value: boolean);
  99982. /**
  99983. * Gets wether the color grading effect is enabled.
  99984. */
  99985. get cameraColorGradingEnabled(): boolean;
  99986. /**
  99987. * Gets wether the color grading effect is enabled.
  99988. */
  99989. set cameraColorGradingEnabled(value: boolean);
  99990. /**
  99991. * Gets wether tonemapping is enabled or not.
  99992. */
  99993. get cameraToneMappingEnabled(): boolean;
  99994. /**
  99995. * Sets wether tonemapping is enabled or not
  99996. */
  99997. set cameraToneMappingEnabled(value: boolean);
  99998. /**
  99999. * The camera exposure used on this material.
  100000. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  100001. * This corresponds to a photographic exposure.
  100002. */
  100003. get cameraExposure(): number;
  100004. /**
  100005. * The camera exposure used on this material.
  100006. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  100007. * This corresponds to a photographic exposure.
  100008. */
  100009. set cameraExposure(value: number);
  100010. /**
  100011. * Gets The camera contrast used on this material.
  100012. */
  100013. get cameraContrast(): number;
  100014. /**
  100015. * Sets The camera contrast used on this material.
  100016. */
  100017. set cameraContrast(value: number);
  100018. /**
  100019. * Gets the Color Grading 2D Lookup Texture.
  100020. */
  100021. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  100022. /**
  100023. * Sets the Color Grading 2D Lookup Texture.
  100024. */
  100025. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  100026. /**
  100027. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  100028. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  100029. * 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;
  100030. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  100031. */
  100032. get cameraColorCurves(): Nullable<ColorCurves>;
  100033. /**
  100034. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  100035. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  100036. * 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;
  100037. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  100038. */
  100039. set cameraColorCurves(value: Nullable<ColorCurves>);
  100040. /**
  100041. * Custom callback helping to override the default shader used in the material.
  100042. */
  100043. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  100044. protected _renderTargets: SmartArray<RenderTargetTexture>;
  100045. protected _worldViewProjectionMatrix: Matrix;
  100046. protected _globalAmbientColor: Color3;
  100047. protected _useLogarithmicDepth: boolean;
  100048. protected _rebuildInParallel: boolean;
  100049. /**
  100050. * Instantiates a new standard material.
  100051. * This is the default material used in Babylon. It is the best trade off between quality
  100052. * and performances.
  100053. * @see http://doc.babylonjs.com/babylon101/materials
  100054. * @param name Define the name of the material in the scene
  100055. * @param scene Define the scene the material belong to
  100056. */
  100057. constructor(name: string, scene: Scene);
  100058. /**
  100059. * Gets a boolean indicating that current material needs to register RTT
  100060. */
  100061. get hasRenderTargetTextures(): boolean;
  100062. /**
  100063. * Gets the current class name of the material e.g. "StandardMaterial"
  100064. * Mainly use in serialization.
  100065. * @returns the class name
  100066. */
  100067. getClassName(): string;
  100068. /**
  100069. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  100070. * You can try switching to logarithmic depth.
  100071. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  100072. */
  100073. get useLogarithmicDepth(): boolean;
  100074. set useLogarithmicDepth(value: boolean);
  100075. /**
  100076. * Specifies if the material will require alpha blending
  100077. * @returns a boolean specifying if alpha blending is needed
  100078. */
  100079. needAlphaBlending(): boolean;
  100080. /**
  100081. * Specifies if this material should be rendered in alpha test mode
  100082. * @returns a boolean specifying if an alpha test is needed.
  100083. */
  100084. needAlphaTesting(): boolean;
  100085. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  100086. /**
  100087. * Get the texture used for alpha test purpose.
  100088. * @returns the diffuse texture in case of the standard material.
  100089. */
  100090. getAlphaTestTexture(): Nullable<BaseTexture>;
  100091. /**
  100092. * Get if the submesh is ready to be used and all its information available.
  100093. * Child classes can use it to update shaders
  100094. * @param mesh defines the mesh to check
  100095. * @param subMesh defines which submesh to check
  100096. * @param useInstances specifies that instances should be used
  100097. * @returns a boolean indicating that the submesh is ready or not
  100098. */
  100099. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  100100. /**
  100101. * Builds the material UBO layouts.
  100102. * Used internally during the effect preparation.
  100103. */
  100104. buildUniformLayout(): void;
  100105. /**
  100106. * Unbinds the material from the mesh
  100107. */
  100108. unbind(): void;
  100109. /**
  100110. * Binds the submesh to this material by preparing the effect and shader to draw
  100111. * @param world defines the world transformation matrix
  100112. * @param mesh defines the mesh containing the submesh
  100113. * @param subMesh defines the submesh to bind the material to
  100114. */
  100115. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  100116. /**
  100117. * Get the list of animatables in the material.
  100118. * @returns the list of animatables object used in the material
  100119. */
  100120. getAnimatables(): IAnimatable[];
  100121. /**
  100122. * Gets the active textures from the material
  100123. * @returns an array of textures
  100124. */
  100125. getActiveTextures(): BaseTexture[];
  100126. /**
  100127. * Specifies if the material uses a texture
  100128. * @param texture defines the texture to check against the material
  100129. * @returns a boolean specifying if the material uses the texture
  100130. */
  100131. hasTexture(texture: BaseTexture): boolean;
  100132. /**
  100133. * Disposes the material
  100134. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  100135. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  100136. */
  100137. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  100138. /**
  100139. * Makes a duplicate of the material, and gives it a new name
  100140. * @param name defines the new name for the duplicated material
  100141. * @returns the cloned material
  100142. */
  100143. clone(name: string): StandardMaterial;
  100144. /**
  100145. * Serializes this material in a JSON representation
  100146. * @returns the serialized material object
  100147. */
  100148. serialize(): any;
  100149. /**
  100150. * Creates a standard material from parsed material data
  100151. * @param source defines the JSON representation of the material
  100152. * @param scene defines the hosting scene
  100153. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100154. * @returns a new standard material
  100155. */
  100156. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  100157. /**
  100158. * Are diffuse textures enabled in the application.
  100159. */
  100160. static get DiffuseTextureEnabled(): boolean;
  100161. static set DiffuseTextureEnabled(value: boolean);
  100162. /**
  100163. * Are ambient textures enabled in the application.
  100164. */
  100165. static get AmbientTextureEnabled(): boolean;
  100166. static set AmbientTextureEnabled(value: boolean);
  100167. /**
  100168. * Are opacity textures enabled in the application.
  100169. */
  100170. static get OpacityTextureEnabled(): boolean;
  100171. static set OpacityTextureEnabled(value: boolean);
  100172. /**
  100173. * Are reflection textures enabled in the application.
  100174. */
  100175. static get ReflectionTextureEnabled(): boolean;
  100176. static set ReflectionTextureEnabled(value: boolean);
  100177. /**
  100178. * Are emissive textures enabled in the application.
  100179. */
  100180. static get EmissiveTextureEnabled(): boolean;
  100181. static set EmissiveTextureEnabled(value: boolean);
  100182. /**
  100183. * Are specular textures enabled in the application.
  100184. */
  100185. static get SpecularTextureEnabled(): boolean;
  100186. static set SpecularTextureEnabled(value: boolean);
  100187. /**
  100188. * Are bump textures enabled in the application.
  100189. */
  100190. static get BumpTextureEnabled(): boolean;
  100191. static set BumpTextureEnabled(value: boolean);
  100192. /**
  100193. * Are lightmap textures enabled in the application.
  100194. */
  100195. static get LightmapTextureEnabled(): boolean;
  100196. static set LightmapTextureEnabled(value: boolean);
  100197. /**
  100198. * Are refraction textures enabled in the application.
  100199. */
  100200. static get RefractionTextureEnabled(): boolean;
  100201. static set RefractionTextureEnabled(value: boolean);
  100202. /**
  100203. * Are color grading textures enabled in the application.
  100204. */
  100205. static get ColorGradingTextureEnabled(): boolean;
  100206. static set ColorGradingTextureEnabled(value: boolean);
  100207. /**
  100208. * Are fresnels enabled in the application.
  100209. */
  100210. static get FresnelEnabled(): boolean;
  100211. static set FresnelEnabled(value: boolean);
  100212. }
  100213. }
  100214. declare module BABYLON {
  100215. /**
  100216. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  100217. *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.
  100218. * The SPS is also a particle system. It provides some methods to manage the particles.
  100219. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  100220. *
  100221. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  100222. */
  100223. export class SolidParticleSystem implements IDisposable {
  100224. /**
  100225. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  100226. * Example : var p = SPS.particles[i];
  100227. */
  100228. particles: SolidParticle[];
  100229. /**
  100230. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  100231. */
  100232. nbParticles: number;
  100233. /**
  100234. * If the particles must ever face the camera (default false). Useful for planar particles.
  100235. */
  100236. billboard: boolean;
  100237. /**
  100238. * Recompute normals when adding a shape
  100239. */
  100240. recomputeNormals: boolean;
  100241. /**
  100242. * This a counter ofr your own usage. It's not set by any SPS functions.
  100243. */
  100244. counter: number;
  100245. /**
  100246. * The SPS name. This name is also given to the underlying mesh.
  100247. */
  100248. name: string;
  100249. /**
  100250. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  100251. */
  100252. mesh: Mesh;
  100253. /**
  100254. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  100255. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  100256. */
  100257. vars: any;
  100258. /**
  100259. * This array is populated when the SPS is set as 'pickable'.
  100260. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  100261. * Each element of this array is an object `{idx: int, faceId: int}`.
  100262. * `idx` is the picked particle index in the `SPS.particles` array
  100263. * `faceId` is the picked face index counted within this particle.
  100264. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  100265. */
  100266. pickedParticles: {
  100267. idx: number;
  100268. faceId: number;
  100269. }[];
  100270. /**
  100271. * This array is populated when `enableDepthSort` is set to true.
  100272. * Each element of this array is an instance of the class DepthSortedParticle.
  100273. */
  100274. depthSortedParticles: DepthSortedParticle[];
  100275. /**
  100276. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  100277. * @hidden
  100278. */
  100279. _bSphereOnly: boolean;
  100280. /**
  100281. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  100282. * @hidden
  100283. */
  100284. _bSphereRadiusFactor: number;
  100285. private _scene;
  100286. private _positions;
  100287. private _indices;
  100288. private _normals;
  100289. private _colors;
  100290. private _uvs;
  100291. private _indices32;
  100292. private _positions32;
  100293. private _normals32;
  100294. private _fixedNormal32;
  100295. private _colors32;
  100296. private _uvs32;
  100297. private _index;
  100298. private _updatable;
  100299. private _pickable;
  100300. private _isVisibilityBoxLocked;
  100301. private _alwaysVisible;
  100302. private _depthSort;
  100303. private _expandable;
  100304. private _shapeCounter;
  100305. private _copy;
  100306. private _color;
  100307. private _computeParticleColor;
  100308. private _computeParticleTexture;
  100309. private _computeParticleRotation;
  100310. private _computeParticleVertex;
  100311. private _computeBoundingBox;
  100312. private _depthSortParticles;
  100313. private _camera;
  100314. private _mustUnrotateFixedNormals;
  100315. private _particlesIntersect;
  100316. private _needs32Bits;
  100317. private _isNotBuilt;
  100318. private _lastParticleId;
  100319. private _idxOfId;
  100320. private _multimaterialEnabled;
  100321. private _useModelMaterial;
  100322. private _indicesByMaterial;
  100323. private _materialIndexes;
  100324. private _depthSortFunction;
  100325. private _materialSortFunction;
  100326. private _materials;
  100327. private _multimaterial;
  100328. private _materialIndexesById;
  100329. private _defaultMaterial;
  100330. private _autoUpdateSubMeshes;
  100331. /**
  100332. * Creates a SPS (Solid Particle System) object.
  100333. * @param name (String) is the SPS name, this will be the underlying mesh name.
  100334. * @param scene (Scene) is the scene in which the SPS is added.
  100335. * @param options defines the options of the sps e.g.
  100336. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  100337. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  100338. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  100339. * * 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.
  100340. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  100341. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  100342. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  100343. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  100344. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  100345. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  100346. */
  100347. constructor(name: string, scene: Scene, options?: {
  100348. updatable?: boolean;
  100349. isPickable?: boolean;
  100350. enableDepthSort?: boolean;
  100351. particleIntersection?: boolean;
  100352. boundingSphereOnly?: boolean;
  100353. bSphereRadiusFactor?: number;
  100354. expandable?: boolean;
  100355. useModelMaterial?: boolean;
  100356. enableMultiMaterial?: boolean;
  100357. });
  100358. /**
  100359. * Builds the SPS underlying mesh. Returns a standard Mesh.
  100360. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  100361. * @returns the created mesh
  100362. */
  100363. buildMesh(): Mesh;
  100364. /**
  100365. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  100366. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  100367. * Thus the particles generated from `digest()` have their property `position` set yet.
  100368. * @param mesh ( Mesh ) is the mesh to be digested
  100369. * @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
  100370. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  100371. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  100372. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  100373. * @returns the current SPS
  100374. */
  100375. digest(mesh: Mesh, options?: {
  100376. facetNb?: number;
  100377. number?: number;
  100378. delta?: number;
  100379. storage?: [];
  100380. }): SolidParticleSystem;
  100381. /**
  100382. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  100383. * @hidden
  100384. */
  100385. private _unrotateFixedNormals;
  100386. /**
  100387. * Resets the temporary working copy particle
  100388. * @hidden
  100389. */
  100390. private _resetCopy;
  100391. /**
  100392. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  100393. * @param p the current index in the positions array to be updated
  100394. * @param ind the current index in the indices array
  100395. * @param shape a Vector3 array, the shape geometry
  100396. * @param positions the positions array to be updated
  100397. * @param meshInd the shape indices array
  100398. * @param indices the indices array to be updated
  100399. * @param meshUV the shape uv array
  100400. * @param uvs the uv array to be updated
  100401. * @param meshCol the shape color array
  100402. * @param colors the color array to be updated
  100403. * @param meshNor the shape normals array
  100404. * @param normals the normals array to be updated
  100405. * @param idx the particle index
  100406. * @param idxInShape the particle index in its shape
  100407. * @param options the addShape() method passed options
  100408. * @model the particle model
  100409. * @hidden
  100410. */
  100411. private _meshBuilder;
  100412. /**
  100413. * Returns a shape Vector3 array from positions float array
  100414. * @param positions float array
  100415. * @returns a vector3 array
  100416. * @hidden
  100417. */
  100418. private _posToShape;
  100419. /**
  100420. * Returns a shapeUV array from a float uvs (array deep copy)
  100421. * @param uvs as a float array
  100422. * @returns a shapeUV array
  100423. * @hidden
  100424. */
  100425. private _uvsToShapeUV;
  100426. /**
  100427. * Adds a new particle object in the particles array
  100428. * @param idx particle index in particles array
  100429. * @param id particle id
  100430. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  100431. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  100432. * @param model particle ModelShape object
  100433. * @param shapeId model shape identifier
  100434. * @param idxInShape index of the particle in the current model
  100435. * @param bInfo model bounding info object
  100436. * @param storage target storage array, if any
  100437. * @hidden
  100438. */
  100439. private _addParticle;
  100440. /**
  100441. * Adds some particles to the SPS from the model shape. Returns the shape id.
  100442. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  100443. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  100444. * @param nb (positive integer) the number of particles to be created from this model
  100445. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  100446. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  100447. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  100448. * @returns the number of shapes in the system
  100449. */
  100450. addShape(mesh: Mesh, nb: number, options?: {
  100451. positionFunction?: any;
  100452. vertexFunction?: any;
  100453. storage?: [];
  100454. }): number;
  100455. /**
  100456. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  100457. * @hidden
  100458. */
  100459. private _rebuildParticle;
  100460. /**
  100461. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  100462. * @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.
  100463. * @returns the SPS.
  100464. */
  100465. rebuildMesh(reset?: boolean): SolidParticleSystem;
  100466. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  100467. * Returns an array with the removed particles.
  100468. * 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.
  100469. * The SPS can't be empty so at least one particle needs to remain in place.
  100470. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  100471. * @param start index of the first particle to remove
  100472. * @param end index of the last particle to remove (included)
  100473. * @returns an array populated with the removed particles
  100474. */
  100475. removeParticles(start: number, end: number): SolidParticle[];
  100476. /**
  100477. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  100478. * @param solidParticleArray an array populated with Solid Particles objects
  100479. * @returns the SPS
  100480. */
  100481. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  100482. /**
  100483. * Creates a new particle and modifies the SPS mesh geometry :
  100484. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  100485. * - calls _addParticle() to populate the particle array
  100486. * factorized code from addShape() and insertParticlesFromArray()
  100487. * @param idx particle index in the particles array
  100488. * @param i particle index in its shape
  100489. * @param modelShape particle ModelShape object
  100490. * @param shape shape vertex array
  100491. * @param meshInd shape indices array
  100492. * @param meshUV shape uv array
  100493. * @param meshCol shape color array
  100494. * @param meshNor shape normals array
  100495. * @param bbInfo shape bounding info
  100496. * @param storage target particle storage
  100497. * @options addShape() passed options
  100498. * @hidden
  100499. */
  100500. private _insertNewParticle;
  100501. /**
  100502. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  100503. * This method calls `updateParticle()` for each particle of the SPS.
  100504. * For an animated SPS, it is usually called within the render loop.
  100505. * 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.
  100506. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  100507. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  100508. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  100509. * @returns the SPS.
  100510. */
  100511. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  100512. /**
  100513. * Disposes the SPS.
  100514. */
  100515. dispose(): void;
  100516. /**
  100517. * Returns a SolidParticle object from its identifier : particle.id
  100518. * @param id (integer) the particle Id
  100519. * @returns the searched particle or null if not found in the SPS.
  100520. */
  100521. getParticleById(id: number): Nullable<SolidParticle>;
  100522. /**
  100523. * Returns a new array populated with the particles having the passed shapeId.
  100524. * @param shapeId (integer) the shape identifier
  100525. * @returns a new solid particle array
  100526. */
  100527. getParticlesByShapeId(shapeId: number): SolidParticle[];
  100528. /**
  100529. * Populates the passed array "ref" with the particles having the passed shapeId.
  100530. * @param shapeId the shape identifier
  100531. * @returns the SPS
  100532. * @param ref
  100533. */
  100534. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  100535. /**
  100536. * Computes the required SubMeshes according the materials assigned to the particles.
  100537. * @returns the solid particle system.
  100538. * Does nothing if called before the SPS mesh is built.
  100539. */
  100540. computeSubMeshes(): SolidParticleSystem;
  100541. /**
  100542. * Sorts the solid particles by material when MultiMaterial is enabled.
  100543. * Updates the indices32 array.
  100544. * Updates the indicesByMaterial array.
  100545. * Updates the mesh indices array.
  100546. * @returns the SPS
  100547. * @hidden
  100548. */
  100549. private _sortParticlesByMaterial;
  100550. /**
  100551. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  100552. * @hidden
  100553. */
  100554. private _setMaterialIndexesById;
  100555. /**
  100556. * Returns an array with unique values of Materials from the passed array
  100557. * @param array the material array to be checked and filtered
  100558. * @hidden
  100559. */
  100560. private _filterUniqueMaterialId;
  100561. /**
  100562. * Sets a new Standard Material as _defaultMaterial if not already set.
  100563. * @hidden
  100564. */
  100565. private _setDefaultMaterial;
  100566. /**
  100567. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  100568. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100569. * @returns the SPS.
  100570. */
  100571. refreshVisibleSize(): SolidParticleSystem;
  100572. /**
  100573. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  100574. * @param size the size (float) of the visibility box
  100575. * note : this doesn't lock the SPS mesh bounding box.
  100576. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100577. */
  100578. setVisibilityBox(size: number): void;
  100579. /**
  100580. * Gets whether the SPS as always visible or not
  100581. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100582. */
  100583. get isAlwaysVisible(): boolean;
  100584. /**
  100585. * Sets the SPS as always visible or not
  100586. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100587. */
  100588. set isAlwaysVisible(val: boolean);
  100589. /**
  100590. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  100591. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100592. */
  100593. set isVisibilityBoxLocked(val: boolean);
  100594. /**
  100595. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  100596. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100597. */
  100598. get isVisibilityBoxLocked(): boolean;
  100599. /**
  100600. * Tells to `setParticles()` to compute the particle rotations or not.
  100601. * Default value : true. The SPS is faster when it's set to false.
  100602. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  100603. */
  100604. set computeParticleRotation(val: boolean);
  100605. /**
  100606. * Tells to `setParticles()` to compute the particle colors or not.
  100607. * Default value : true. The SPS is faster when it's set to false.
  100608. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  100609. */
  100610. set computeParticleColor(val: boolean);
  100611. set computeParticleTexture(val: boolean);
  100612. /**
  100613. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  100614. * Default value : false. The SPS is faster when it's set to false.
  100615. * Note : the particle custom vertex positions aren't stored values.
  100616. */
  100617. set computeParticleVertex(val: boolean);
  100618. /**
  100619. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  100620. */
  100621. set computeBoundingBox(val: boolean);
  100622. /**
  100623. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  100624. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  100625. * Default : `true`
  100626. */
  100627. set depthSortParticles(val: boolean);
  100628. /**
  100629. * Gets if `setParticles()` computes the particle rotations or not.
  100630. * Default value : true. The SPS is faster when it's set to false.
  100631. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  100632. */
  100633. get computeParticleRotation(): boolean;
  100634. /**
  100635. * Gets if `setParticles()` computes the particle colors or not.
  100636. * Default value : true. The SPS is faster when it's set to false.
  100637. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  100638. */
  100639. get computeParticleColor(): boolean;
  100640. /**
  100641. * Gets if `setParticles()` computes the particle textures or not.
  100642. * Default value : true. The SPS is faster when it's set to false.
  100643. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  100644. */
  100645. get computeParticleTexture(): boolean;
  100646. /**
  100647. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  100648. * Default value : false. The SPS is faster when it's set to false.
  100649. * Note : the particle custom vertex positions aren't stored values.
  100650. */
  100651. get computeParticleVertex(): boolean;
  100652. /**
  100653. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  100654. */
  100655. get computeBoundingBox(): boolean;
  100656. /**
  100657. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  100658. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  100659. * Default : `true`
  100660. */
  100661. get depthSortParticles(): boolean;
  100662. /**
  100663. * Gets if the SPS is created as expandable at construction time.
  100664. * Default : `false`
  100665. */
  100666. get expandable(): boolean;
  100667. /**
  100668. * Gets if the SPS supports the Multi Materials
  100669. */
  100670. get multimaterialEnabled(): boolean;
  100671. /**
  100672. * Gets if the SPS uses the model materials for its own multimaterial.
  100673. */
  100674. get useModelMaterial(): boolean;
  100675. /**
  100676. * The SPS used material array.
  100677. */
  100678. get materials(): Material[];
  100679. /**
  100680. * Sets the SPS MultiMaterial from the passed materials.
  100681. * Note : the passed array is internally copied and not used then by reference.
  100682. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  100683. */
  100684. setMultiMaterial(materials: Material[]): void;
  100685. /**
  100686. * The SPS computed multimaterial object
  100687. */
  100688. get multimaterial(): MultiMaterial;
  100689. set multimaterial(mm: MultiMaterial);
  100690. /**
  100691. * If the subMeshes must be updated on the next call to setParticles()
  100692. */
  100693. get autoUpdateSubMeshes(): boolean;
  100694. set autoUpdateSubMeshes(val: boolean);
  100695. /**
  100696. * This function does nothing. It may be overwritten to set all the particle first values.
  100697. * The SPS doesn't call this function, you may have to call it by your own.
  100698. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100699. */
  100700. initParticles(): void;
  100701. /**
  100702. * This function does nothing. It may be overwritten to recycle a particle.
  100703. * The SPS doesn't call this function, you may have to call it by your own.
  100704. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100705. * @param particle The particle to recycle
  100706. * @returns the recycled particle
  100707. */
  100708. recycleParticle(particle: SolidParticle): SolidParticle;
  100709. /**
  100710. * Updates a particle : this function should be overwritten by the user.
  100711. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  100712. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100713. * @example : just set a particle position or velocity and recycle conditions
  100714. * @param particle The particle to update
  100715. * @returns the updated particle
  100716. */
  100717. updateParticle(particle: SolidParticle): SolidParticle;
  100718. /**
  100719. * Updates a vertex of a particle : it can be overwritten by the user.
  100720. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  100721. * @param particle the current particle
  100722. * @param vertex the current index of the current particle
  100723. * @param pt the index of the current vertex in the particle shape
  100724. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  100725. * @example : just set a vertex particle position
  100726. * @returns the updated vertex
  100727. */
  100728. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  100729. /**
  100730. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  100731. * This does nothing and may be overwritten by the user.
  100732. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100733. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100734. * @param update the boolean update value actually passed to setParticles()
  100735. */
  100736. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  100737. /**
  100738. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  100739. * This will be passed three parameters.
  100740. * This does nothing and may be overwritten by the user.
  100741. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100742. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100743. * @param update the boolean update value actually passed to setParticles()
  100744. */
  100745. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  100746. }
  100747. }
  100748. declare module BABYLON {
  100749. /**
  100750. * Represents one particle of a solid particle system.
  100751. */
  100752. export class SolidParticle {
  100753. /**
  100754. * particle global index
  100755. */
  100756. idx: number;
  100757. /**
  100758. * particle identifier
  100759. */
  100760. id: number;
  100761. /**
  100762. * The color of the particle
  100763. */
  100764. color: Nullable<Color4>;
  100765. /**
  100766. * The world space position of the particle.
  100767. */
  100768. position: Vector3;
  100769. /**
  100770. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  100771. */
  100772. rotation: Vector3;
  100773. /**
  100774. * The world space rotation quaternion of the particle.
  100775. */
  100776. rotationQuaternion: Nullable<Quaternion>;
  100777. /**
  100778. * The scaling of the particle.
  100779. */
  100780. scaling: Vector3;
  100781. /**
  100782. * The uvs of the particle.
  100783. */
  100784. uvs: Vector4;
  100785. /**
  100786. * The current speed of the particle.
  100787. */
  100788. velocity: Vector3;
  100789. /**
  100790. * The pivot point in the particle local space.
  100791. */
  100792. pivot: Vector3;
  100793. /**
  100794. * Must the particle be translated from its pivot point in its local space ?
  100795. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  100796. * Default : false
  100797. */
  100798. translateFromPivot: boolean;
  100799. /**
  100800. * Is the particle active or not ?
  100801. */
  100802. alive: boolean;
  100803. /**
  100804. * Is the particle visible or not ?
  100805. */
  100806. isVisible: boolean;
  100807. /**
  100808. * Index of this particle in the global "positions" array (Internal use)
  100809. * @hidden
  100810. */
  100811. _pos: number;
  100812. /**
  100813. * @hidden Index of this particle in the global "indices" array (Internal use)
  100814. */
  100815. _ind: number;
  100816. /**
  100817. * @hidden ModelShape of this particle (Internal use)
  100818. */
  100819. _model: ModelShape;
  100820. /**
  100821. * ModelShape id of this particle
  100822. */
  100823. shapeId: number;
  100824. /**
  100825. * Index of the particle in its shape id
  100826. */
  100827. idxInShape: number;
  100828. /**
  100829. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  100830. */
  100831. _modelBoundingInfo: BoundingInfo;
  100832. /**
  100833. * @hidden Particle BoundingInfo object (Internal use)
  100834. */
  100835. _boundingInfo: BoundingInfo;
  100836. /**
  100837. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  100838. */
  100839. _sps: SolidParticleSystem;
  100840. /**
  100841. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  100842. */
  100843. _stillInvisible: boolean;
  100844. /**
  100845. * @hidden Last computed particle rotation matrix
  100846. */
  100847. _rotationMatrix: number[];
  100848. /**
  100849. * Parent particle Id, if any.
  100850. * Default null.
  100851. */
  100852. parentId: Nullable<number>;
  100853. /**
  100854. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  100855. */
  100856. materialIndex: Nullable<number>;
  100857. /**
  100858. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  100859. * The possible values are :
  100860. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  100861. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  100862. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  100863. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  100864. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  100865. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  100866. * */
  100867. cullingStrategy: number;
  100868. /**
  100869. * @hidden Internal global position in the SPS.
  100870. */
  100871. _globalPosition: Vector3;
  100872. /**
  100873. * Creates a Solid Particle object.
  100874. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  100875. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  100876. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  100877. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  100878. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  100879. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  100880. * @param shapeId (integer) is the model shape identifier in the SPS.
  100881. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  100882. * @param sps defines the sps it is associated to
  100883. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  100884. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  100885. */
  100886. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  100887. /**
  100888. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  100889. * @param target the particle target
  100890. * @returns the current particle
  100891. */
  100892. copyToRef(target: SolidParticle): SolidParticle;
  100893. /**
  100894. * Legacy support, changed scale to scaling
  100895. */
  100896. get scale(): Vector3;
  100897. /**
  100898. * Legacy support, changed scale to scaling
  100899. */
  100900. set scale(scale: Vector3);
  100901. /**
  100902. * Legacy support, changed quaternion to rotationQuaternion
  100903. */
  100904. get quaternion(): Nullable<Quaternion>;
  100905. /**
  100906. * Legacy support, changed quaternion to rotationQuaternion
  100907. */
  100908. set quaternion(q: Nullable<Quaternion>);
  100909. /**
  100910. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  100911. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  100912. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  100913. * @returns true if it intersects
  100914. */
  100915. intersectsMesh(target: Mesh | SolidParticle): boolean;
  100916. /**
  100917. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  100918. * A particle is in the frustum if its bounding box intersects the frustum
  100919. * @param frustumPlanes defines the frustum to test
  100920. * @returns true if the particle is in the frustum planes
  100921. */
  100922. isInFrustum(frustumPlanes: Plane[]): boolean;
  100923. /**
  100924. * get the rotation matrix of the particle
  100925. * @hidden
  100926. */
  100927. getRotationMatrix(m: Matrix): void;
  100928. }
  100929. /**
  100930. * Represents the shape of the model used by one particle of a solid particle system.
  100931. * SPS internal tool, don't use it manually.
  100932. */
  100933. export class ModelShape {
  100934. /**
  100935. * The shape id
  100936. * @hidden
  100937. */
  100938. shapeID: number;
  100939. /**
  100940. * flat array of model positions (internal use)
  100941. * @hidden
  100942. */
  100943. _shape: Vector3[];
  100944. /**
  100945. * flat array of model UVs (internal use)
  100946. * @hidden
  100947. */
  100948. _shapeUV: number[];
  100949. /**
  100950. * color array of the model
  100951. * @hidden
  100952. */
  100953. _shapeColors: number[];
  100954. /**
  100955. * indices array of the model
  100956. * @hidden
  100957. */
  100958. _indices: number[];
  100959. /**
  100960. * normals array of the model
  100961. * @hidden
  100962. */
  100963. _normals: number[];
  100964. /**
  100965. * length of the shape in the model indices array (internal use)
  100966. * @hidden
  100967. */
  100968. _indicesLength: number;
  100969. /**
  100970. * Custom position function (internal use)
  100971. * @hidden
  100972. */
  100973. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  100974. /**
  100975. * Custom vertex function (internal use)
  100976. * @hidden
  100977. */
  100978. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  100979. /**
  100980. * Model material (internal use)
  100981. * @hidden
  100982. */
  100983. _material: Nullable<Material>;
  100984. /**
  100985. * 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.
  100986. * SPS internal tool, don't use it manually.
  100987. * @hidden
  100988. */
  100989. 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>);
  100990. }
  100991. /**
  100992. * Represents a Depth Sorted Particle in the solid particle system.
  100993. * @hidden
  100994. */
  100995. export class DepthSortedParticle {
  100996. /**
  100997. * Index of the particle in the "indices" array
  100998. */
  100999. ind: number;
  101000. /**
  101001. * Length of the particle shape in the "indices" array
  101002. */
  101003. indicesLength: number;
  101004. /**
  101005. * Squared distance from the particle to the camera
  101006. */
  101007. sqDistance: number;
  101008. /**
  101009. * Material index when used with MultiMaterials
  101010. */
  101011. materialIndex: number;
  101012. /**
  101013. * Creates a new sorted particle
  101014. * @param materialIndex
  101015. */
  101016. constructor(ind: number, indLength: number, materialIndex: number);
  101017. }
  101018. }
  101019. declare module BABYLON {
  101020. /**
  101021. * @hidden
  101022. */
  101023. export class _MeshCollisionData {
  101024. _checkCollisions: boolean;
  101025. _collisionMask: number;
  101026. _collisionGroup: number;
  101027. _collider: Nullable<Collider>;
  101028. _oldPositionForCollisions: Vector3;
  101029. _diffPositionForCollisions: Vector3;
  101030. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  101031. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  101032. }
  101033. }
  101034. declare module BABYLON {
  101035. /** @hidden */
  101036. class _FacetDataStorage {
  101037. facetPositions: Vector3[];
  101038. facetNormals: Vector3[];
  101039. facetPartitioning: number[][];
  101040. facetNb: number;
  101041. partitioningSubdivisions: number;
  101042. partitioningBBoxRatio: number;
  101043. facetDataEnabled: boolean;
  101044. facetParameters: any;
  101045. bbSize: Vector3;
  101046. subDiv: {
  101047. max: number;
  101048. X: number;
  101049. Y: number;
  101050. Z: number;
  101051. };
  101052. facetDepthSort: boolean;
  101053. facetDepthSortEnabled: boolean;
  101054. depthSortedIndices: IndicesArray;
  101055. depthSortedFacets: {
  101056. ind: number;
  101057. sqDistance: number;
  101058. }[];
  101059. facetDepthSortFunction: (f1: {
  101060. ind: number;
  101061. sqDistance: number;
  101062. }, f2: {
  101063. ind: number;
  101064. sqDistance: number;
  101065. }) => number;
  101066. facetDepthSortFrom: Vector3;
  101067. facetDepthSortOrigin: Vector3;
  101068. invertedMatrix: Matrix;
  101069. }
  101070. /**
  101071. * @hidden
  101072. **/
  101073. class _InternalAbstractMeshDataInfo {
  101074. _hasVertexAlpha: boolean;
  101075. _useVertexColors: boolean;
  101076. _numBoneInfluencers: number;
  101077. _applyFog: boolean;
  101078. _receiveShadows: boolean;
  101079. _facetData: _FacetDataStorage;
  101080. _visibility: number;
  101081. _skeleton: Nullable<Skeleton>;
  101082. _layerMask: number;
  101083. _computeBonesUsingShaders: boolean;
  101084. _isActive: boolean;
  101085. _onlyForInstances: boolean;
  101086. _isActiveIntermediate: boolean;
  101087. _onlyForInstancesIntermediate: boolean;
  101088. _actAsRegularMesh: boolean;
  101089. }
  101090. /**
  101091. * Class used to store all common mesh properties
  101092. */
  101093. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  101094. /** No occlusion */
  101095. static OCCLUSION_TYPE_NONE: number;
  101096. /** Occlusion set to optimisitic */
  101097. static OCCLUSION_TYPE_OPTIMISTIC: number;
  101098. /** Occlusion set to strict */
  101099. static OCCLUSION_TYPE_STRICT: number;
  101100. /** Use an accurante occlusion algorithm */
  101101. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  101102. /** Use a conservative occlusion algorithm */
  101103. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  101104. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  101105. * Test order :
  101106. * Is the bounding sphere outside the frustum ?
  101107. * If not, are the bounding box vertices outside the frustum ?
  101108. * It not, then the cullable object is in the frustum.
  101109. */
  101110. static readonly CULLINGSTRATEGY_STANDARD: number;
  101111. /** Culling strategy : Bounding Sphere Only.
  101112. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  101113. * It's also less accurate than the standard because some not visible objects can still be selected.
  101114. * Test : is the bounding sphere outside the frustum ?
  101115. * If not, then the cullable object is in the frustum.
  101116. */
  101117. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  101118. /** Culling strategy : Optimistic Inclusion.
  101119. * This in an inclusion test first, then the standard exclusion test.
  101120. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  101121. * 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.
  101122. * Anyway, it's as accurate as the standard strategy.
  101123. * Test :
  101124. * Is the cullable object bounding sphere center in the frustum ?
  101125. * If not, apply the default culling strategy.
  101126. */
  101127. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  101128. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  101129. * This in an inclusion test first, then the bounding sphere only exclusion test.
  101130. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  101131. * 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.
  101132. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  101133. * Test :
  101134. * Is the cullable object bounding sphere center in the frustum ?
  101135. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  101136. */
  101137. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  101138. /**
  101139. * No billboard
  101140. */
  101141. static get BILLBOARDMODE_NONE(): number;
  101142. /** Billboard on X axis */
  101143. static get BILLBOARDMODE_X(): number;
  101144. /** Billboard on Y axis */
  101145. static get BILLBOARDMODE_Y(): number;
  101146. /** Billboard on Z axis */
  101147. static get BILLBOARDMODE_Z(): number;
  101148. /** Billboard on all axes */
  101149. static get BILLBOARDMODE_ALL(): number;
  101150. /** Billboard on using position instead of orientation */
  101151. static get BILLBOARDMODE_USE_POSITION(): number;
  101152. /** @hidden */
  101153. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  101154. /**
  101155. * The culling strategy to use to check whether the mesh must be rendered or not.
  101156. * This value can be changed at any time and will be used on the next render mesh selection.
  101157. * The possible values are :
  101158. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  101159. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  101160. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  101161. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  101162. * Please read each static variable documentation to get details about the culling process.
  101163. * */
  101164. cullingStrategy: number;
  101165. /**
  101166. * Gets the number of facets in the mesh
  101167. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  101168. */
  101169. get facetNb(): number;
  101170. /**
  101171. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  101172. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  101173. */
  101174. get partitioningSubdivisions(): number;
  101175. set partitioningSubdivisions(nb: number);
  101176. /**
  101177. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  101178. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  101179. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  101180. */
  101181. get partitioningBBoxRatio(): number;
  101182. set partitioningBBoxRatio(ratio: number);
  101183. /**
  101184. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  101185. * Works only for updatable meshes.
  101186. * Doesn't work with multi-materials
  101187. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  101188. */
  101189. get mustDepthSortFacets(): boolean;
  101190. set mustDepthSortFacets(sort: boolean);
  101191. /**
  101192. * The location (Vector3) where the facet depth sort must be computed from.
  101193. * By default, the active camera position.
  101194. * Used only when facet depth sort is enabled
  101195. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  101196. */
  101197. get facetDepthSortFrom(): Vector3;
  101198. set facetDepthSortFrom(location: Vector3);
  101199. /**
  101200. * gets a boolean indicating if facetData is enabled
  101201. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  101202. */
  101203. get isFacetDataEnabled(): boolean;
  101204. /** @hidden */
  101205. _updateNonUniformScalingState(value: boolean): boolean;
  101206. /**
  101207. * An event triggered when this mesh collides with another one
  101208. */
  101209. onCollideObservable: Observable<AbstractMesh>;
  101210. /** Set a function to call when this mesh collides with another one */
  101211. set onCollide(callback: () => void);
  101212. /**
  101213. * An event triggered when the collision's position changes
  101214. */
  101215. onCollisionPositionChangeObservable: Observable<Vector3>;
  101216. /** Set a function to call when the collision's position changes */
  101217. set onCollisionPositionChange(callback: () => void);
  101218. /**
  101219. * An event triggered when material is changed
  101220. */
  101221. onMaterialChangedObservable: Observable<AbstractMesh>;
  101222. /**
  101223. * Gets or sets the orientation for POV movement & rotation
  101224. */
  101225. definedFacingForward: boolean;
  101226. /** @hidden */
  101227. _occlusionQuery: Nullable<WebGLQuery>;
  101228. /** @hidden */
  101229. _renderingGroup: Nullable<RenderingGroup>;
  101230. /**
  101231. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  101232. */
  101233. get visibility(): number;
  101234. /**
  101235. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  101236. */
  101237. set visibility(value: number);
  101238. /** Gets or sets the alpha index used to sort transparent meshes
  101239. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  101240. */
  101241. alphaIndex: number;
  101242. /**
  101243. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  101244. */
  101245. isVisible: boolean;
  101246. /**
  101247. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  101248. */
  101249. isPickable: boolean;
  101250. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  101251. showSubMeshesBoundingBox: boolean;
  101252. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  101253. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  101254. */
  101255. isBlocker: boolean;
  101256. /**
  101257. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  101258. */
  101259. enablePointerMoveEvents: boolean;
  101260. /**
  101261. * Specifies the rendering group id for this mesh (0 by default)
  101262. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  101263. */
  101264. renderingGroupId: number;
  101265. private _material;
  101266. /** Gets or sets current material */
  101267. get material(): Nullable<Material>;
  101268. set material(value: Nullable<Material>);
  101269. /**
  101270. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  101271. * @see http://doc.babylonjs.com/babylon101/shadows
  101272. */
  101273. get receiveShadows(): boolean;
  101274. set receiveShadows(value: boolean);
  101275. /** Defines color to use when rendering outline */
  101276. outlineColor: Color3;
  101277. /** Define width to use when rendering outline */
  101278. outlineWidth: number;
  101279. /** Defines color to use when rendering overlay */
  101280. overlayColor: Color3;
  101281. /** Defines alpha to use when rendering overlay */
  101282. overlayAlpha: number;
  101283. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  101284. get hasVertexAlpha(): boolean;
  101285. set hasVertexAlpha(value: boolean);
  101286. /** 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) */
  101287. get useVertexColors(): boolean;
  101288. set useVertexColors(value: boolean);
  101289. /**
  101290. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  101291. */
  101292. get computeBonesUsingShaders(): boolean;
  101293. set computeBonesUsingShaders(value: boolean);
  101294. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  101295. get numBoneInfluencers(): number;
  101296. set numBoneInfluencers(value: number);
  101297. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  101298. get applyFog(): boolean;
  101299. set applyFog(value: boolean);
  101300. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  101301. useOctreeForRenderingSelection: boolean;
  101302. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  101303. useOctreeForPicking: boolean;
  101304. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  101305. useOctreeForCollisions: boolean;
  101306. /**
  101307. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  101308. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  101309. */
  101310. get layerMask(): number;
  101311. set layerMask(value: number);
  101312. /**
  101313. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  101314. */
  101315. alwaysSelectAsActiveMesh: boolean;
  101316. /**
  101317. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  101318. */
  101319. doNotSyncBoundingInfo: boolean;
  101320. /**
  101321. * Gets or sets the current action manager
  101322. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101323. */
  101324. actionManager: Nullable<AbstractActionManager>;
  101325. private _meshCollisionData;
  101326. /**
  101327. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  101328. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101329. */
  101330. ellipsoid: Vector3;
  101331. /**
  101332. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  101333. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101334. */
  101335. ellipsoidOffset: Vector3;
  101336. /**
  101337. * Gets or sets a collision mask used to mask collisions (default is -1).
  101338. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  101339. */
  101340. get collisionMask(): number;
  101341. set collisionMask(mask: number);
  101342. /**
  101343. * Gets or sets the current collision group mask (-1 by default).
  101344. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  101345. */
  101346. get collisionGroup(): number;
  101347. set collisionGroup(mask: number);
  101348. /**
  101349. * Defines edge width used when edgesRenderer is enabled
  101350. * @see https://www.babylonjs-playground.com/#10OJSG#13
  101351. */
  101352. edgesWidth: number;
  101353. /**
  101354. * Defines edge color used when edgesRenderer is enabled
  101355. * @see https://www.babylonjs-playground.com/#10OJSG#13
  101356. */
  101357. edgesColor: Color4;
  101358. /** @hidden */
  101359. _edgesRenderer: Nullable<IEdgesRenderer>;
  101360. /** @hidden */
  101361. _masterMesh: Nullable<AbstractMesh>;
  101362. /** @hidden */
  101363. _boundingInfo: Nullable<BoundingInfo>;
  101364. /** @hidden */
  101365. _renderId: number;
  101366. /**
  101367. * Gets or sets the list of subMeshes
  101368. * @see http://doc.babylonjs.com/how_to/multi_materials
  101369. */
  101370. subMeshes: SubMesh[];
  101371. /** @hidden */
  101372. _intersectionsInProgress: AbstractMesh[];
  101373. /** @hidden */
  101374. _unIndexed: boolean;
  101375. /** @hidden */
  101376. _lightSources: Light[];
  101377. /** Gets the list of lights affecting that mesh */
  101378. get lightSources(): Light[];
  101379. /** @hidden */
  101380. get _positions(): Nullable<Vector3[]>;
  101381. /** @hidden */
  101382. _waitingData: {
  101383. lods: Nullable<any>;
  101384. actions: Nullable<any>;
  101385. freezeWorldMatrix: Nullable<boolean>;
  101386. };
  101387. /** @hidden */
  101388. _bonesTransformMatrices: Nullable<Float32Array>;
  101389. /** @hidden */
  101390. _transformMatrixTexture: Nullable<RawTexture>;
  101391. /**
  101392. * Gets or sets a skeleton to apply skining transformations
  101393. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  101394. */
  101395. set skeleton(value: Nullable<Skeleton>);
  101396. get skeleton(): Nullable<Skeleton>;
  101397. /**
  101398. * An event triggered when the mesh is rebuilt.
  101399. */
  101400. onRebuildObservable: Observable<AbstractMesh>;
  101401. /**
  101402. * Creates a new AbstractMesh
  101403. * @param name defines the name of the mesh
  101404. * @param scene defines the hosting scene
  101405. */
  101406. constructor(name: string, scene?: Nullable<Scene>);
  101407. /**
  101408. * Returns the string "AbstractMesh"
  101409. * @returns "AbstractMesh"
  101410. */
  101411. getClassName(): string;
  101412. /**
  101413. * Gets a string representation of the current mesh
  101414. * @param fullDetails defines a boolean indicating if full details must be included
  101415. * @returns a string representation of the current mesh
  101416. */
  101417. toString(fullDetails?: boolean): string;
  101418. /**
  101419. * @hidden
  101420. */
  101421. protected _getEffectiveParent(): Nullable<Node>;
  101422. /** @hidden */
  101423. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  101424. /** @hidden */
  101425. _rebuild(): void;
  101426. /** @hidden */
  101427. _resyncLightSources(): void;
  101428. /** @hidden */
  101429. _resyncLightSource(light: Light): void;
  101430. /** @hidden */
  101431. _unBindEffect(): void;
  101432. /** @hidden */
  101433. _removeLightSource(light: Light, dispose: boolean): void;
  101434. private _markSubMeshesAsDirty;
  101435. /** @hidden */
  101436. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  101437. /** @hidden */
  101438. _markSubMeshesAsAttributesDirty(): void;
  101439. /** @hidden */
  101440. _markSubMeshesAsMiscDirty(): void;
  101441. /**
  101442. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  101443. */
  101444. get scaling(): Vector3;
  101445. set scaling(newScaling: Vector3);
  101446. /**
  101447. * Returns true if the mesh is blocked. Implemented by child classes
  101448. */
  101449. get isBlocked(): boolean;
  101450. /**
  101451. * Returns the mesh itself by default. Implemented by child classes
  101452. * @param camera defines the camera to use to pick the right LOD level
  101453. * @returns the currentAbstractMesh
  101454. */
  101455. getLOD(camera: Camera): Nullable<AbstractMesh>;
  101456. /**
  101457. * Returns 0 by default. Implemented by child classes
  101458. * @returns an integer
  101459. */
  101460. getTotalVertices(): number;
  101461. /**
  101462. * Returns a positive integer : the total number of indices in this mesh geometry.
  101463. * @returns the numner of indices or zero if the mesh has no geometry.
  101464. */
  101465. getTotalIndices(): number;
  101466. /**
  101467. * Returns null by default. Implemented by child classes
  101468. * @returns null
  101469. */
  101470. getIndices(): Nullable<IndicesArray>;
  101471. /**
  101472. * Returns the array of the requested vertex data kind. Implemented by child classes
  101473. * @param kind defines the vertex data kind to use
  101474. * @returns null
  101475. */
  101476. getVerticesData(kind: string): Nullable<FloatArray>;
  101477. /**
  101478. * Sets the vertex data of the mesh geometry for the requested `kind`.
  101479. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  101480. * Note that a new underlying VertexBuffer object is created each call.
  101481. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  101482. * @param kind defines vertex data kind:
  101483. * * VertexBuffer.PositionKind
  101484. * * VertexBuffer.UVKind
  101485. * * VertexBuffer.UV2Kind
  101486. * * VertexBuffer.UV3Kind
  101487. * * VertexBuffer.UV4Kind
  101488. * * VertexBuffer.UV5Kind
  101489. * * VertexBuffer.UV6Kind
  101490. * * VertexBuffer.ColorKind
  101491. * * VertexBuffer.MatricesIndicesKind
  101492. * * VertexBuffer.MatricesIndicesExtraKind
  101493. * * VertexBuffer.MatricesWeightsKind
  101494. * * VertexBuffer.MatricesWeightsExtraKind
  101495. * @param data defines the data source
  101496. * @param updatable defines if the data must be flagged as updatable (or static)
  101497. * @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
  101498. * @returns the current mesh
  101499. */
  101500. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  101501. /**
  101502. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  101503. * If the mesh has no geometry, it is simply returned as it is.
  101504. * @param kind defines vertex data kind:
  101505. * * VertexBuffer.PositionKind
  101506. * * VertexBuffer.UVKind
  101507. * * VertexBuffer.UV2Kind
  101508. * * VertexBuffer.UV3Kind
  101509. * * VertexBuffer.UV4Kind
  101510. * * VertexBuffer.UV5Kind
  101511. * * VertexBuffer.UV6Kind
  101512. * * VertexBuffer.ColorKind
  101513. * * VertexBuffer.MatricesIndicesKind
  101514. * * VertexBuffer.MatricesIndicesExtraKind
  101515. * * VertexBuffer.MatricesWeightsKind
  101516. * * VertexBuffer.MatricesWeightsExtraKind
  101517. * @param data defines the data source
  101518. * @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
  101519. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  101520. * @returns the current mesh
  101521. */
  101522. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  101523. /**
  101524. * Sets the mesh indices,
  101525. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  101526. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  101527. * @param totalVertices Defines the total number of vertices
  101528. * @returns the current mesh
  101529. */
  101530. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  101531. /**
  101532. * Gets a boolean indicating if specific vertex data is present
  101533. * @param kind defines the vertex data kind to use
  101534. * @returns true is data kind is present
  101535. */
  101536. isVerticesDataPresent(kind: string): boolean;
  101537. /**
  101538. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  101539. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  101540. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  101541. * @returns a BoundingInfo
  101542. */
  101543. getBoundingInfo(): BoundingInfo;
  101544. /**
  101545. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  101546. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  101547. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  101548. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  101549. * @returns the current mesh
  101550. */
  101551. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  101552. /**
  101553. * Overwrite the current bounding info
  101554. * @param boundingInfo defines the new bounding info
  101555. * @returns the current mesh
  101556. */
  101557. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  101558. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  101559. get useBones(): boolean;
  101560. /** @hidden */
  101561. _preActivate(): void;
  101562. /** @hidden */
  101563. _preActivateForIntermediateRendering(renderId: number): void;
  101564. /** @hidden */
  101565. _activate(renderId: number, intermediateRendering: boolean): boolean;
  101566. /** @hidden */
  101567. _postActivate(): void;
  101568. /** @hidden */
  101569. _freeze(): void;
  101570. /** @hidden */
  101571. _unFreeze(): void;
  101572. /**
  101573. * Gets the current world matrix
  101574. * @returns a Matrix
  101575. */
  101576. getWorldMatrix(): Matrix;
  101577. /** @hidden */
  101578. _getWorldMatrixDeterminant(): number;
  101579. /**
  101580. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  101581. */
  101582. get isAnInstance(): boolean;
  101583. /**
  101584. * Gets a boolean indicating if this mesh has instances
  101585. */
  101586. get hasInstances(): boolean;
  101587. /**
  101588. * Perform relative position change from the point of view of behind the front of the mesh.
  101589. * This is performed taking into account the meshes current rotation, so you do not have to care.
  101590. * Supports definition of mesh facing forward or backward
  101591. * @param amountRight defines the distance on the right axis
  101592. * @param amountUp defines the distance on the up axis
  101593. * @param amountForward defines the distance on the forward axis
  101594. * @returns the current mesh
  101595. */
  101596. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  101597. /**
  101598. * Calculate relative position change from the point of view of behind the front of the mesh.
  101599. * This is performed taking into account the meshes current rotation, so you do not have to care.
  101600. * Supports definition of mesh facing forward or backward
  101601. * @param amountRight defines the distance on the right axis
  101602. * @param amountUp defines the distance on the up axis
  101603. * @param amountForward defines the distance on the forward axis
  101604. * @returns the new displacement vector
  101605. */
  101606. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  101607. /**
  101608. * Perform relative rotation change from the point of view of behind the front of the mesh.
  101609. * Supports definition of mesh facing forward or backward
  101610. * @param flipBack defines the flip
  101611. * @param twirlClockwise defines the twirl
  101612. * @param tiltRight defines the tilt
  101613. * @returns the current mesh
  101614. */
  101615. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  101616. /**
  101617. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  101618. * Supports definition of mesh facing forward or backward.
  101619. * @param flipBack defines the flip
  101620. * @param twirlClockwise defines the twirl
  101621. * @param tiltRight defines the tilt
  101622. * @returns the new rotation vector
  101623. */
  101624. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  101625. /**
  101626. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  101627. * This means the mesh underlying bounding box and sphere are recomputed.
  101628. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  101629. * @returns the current mesh
  101630. */
  101631. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  101632. /** @hidden */
  101633. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  101634. /** @hidden */
  101635. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  101636. /** @hidden */
  101637. _updateBoundingInfo(): AbstractMesh;
  101638. /** @hidden */
  101639. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  101640. /** @hidden */
  101641. protected _afterComputeWorldMatrix(): void;
  101642. /** @hidden */
  101643. get _effectiveMesh(): AbstractMesh;
  101644. /**
  101645. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  101646. * A mesh is in the frustum if its bounding box intersects the frustum
  101647. * @param frustumPlanes defines the frustum to test
  101648. * @returns true if the mesh is in the frustum planes
  101649. */
  101650. isInFrustum(frustumPlanes: Plane[]): boolean;
  101651. /**
  101652. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  101653. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  101654. * @param frustumPlanes defines the frustum to test
  101655. * @returns true if the mesh is completely in the frustum planes
  101656. */
  101657. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  101658. /**
  101659. * True if the mesh intersects another mesh or a SolidParticle object
  101660. * @param mesh defines a target mesh or SolidParticle to test
  101661. * @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)
  101662. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  101663. * @returns true if there is an intersection
  101664. */
  101665. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  101666. /**
  101667. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  101668. * @param point defines the point to test
  101669. * @returns true if there is an intersection
  101670. */
  101671. intersectsPoint(point: Vector3): boolean;
  101672. /**
  101673. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  101674. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101675. */
  101676. get checkCollisions(): boolean;
  101677. set checkCollisions(collisionEnabled: boolean);
  101678. /**
  101679. * Gets Collider object used to compute collisions (not physics)
  101680. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101681. */
  101682. get collider(): Nullable<Collider>;
  101683. /**
  101684. * Move the mesh using collision engine
  101685. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101686. * @param displacement defines the requested displacement vector
  101687. * @returns the current mesh
  101688. */
  101689. moveWithCollisions(displacement: Vector3): AbstractMesh;
  101690. private _onCollisionPositionChange;
  101691. /** @hidden */
  101692. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  101693. /** @hidden */
  101694. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  101695. /** @hidden */
  101696. _checkCollision(collider: Collider): AbstractMesh;
  101697. /** @hidden */
  101698. _generatePointsArray(): boolean;
  101699. /**
  101700. * Checks if the passed Ray intersects with the mesh
  101701. * @param ray defines the ray to use
  101702. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  101703. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101704. * @returns the picking info
  101705. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  101706. */
  101707. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  101708. /**
  101709. * Clones the current mesh
  101710. * @param name defines the mesh name
  101711. * @param newParent defines the new mesh parent
  101712. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  101713. * @returns the new mesh
  101714. */
  101715. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  101716. /**
  101717. * Disposes all the submeshes of the current meshnp
  101718. * @returns the current mesh
  101719. */
  101720. releaseSubMeshes(): AbstractMesh;
  101721. /**
  101722. * Releases resources associated with this abstract mesh.
  101723. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  101724. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  101725. */
  101726. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  101727. /**
  101728. * Adds the passed mesh as a child to the current mesh
  101729. * @param mesh defines the child mesh
  101730. * @returns the current mesh
  101731. */
  101732. addChild(mesh: AbstractMesh): AbstractMesh;
  101733. /**
  101734. * Removes the passed mesh from the current mesh children list
  101735. * @param mesh defines the child mesh
  101736. * @returns the current mesh
  101737. */
  101738. removeChild(mesh: AbstractMesh): AbstractMesh;
  101739. /** @hidden */
  101740. private _initFacetData;
  101741. /**
  101742. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  101743. * This method can be called within the render loop.
  101744. * 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
  101745. * @returns the current mesh
  101746. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101747. */
  101748. updateFacetData(): AbstractMesh;
  101749. /**
  101750. * Returns the facetLocalNormals array.
  101751. * The normals are expressed in the mesh local spac
  101752. * @returns an array of Vector3
  101753. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101754. */
  101755. getFacetLocalNormals(): Vector3[];
  101756. /**
  101757. * Returns the facetLocalPositions array.
  101758. * The facet positions are expressed in the mesh local space
  101759. * @returns an array of Vector3
  101760. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101761. */
  101762. getFacetLocalPositions(): Vector3[];
  101763. /**
  101764. * Returns the facetLocalPartioning array
  101765. * @returns an array of array of numbers
  101766. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101767. */
  101768. getFacetLocalPartitioning(): number[][];
  101769. /**
  101770. * Returns the i-th facet position in the world system.
  101771. * This method allocates a new Vector3 per call
  101772. * @param i defines the facet index
  101773. * @returns a new Vector3
  101774. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101775. */
  101776. getFacetPosition(i: number): Vector3;
  101777. /**
  101778. * Sets the reference Vector3 with the i-th facet position in the world system
  101779. * @param i defines the facet index
  101780. * @param ref defines the target vector
  101781. * @returns the current mesh
  101782. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101783. */
  101784. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  101785. /**
  101786. * Returns the i-th facet normal in the world system.
  101787. * This method allocates a new Vector3 per call
  101788. * @param i defines the facet index
  101789. * @returns a new Vector3
  101790. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101791. */
  101792. getFacetNormal(i: number): Vector3;
  101793. /**
  101794. * Sets the reference Vector3 with the i-th facet normal in the world system
  101795. * @param i defines the facet index
  101796. * @param ref defines the target vector
  101797. * @returns the current mesh
  101798. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101799. */
  101800. getFacetNormalToRef(i: number, ref: Vector3): this;
  101801. /**
  101802. * 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)
  101803. * @param x defines x coordinate
  101804. * @param y defines y coordinate
  101805. * @param z defines z coordinate
  101806. * @returns the array of facet indexes
  101807. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101808. */
  101809. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  101810. /**
  101811. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  101812. * @param projected sets as the (x,y,z) world projection on the facet
  101813. * @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
  101814. * @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
  101815. * @param x defines x coordinate
  101816. * @param y defines y coordinate
  101817. * @param z defines z coordinate
  101818. * @returns the face index if found (or null instead)
  101819. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101820. */
  101821. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  101822. /**
  101823. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  101824. * @param projected sets as the (x,y,z) local projection on the facet
  101825. * @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
  101826. * @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
  101827. * @param x defines x coordinate
  101828. * @param y defines y coordinate
  101829. * @param z defines z coordinate
  101830. * @returns the face index if found (or null instead)
  101831. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101832. */
  101833. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  101834. /**
  101835. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  101836. * @returns the parameters
  101837. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101838. */
  101839. getFacetDataParameters(): any;
  101840. /**
  101841. * Disables the feature FacetData and frees the related memory
  101842. * @returns the current mesh
  101843. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101844. */
  101845. disableFacetData(): AbstractMesh;
  101846. /**
  101847. * Updates the AbstractMesh indices array
  101848. * @param indices defines the data source
  101849. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  101850. * @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)
  101851. * @returns the current mesh
  101852. */
  101853. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  101854. /**
  101855. * Creates new normals data for the mesh
  101856. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  101857. * @returns the current mesh
  101858. */
  101859. createNormals(updatable: boolean): AbstractMesh;
  101860. /**
  101861. * Align the mesh with a normal
  101862. * @param normal defines the normal to use
  101863. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  101864. * @returns the current mesh
  101865. */
  101866. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  101867. /** @hidden */
  101868. _checkOcclusionQuery(): boolean;
  101869. /**
  101870. * Disables the mesh edge rendering mode
  101871. * @returns the currentAbstractMesh
  101872. */
  101873. disableEdgesRendering(): AbstractMesh;
  101874. /**
  101875. * Enables the edge rendering mode on the mesh.
  101876. * This mode makes the mesh edges visible
  101877. * @param epsilon defines the maximal distance between two angles to detect a face
  101878. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  101879. * @returns the currentAbstractMesh
  101880. * @see https://www.babylonjs-playground.com/#19O9TU#0
  101881. */
  101882. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  101883. }
  101884. }
  101885. declare module BABYLON {
  101886. /**
  101887. * Interface used to define ActionEvent
  101888. */
  101889. export interface IActionEvent {
  101890. /** The mesh or sprite that triggered the action */
  101891. source: any;
  101892. /** The X mouse cursor position at the time of the event */
  101893. pointerX: number;
  101894. /** The Y mouse cursor position at the time of the event */
  101895. pointerY: number;
  101896. /** The mesh that is currently pointed at (can be null) */
  101897. meshUnderPointer: Nullable<AbstractMesh>;
  101898. /** the original (browser) event that triggered the ActionEvent */
  101899. sourceEvent?: any;
  101900. /** additional data for the event */
  101901. additionalData?: any;
  101902. }
  101903. /**
  101904. * ActionEvent is the event being sent when an action is triggered.
  101905. */
  101906. export class ActionEvent implements IActionEvent {
  101907. /** The mesh or sprite that triggered the action */
  101908. source: any;
  101909. /** The X mouse cursor position at the time of the event */
  101910. pointerX: number;
  101911. /** The Y mouse cursor position at the time of the event */
  101912. pointerY: number;
  101913. /** The mesh that is currently pointed at (can be null) */
  101914. meshUnderPointer: Nullable<AbstractMesh>;
  101915. /** the original (browser) event that triggered the ActionEvent */
  101916. sourceEvent?: any;
  101917. /** additional data for the event */
  101918. additionalData?: any;
  101919. /**
  101920. * Creates a new ActionEvent
  101921. * @param source The mesh or sprite that triggered the action
  101922. * @param pointerX The X mouse cursor position at the time of the event
  101923. * @param pointerY The Y mouse cursor position at the time of the event
  101924. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  101925. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  101926. * @param additionalData additional data for the event
  101927. */
  101928. constructor(
  101929. /** The mesh or sprite that triggered the action */
  101930. source: any,
  101931. /** The X mouse cursor position at the time of the event */
  101932. pointerX: number,
  101933. /** The Y mouse cursor position at the time of the event */
  101934. pointerY: number,
  101935. /** The mesh that is currently pointed at (can be null) */
  101936. meshUnderPointer: Nullable<AbstractMesh>,
  101937. /** the original (browser) event that triggered the ActionEvent */
  101938. sourceEvent?: any,
  101939. /** additional data for the event */
  101940. additionalData?: any);
  101941. /**
  101942. * Helper function to auto-create an ActionEvent from a source mesh.
  101943. * @param source The source mesh that triggered the event
  101944. * @param evt The original (browser) event
  101945. * @param additionalData additional data for the event
  101946. * @returns the new ActionEvent
  101947. */
  101948. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  101949. /**
  101950. * Helper function to auto-create an ActionEvent from a source sprite
  101951. * @param source The source sprite that triggered the event
  101952. * @param scene Scene associated with the sprite
  101953. * @param evt The original (browser) event
  101954. * @param additionalData additional data for the event
  101955. * @returns the new ActionEvent
  101956. */
  101957. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  101958. /**
  101959. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  101960. * @param scene the scene where the event occurred
  101961. * @param evt The original (browser) event
  101962. * @returns the new ActionEvent
  101963. */
  101964. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  101965. /**
  101966. * Helper function to auto-create an ActionEvent from a primitive
  101967. * @param prim defines the target primitive
  101968. * @param pointerPos defines the pointer position
  101969. * @param evt The original (browser) event
  101970. * @param additionalData additional data for the event
  101971. * @returns the new ActionEvent
  101972. */
  101973. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  101974. }
  101975. }
  101976. declare module BABYLON {
  101977. /**
  101978. * Abstract class used to decouple action Manager from scene and meshes.
  101979. * Do not instantiate.
  101980. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101981. */
  101982. export abstract class AbstractActionManager implements IDisposable {
  101983. /** Gets the list of active triggers */
  101984. static Triggers: {
  101985. [key: string]: number;
  101986. };
  101987. /** Gets the cursor to use when hovering items */
  101988. hoverCursor: string;
  101989. /** Gets the list of actions */
  101990. actions: IAction[];
  101991. /**
  101992. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  101993. */
  101994. isRecursive: boolean;
  101995. /**
  101996. * Releases all associated resources
  101997. */
  101998. abstract dispose(): void;
  101999. /**
  102000. * Does this action manager has pointer triggers
  102001. */
  102002. abstract get hasPointerTriggers(): boolean;
  102003. /**
  102004. * Does this action manager has pick triggers
  102005. */
  102006. abstract get hasPickTriggers(): boolean;
  102007. /**
  102008. * Process a specific trigger
  102009. * @param trigger defines the trigger to process
  102010. * @param evt defines the event details to be processed
  102011. */
  102012. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  102013. /**
  102014. * Does this action manager handles actions of any of the given triggers
  102015. * @param triggers defines the triggers to be tested
  102016. * @return a boolean indicating whether one (or more) of the triggers is handled
  102017. */
  102018. abstract hasSpecificTriggers(triggers: number[]): boolean;
  102019. /**
  102020. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  102021. * speed.
  102022. * @param triggerA defines the trigger to be tested
  102023. * @param triggerB defines the trigger to be tested
  102024. * @return a boolean indicating whether one (or more) of the triggers is handled
  102025. */
  102026. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  102027. /**
  102028. * Does this action manager handles actions of a given trigger
  102029. * @param trigger defines the trigger to be tested
  102030. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  102031. * @return whether the trigger is handled
  102032. */
  102033. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  102034. /**
  102035. * Serialize this manager to a JSON object
  102036. * @param name defines the property name to store this manager
  102037. * @returns a JSON representation of this manager
  102038. */
  102039. abstract serialize(name: string): any;
  102040. /**
  102041. * Registers an action to this action manager
  102042. * @param action defines the action to be registered
  102043. * @return the action amended (prepared) after registration
  102044. */
  102045. abstract registerAction(action: IAction): Nullable<IAction>;
  102046. /**
  102047. * Unregisters an action to this action manager
  102048. * @param action defines the action to be unregistered
  102049. * @return a boolean indicating whether the action has been unregistered
  102050. */
  102051. abstract unregisterAction(action: IAction): Boolean;
  102052. /**
  102053. * Does exist one action manager with at least one trigger
  102054. **/
  102055. static get HasTriggers(): boolean;
  102056. /**
  102057. * Does exist one action manager with at least one pick trigger
  102058. **/
  102059. static get HasPickTriggers(): boolean;
  102060. /**
  102061. * Does exist one action manager that handles actions of a given trigger
  102062. * @param trigger defines the trigger to be tested
  102063. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  102064. **/
  102065. static HasSpecificTrigger(trigger: number): boolean;
  102066. }
  102067. }
  102068. declare module BABYLON {
  102069. /**
  102070. * Defines how a node can be built from a string name.
  102071. */
  102072. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  102073. /**
  102074. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  102075. */
  102076. export class Node implements IBehaviorAware<Node> {
  102077. /** @hidden */
  102078. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  102079. private static _NodeConstructors;
  102080. /**
  102081. * Add a new node constructor
  102082. * @param type defines the type name of the node to construct
  102083. * @param constructorFunc defines the constructor function
  102084. */
  102085. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  102086. /**
  102087. * Returns a node constructor based on type name
  102088. * @param type defines the type name
  102089. * @param name defines the new node name
  102090. * @param scene defines the hosting scene
  102091. * @param options defines optional options to transmit to constructors
  102092. * @returns the new constructor or null
  102093. */
  102094. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  102095. /**
  102096. * Gets or sets the name of the node
  102097. */
  102098. name: string;
  102099. /**
  102100. * Gets or sets the id of the node
  102101. */
  102102. id: string;
  102103. /**
  102104. * Gets or sets the unique id of the node
  102105. */
  102106. uniqueId: number;
  102107. /**
  102108. * Gets or sets a string used to store user defined state for the node
  102109. */
  102110. state: string;
  102111. /**
  102112. * Gets or sets an object used to store user defined information for the node
  102113. */
  102114. metadata: any;
  102115. /**
  102116. * For internal use only. Please do not use.
  102117. */
  102118. reservedDataStore: any;
  102119. /**
  102120. * List of inspectable custom properties (used by the Inspector)
  102121. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  102122. */
  102123. inspectableCustomProperties: IInspectable[];
  102124. private _doNotSerialize;
  102125. /**
  102126. * Gets or sets a boolean used to define if the node must be serialized
  102127. */
  102128. get doNotSerialize(): boolean;
  102129. set doNotSerialize(value: boolean);
  102130. /** @hidden */
  102131. _isDisposed: boolean;
  102132. /**
  102133. * Gets a list of Animations associated with the node
  102134. */
  102135. animations: Animation[];
  102136. protected _ranges: {
  102137. [name: string]: Nullable<AnimationRange>;
  102138. };
  102139. /**
  102140. * Callback raised when the node is ready to be used
  102141. */
  102142. onReady: Nullable<(node: Node) => void>;
  102143. private _isEnabled;
  102144. private _isParentEnabled;
  102145. private _isReady;
  102146. /** @hidden */
  102147. _currentRenderId: number;
  102148. private _parentUpdateId;
  102149. /** @hidden */
  102150. _childUpdateId: number;
  102151. /** @hidden */
  102152. _waitingParentId: Nullable<string>;
  102153. /** @hidden */
  102154. _scene: Scene;
  102155. /** @hidden */
  102156. _cache: any;
  102157. private _parentNode;
  102158. private _children;
  102159. /** @hidden */
  102160. _worldMatrix: Matrix;
  102161. /** @hidden */
  102162. _worldMatrixDeterminant: number;
  102163. /** @hidden */
  102164. _worldMatrixDeterminantIsDirty: boolean;
  102165. /** @hidden */
  102166. private _sceneRootNodesIndex;
  102167. /**
  102168. * Gets a boolean indicating if the node has been disposed
  102169. * @returns true if the node was disposed
  102170. */
  102171. isDisposed(): boolean;
  102172. /**
  102173. * Gets or sets the parent of the node (without keeping the current position in the scene)
  102174. * @see https://doc.babylonjs.com/how_to/parenting
  102175. */
  102176. set parent(parent: Nullable<Node>);
  102177. get parent(): Nullable<Node>;
  102178. /** @hidden */
  102179. _addToSceneRootNodes(): void;
  102180. /** @hidden */
  102181. _removeFromSceneRootNodes(): void;
  102182. private _animationPropertiesOverride;
  102183. /**
  102184. * Gets or sets the animation properties override
  102185. */
  102186. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  102187. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  102188. /**
  102189. * Gets a string idenfifying the name of the class
  102190. * @returns "Node" string
  102191. */
  102192. getClassName(): string;
  102193. /** @hidden */
  102194. readonly _isNode: boolean;
  102195. /**
  102196. * An event triggered when the mesh is disposed
  102197. */
  102198. onDisposeObservable: Observable<Node>;
  102199. private _onDisposeObserver;
  102200. /**
  102201. * Sets a callback that will be raised when the node will be disposed
  102202. */
  102203. set onDispose(callback: () => void);
  102204. /**
  102205. * Creates a new Node
  102206. * @param name the name and id to be given to this node
  102207. * @param scene the scene this node will be added to
  102208. */
  102209. constructor(name: string, scene?: Nullable<Scene>);
  102210. /**
  102211. * Gets the scene of the node
  102212. * @returns a scene
  102213. */
  102214. getScene(): Scene;
  102215. /**
  102216. * Gets the engine of the node
  102217. * @returns a Engine
  102218. */
  102219. getEngine(): Engine;
  102220. private _behaviors;
  102221. /**
  102222. * Attach a behavior to the node
  102223. * @see http://doc.babylonjs.com/features/behaviour
  102224. * @param behavior defines the behavior to attach
  102225. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  102226. * @returns the current Node
  102227. */
  102228. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  102229. /**
  102230. * Remove an attached behavior
  102231. * @see http://doc.babylonjs.com/features/behaviour
  102232. * @param behavior defines the behavior to attach
  102233. * @returns the current Node
  102234. */
  102235. removeBehavior(behavior: Behavior<Node>): Node;
  102236. /**
  102237. * Gets the list of attached behaviors
  102238. * @see http://doc.babylonjs.com/features/behaviour
  102239. */
  102240. get behaviors(): Behavior<Node>[];
  102241. /**
  102242. * Gets an attached behavior by name
  102243. * @param name defines the name of the behavior to look for
  102244. * @see http://doc.babylonjs.com/features/behaviour
  102245. * @returns null if behavior was not found else the requested behavior
  102246. */
  102247. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  102248. /**
  102249. * Returns the latest update of the World matrix
  102250. * @returns a Matrix
  102251. */
  102252. getWorldMatrix(): Matrix;
  102253. /** @hidden */
  102254. _getWorldMatrixDeterminant(): number;
  102255. /**
  102256. * Returns directly the latest state of the mesh World matrix.
  102257. * A Matrix is returned.
  102258. */
  102259. get worldMatrixFromCache(): Matrix;
  102260. /** @hidden */
  102261. _initCache(): void;
  102262. /** @hidden */
  102263. updateCache(force?: boolean): void;
  102264. /** @hidden */
  102265. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  102266. /** @hidden */
  102267. _updateCache(ignoreParentClass?: boolean): void;
  102268. /** @hidden */
  102269. _isSynchronized(): boolean;
  102270. /** @hidden */
  102271. _markSyncedWithParent(): void;
  102272. /** @hidden */
  102273. isSynchronizedWithParent(): boolean;
  102274. /** @hidden */
  102275. isSynchronized(): boolean;
  102276. /**
  102277. * Is this node ready to be used/rendered
  102278. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  102279. * @return true if the node is ready
  102280. */
  102281. isReady(completeCheck?: boolean): boolean;
  102282. /**
  102283. * Is this node enabled?
  102284. * 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
  102285. * @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
  102286. * @return whether this node (and its parent) is enabled
  102287. */
  102288. isEnabled(checkAncestors?: boolean): boolean;
  102289. /** @hidden */
  102290. protected _syncParentEnabledState(): void;
  102291. /**
  102292. * Set the enabled state of this node
  102293. * @param value defines the new enabled state
  102294. */
  102295. setEnabled(value: boolean): void;
  102296. /**
  102297. * Is this node a descendant of the given node?
  102298. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  102299. * @param ancestor defines the parent node to inspect
  102300. * @returns a boolean indicating if this node is a descendant of the given node
  102301. */
  102302. isDescendantOf(ancestor: Node): boolean;
  102303. /** @hidden */
  102304. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  102305. /**
  102306. * Will return all nodes that have this node as ascendant
  102307. * @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
  102308. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  102309. * @return all children nodes of all types
  102310. */
  102311. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  102312. /**
  102313. * Get all child-meshes of this node
  102314. * @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)
  102315. * @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
  102316. * @returns an array of AbstractMesh
  102317. */
  102318. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  102319. /**
  102320. * Get all direct children of this node
  102321. * @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
  102322. * @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)
  102323. * @returns an array of Node
  102324. */
  102325. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  102326. /** @hidden */
  102327. _setReady(state: boolean): void;
  102328. /**
  102329. * Get an animation by name
  102330. * @param name defines the name of the animation to look for
  102331. * @returns null if not found else the requested animation
  102332. */
  102333. getAnimationByName(name: string): Nullable<Animation>;
  102334. /**
  102335. * Creates an animation range for this node
  102336. * @param name defines the name of the range
  102337. * @param from defines the starting key
  102338. * @param to defines the end key
  102339. */
  102340. createAnimationRange(name: string, from: number, to: number): void;
  102341. /**
  102342. * Delete a specific animation range
  102343. * @param name defines the name of the range to delete
  102344. * @param deleteFrames defines if animation frames from the range must be deleted as well
  102345. */
  102346. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  102347. /**
  102348. * Get an animation range by name
  102349. * @param name defines the name of the animation range to look for
  102350. * @returns null if not found else the requested animation range
  102351. */
  102352. getAnimationRange(name: string): Nullable<AnimationRange>;
  102353. /**
  102354. * Gets the list of all animation ranges defined on this node
  102355. * @returns an array
  102356. */
  102357. getAnimationRanges(): Nullable<AnimationRange>[];
  102358. /**
  102359. * Will start the animation sequence
  102360. * @param name defines the range frames for animation sequence
  102361. * @param loop defines if the animation should loop (false by default)
  102362. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  102363. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  102364. * @returns the object created for this animation. If range does not exist, it will return null
  102365. */
  102366. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  102367. /**
  102368. * Serialize animation ranges into a JSON compatible object
  102369. * @returns serialization object
  102370. */
  102371. serializeAnimationRanges(): any;
  102372. /**
  102373. * Computes the world matrix of the node
  102374. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  102375. * @returns the world matrix
  102376. */
  102377. computeWorldMatrix(force?: boolean): Matrix;
  102378. /**
  102379. * Releases resources associated with this node.
  102380. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  102381. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  102382. */
  102383. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  102384. /**
  102385. * Parse animation range data from a serialization object and store them into a given node
  102386. * @param node defines where to store the animation ranges
  102387. * @param parsedNode defines the serialization object to read data from
  102388. * @param scene defines the hosting scene
  102389. */
  102390. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  102391. /**
  102392. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  102393. * @param includeDescendants Include bounding info from descendants as well (true by default)
  102394. * @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
  102395. * @returns the new bounding vectors
  102396. */
  102397. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  102398. min: Vector3;
  102399. max: Vector3;
  102400. };
  102401. }
  102402. }
  102403. declare module BABYLON {
  102404. /**
  102405. * @hidden
  102406. */
  102407. export class _IAnimationState {
  102408. key: number;
  102409. repeatCount: number;
  102410. workValue?: any;
  102411. loopMode?: number;
  102412. offsetValue?: any;
  102413. highLimitValue?: any;
  102414. }
  102415. /**
  102416. * Class used to store any kind of animation
  102417. */
  102418. export class Animation {
  102419. /**Name of the animation */
  102420. name: string;
  102421. /**Property to animate */
  102422. targetProperty: string;
  102423. /**The frames per second of the animation */
  102424. framePerSecond: number;
  102425. /**The data type of the animation */
  102426. dataType: number;
  102427. /**The loop mode of the animation */
  102428. loopMode?: number | undefined;
  102429. /**Specifies if blending should be enabled */
  102430. enableBlending?: boolean | undefined;
  102431. /**
  102432. * Use matrix interpolation instead of using direct key value when animating matrices
  102433. */
  102434. static AllowMatricesInterpolation: boolean;
  102435. /**
  102436. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  102437. */
  102438. static AllowMatrixDecomposeForInterpolation: boolean;
  102439. /**
  102440. * Stores the key frames of the animation
  102441. */
  102442. private _keys;
  102443. /**
  102444. * Stores the easing function of the animation
  102445. */
  102446. private _easingFunction;
  102447. /**
  102448. * @hidden Internal use only
  102449. */
  102450. _runtimeAnimations: RuntimeAnimation[];
  102451. /**
  102452. * The set of event that will be linked to this animation
  102453. */
  102454. private _events;
  102455. /**
  102456. * Stores an array of target property paths
  102457. */
  102458. targetPropertyPath: string[];
  102459. /**
  102460. * Stores the blending speed of the animation
  102461. */
  102462. blendingSpeed: number;
  102463. /**
  102464. * Stores the animation ranges for the animation
  102465. */
  102466. private _ranges;
  102467. /**
  102468. * @hidden Internal use
  102469. */
  102470. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  102471. /**
  102472. * Sets up an animation
  102473. * @param property The property to animate
  102474. * @param animationType The animation type to apply
  102475. * @param framePerSecond The frames per second of the animation
  102476. * @param easingFunction The easing function used in the animation
  102477. * @returns The created animation
  102478. */
  102479. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  102480. /**
  102481. * Create and start an animation on a node
  102482. * @param name defines the name of the global animation that will be run on all nodes
  102483. * @param node defines the root node where the animation will take place
  102484. * @param targetProperty defines property to animate
  102485. * @param framePerSecond defines the number of frame per second yo use
  102486. * @param totalFrame defines the number of frames in total
  102487. * @param from defines the initial value
  102488. * @param to defines the final value
  102489. * @param loopMode defines which loop mode you want to use (off by default)
  102490. * @param easingFunction defines the easing function to use (linear by default)
  102491. * @param onAnimationEnd defines the callback to call when animation end
  102492. * @returns the animatable created for this animation
  102493. */
  102494. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  102495. /**
  102496. * Create and start an animation on a node and its descendants
  102497. * @param name defines the name of the global animation that will be run on all nodes
  102498. * @param node defines the root node where the animation will take place
  102499. * @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
  102500. * @param targetProperty defines property to animate
  102501. * @param framePerSecond defines the number of frame per second to use
  102502. * @param totalFrame defines the number of frames in total
  102503. * @param from defines the initial value
  102504. * @param to defines the final value
  102505. * @param loopMode defines which loop mode you want to use (off by default)
  102506. * @param easingFunction defines the easing function to use (linear by default)
  102507. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  102508. * @returns the list of animatables created for all nodes
  102509. * @example https://www.babylonjs-playground.com/#MH0VLI
  102510. */
  102511. 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[]>;
  102512. /**
  102513. * Creates a new animation, merges it with the existing animations and starts it
  102514. * @param name Name of the animation
  102515. * @param node Node which contains the scene that begins the animations
  102516. * @param targetProperty Specifies which property to animate
  102517. * @param framePerSecond The frames per second of the animation
  102518. * @param totalFrame The total number of frames
  102519. * @param from The frame at the beginning of the animation
  102520. * @param to The frame at the end of the animation
  102521. * @param loopMode Specifies the loop mode of the animation
  102522. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  102523. * @param onAnimationEnd Callback to run once the animation is complete
  102524. * @returns Nullable animation
  102525. */
  102526. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  102527. /**
  102528. * Transition property of an host to the target Value
  102529. * @param property The property to transition
  102530. * @param targetValue The target Value of the property
  102531. * @param host The object where the property to animate belongs
  102532. * @param scene Scene used to run the animation
  102533. * @param frameRate Framerate (in frame/s) to use
  102534. * @param transition The transition type we want to use
  102535. * @param duration The duration of the animation, in milliseconds
  102536. * @param onAnimationEnd Callback trigger at the end of the animation
  102537. * @returns Nullable animation
  102538. */
  102539. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  102540. /**
  102541. * Return the array of runtime animations currently using this animation
  102542. */
  102543. get runtimeAnimations(): RuntimeAnimation[];
  102544. /**
  102545. * Specifies if any of the runtime animations are currently running
  102546. */
  102547. get hasRunningRuntimeAnimations(): boolean;
  102548. /**
  102549. * Initializes the animation
  102550. * @param name Name of the animation
  102551. * @param targetProperty Property to animate
  102552. * @param framePerSecond The frames per second of the animation
  102553. * @param dataType The data type of the animation
  102554. * @param loopMode The loop mode of the animation
  102555. * @param enableBlending Specifies if blending should be enabled
  102556. */
  102557. constructor(
  102558. /**Name of the animation */
  102559. name: string,
  102560. /**Property to animate */
  102561. targetProperty: string,
  102562. /**The frames per second of the animation */
  102563. framePerSecond: number,
  102564. /**The data type of the animation */
  102565. dataType: number,
  102566. /**The loop mode of the animation */
  102567. loopMode?: number | undefined,
  102568. /**Specifies if blending should be enabled */
  102569. enableBlending?: boolean | undefined);
  102570. /**
  102571. * Converts the animation to a string
  102572. * @param fullDetails support for multiple levels of logging within scene loading
  102573. * @returns String form of the animation
  102574. */
  102575. toString(fullDetails?: boolean): string;
  102576. /**
  102577. * Add an event to this animation
  102578. * @param event Event to add
  102579. */
  102580. addEvent(event: AnimationEvent): void;
  102581. /**
  102582. * Remove all events found at the given frame
  102583. * @param frame The frame to remove events from
  102584. */
  102585. removeEvents(frame: number): void;
  102586. /**
  102587. * Retrieves all the events from the animation
  102588. * @returns Events from the animation
  102589. */
  102590. getEvents(): AnimationEvent[];
  102591. /**
  102592. * Creates an animation range
  102593. * @param name Name of the animation range
  102594. * @param from Starting frame of the animation range
  102595. * @param to Ending frame of the animation
  102596. */
  102597. createRange(name: string, from: number, to: number): void;
  102598. /**
  102599. * Deletes an animation range by name
  102600. * @param name Name of the animation range to delete
  102601. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  102602. */
  102603. deleteRange(name: string, deleteFrames?: boolean): void;
  102604. /**
  102605. * Gets the animation range by name, or null if not defined
  102606. * @param name Name of the animation range
  102607. * @returns Nullable animation range
  102608. */
  102609. getRange(name: string): Nullable<AnimationRange>;
  102610. /**
  102611. * Gets the key frames from the animation
  102612. * @returns The key frames of the animation
  102613. */
  102614. getKeys(): Array<IAnimationKey>;
  102615. /**
  102616. * Gets the highest frame rate of the animation
  102617. * @returns Highest frame rate of the animation
  102618. */
  102619. getHighestFrame(): number;
  102620. /**
  102621. * Gets the easing function of the animation
  102622. * @returns Easing function of the animation
  102623. */
  102624. getEasingFunction(): IEasingFunction;
  102625. /**
  102626. * Sets the easing function of the animation
  102627. * @param easingFunction A custom mathematical formula for animation
  102628. */
  102629. setEasingFunction(easingFunction: EasingFunction): void;
  102630. /**
  102631. * Interpolates a scalar linearly
  102632. * @param startValue Start value of the animation curve
  102633. * @param endValue End value of the animation curve
  102634. * @param gradient Scalar amount to interpolate
  102635. * @returns Interpolated scalar value
  102636. */
  102637. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  102638. /**
  102639. * Interpolates a scalar cubically
  102640. * @param startValue Start value of the animation curve
  102641. * @param outTangent End tangent of the animation
  102642. * @param endValue End value of the animation curve
  102643. * @param inTangent Start tangent of the animation curve
  102644. * @param gradient Scalar amount to interpolate
  102645. * @returns Interpolated scalar value
  102646. */
  102647. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  102648. /**
  102649. * Interpolates a quaternion using a spherical linear interpolation
  102650. * @param startValue Start value of the animation curve
  102651. * @param endValue End value of the animation curve
  102652. * @param gradient Scalar amount to interpolate
  102653. * @returns Interpolated quaternion value
  102654. */
  102655. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  102656. /**
  102657. * Interpolates a quaternion cubically
  102658. * @param startValue Start value of the animation curve
  102659. * @param outTangent End tangent of the animation curve
  102660. * @param endValue End value of the animation curve
  102661. * @param inTangent Start tangent of the animation curve
  102662. * @param gradient Scalar amount to interpolate
  102663. * @returns Interpolated quaternion value
  102664. */
  102665. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  102666. /**
  102667. * Interpolates a Vector3 linearl
  102668. * @param startValue Start value of the animation curve
  102669. * @param endValue End value of the animation curve
  102670. * @param gradient Scalar amount to interpolate
  102671. * @returns Interpolated scalar value
  102672. */
  102673. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  102674. /**
  102675. * Interpolates a Vector3 cubically
  102676. * @param startValue Start value of the animation curve
  102677. * @param outTangent End tangent of the animation
  102678. * @param endValue End value of the animation curve
  102679. * @param inTangent Start tangent of the animation curve
  102680. * @param gradient Scalar amount to interpolate
  102681. * @returns InterpolatedVector3 value
  102682. */
  102683. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  102684. /**
  102685. * Interpolates a Vector2 linearly
  102686. * @param startValue Start value of the animation curve
  102687. * @param endValue End value of the animation curve
  102688. * @param gradient Scalar amount to interpolate
  102689. * @returns Interpolated Vector2 value
  102690. */
  102691. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  102692. /**
  102693. * Interpolates a Vector2 cubically
  102694. * @param startValue Start value of the animation curve
  102695. * @param outTangent End tangent of the animation
  102696. * @param endValue End value of the animation curve
  102697. * @param inTangent Start tangent of the animation curve
  102698. * @param gradient Scalar amount to interpolate
  102699. * @returns Interpolated Vector2 value
  102700. */
  102701. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  102702. /**
  102703. * Interpolates a size linearly
  102704. * @param startValue Start value of the animation curve
  102705. * @param endValue End value of the animation curve
  102706. * @param gradient Scalar amount to interpolate
  102707. * @returns Interpolated Size value
  102708. */
  102709. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  102710. /**
  102711. * Interpolates a Color3 linearly
  102712. * @param startValue Start value of the animation curve
  102713. * @param endValue End value of the animation curve
  102714. * @param gradient Scalar amount to interpolate
  102715. * @returns Interpolated Color3 value
  102716. */
  102717. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  102718. /**
  102719. * Interpolates a Color4 linearly
  102720. * @param startValue Start value of the animation curve
  102721. * @param endValue End value of the animation curve
  102722. * @param gradient Scalar amount to interpolate
  102723. * @returns Interpolated Color3 value
  102724. */
  102725. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  102726. /**
  102727. * @hidden Internal use only
  102728. */
  102729. _getKeyValue(value: any): any;
  102730. /**
  102731. * @hidden Internal use only
  102732. */
  102733. _interpolate(currentFrame: number, state: _IAnimationState): any;
  102734. /**
  102735. * Defines the function to use to interpolate matrices
  102736. * @param startValue defines the start matrix
  102737. * @param endValue defines the end matrix
  102738. * @param gradient defines the gradient between both matrices
  102739. * @param result defines an optional target matrix where to store the interpolation
  102740. * @returns the interpolated matrix
  102741. */
  102742. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  102743. /**
  102744. * Makes a copy of the animation
  102745. * @returns Cloned animation
  102746. */
  102747. clone(): Animation;
  102748. /**
  102749. * Sets the key frames of the animation
  102750. * @param values The animation key frames to set
  102751. */
  102752. setKeys(values: Array<IAnimationKey>): void;
  102753. /**
  102754. * Serializes the animation to an object
  102755. * @returns Serialized object
  102756. */
  102757. serialize(): any;
  102758. /**
  102759. * Float animation type
  102760. */
  102761. static readonly ANIMATIONTYPE_FLOAT: number;
  102762. /**
  102763. * Vector3 animation type
  102764. */
  102765. static readonly ANIMATIONTYPE_VECTOR3: number;
  102766. /**
  102767. * Quaternion animation type
  102768. */
  102769. static readonly ANIMATIONTYPE_QUATERNION: number;
  102770. /**
  102771. * Matrix animation type
  102772. */
  102773. static readonly ANIMATIONTYPE_MATRIX: number;
  102774. /**
  102775. * Color3 animation type
  102776. */
  102777. static readonly ANIMATIONTYPE_COLOR3: number;
  102778. /**
  102779. * Color3 animation type
  102780. */
  102781. static readonly ANIMATIONTYPE_COLOR4: number;
  102782. /**
  102783. * Vector2 animation type
  102784. */
  102785. static readonly ANIMATIONTYPE_VECTOR2: number;
  102786. /**
  102787. * Size animation type
  102788. */
  102789. static readonly ANIMATIONTYPE_SIZE: number;
  102790. /**
  102791. * Relative Loop Mode
  102792. */
  102793. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  102794. /**
  102795. * Cycle Loop Mode
  102796. */
  102797. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  102798. /**
  102799. * Constant Loop Mode
  102800. */
  102801. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  102802. /** @hidden */
  102803. static _UniversalLerp(left: any, right: any, amount: number): any;
  102804. /**
  102805. * Parses an animation object and creates an animation
  102806. * @param parsedAnimation Parsed animation object
  102807. * @returns Animation object
  102808. */
  102809. static Parse(parsedAnimation: any): Animation;
  102810. /**
  102811. * Appends the serialized animations from the source animations
  102812. * @param source Source containing the animations
  102813. * @param destination Target to store the animations
  102814. */
  102815. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  102816. }
  102817. }
  102818. declare module BABYLON {
  102819. /**
  102820. * Interface containing an array of animations
  102821. */
  102822. export interface IAnimatable {
  102823. /**
  102824. * Array of animations
  102825. */
  102826. animations: Nullable<Array<Animation>>;
  102827. }
  102828. }
  102829. declare module BABYLON {
  102830. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  102831. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102832. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102833. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102834. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102835. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102836. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102837. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102838. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102839. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102840. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102841. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102842. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102843. /**
  102844. * Decorator used to define property that can be serialized as reference to a camera
  102845. * @param sourceName defines the name of the property to decorate
  102846. */
  102847. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102848. /**
  102849. * Class used to help serialization objects
  102850. */
  102851. export class SerializationHelper {
  102852. /** @hidden */
  102853. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  102854. /** @hidden */
  102855. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  102856. /** @hidden */
  102857. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  102858. /** @hidden */
  102859. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  102860. /**
  102861. * Appends the serialized animations from the source animations
  102862. * @param source Source containing the animations
  102863. * @param destination Target to store the animations
  102864. */
  102865. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  102866. /**
  102867. * Static function used to serialized a specific entity
  102868. * @param entity defines the entity to serialize
  102869. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  102870. * @returns a JSON compatible object representing the serialization of the entity
  102871. */
  102872. static Serialize<T>(entity: T, serializationObject?: any): any;
  102873. /**
  102874. * Creates a new entity from a serialization data object
  102875. * @param creationFunction defines a function used to instanciated the new entity
  102876. * @param source defines the source serialization data
  102877. * @param scene defines the hosting scene
  102878. * @param rootUrl defines the root url for resources
  102879. * @returns a new entity
  102880. */
  102881. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  102882. /**
  102883. * Clones an object
  102884. * @param creationFunction defines the function used to instanciate the new object
  102885. * @param source defines the source object
  102886. * @returns the cloned object
  102887. */
  102888. static Clone<T>(creationFunction: () => T, source: T): T;
  102889. /**
  102890. * Instanciates a new object based on a source one (some data will be shared between both object)
  102891. * @param creationFunction defines the function used to instanciate the new object
  102892. * @param source defines the source object
  102893. * @returns the new object
  102894. */
  102895. static Instanciate<T>(creationFunction: () => T, source: T): T;
  102896. }
  102897. }
  102898. declare module BABYLON {
  102899. /**
  102900. * Class used to manipulate GUIDs
  102901. */
  102902. export class GUID {
  102903. /**
  102904. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  102905. * Be aware Math.random() could cause collisions, but:
  102906. * "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"
  102907. * @returns a pseudo random id
  102908. */
  102909. static RandomId(): string;
  102910. }
  102911. }
  102912. declare module BABYLON {
  102913. /**
  102914. * Base class of all the textures in babylon.
  102915. * It groups all the common properties the materials, post process, lights... might need
  102916. * in order to make a correct use of the texture.
  102917. */
  102918. export class BaseTexture implements IAnimatable {
  102919. /**
  102920. * Default anisotropic filtering level for the application.
  102921. * It is set to 4 as a good tradeoff between perf and quality.
  102922. */
  102923. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  102924. /**
  102925. * Gets or sets the unique id of the texture
  102926. */
  102927. uniqueId: number;
  102928. /**
  102929. * Define the name of the texture.
  102930. */
  102931. name: string;
  102932. /**
  102933. * Gets or sets an object used to store user defined information.
  102934. */
  102935. metadata: any;
  102936. /**
  102937. * For internal use only. Please do not use.
  102938. */
  102939. reservedDataStore: any;
  102940. private _hasAlpha;
  102941. /**
  102942. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  102943. */
  102944. set hasAlpha(value: boolean);
  102945. get hasAlpha(): boolean;
  102946. /**
  102947. * Defines if the alpha value should be determined via the rgb values.
  102948. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  102949. */
  102950. getAlphaFromRGB: boolean;
  102951. /**
  102952. * Intensity or strength of the texture.
  102953. * It is commonly used by materials to fine tune the intensity of the texture
  102954. */
  102955. level: number;
  102956. /**
  102957. * Define the UV chanel to use starting from 0 and defaulting to 0.
  102958. * This is part of the texture as textures usually maps to one uv set.
  102959. */
  102960. coordinatesIndex: number;
  102961. private _coordinatesMode;
  102962. /**
  102963. * How a texture is mapped.
  102964. *
  102965. * | Value | Type | Description |
  102966. * | ----- | ----------------------------------- | ----------- |
  102967. * | 0 | EXPLICIT_MODE | |
  102968. * | 1 | SPHERICAL_MODE | |
  102969. * | 2 | PLANAR_MODE | |
  102970. * | 3 | CUBIC_MODE | |
  102971. * | 4 | PROJECTION_MODE | |
  102972. * | 5 | SKYBOX_MODE | |
  102973. * | 6 | INVCUBIC_MODE | |
  102974. * | 7 | EQUIRECTANGULAR_MODE | |
  102975. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  102976. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  102977. */
  102978. set coordinatesMode(value: number);
  102979. get coordinatesMode(): number;
  102980. /**
  102981. * | Value | Type | Description |
  102982. * | ----- | ------------------ | ----------- |
  102983. * | 0 | CLAMP_ADDRESSMODE | |
  102984. * | 1 | WRAP_ADDRESSMODE | |
  102985. * | 2 | MIRROR_ADDRESSMODE | |
  102986. */
  102987. wrapU: number;
  102988. /**
  102989. * | Value | Type | Description |
  102990. * | ----- | ------------------ | ----------- |
  102991. * | 0 | CLAMP_ADDRESSMODE | |
  102992. * | 1 | WRAP_ADDRESSMODE | |
  102993. * | 2 | MIRROR_ADDRESSMODE | |
  102994. */
  102995. wrapV: number;
  102996. /**
  102997. * | Value | Type | Description |
  102998. * | ----- | ------------------ | ----------- |
  102999. * | 0 | CLAMP_ADDRESSMODE | |
  103000. * | 1 | WRAP_ADDRESSMODE | |
  103001. * | 2 | MIRROR_ADDRESSMODE | |
  103002. */
  103003. wrapR: number;
  103004. /**
  103005. * With compliant hardware and browser (supporting anisotropic filtering)
  103006. * this defines the level of anisotropic filtering in the texture.
  103007. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  103008. */
  103009. anisotropicFilteringLevel: number;
  103010. /**
  103011. * Define if the texture is a cube texture or if false a 2d texture.
  103012. */
  103013. get isCube(): boolean;
  103014. set isCube(value: boolean);
  103015. /**
  103016. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  103017. */
  103018. get is3D(): boolean;
  103019. set is3D(value: boolean);
  103020. /**
  103021. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  103022. */
  103023. get is2DArray(): boolean;
  103024. set is2DArray(value: boolean);
  103025. /**
  103026. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  103027. * HDR texture are usually stored in linear space.
  103028. * This only impacts the PBR and Background materials
  103029. */
  103030. gammaSpace: boolean;
  103031. /**
  103032. * Gets or sets whether or not the texture contains RGBD data.
  103033. */
  103034. get isRGBD(): boolean;
  103035. set isRGBD(value: boolean);
  103036. /**
  103037. * Is Z inverted in the texture (useful in a cube texture).
  103038. */
  103039. invertZ: boolean;
  103040. /**
  103041. * Are mip maps generated for this texture or not.
  103042. */
  103043. get noMipmap(): boolean;
  103044. /**
  103045. * @hidden
  103046. */
  103047. lodLevelInAlpha: boolean;
  103048. /**
  103049. * With prefiltered texture, defined the offset used during the prefiltering steps.
  103050. */
  103051. get lodGenerationOffset(): number;
  103052. set lodGenerationOffset(value: number);
  103053. /**
  103054. * With prefiltered texture, defined the scale used during the prefiltering steps.
  103055. */
  103056. get lodGenerationScale(): number;
  103057. set lodGenerationScale(value: number);
  103058. /**
  103059. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  103060. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  103061. * average roughness values.
  103062. */
  103063. get linearSpecularLOD(): boolean;
  103064. set linearSpecularLOD(value: boolean);
  103065. /**
  103066. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  103067. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  103068. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  103069. */
  103070. get irradianceTexture(): Nullable<BaseTexture>;
  103071. set irradianceTexture(value: Nullable<BaseTexture>);
  103072. /**
  103073. * Define if the texture is a render target.
  103074. */
  103075. isRenderTarget: boolean;
  103076. /**
  103077. * Define the unique id of the texture in the scene.
  103078. */
  103079. get uid(): string;
  103080. /**
  103081. * Return a string representation of the texture.
  103082. * @returns the texture as a string
  103083. */
  103084. toString(): string;
  103085. /**
  103086. * Get the class name of the texture.
  103087. * @returns "BaseTexture"
  103088. */
  103089. getClassName(): string;
  103090. /**
  103091. * Define the list of animation attached to the texture.
  103092. */
  103093. animations: Animation[];
  103094. /**
  103095. * An event triggered when the texture is disposed.
  103096. */
  103097. onDisposeObservable: Observable<BaseTexture>;
  103098. private _onDisposeObserver;
  103099. /**
  103100. * Callback triggered when the texture has been disposed.
  103101. * Kept for back compatibility, you can use the onDisposeObservable instead.
  103102. */
  103103. set onDispose(callback: () => void);
  103104. /**
  103105. * Define the current state of the loading sequence when in delayed load mode.
  103106. */
  103107. delayLoadState: number;
  103108. private _scene;
  103109. /** @hidden */
  103110. _texture: Nullable<InternalTexture>;
  103111. private _uid;
  103112. /**
  103113. * Define if the texture is preventinga material to render or not.
  103114. * If not and the texture is not ready, the engine will use a default black texture instead.
  103115. */
  103116. get isBlocking(): boolean;
  103117. /**
  103118. * Instantiates a new BaseTexture.
  103119. * Base class of all the textures in babylon.
  103120. * It groups all the common properties the materials, post process, lights... might need
  103121. * in order to make a correct use of the texture.
  103122. * @param scene Define the scene the texture blongs to
  103123. */
  103124. constructor(scene: Nullable<Scene>);
  103125. /**
  103126. * Get the scene the texture belongs to.
  103127. * @returns the scene or null if undefined
  103128. */
  103129. getScene(): Nullable<Scene>;
  103130. /**
  103131. * Get the texture transform matrix used to offset tile the texture for istance.
  103132. * @returns the transformation matrix
  103133. */
  103134. getTextureMatrix(): Matrix;
  103135. /**
  103136. * Get the texture reflection matrix used to rotate/transform the reflection.
  103137. * @returns the reflection matrix
  103138. */
  103139. getReflectionTextureMatrix(): Matrix;
  103140. /**
  103141. * Get the underlying lower level texture from Babylon.
  103142. * @returns the insternal texture
  103143. */
  103144. getInternalTexture(): Nullable<InternalTexture>;
  103145. /**
  103146. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  103147. * @returns true if ready or not blocking
  103148. */
  103149. isReadyOrNotBlocking(): boolean;
  103150. /**
  103151. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  103152. * @returns true if fully ready
  103153. */
  103154. isReady(): boolean;
  103155. private _cachedSize;
  103156. /**
  103157. * Get the size of the texture.
  103158. * @returns the texture size.
  103159. */
  103160. getSize(): ISize;
  103161. /**
  103162. * Get the base size of the texture.
  103163. * It can be different from the size if the texture has been resized for POT for instance
  103164. * @returns the base size
  103165. */
  103166. getBaseSize(): ISize;
  103167. /**
  103168. * Update the sampling mode of the texture.
  103169. * Default is Trilinear mode.
  103170. *
  103171. * | Value | Type | Description |
  103172. * | ----- | ------------------ | ----------- |
  103173. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  103174. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  103175. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  103176. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  103177. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  103178. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  103179. * | 7 | NEAREST_LINEAR | |
  103180. * | 8 | NEAREST_NEAREST | |
  103181. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  103182. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  103183. * | 11 | LINEAR_LINEAR | |
  103184. * | 12 | LINEAR_NEAREST | |
  103185. *
  103186. * > _mag_: magnification filter (close to the viewer)
  103187. * > _min_: minification filter (far from the viewer)
  103188. * > _mip_: filter used between mip map levels
  103189. *@param samplingMode Define the new sampling mode of the texture
  103190. */
  103191. updateSamplingMode(samplingMode: number): void;
  103192. /**
  103193. * Scales the texture if is `canRescale()`
  103194. * @param ratio the resize factor we want to use to rescale
  103195. */
  103196. scale(ratio: number): void;
  103197. /**
  103198. * Get if the texture can rescale.
  103199. */
  103200. get canRescale(): boolean;
  103201. /** @hidden */
  103202. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  103203. /** @hidden */
  103204. _rebuild(): void;
  103205. /**
  103206. * Triggers the load sequence in delayed load mode.
  103207. */
  103208. delayLoad(): void;
  103209. /**
  103210. * Clones the texture.
  103211. * @returns the cloned texture
  103212. */
  103213. clone(): Nullable<BaseTexture>;
  103214. /**
  103215. * Get the texture underlying type (INT, FLOAT...)
  103216. */
  103217. get textureType(): number;
  103218. /**
  103219. * Get the texture underlying format (RGB, RGBA...)
  103220. */
  103221. get textureFormat(): number;
  103222. /**
  103223. * Indicates that textures need to be re-calculated for all materials
  103224. */
  103225. protected _markAllSubMeshesAsTexturesDirty(): void;
  103226. /**
  103227. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  103228. * This will returns an RGBA array buffer containing either in values (0-255) or
  103229. * float values (0-1) depending of the underlying buffer type.
  103230. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  103231. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  103232. * @param buffer defines a user defined buffer to fill with data (can be null)
  103233. * @returns The Array buffer containing the pixels data.
  103234. */
  103235. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  103236. /**
  103237. * Release and destroy the underlying lower level texture aka internalTexture.
  103238. */
  103239. releaseInternalTexture(): void;
  103240. /** @hidden */
  103241. get _lodTextureHigh(): Nullable<BaseTexture>;
  103242. /** @hidden */
  103243. get _lodTextureMid(): Nullable<BaseTexture>;
  103244. /** @hidden */
  103245. get _lodTextureLow(): Nullable<BaseTexture>;
  103246. /**
  103247. * Dispose the texture and release its associated resources.
  103248. */
  103249. dispose(): void;
  103250. /**
  103251. * Serialize the texture into a JSON representation that can be parsed later on.
  103252. * @returns the JSON representation of the texture
  103253. */
  103254. serialize(): any;
  103255. /**
  103256. * Helper function to be called back once a list of texture contains only ready textures.
  103257. * @param textures Define the list of textures to wait for
  103258. * @param callback Define the callback triggered once the entire list will be ready
  103259. */
  103260. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  103261. }
  103262. }
  103263. declare module BABYLON {
  103264. /**
  103265. * Options to be used when creating an effect.
  103266. */
  103267. export interface IEffectCreationOptions {
  103268. /**
  103269. * Atrributes that will be used in the shader.
  103270. */
  103271. attributes: string[];
  103272. /**
  103273. * Uniform varible names that will be set in the shader.
  103274. */
  103275. uniformsNames: string[];
  103276. /**
  103277. * Uniform buffer variable names that will be set in the shader.
  103278. */
  103279. uniformBuffersNames: string[];
  103280. /**
  103281. * Sampler texture variable names that will be set in the shader.
  103282. */
  103283. samplers: string[];
  103284. /**
  103285. * Define statements that will be set in the shader.
  103286. */
  103287. defines: any;
  103288. /**
  103289. * Possible fallbacks for this effect to improve performance when needed.
  103290. */
  103291. fallbacks: Nullable<IEffectFallbacks>;
  103292. /**
  103293. * Callback that will be called when the shader is compiled.
  103294. */
  103295. onCompiled: Nullable<(effect: Effect) => void>;
  103296. /**
  103297. * Callback that will be called if an error occurs during shader compilation.
  103298. */
  103299. onError: Nullable<(effect: Effect, errors: string) => void>;
  103300. /**
  103301. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  103302. */
  103303. indexParameters?: any;
  103304. /**
  103305. * Max number of lights that can be used in the shader.
  103306. */
  103307. maxSimultaneousLights?: number;
  103308. /**
  103309. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  103310. */
  103311. transformFeedbackVaryings?: Nullable<string[]>;
  103312. }
  103313. /**
  103314. * Effect containing vertex and fragment shader that can be executed on an object.
  103315. */
  103316. export class Effect implements IDisposable {
  103317. /**
  103318. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  103319. */
  103320. static ShadersRepository: string;
  103321. /**
  103322. * Name of the effect.
  103323. */
  103324. name: any;
  103325. /**
  103326. * String container all the define statements that should be set on the shader.
  103327. */
  103328. defines: string;
  103329. /**
  103330. * Callback that will be called when the shader is compiled.
  103331. */
  103332. onCompiled: Nullable<(effect: Effect) => void>;
  103333. /**
  103334. * Callback that will be called if an error occurs during shader compilation.
  103335. */
  103336. onError: Nullable<(effect: Effect, errors: string) => void>;
  103337. /**
  103338. * Callback that will be called when effect is bound.
  103339. */
  103340. onBind: Nullable<(effect: Effect) => void>;
  103341. /**
  103342. * Unique ID of the effect.
  103343. */
  103344. uniqueId: number;
  103345. /**
  103346. * Observable that will be called when the shader is compiled.
  103347. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  103348. */
  103349. onCompileObservable: Observable<Effect>;
  103350. /**
  103351. * Observable that will be called if an error occurs during shader compilation.
  103352. */
  103353. onErrorObservable: Observable<Effect>;
  103354. /** @hidden */
  103355. _onBindObservable: Nullable<Observable<Effect>>;
  103356. /**
  103357. * @hidden
  103358. * Specifies if the effect was previously ready
  103359. */
  103360. _wasPreviouslyReady: boolean;
  103361. /**
  103362. * Observable that will be called when effect is bound.
  103363. */
  103364. get onBindObservable(): Observable<Effect>;
  103365. /** @hidden */
  103366. _bonesComputationForcedToCPU: boolean;
  103367. private static _uniqueIdSeed;
  103368. private _engine;
  103369. private _uniformBuffersNames;
  103370. private _uniformsNames;
  103371. private _samplerList;
  103372. private _samplers;
  103373. private _isReady;
  103374. private _compilationError;
  103375. private _allFallbacksProcessed;
  103376. private _attributesNames;
  103377. private _attributes;
  103378. private _attributeLocationByName;
  103379. private _uniforms;
  103380. /**
  103381. * Key for the effect.
  103382. * @hidden
  103383. */
  103384. _key: string;
  103385. private _indexParameters;
  103386. private _fallbacks;
  103387. private _vertexSourceCode;
  103388. private _fragmentSourceCode;
  103389. private _vertexSourceCodeOverride;
  103390. private _fragmentSourceCodeOverride;
  103391. private _transformFeedbackVaryings;
  103392. /**
  103393. * Compiled shader to webGL program.
  103394. * @hidden
  103395. */
  103396. _pipelineContext: Nullable<IPipelineContext>;
  103397. private _valueCache;
  103398. private static _baseCache;
  103399. /**
  103400. * Instantiates an effect.
  103401. * An effect can be used to create/manage/execute vertex and fragment shaders.
  103402. * @param baseName Name of the effect.
  103403. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  103404. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  103405. * @param samplers List of sampler variables that will be passed to the shader.
  103406. * @param engine Engine to be used to render the effect
  103407. * @param defines Define statements to be added to the shader.
  103408. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  103409. * @param onCompiled Callback that will be called when the shader is compiled.
  103410. * @param onError Callback that will be called if an error occurs during shader compilation.
  103411. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  103412. */
  103413. 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);
  103414. private _useFinalCode;
  103415. /**
  103416. * Unique key for this effect
  103417. */
  103418. get key(): string;
  103419. /**
  103420. * If the effect has been compiled and prepared.
  103421. * @returns if the effect is compiled and prepared.
  103422. */
  103423. isReady(): boolean;
  103424. private _isReadyInternal;
  103425. /**
  103426. * The engine the effect was initialized with.
  103427. * @returns the engine.
  103428. */
  103429. getEngine(): Engine;
  103430. /**
  103431. * The pipeline context for this effect
  103432. * @returns the associated pipeline context
  103433. */
  103434. getPipelineContext(): Nullable<IPipelineContext>;
  103435. /**
  103436. * The set of names of attribute variables for the shader.
  103437. * @returns An array of attribute names.
  103438. */
  103439. getAttributesNames(): string[];
  103440. /**
  103441. * Returns the attribute at the given index.
  103442. * @param index The index of the attribute.
  103443. * @returns The location of the attribute.
  103444. */
  103445. getAttributeLocation(index: number): number;
  103446. /**
  103447. * Returns the attribute based on the name of the variable.
  103448. * @param name of the attribute to look up.
  103449. * @returns the attribute location.
  103450. */
  103451. getAttributeLocationByName(name: string): number;
  103452. /**
  103453. * The number of attributes.
  103454. * @returns the numnber of attributes.
  103455. */
  103456. getAttributesCount(): number;
  103457. /**
  103458. * Gets the index of a uniform variable.
  103459. * @param uniformName of the uniform to look up.
  103460. * @returns the index.
  103461. */
  103462. getUniformIndex(uniformName: string): number;
  103463. /**
  103464. * Returns the attribute based on the name of the variable.
  103465. * @param uniformName of the uniform to look up.
  103466. * @returns the location of the uniform.
  103467. */
  103468. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  103469. /**
  103470. * Returns an array of sampler variable names
  103471. * @returns The array of sampler variable neames.
  103472. */
  103473. getSamplers(): string[];
  103474. /**
  103475. * The error from the last compilation.
  103476. * @returns the error string.
  103477. */
  103478. getCompilationError(): string;
  103479. /**
  103480. * Gets a boolean indicating that all fallbacks were used during compilation
  103481. * @returns true if all fallbacks were used
  103482. */
  103483. allFallbacksProcessed(): boolean;
  103484. /**
  103485. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  103486. * @param func The callback to be used.
  103487. */
  103488. executeWhenCompiled(func: (effect: Effect) => void): void;
  103489. private _checkIsReady;
  103490. private _loadShader;
  103491. /**
  103492. * Recompiles the webGL program
  103493. * @param vertexSourceCode The source code for the vertex shader.
  103494. * @param fragmentSourceCode The source code for the fragment shader.
  103495. * @param onCompiled Callback called when completed.
  103496. * @param onError Callback called on error.
  103497. * @hidden
  103498. */
  103499. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  103500. /**
  103501. * Prepares the effect
  103502. * @hidden
  103503. */
  103504. _prepareEffect(): void;
  103505. private _processCompilationErrors;
  103506. /**
  103507. * Checks if the effect is supported. (Must be called after compilation)
  103508. */
  103509. get isSupported(): boolean;
  103510. /**
  103511. * Binds a texture to the engine to be used as output of the shader.
  103512. * @param channel Name of the output variable.
  103513. * @param texture Texture to bind.
  103514. * @hidden
  103515. */
  103516. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  103517. /**
  103518. * Sets a texture on the engine to be used in the shader.
  103519. * @param channel Name of the sampler variable.
  103520. * @param texture Texture to set.
  103521. */
  103522. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  103523. /**
  103524. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  103525. * @param channel Name of the sampler variable.
  103526. * @param texture Texture to set.
  103527. */
  103528. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  103529. /**
  103530. * Sets an array of textures on the engine to be used in the shader.
  103531. * @param channel Name of the variable.
  103532. * @param textures Textures to set.
  103533. */
  103534. setTextureArray(channel: string, textures: BaseTexture[]): void;
  103535. /**
  103536. * 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)
  103537. * @param channel Name of the sampler variable.
  103538. * @param postProcess Post process to get the input texture from.
  103539. */
  103540. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  103541. /**
  103542. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  103543. * 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)
  103544. * @param channel Name of the sampler variable.
  103545. * @param postProcess Post process to get the output texture from.
  103546. */
  103547. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  103548. /** @hidden */
  103549. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  103550. /** @hidden */
  103551. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  103552. /** @hidden */
  103553. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  103554. /** @hidden */
  103555. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  103556. /**
  103557. * Binds a buffer to a uniform.
  103558. * @param buffer Buffer to bind.
  103559. * @param name Name of the uniform variable to bind to.
  103560. */
  103561. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  103562. /**
  103563. * Binds block to a uniform.
  103564. * @param blockName Name of the block to bind.
  103565. * @param index Index to bind.
  103566. */
  103567. bindUniformBlock(blockName: string, index: number): void;
  103568. /**
  103569. * Sets an interger value on a uniform variable.
  103570. * @param uniformName Name of the variable.
  103571. * @param value Value to be set.
  103572. * @returns this effect.
  103573. */
  103574. setInt(uniformName: string, value: number): Effect;
  103575. /**
  103576. * Sets an int array on a uniform variable.
  103577. * @param uniformName Name of the variable.
  103578. * @param array array to be set.
  103579. * @returns this effect.
  103580. */
  103581. setIntArray(uniformName: string, array: Int32Array): Effect;
  103582. /**
  103583. * 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)
  103584. * @param uniformName Name of the variable.
  103585. * @param array array to be set.
  103586. * @returns this effect.
  103587. */
  103588. setIntArray2(uniformName: string, array: Int32Array): Effect;
  103589. /**
  103590. * 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)
  103591. * @param uniformName Name of the variable.
  103592. * @param array array to be set.
  103593. * @returns this effect.
  103594. */
  103595. setIntArray3(uniformName: string, array: Int32Array): Effect;
  103596. /**
  103597. * 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)
  103598. * @param uniformName Name of the variable.
  103599. * @param array array to be set.
  103600. * @returns this effect.
  103601. */
  103602. setIntArray4(uniformName: string, array: Int32Array): Effect;
  103603. /**
  103604. * Sets an float array on a uniform variable.
  103605. * @param uniformName Name of the variable.
  103606. * @param array array to be set.
  103607. * @returns this effect.
  103608. */
  103609. setFloatArray(uniformName: string, array: Float32Array): Effect;
  103610. /**
  103611. * 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)
  103612. * @param uniformName Name of the variable.
  103613. * @param array array to be set.
  103614. * @returns this effect.
  103615. */
  103616. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  103617. /**
  103618. * 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)
  103619. * @param uniformName Name of the variable.
  103620. * @param array array to be set.
  103621. * @returns this effect.
  103622. */
  103623. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  103624. /**
  103625. * 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)
  103626. * @param uniformName Name of the variable.
  103627. * @param array array to be set.
  103628. * @returns this effect.
  103629. */
  103630. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  103631. /**
  103632. * Sets an array on a uniform variable.
  103633. * @param uniformName Name of the variable.
  103634. * @param array array to be set.
  103635. * @returns this effect.
  103636. */
  103637. setArray(uniformName: string, array: number[]): Effect;
  103638. /**
  103639. * 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)
  103640. * @param uniformName Name of the variable.
  103641. * @param array array to be set.
  103642. * @returns this effect.
  103643. */
  103644. setArray2(uniformName: string, array: number[]): Effect;
  103645. /**
  103646. * 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)
  103647. * @param uniformName Name of the variable.
  103648. * @param array array to be set.
  103649. * @returns this effect.
  103650. */
  103651. setArray3(uniformName: string, array: number[]): Effect;
  103652. /**
  103653. * 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)
  103654. * @param uniformName Name of the variable.
  103655. * @param array array to be set.
  103656. * @returns this effect.
  103657. */
  103658. setArray4(uniformName: string, array: number[]): Effect;
  103659. /**
  103660. * Sets matrices on a uniform variable.
  103661. * @param uniformName Name of the variable.
  103662. * @param matrices matrices to be set.
  103663. * @returns this effect.
  103664. */
  103665. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  103666. /**
  103667. * Sets matrix on a uniform variable.
  103668. * @param uniformName Name of the variable.
  103669. * @param matrix matrix to be set.
  103670. * @returns this effect.
  103671. */
  103672. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  103673. /**
  103674. * 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)
  103675. * @param uniformName Name of the variable.
  103676. * @param matrix matrix to be set.
  103677. * @returns this effect.
  103678. */
  103679. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  103680. /**
  103681. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  103682. * @param uniformName Name of the variable.
  103683. * @param matrix matrix to be set.
  103684. * @returns this effect.
  103685. */
  103686. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  103687. /**
  103688. * Sets a float on a uniform variable.
  103689. * @param uniformName Name of the variable.
  103690. * @param value value to be set.
  103691. * @returns this effect.
  103692. */
  103693. setFloat(uniformName: string, value: number): Effect;
  103694. /**
  103695. * Sets a boolean on a uniform variable.
  103696. * @param uniformName Name of the variable.
  103697. * @param bool value to be set.
  103698. * @returns this effect.
  103699. */
  103700. setBool(uniformName: string, bool: boolean): Effect;
  103701. /**
  103702. * Sets a Vector2 on a uniform variable.
  103703. * @param uniformName Name of the variable.
  103704. * @param vector2 vector2 to be set.
  103705. * @returns this effect.
  103706. */
  103707. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  103708. /**
  103709. * Sets a float2 on a uniform variable.
  103710. * @param uniformName Name of the variable.
  103711. * @param x First float in float2.
  103712. * @param y Second float in float2.
  103713. * @returns this effect.
  103714. */
  103715. setFloat2(uniformName: string, x: number, y: number): Effect;
  103716. /**
  103717. * Sets a Vector3 on a uniform variable.
  103718. * @param uniformName Name of the variable.
  103719. * @param vector3 Value to be set.
  103720. * @returns this effect.
  103721. */
  103722. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  103723. /**
  103724. * Sets a float3 on a uniform variable.
  103725. * @param uniformName Name of the variable.
  103726. * @param x First float in float3.
  103727. * @param y Second float in float3.
  103728. * @param z Third float in float3.
  103729. * @returns this effect.
  103730. */
  103731. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  103732. /**
  103733. * Sets a Vector4 on a uniform variable.
  103734. * @param uniformName Name of the variable.
  103735. * @param vector4 Value to be set.
  103736. * @returns this effect.
  103737. */
  103738. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  103739. /**
  103740. * Sets a float4 on a uniform variable.
  103741. * @param uniformName Name of the variable.
  103742. * @param x First float in float4.
  103743. * @param y Second float in float4.
  103744. * @param z Third float in float4.
  103745. * @param w Fourth float in float4.
  103746. * @returns this effect.
  103747. */
  103748. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  103749. /**
  103750. * Sets a Color3 on a uniform variable.
  103751. * @param uniformName Name of the variable.
  103752. * @param color3 Value to be set.
  103753. * @returns this effect.
  103754. */
  103755. setColor3(uniformName: string, color3: IColor3Like): Effect;
  103756. /**
  103757. * Sets a Color4 on a uniform variable.
  103758. * @param uniformName Name of the variable.
  103759. * @param color3 Value to be set.
  103760. * @param alpha Alpha value to be set.
  103761. * @returns this effect.
  103762. */
  103763. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  103764. /**
  103765. * Sets a Color4 on a uniform variable
  103766. * @param uniformName defines the name of the variable
  103767. * @param color4 defines the value to be set
  103768. * @returns this effect.
  103769. */
  103770. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  103771. /** Release all associated resources */
  103772. dispose(): void;
  103773. /**
  103774. * This function will add a new shader to the shader store
  103775. * @param name the name of the shader
  103776. * @param pixelShader optional pixel shader content
  103777. * @param vertexShader optional vertex shader content
  103778. */
  103779. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  103780. /**
  103781. * Store of each shader (The can be looked up using effect.key)
  103782. */
  103783. static ShadersStore: {
  103784. [key: string]: string;
  103785. };
  103786. /**
  103787. * Store of each included file for a shader (The can be looked up using effect.key)
  103788. */
  103789. static IncludesShadersStore: {
  103790. [key: string]: string;
  103791. };
  103792. /**
  103793. * Resets the cache of effects.
  103794. */
  103795. static ResetCache(): void;
  103796. }
  103797. }
  103798. declare module BABYLON {
  103799. /**
  103800. * Interface used to describe the capabilities of the engine relatively to the current browser
  103801. */
  103802. export interface EngineCapabilities {
  103803. /** Maximum textures units per fragment shader */
  103804. maxTexturesImageUnits: number;
  103805. /** Maximum texture units per vertex shader */
  103806. maxVertexTextureImageUnits: number;
  103807. /** Maximum textures units in the entire pipeline */
  103808. maxCombinedTexturesImageUnits: number;
  103809. /** Maximum texture size */
  103810. maxTextureSize: number;
  103811. /** Maximum texture samples */
  103812. maxSamples?: number;
  103813. /** Maximum cube texture size */
  103814. maxCubemapTextureSize: number;
  103815. /** Maximum render texture size */
  103816. maxRenderTextureSize: number;
  103817. /** Maximum number of vertex attributes */
  103818. maxVertexAttribs: number;
  103819. /** Maximum number of varyings */
  103820. maxVaryingVectors: number;
  103821. /** Maximum number of uniforms per vertex shader */
  103822. maxVertexUniformVectors: number;
  103823. /** Maximum number of uniforms per fragment shader */
  103824. maxFragmentUniformVectors: number;
  103825. /** Defines if standard derivates (dx/dy) are supported */
  103826. standardDerivatives: boolean;
  103827. /** Defines if s3tc texture compression is supported */
  103828. s3tc?: WEBGL_compressed_texture_s3tc;
  103829. /** Defines if pvrtc texture compression is supported */
  103830. pvrtc: any;
  103831. /** Defines if etc1 texture compression is supported */
  103832. etc1: any;
  103833. /** Defines if etc2 texture compression is supported */
  103834. etc2: any;
  103835. /** Defines if astc texture compression is supported */
  103836. astc: any;
  103837. /** Defines if float textures are supported */
  103838. textureFloat: boolean;
  103839. /** Defines if vertex array objects are supported */
  103840. vertexArrayObject: boolean;
  103841. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  103842. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  103843. /** Gets the maximum level of anisotropy supported */
  103844. maxAnisotropy: number;
  103845. /** Defines if instancing is supported */
  103846. instancedArrays: boolean;
  103847. /** Defines if 32 bits indices are supported */
  103848. uintIndices: boolean;
  103849. /** Defines if high precision shaders are supported */
  103850. highPrecisionShaderSupported: boolean;
  103851. /** Defines if depth reading in the fragment shader is supported */
  103852. fragmentDepthSupported: boolean;
  103853. /** Defines if float texture linear filtering is supported*/
  103854. textureFloatLinearFiltering: boolean;
  103855. /** Defines if rendering to float textures is supported */
  103856. textureFloatRender: boolean;
  103857. /** Defines if half float textures are supported*/
  103858. textureHalfFloat: boolean;
  103859. /** Defines if half float texture linear filtering is supported*/
  103860. textureHalfFloatLinearFiltering: boolean;
  103861. /** Defines if rendering to half float textures is supported */
  103862. textureHalfFloatRender: boolean;
  103863. /** Defines if textureLOD shader command is supported */
  103864. textureLOD: boolean;
  103865. /** Defines if draw buffers extension is supported */
  103866. drawBuffersExtension: boolean;
  103867. /** Defines if depth textures are supported */
  103868. depthTextureExtension: boolean;
  103869. /** Defines if float color buffer are supported */
  103870. colorBufferFloat: boolean;
  103871. /** Gets disjoint timer query extension (null if not supported) */
  103872. timerQuery?: EXT_disjoint_timer_query;
  103873. /** Defines if timestamp can be used with timer query */
  103874. canUseTimestampForTimerQuery: boolean;
  103875. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  103876. multiview?: any;
  103877. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  103878. oculusMultiview?: any;
  103879. /** Function used to let the system compiles shaders in background */
  103880. parallelShaderCompile?: {
  103881. COMPLETION_STATUS_KHR: number;
  103882. };
  103883. /** Max number of texture samples for MSAA */
  103884. maxMSAASamples: number;
  103885. /** Defines if the blend min max extension is supported */
  103886. blendMinMax: boolean;
  103887. }
  103888. }
  103889. declare module BABYLON {
  103890. /**
  103891. * @hidden
  103892. **/
  103893. export class DepthCullingState {
  103894. private _isDepthTestDirty;
  103895. private _isDepthMaskDirty;
  103896. private _isDepthFuncDirty;
  103897. private _isCullFaceDirty;
  103898. private _isCullDirty;
  103899. private _isZOffsetDirty;
  103900. private _isFrontFaceDirty;
  103901. private _depthTest;
  103902. private _depthMask;
  103903. private _depthFunc;
  103904. private _cull;
  103905. private _cullFace;
  103906. private _zOffset;
  103907. private _frontFace;
  103908. /**
  103909. * Initializes the state.
  103910. */
  103911. constructor();
  103912. get isDirty(): boolean;
  103913. get zOffset(): number;
  103914. set zOffset(value: number);
  103915. get cullFace(): Nullable<number>;
  103916. set cullFace(value: Nullable<number>);
  103917. get cull(): Nullable<boolean>;
  103918. set cull(value: Nullable<boolean>);
  103919. get depthFunc(): Nullable<number>;
  103920. set depthFunc(value: Nullable<number>);
  103921. get depthMask(): boolean;
  103922. set depthMask(value: boolean);
  103923. get depthTest(): boolean;
  103924. set depthTest(value: boolean);
  103925. get frontFace(): Nullable<number>;
  103926. set frontFace(value: Nullable<number>);
  103927. reset(): void;
  103928. apply(gl: WebGLRenderingContext): void;
  103929. }
  103930. }
  103931. declare module BABYLON {
  103932. /**
  103933. * @hidden
  103934. **/
  103935. export class StencilState {
  103936. /** 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 */
  103937. static readonly ALWAYS: number;
  103938. /** Passed to stencilOperation to specify that stencil value must be kept */
  103939. static readonly KEEP: number;
  103940. /** Passed to stencilOperation to specify that stencil value must be replaced */
  103941. static readonly REPLACE: number;
  103942. private _isStencilTestDirty;
  103943. private _isStencilMaskDirty;
  103944. private _isStencilFuncDirty;
  103945. private _isStencilOpDirty;
  103946. private _stencilTest;
  103947. private _stencilMask;
  103948. private _stencilFunc;
  103949. private _stencilFuncRef;
  103950. private _stencilFuncMask;
  103951. private _stencilOpStencilFail;
  103952. private _stencilOpDepthFail;
  103953. private _stencilOpStencilDepthPass;
  103954. get isDirty(): boolean;
  103955. get stencilFunc(): number;
  103956. set stencilFunc(value: number);
  103957. get stencilFuncRef(): number;
  103958. set stencilFuncRef(value: number);
  103959. get stencilFuncMask(): number;
  103960. set stencilFuncMask(value: number);
  103961. get stencilOpStencilFail(): number;
  103962. set stencilOpStencilFail(value: number);
  103963. get stencilOpDepthFail(): number;
  103964. set stencilOpDepthFail(value: number);
  103965. get stencilOpStencilDepthPass(): number;
  103966. set stencilOpStencilDepthPass(value: number);
  103967. get stencilMask(): number;
  103968. set stencilMask(value: number);
  103969. get stencilTest(): boolean;
  103970. set stencilTest(value: boolean);
  103971. constructor();
  103972. reset(): void;
  103973. apply(gl: WebGLRenderingContext): void;
  103974. }
  103975. }
  103976. declare module BABYLON {
  103977. /**
  103978. * @hidden
  103979. **/
  103980. export class AlphaState {
  103981. private _isAlphaBlendDirty;
  103982. private _isBlendFunctionParametersDirty;
  103983. private _isBlendEquationParametersDirty;
  103984. private _isBlendConstantsDirty;
  103985. private _alphaBlend;
  103986. private _blendFunctionParameters;
  103987. private _blendEquationParameters;
  103988. private _blendConstants;
  103989. /**
  103990. * Initializes the state.
  103991. */
  103992. constructor();
  103993. get isDirty(): boolean;
  103994. get alphaBlend(): boolean;
  103995. set alphaBlend(value: boolean);
  103996. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  103997. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  103998. setAlphaEquationParameters(rgb: number, alpha: number): void;
  103999. reset(): void;
  104000. apply(gl: WebGLRenderingContext): void;
  104001. }
  104002. }
  104003. declare module BABYLON {
  104004. /** @hidden */
  104005. export class WebGL2ShaderProcessor implements IShaderProcessor {
  104006. attributeProcessor(attribute: string): string;
  104007. varyingProcessor(varying: string, isFragment: boolean): string;
  104008. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  104009. }
  104010. }
  104011. declare module BABYLON {
  104012. /**
  104013. * Interface for attribute information associated with buffer instanciation
  104014. */
  104015. export interface InstancingAttributeInfo {
  104016. /**
  104017. * Name of the GLSL attribute
  104018. * if attribute index is not specified, this is used to retrieve the index from the effect
  104019. */
  104020. attributeName: string;
  104021. /**
  104022. * Index/offset of the attribute in the vertex shader
  104023. * if not specified, this will be computes from the name.
  104024. */
  104025. index?: number;
  104026. /**
  104027. * size of the attribute, 1, 2, 3 or 4
  104028. */
  104029. attributeSize: number;
  104030. /**
  104031. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  104032. */
  104033. offset: number;
  104034. /**
  104035. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  104036. * default to 1
  104037. */
  104038. divisor?: number;
  104039. /**
  104040. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  104041. * default is FLOAT
  104042. */
  104043. attributeType?: number;
  104044. /**
  104045. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  104046. */
  104047. normalized?: boolean;
  104048. }
  104049. }
  104050. declare module BABYLON {
  104051. interface ThinEngine {
  104052. /**
  104053. * Update a video texture
  104054. * @param texture defines the texture to update
  104055. * @param video defines the video element to use
  104056. * @param invertY defines if data must be stored with Y axis inverted
  104057. */
  104058. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  104059. }
  104060. }
  104061. declare module BABYLON {
  104062. /**
  104063. * Settings for finer control over video usage
  104064. */
  104065. export interface VideoTextureSettings {
  104066. /**
  104067. * Applies `autoplay` to video, if specified
  104068. */
  104069. autoPlay?: boolean;
  104070. /**
  104071. * Applies `loop` to video, if specified
  104072. */
  104073. loop?: boolean;
  104074. /**
  104075. * Automatically updates internal texture from video at every frame in the render loop
  104076. */
  104077. autoUpdateTexture: boolean;
  104078. /**
  104079. * Image src displayed during the video loading or until the user interacts with the video.
  104080. */
  104081. poster?: string;
  104082. }
  104083. /**
  104084. * If you want to display a video in your scene, this is the special texture for that.
  104085. * This special texture works similar to other textures, with the exception of a few parameters.
  104086. * @see https://doc.babylonjs.com/how_to/video_texture
  104087. */
  104088. export class VideoTexture extends Texture {
  104089. /**
  104090. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  104091. */
  104092. readonly autoUpdateTexture: boolean;
  104093. /**
  104094. * The video instance used by the texture internally
  104095. */
  104096. readonly video: HTMLVideoElement;
  104097. private _onUserActionRequestedObservable;
  104098. /**
  104099. * Event triggerd when a dom action is required by the user to play the video.
  104100. * This happens due to recent changes in browser policies preventing video to auto start.
  104101. */
  104102. get onUserActionRequestedObservable(): Observable<Texture>;
  104103. private _generateMipMaps;
  104104. private _engine;
  104105. private _stillImageCaptured;
  104106. private _displayingPosterTexture;
  104107. private _settings;
  104108. private _createInternalTextureOnEvent;
  104109. private _frameId;
  104110. private _currentSrc;
  104111. /**
  104112. * Creates a video texture.
  104113. * If you want to display a video in your scene, this is the special texture for that.
  104114. * This special texture works similar to other textures, with the exception of a few parameters.
  104115. * @see https://doc.babylonjs.com/how_to/video_texture
  104116. * @param name optional name, will detect from video source, if not defined
  104117. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  104118. * @param scene is obviously the current scene.
  104119. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  104120. * @param invertY is false by default but can be used to invert video on Y axis
  104121. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  104122. * @param settings allows finer control over video usage
  104123. */
  104124. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  104125. private _getName;
  104126. private _getVideo;
  104127. private _createInternalTexture;
  104128. private reset;
  104129. /**
  104130. * @hidden Internal method to initiate `update`.
  104131. */
  104132. _rebuild(): void;
  104133. /**
  104134. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  104135. */
  104136. update(): void;
  104137. /**
  104138. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  104139. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  104140. */
  104141. updateTexture(isVisible: boolean): void;
  104142. protected _updateInternalTexture: () => void;
  104143. /**
  104144. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  104145. * @param url New url.
  104146. */
  104147. updateURL(url: string): void;
  104148. /**
  104149. * Clones the texture.
  104150. * @returns the cloned texture
  104151. */
  104152. clone(): VideoTexture;
  104153. /**
  104154. * Dispose the texture and release its associated resources.
  104155. */
  104156. dispose(): void;
  104157. /**
  104158. * Creates a video texture straight from a stream.
  104159. * @param scene Define the scene the texture should be created in
  104160. * @param stream Define the stream the texture should be created from
  104161. * @returns The created video texture as a promise
  104162. */
  104163. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  104164. /**
  104165. * Creates a video texture straight from your WebCam video feed.
  104166. * @param scene Define the scene the texture should be created in
  104167. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  104168. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  104169. * @returns The created video texture as a promise
  104170. */
  104171. static CreateFromWebCamAsync(scene: Scene, constraints: {
  104172. minWidth: number;
  104173. maxWidth: number;
  104174. minHeight: number;
  104175. maxHeight: number;
  104176. deviceId: string;
  104177. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  104178. /**
  104179. * Creates a video texture straight from your WebCam video feed.
  104180. * @param scene Define the scene the texture should be created in
  104181. * @param onReady Define a callback to triggered once the texture will be ready
  104182. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  104183. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  104184. */
  104185. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  104186. minWidth: number;
  104187. maxWidth: number;
  104188. minHeight: number;
  104189. maxHeight: number;
  104190. deviceId: string;
  104191. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  104192. }
  104193. }
  104194. declare module BABYLON {
  104195. /**
  104196. * Defines the interface used by objects working like Scene
  104197. * @hidden
  104198. */
  104199. interface ISceneLike {
  104200. _addPendingData(data: any): void;
  104201. _removePendingData(data: any): void;
  104202. offlineProvider: IOfflineProvider;
  104203. }
  104204. /** Interface defining initialization parameters for Engine class */
  104205. export interface EngineOptions extends WebGLContextAttributes {
  104206. /**
  104207. * Defines if the engine should no exceed a specified device ratio
  104208. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  104209. */
  104210. limitDeviceRatio?: number;
  104211. /**
  104212. * Defines if webvr should be enabled automatically
  104213. * @see http://doc.babylonjs.com/how_to/webvr_camera
  104214. */
  104215. autoEnableWebVR?: boolean;
  104216. /**
  104217. * Defines if webgl2 should be turned off even if supported
  104218. * @see http://doc.babylonjs.com/features/webgl2
  104219. */
  104220. disableWebGL2Support?: boolean;
  104221. /**
  104222. * Defines if webaudio should be initialized as well
  104223. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104224. */
  104225. audioEngine?: boolean;
  104226. /**
  104227. * Defines if animations should run using a deterministic lock step
  104228. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104229. */
  104230. deterministicLockstep?: boolean;
  104231. /** Defines the maximum steps to use with deterministic lock step mode */
  104232. lockstepMaxSteps?: number;
  104233. /** Defines the seconds between each deterministic lock step */
  104234. timeStep?: number;
  104235. /**
  104236. * Defines that engine should ignore context lost events
  104237. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  104238. */
  104239. doNotHandleContextLost?: boolean;
  104240. /**
  104241. * Defines that engine should ignore modifying touch action attribute and style
  104242. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  104243. */
  104244. doNotHandleTouchAction?: boolean;
  104245. /**
  104246. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  104247. */
  104248. useHighPrecisionFloats?: boolean;
  104249. }
  104250. /**
  104251. * The base engine class (root of all engines)
  104252. */
  104253. export class ThinEngine {
  104254. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  104255. static ExceptionList: ({
  104256. key: string;
  104257. capture: string;
  104258. captureConstraint: number;
  104259. targets: string[];
  104260. } | {
  104261. key: string;
  104262. capture: null;
  104263. captureConstraint: null;
  104264. targets: string[];
  104265. })[];
  104266. /** @hidden */
  104267. static _TextureLoaders: IInternalTextureLoader[];
  104268. /**
  104269. * Returns the current npm package of the sdk
  104270. */
  104271. static get NpmPackage(): string;
  104272. /**
  104273. * Returns the current version of the framework
  104274. */
  104275. static get Version(): string;
  104276. /**
  104277. * Returns a string describing the current engine
  104278. */
  104279. get description(): string;
  104280. /**
  104281. * Gets or sets the epsilon value used by collision engine
  104282. */
  104283. static CollisionsEpsilon: number;
  104284. /**
  104285. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  104286. */
  104287. static get ShadersRepository(): string;
  104288. static set ShadersRepository(value: string);
  104289. /**
  104290. * Gets or sets the textures that the engine should not attempt to load as compressed
  104291. */
  104292. protected _excludedCompressedTextures: string[];
  104293. /**
  104294. * Filters the compressed texture formats to only include
  104295. * files that are not included in the skippable list
  104296. *
  104297. * @param url the current extension
  104298. * @param textureFormatInUse the current compressed texture format
  104299. * @returns "format" string
  104300. */
  104301. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  104302. /** @hidden */
  104303. _shaderProcessor: IShaderProcessor;
  104304. /**
  104305. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  104306. */
  104307. forcePOTTextures: boolean;
  104308. /**
  104309. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  104310. */
  104311. isFullscreen: boolean;
  104312. /**
  104313. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  104314. */
  104315. cullBackFaces: boolean;
  104316. /**
  104317. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  104318. */
  104319. renderEvenInBackground: boolean;
  104320. /**
  104321. * Gets or sets a boolean indicating that cache can be kept between frames
  104322. */
  104323. preventCacheWipeBetweenFrames: boolean;
  104324. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  104325. validateShaderPrograms: boolean;
  104326. /**
  104327. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  104328. * This can provide greater z depth for distant objects.
  104329. */
  104330. useReverseDepthBuffer: boolean;
  104331. /**
  104332. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  104333. */
  104334. disableUniformBuffers: boolean;
  104335. /** @hidden */
  104336. _uniformBuffers: UniformBuffer[];
  104337. /**
  104338. * Gets a boolean indicating that the engine supports uniform buffers
  104339. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  104340. */
  104341. get supportsUniformBuffers(): boolean;
  104342. /** @hidden */
  104343. _gl: WebGLRenderingContext;
  104344. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  104345. protected _windowIsBackground: boolean;
  104346. protected _webGLVersion: number;
  104347. protected _creationOptions: EngineOptions;
  104348. protected _highPrecisionShadersAllowed: boolean;
  104349. /** @hidden */
  104350. get _shouldUseHighPrecisionShader(): boolean;
  104351. /**
  104352. * Gets a boolean indicating that only power of 2 textures are supported
  104353. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  104354. */
  104355. get needPOTTextures(): boolean;
  104356. /** @hidden */
  104357. _badOS: boolean;
  104358. /** @hidden */
  104359. _badDesktopOS: boolean;
  104360. private _hardwareScalingLevel;
  104361. /** @hidden */
  104362. _caps: EngineCapabilities;
  104363. private _isStencilEnable;
  104364. private _glVersion;
  104365. private _glRenderer;
  104366. private _glVendor;
  104367. /** @hidden */
  104368. _videoTextureSupported: boolean;
  104369. protected _renderingQueueLaunched: boolean;
  104370. protected _activeRenderLoops: (() => void)[];
  104371. /**
  104372. * Observable signaled when a context lost event is raised
  104373. */
  104374. onContextLostObservable: Observable<ThinEngine>;
  104375. /**
  104376. * Observable signaled when a context restored event is raised
  104377. */
  104378. onContextRestoredObservable: Observable<ThinEngine>;
  104379. private _onContextLost;
  104380. private _onContextRestored;
  104381. protected _contextWasLost: boolean;
  104382. /** @hidden */
  104383. _doNotHandleContextLost: boolean;
  104384. /**
  104385. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  104386. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  104387. */
  104388. get doNotHandleContextLost(): boolean;
  104389. set doNotHandleContextLost(value: boolean);
  104390. /**
  104391. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  104392. */
  104393. disableVertexArrayObjects: boolean;
  104394. /** @hidden */
  104395. protected _colorWrite: boolean;
  104396. /** @hidden */
  104397. protected _colorWriteChanged: boolean;
  104398. /** @hidden */
  104399. protected _depthCullingState: DepthCullingState;
  104400. /** @hidden */
  104401. protected _stencilState: StencilState;
  104402. /** @hidden */
  104403. _alphaState: AlphaState;
  104404. /** @hidden */
  104405. _alphaMode: number;
  104406. /** @hidden */
  104407. _alphaEquation: number;
  104408. /** @hidden */
  104409. _internalTexturesCache: InternalTexture[];
  104410. /** @hidden */
  104411. protected _activeChannel: number;
  104412. private _currentTextureChannel;
  104413. /** @hidden */
  104414. protected _boundTexturesCache: {
  104415. [key: string]: Nullable<InternalTexture>;
  104416. };
  104417. /** @hidden */
  104418. protected _currentEffect: Nullable<Effect>;
  104419. /** @hidden */
  104420. protected _currentProgram: Nullable<WebGLProgram>;
  104421. private _compiledEffects;
  104422. private _vertexAttribArraysEnabled;
  104423. /** @hidden */
  104424. protected _cachedViewport: Nullable<IViewportLike>;
  104425. private _cachedVertexArrayObject;
  104426. /** @hidden */
  104427. protected _cachedVertexBuffers: any;
  104428. /** @hidden */
  104429. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  104430. /** @hidden */
  104431. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  104432. /** @hidden */
  104433. _currentRenderTarget: Nullable<InternalTexture>;
  104434. private _uintIndicesCurrentlySet;
  104435. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  104436. /** @hidden */
  104437. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  104438. private _currentBufferPointers;
  104439. private _currentInstanceLocations;
  104440. private _currentInstanceBuffers;
  104441. private _textureUnits;
  104442. /** @hidden */
  104443. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  104444. /** @hidden */
  104445. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  104446. /** @hidden */
  104447. _boundRenderFunction: any;
  104448. private _vaoRecordInProgress;
  104449. private _mustWipeVertexAttributes;
  104450. private _emptyTexture;
  104451. private _emptyCubeTexture;
  104452. private _emptyTexture3D;
  104453. private _emptyTexture2DArray;
  104454. /** @hidden */
  104455. _frameHandler: number;
  104456. private _nextFreeTextureSlots;
  104457. private _maxSimultaneousTextures;
  104458. private _activeRequests;
  104459. protected _texturesSupported: string[];
  104460. /** @hidden */
  104461. _textureFormatInUse: Nullable<string>;
  104462. protected get _supportsHardwareTextureRescaling(): boolean;
  104463. /**
  104464. * Gets the list of texture formats supported
  104465. */
  104466. get texturesSupported(): Array<string>;
  104467. /**
  104468. * Gets the list of texture formats in use
  104469. */
  104470. get textureFormatInUse(): Nullable<string>;
  104471. /**
  104472. * Gets the current viewport
  104473. */
  104474. get currentViewport(): Nullable<IViewportLike>;
  104475. /**
  104476. * Gets the default empty texture
  104477. */
  104478. get emptyTexture(): InternalTexture;
  104479. /**
  104480. * Gets the default empty 3D texture
  104481. */
  104482. get emptyTexture3D(): InternalTexture;
  104483. /**
  104484. * Gets the default empty 2D array texture
  104485. */
  104486. get emptyTexture2DArray(): InternalTexture;
  104487. /**
  104488. * Gets the default empty cube texture
  104489. */
  104490. get emptyCubeTexture(): InternalTexture;
  104491. /**
  104492. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  104493. */
  104494. readonly premultipliedAlpha: boolean;
  104495. /**
  104496. * Observable event triggered before each texture is initialized
  104497. */
  104498. onBeforeTextureInitObservable: Observable<Texture>;
  104499. /**
  104500. * Creates a new engine
  104501. * @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
  104502. * @param antialias defines enable antialiasing (default: false)
  104503. * @param options defines further options to be sent to the getContext() function
  104504. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  104505. */
  104506. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  104507. private _rebuildInternalTextures;
  104508. private _rebuildEffects;
  104509. /**
  104510. * Gets a boolean indicating if all created effects are ready
  104511. * @returns true if all effects are ready
  104512. */
  104513. areAllEffectsReady(): boolean;
  104514. protected _rebuildBuffers(): void;
  104515. private _initGLContext;
  104516. /**
  104517. * Gets version of the current webGL context
  104518. */
  104519. get webGLVersion(): number;
  104520. /**
  104521. * Gets a string idenfifying the name of the class
  104522. * @returns "Engine" string
  104523. */
  104524. getClassName(): string;
  104525. /**
  104526. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  104527. */
  104528. get isStencilEnable(): boolean;
  104529. /** @hidden */
  104530. _prepareWorkingCanvas(): void;
  104531. /**
  104532. * Reset the texture cache to empty state
  104533. */
  104534. resetTextureCache(): void;
  104535. /**
  104536. * Gets an object containing information about the current webGL context
  104537. * @returns an object containing the vender, the renderer and the version of the current webGL context
  104538. */
  104539. getGlInfo(): {
  104540. vendor: string;
  104541. renderer: string;
  104542. version: string;
  104543. };
  104544. /**
  104545. * Defines the hardware scaling level.
  104546. * By default the hardware scaling level is computed from the window device ratio.
  104547. * 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.
  104548. * @param level defines the level to use
  104549. */
  104550. setHardwareScalingLevel(level: number): void;
  104551. /**
  104552. * Gets the current hardware scaling level.
  104553. * By default the hardware scaling level is computed from the window device ratio.
  104554. * 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.
  104555. * @returns a number indicating the current hardware scaling level
  104556. */
  104557. getHardwareScalingLevel(): number;
  104558. /**
  104559. * Gets the list of loaded textures
  104560. * @returns an array containing all loaded textures
  104561. */
  104562. getLoadedTexturesCache(): InternalTexture[];
  104563. /**
  104564. * Gets the object containing all engine capabilities
  104565. * @returns the EngineCapabilities object
  104566. */
  104567. getCaps(): EngineCapabilities;
  104568. /**
  104569. * stop executing a render loop function and remove it from the execution array
  104570. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  104571. */
  104572. stopRenderLoop(renderFunction?: () => void): void;
  104573. /** @hidden */
  104574. _renderLoop(): void;
  104575. /**
  104576. * Gets the HTML canvas attached with the current webGL context
  104577. * @returns a HTML canvas
  104578. */
  104579. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  104580. /**
  104581. * Gets host window
  104582. * @returns the host window object
  104583. */
  104584. getHostWindow(): Nullable<Window>;
  104585. /**
  104586. * Gets the current render width
  104587. * @param useScreen defines if screen size must be used (or the current render target if any)
  104588. * @returns a number defining the current render width
  104589. */
  104590. getRenderWidth(useScreen?: boolean): number;
  104591. /**
  104592. * Gets the current render height
  104593. * @param useScreen defines if screen size must be used (or the current render target if any)
  104594. * @returns a number defining the current render height
  104595. */
  104596. getRenderHeight(useScreen?: boolean): number;
  104597. /**
  104598. * Can be used to override the current requestAnimationFrame requester.
  104599. * @hidden
  104600. */
  104601. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  104602. /**
  104603. * Register and execute a render loop. The engine can have more than one render function
  104604. * @param renderFunction defines the function to continuously execute
  104605. */
  104606. runRenderLoop(renderFunction: () => void): void;
  104607. /**
  104608. * Clear the current render buffer or the current render target (if any is set up)
  104609. * @param color defines the color to use
  104610. * @param backBuffer defines if the back buffer must be cleared
  104611. * @param depth defines if the depth buffer must be cleared
  104612. * @param stencil defines if the stencil buffer must be cleared
  104613. */
  104614. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  104615. private _viewportCached;
  104616. /** @hidden */
  104617. _viewport(x: number, y: number, width: number, height: number): void;
  104618. /**
  104619. * Set the WebGL's viewport
  104620. * @param viewport defines the viewport element to be used
  104621. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  104622. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  104623. */
  104624. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  104625. /**
  104626. * Begin a new frame
  104627. */
  104628. beginFrame(): void;
  104629. /**
  104630. * Enf the current frame
  104631. */
  104632. endFrame(): void;
  104633. /**
  104634. * Resize the view according to the canvas' size
  104635. */
  104636. resize(): void;
  104637. /**
  104638. * Force a specific size of the canvas
  104639. * @param width defines the new canvas' width
  104640. * @param height defines the new canvas' height
  104641. */
  104642. setSize(width: number, height: number): void;
  104643. /**
  104644. * Binds the frame buffer to the specified texture.
  104645. * @param texture The texture to render to or null for the default canvas
  104646. * @param faceIndex The face of the texture to render to in case of cube texture
  104647. * @param requiredWidth The width of the target to render to
  104648. * @param requiredHeight The height of the target to render to
  104649. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  104650. * @param lodLevel defines the lod level to bind to the frame buffer
  104651. * @param layer defines the 2d array index to bind to frame buffer to
  104652. */
  104653. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  104654. /** @hidden */
  104655. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  104656. /**
  104657. * Unbind the current render target texture from the webGL context
  104658. * @param texture defines the render target texture to unbind
  104659. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  104660. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  104661. */
  104662. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  104663. /**
  104664. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  104665. */
  104666. flushFramebuffer(): void;
  104667. /**
  104668. * Unbind the current render target and bind the default framebuffer
  104669. */
  104670. restoreDefaultFramebuffer(): void;
  104671. /** @hidden */
  104672. protected _resetVertexBufferBinding(): void;
  104673. /**
  104674. * Creates a vertex buffer
  104675. * @param data the data for the vertex buffer
  104676. * @returns the new WebGL static buffer
  104677. */
  104678. createVertexBuffer(data: DataArray): DataBuffer;
  104679. private _createVertexBuffer;
  104680. /**
  104681. * Creates a dynamic vertex buffer
  104682. * @param data the data for the dynamic vertex buffer
  104683. * @returns the new WebGL dynamic buffer
  104684. */
  104685. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  104686. protected _resetIndexBufferBinding(): void;
  104687. /**
  104688. * Creates a new index buffer
  104689. * @param indices defines the content of the index buffer
  104690. * @param updatable defines if the index buffer must be updatable
  104691. * @returns a new webGL buffer
  104692. */
  104693. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  104694. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  104695. /**
  104696. * Bind a webGL buffer to the webGL context
  104697. * @param buffer defines the buffer to bind
  104698. */
  104699. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  104700. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  104701. private bindBuffer;
  104702. /**
  104703. * update the bound buffer with the given data
  104704. * @param data defines the data to update
  104705. */
  104706. updateArrayBuffer(data: Float32Array): void;
  104707. private _vertexAttribPointer;
  104708. /** @hidden */
  104709. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  104710. private _bindVertexBuffersAttributes;
  104711. /**
  104712. * Records a vertex array object
  104713. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  104714. * @param vertexBuffers defines the list of vertex buffers to store
  104715. * @param indexBuffer defines the index buffer to store
  104716. * @param effect defines the effect to store
  104717. * @returns the new vertex array object
  104718. */
  104719. recordVertexArrayObject(vertexBuffers: {
  104720. [key: string]: VertexBuffer;
  104721. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  104722. /**
  104723. * Bind a specific vertex array object
  104724. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  104725. * @param vertexArrayObject defines the vertex array object to bind
  104726. * @param indexBuffer defines the index buffer to bind
  104727. */
  104728. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  104729. /**
  104730. * Bind webGl buffers directly to the webGL context
  104731. * @param vertexBuffer defines the vertex buffer to bind
  104732. * @param indexBuffer defines the index buffer to bind
  104733. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  104734. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  104735. * @param effect defines the effect associated with the vertex buffer
  104736. */
  104737. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  104738. private _unbindVertexArrayObject;
  104739. /**
  104740. * Bind a list of vertex buffers to the webGL context
  104741. * @param vertexBuffers defines the list of vertex buffers to bind
  104742. * @param indexBuffer defines the index buffer to bind
  104743. * @param effect defines the effect associated with the vertex buffers
  104744. */
  104745. bindBuffers(vertexBuffers: {
  104746. [key: string]: Nullable<VertexBuffer>;
  104747. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  104748. /**
  104749. * Unbind all instance attributes
  104750. */
  104751. unbindInstanceAttributes(): void;
  104752. /**
  104753. * Release and free the memory of a vertex array object
  104754. * @param vao defines the vertex array object to delete
  104755. */
  104756. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  104757. /** @hidden */
  104758. _releaseBuffer(buffer: DataBuffer): boolean;
  104759. protected _deleteBuffer(buffer: DataBuffer): void;
  104760. /**
  104761. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  104762. * @param instancesBuffer defines the webGL buffer to update and bind
  104763. * @param data defines the data to store in the buffer
  104764. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  104765. */
  104766. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  104767. /**
  104768. * Bind the content of a webGL buffer used with instantiation
  104769. * @param instancesBuffer defines the webGL buffer to bind
  104770. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  104771. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  104772. */
  104773. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  104774. /**
  104775. * Disable the instance attribute corresponding to the name in parameter
  104776. * @param name defines the name of the attribute to disable
  104777. */
  104778. disableInstanceAttributeByName(name: string): void;
  104779. /**
  104780. * Disable the instance attribute corresponding to the location in parameter
  104781. * @param attributeLocation defines the attribute location of the attribute to disable
  104782. */
  104783. disableInstanceAttribute(attributeLocation: number): void;
  104784. /**
  104785. * Disable the attribute corresponding to the location in parameter
  104786. * @param attributeLocation defines the attribute location of the attribute to disable
  104787. */
  104788. disableAttributeByIndex(attributeLocation: number): void;
  104789. /**
  104790. * Send a draw order
  104791. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  104792. * @param indexStart defines the starting index
  104793. * @param indexCount defines the number of index to draw
  104794. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104795. */
  104796. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  104797. /**
  104798. * Draw a list of points
  104799. * @param verticesStart defines the index of first vertex to draw
  104800. * @param verticesCount defines the count of vertices to draw
  104801. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104802. */
  104803. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104804. /**
  104805. * Draw a list of unindexed primitives
  104806. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  104807. * @param verticesStart defines the index of first vertex to draw
  104808. * @param verticesCount defines the count of vertices to draw
  104809. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104810. */
  104811. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104812. /**
  104813. * Draw a list of indexed primitives
  104814. * @param fillMode defines the primitive to use
  104815. * @param indexStart defines the starting index
  104816. * @param indexCount defines the number of index to draw
  104817. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104818. */
  104819. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  104820. /**
  104821. * Draw a list of unindexed primitives
  104822. * @param fillMode defines the primitive to use
  104823. * @param verticesStart defines the index of first vertex to draw
  104824. * @param verticesCount defines the count of vertices to draw
  104825. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104826. */
  104827. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104828. private _drawMode;
  104829. /** @hidden */
  104830. protected _reportDrawCall(): void;
  104831. /** @hidden */
  104832. _releaseEffect(effect: Effect): void;
  104833. /** @hidden */
  104834. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  104835. /**
  104836. * Create a new effect (used to store vertex/fragment shaders)
  104837. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  104838. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  104839. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  104840. * @param samplers defines an array of string used to represent textures
  104841. * @param defines defines the string containing the defines to use to compile the shaders
  104842. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  104843. * @param onCompiled defines a function to call when the effect creation is successful
  104844. * @param onError defines a function to call when the effect creation has failed
  104845. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  104846. * @returns the new Effect
  104847. */
  104848. 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;
  104849. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  104850. private _compileShader;
  104851. private _compileRawShader;
  104852. /**
  104853. * Directly creates a webGL program
  104854. * @param pipelineContext defines the pipeline context to attach to
  104855. * @param vertexCode defines the vertex shader code to use
  104856. * @param fragmentCode defines the fragment shader code to use
  104857. * @param context defines the webGL context to use (if not set, the current one will be used)
  104858. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  104859. * @returns the new webGL program
  104860. */
  104861. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104862. /**
  104863. * Creates a webGL program
  104864. * @param pipelineContext defines the pipeline context to attach to
  104865. * @param vertexCode defines the vertex shader code to use
  104866. * @param fragmentCode defines the fragment shader code to use
  104867. * @param defines defines the string containing the defines to use to compile the shaders
  104868. * @param context defines the webGL context to use (if not set, the current one will be used)
  104869. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  104870. * @returns the new webGL program
  104871. */
  104872. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104873. /**
  104874. * Creates a new pipeline context
  104875. * @returns the new pipeline
  104876. */
  104877. createPipelineContext(): IPipelineContext;
  104878. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104879. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  104880. /** @hidden */
  104881. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  104882. /** @hidden */
  104883. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  104884. /** @hidden */
  104885. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  104886. /**
  104887. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  104888. * @param pipelineContext defines the pipeline context to use
  104889. * @param uniformsNames defines the list of uniform names
  104890. * @returns an array of webGL uniform locations
  104891. */
  104892. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  104893. /**
  104894. * Gets the lsit of active attributes for a given webGL program
  104895. * @param pipelineContext defines the pipeline context to use
  104896. * @param attributesNames defines the list of attribute names to get
  104897. * @returns an array of indices indicating the offset of each attribute
  104898. */
  104899. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  104900. /**
  104901. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  104902. * @param effect defines the effect to activate
  104903. */
  104904. enableEffect(effect: Nullable<Effect>): void;
  104905. /**
  104906. * Set the value of an uniform to a number (int)
  104907. * @param uniform defines the webGL uniform location where to store the value
  104908. * @param value defines the int number to store
  104909. */
  104910. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  104911. /**
  104912. * Set the value of an uniform to an array of int32
  104913. * @param uniform defines the webGL uniform location where to store the value
  104914. * @param array defines the array of int32 to store
  104915. */
  104916. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104917. /**
  104918. * Set the value of an uniform to an array of int32 (stored as vec2)
  104919. * @param uniform defines the webGL uniform location where to store the value
  104920. * @param array defines the array of int32 to store
  104921. */
  104922. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104923. /**
  104924. * Set the value of an uniform to an array of int32 (stored as vec3)
  104925. * @param uniform defines the webGL uniform location where to store the value
  104926. * @param array defines the array of int32 to store
  104927. */
  104928. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104929. /**
  104930. * Set the value of an uniform to an array of int32 (stored as vec4)
  104931. * @param uniform defines the webGL uniform location where to store the value
  104932. * @param array defines the array of int32 to store
  104933. */
  104934. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104935. /**
  104936. * Set the value of an uniform to an array of number
  104937. * @param uniform defines the webGL uniform location where to store the value
  104938. * @param array defines the array of number to store
  104939. */
  104940. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104941. /**
  104942. * Set the value of an uniform to an array of number (stored as vec2)
  104943. * @param uniform defines the webGL uniform location where to store the value
  104944. * @param array defines the array of number to store
  104945. */
  104946. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104947. /**
  104948. * Set the value of an uniform to an array of number (stored as vec3)
  104949. * @param uniform defines the webGL uniform location where to store the value
  104950. * @param array defines the array of number to store
  104951. */
  104952. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104953. /**
  104954. * Set the value of an uniform to an array of number (stored as vec4)
  104955. * @param uniform defines the webGL uniform location where to store the value
  104956. * @param array defines the array of number to store
  104957. */
  104958. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104959. /**
  104960. * Set the value of an uniform to an array of float32 (stored as matrices)
  104961. * @param uniform defines the webGL uniform location where to store the value
  104962. * @param matrices defines the array of float32 to store
  104963. */
  104964. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  104965. /**
  104966. * Set the value of an uniform to a matrix (3x3)
  104967. * @param uniform defines the webGL uniform location where to store the value
  104968. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  104969. */
  104970. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  104971. /**
  104972. * Set the value of an uniform to a matrix (2x2)
  104973. * @param uniform defines the webGL uniform location where to store the value
  104974. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  104975. */
  104976. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  104977. /**
  104978. * Set the value of an uniform to a number (float)
  104979. * @param uniform defines the webGL uniform location where to store the value
  104980. * @param value defines the float number to store
  104981. */
  104982. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  104983. /**
  104984. * Set the value of an uniform to a vec2
  104985. * @param uniform defines the webGL uniform location where to store the value
  104986. * @param x defines the 1st component of the value
  104987. * @param y defines the 2nd component of the value
  104988. */
  104989. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  104990. /**
  104991. * Set the value of an uniform to a vec3
  104992. * @param uniform defines the webGL uniform location where to store the value
  104993. * @param x defines the 1st component of the value
  104994. * @param y defines the 2nd component of the value
  104995. * @param z defines the 3rd component of the value
  104996. */
  104997. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  104998. /**
  104999. * Set the value of an uniform to a vec4
  105000. * @param uniform defines the webGL uniform location where to store the value
  105001. * @param x defines the 1st component of the value
  105002. * @param y defines the 2nd component of the value
  105003. * @param z defines the 3rd component of the value
  105004. * @param w defines the 4th component of the value
  105005. */
  105006. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  105007. /**
  105008. * Apply all cached states (depth, culling, stencil and alpha)
  105009. */
  105010. applyStates(): void;
  105011. /**
  105012. * Enable or disable color writing
  105013. * @param enable defines the state to set
  105014. */
  105015. setColorWrite(enable: boolean): void;
  105016. /**
  105017. * Gets a boolean indicating if color writing is enabled
  105018. * @returns the current color writing state
  105019. */
  105020. getColorWrite(): boolean;
  105021. /**
  105022. * Gets the depth culling state manager
  105023. */
  105024. get depthCullingState(): DepthCullingState;
  105025. /**
  105026. * Gets the alpha state manager
  105027. */
  105028. get alphaState(): AlphaState;
  105029. /**
  105030. * Gets the stencil state manager
  105031. */
  105032. get stencilState(): StencilState;
  105033. /**
  105034. * Clears the list of texture accessible through engine.
  105035. * This can help preventing texture load conflict due to name collision.
  105036. */
  105037. clearInternalTexturesCache(): void;
  105038. /**
  105039. * Force the entire cache to be cleared
  105040. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  105041. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  105042. */
  105043. wipeCaches(bruteForce?: boolean): void;
  105044. /** @hidden */
  105045. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  105046. min: number;
  105047. mag: number;
  105048. };
  105049. /** @hidden */
  105050. _createTexture(): WebGLTexture;
  105051. /**
  105052. * Usually called from Texture.ts.
  105053. * Passed information to create a WebGLTexture
  105054. * @param urlArg defines a value which contains one of the following:
  105055. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  105056. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  105057. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  105058. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  105059. * @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)
  105060. * @param scene needed for loading to the correct scene
  105061. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  105062. * @param onLoad optional callback to be called upon successful completion
  105063. * @param onError optional callback to be called upon failure
  105064. * @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
  105065. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  105066. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  105067. * @param forcedExtension defines the extension to use to pick the right loader
  105068. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  105069. * @param mimeType defines an optional mime type
  105070. * @returns a InternalTexture for assignment back into BABYLON.Texture
  105071. */
  105072. 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;
  105073. /**
  105074. * Loads an image as an HTMLImageElement.
  105075. * @param input url string, ArrayBuffer, or Blob to load
  105076. * @param onLoad callback called when the image successfully loads
  105077. * @param onError callback called when the image fails to load
  105078. * @param offlineProvider offline provider for caching
  105079. * @param mimeType optional mime type
  105080. * @returns the HTMLImageElement of the loaded image
  105081. * @hidden
  105082. */
  105083. 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>;
  105084. /**
  105085. * @hidden
  105086. */
  105087. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  105088. /**
  105089. * Creates a raw texture
  105090. * @param data defines the data to store in the texture
  105091. * @param width defines the width of the texture
  105092. * @param height defines the height of the texture
  105093. * @param format defines the format of the data
  105094. * @param generateMipMaps defines if the engine should generate the mip levels
  105095. * @param invertY defines if data must be stored with Y axis inverted
  105096. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  105097. * @param compression defines the compression used (null by default)
  105098. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  105099. * @returns the raw texture inside an InternalTexture
  105100. */
  105101. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  105102. /**
  105103. * Creates a new raw cube texture
  105104. * @param data defines the array of data to use to create each face
  105105. * @param size defines the size of the textures
  105106. * @param format defines the format of the data
  105107. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  105108. * @param generateMipMaps defines if the engine should generate the mip levels
  105109. * @param invertY defines if data must be stored with Y axis inverted
  105110. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105111. * @param compression defines the compression used (null by default)
  105112. * @returns the cube texture as an InternalTexture
  105113. */
  105114. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  105115. /**
  105116. * Creates a new raw 3D texture
  105117. * @param data defines the data used to create the texture
  105118. * @param width defines the width of the texture
  105119. * @param height defines the height of the texture
  105120. * @param depth defines the depth of the texture
  105121. * @param format defines the format of the texture
  105122. * @param generateMipMaps defines if the engine must generate mip levels
  105123. * @param invertY defines if data must be stored with Y axis inverted
  105124. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105125. * @param compression defines the compressed used (can be null)
  105126. * @param textureType defines the compressed used (can be null)
  105127. * @returns a new raw 3D texture (stored in an InternalTexture)
  105128. */
  105129. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  105130. /**
  105131. * Creates a new raw 2D array texture
  105132. * @param data defines the data used to create the texture
  105133. * @param width defines the width of the texture
  105134. * @param height defines the height of the texture
  105135. * @param depth defines the number of layers of the texture
  105136. * @param format defines the format of the texture
  105137. * @param generateMipMaps defines if the engine must generate mip levels
  105138. * @param invertY defines if data must be stored with Y axis inverted
  105139. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105140. * @param compression defines the compressed used (can be null)
  105141. * @param textureType defines the compressed used (can be null)
  105142. * @returns a new raw 2D array texture (stored in an InternalTexture)
  105143. */
  105144. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  105145. private _unpackFlipYCached;
  105146. /**
  105147. * In case you are sharing the context with other applications, it might
  105148. * be interested to not cache the unpack flip y state to ensure a consistent
  105149. * value would be set.
  105150. */
  105151. enableUnpackFlipYCached: boolean;
  105152. /** @hidden */
  105153. _unpackFlipY(value: boolean): void;
  105154. /** @hidden */
  105155. _getUnpackAlignement(): number;
  105156. private _getTextureTarget;
  105157. /**
  105158. * Update the sampling mode of a given texture
  105159. * @param samplingMode defines the required sampling mode
  105160. * @param texture defines the texture to update
  105161. * @param generateMipMaps defines whether to generate mipmaps for the texture
  105162. */
  105163. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  105164. /**
  105165. * Update the sampling mode of a given texture
  105166. * @param texture defines the texture to update
  105167. * @param wrapU defines the texture wrap mode of the u coordinates
  105168. * @param wrapV defines the texture wrap mode of the v coordinates
  105169. * @param wrapR defines the texture wrap mode of the r coordinates
  105170. */
  105171. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  105172. /** @hidden */
  105173. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  105174. width: number;
  105175. height: number;
  105176. layers?: number;
  105177. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  105178. /** @hidden */
  105179. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  105180. /** @hidden */
  105181. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  105182. /**
  105183. * Update a portion of an internal texture
  105184. * @param texture defines the texture to update
  105185. * @param imageData defines the data to store into the texture
  105186. * @param xOffset defines the x coordinates of the update rectangle
  105187. * @param yOffset defines the y coordinates of the update rectangle
  105188. * @param width defines the width of the update rectangle
  105189. * @param height defines the height of the update rectangle
  105190. * @param faceIndex defines the face index if texture is a cube (0 by default)
  105191. * @param lod defines the lod level to update (0 by default)
  105192. */
  105193. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  105194. /** @hidden */
  105195. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  105196. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  105197. private _prepareWebGLTexture;
  105198. /** @hidden */
  105199. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  105200. private _getDepthStencilBuffer;
  105201. /** @hidden */
  105202. _releaseFramebufferObjects(texture: InternalTexture): void;
  105203. /** @hidden */
  105204. _releaseTexture(texture: InternalTexture): void;
  105205. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  105206. protected _setProgram(program: WebGLProgram): void;
  105207. protected _boundUniforms: {
  105208. [key: number]: WebGLUniformLocation;
  105209. };
  105210. /**
  105211. * Binds an effect to the webGL context
  105212. * @param effect defines the effect to bind
  105213. */
  105214. bindSamplers(effect: Effect): void;
  105215. private _activateCurrentTexture;
  105216. /** @hidden */
  105217. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  105218. /** @hidden */
  105219. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  105220. /**
  105221. * Unbind all textures from the webGL context
  105222. */
  105223. unbindAllTextures(): void;
  105224. /**
  105225. * Sets a texture to the according uniform.
  105226. * @param channel The texture channel
  105227. * @param uniform The uniform to set
  105228. * @param texture The texture to apply
  105229. */
  105230. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  105231. private _bindSamplerUniformToChannel;
  105232. private _getTextureWrapMode;
  105233. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  105234. /**
  105235. * Sets an array of texture to the webGL context
  105236. * @param channel defines the channel where the texture array must be set
  105237. * @param uniform defines the associated uniform location
  105238. * @param textures defines the array of textures to bind
  105239. */
  105240. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  105241. /** @hidden */
  105242. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  105243. private _setTextureParameterFloat;
  105244. private _setTextureParameterInteger;
  105245. /**
  105246. * Unbind all vertex attributes from the webGL context
  105247. */
  105248. unbindAllAttributes(): void;
  105249. /**
  105250. * 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
  105251. */
  105252. releaseEffects(): void;
  105253. /**
  105254. * Dispose and release all associated resources
  105255. */
  105256. dispose(): void;
  105257. /**
  105258. * Attach a new callback raised when context lost event is fired
  105259. * @param callback defines the callback to call
  105260. */
  105261. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  105262. /**
  105263. * Attach a new callback raised when context restored event is fired
  105264. * @param callback defines the callback to call
  105265. */
  105266. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  105267. /**
  105268. * Get the current error code of the webGL context
  105269. * @returns the error code
  105270. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  105271. */
  105272. getError(): number;
  105273. private _canRenderToFloatFramebuffer;
  105274. private _canRenderToHalfFloatFramebuffer;
  105275. private _canRenderToFramebuffer;
  105276. /** @hidden */
  105277. _getWebGLTextureType(type: number): number;
  105278. /** @hidden */
  105279. _getInternalFormat(format: number): number;
  105280. /** @hidden */
  105281. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  105282. /** @hidden */
  105283. _getRGBAMultiSampleBufferFormat(type: number): number;
  105284. /** @hidden */
  105285. _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;
  105286. /**
  105287. * Loads a file from a url
  105288. * @param url url to load
  105289. * @param onSuccess callback called when the file successfully loads
  105290. * @param onProgress callback called while file is loading (if the server supports this mode)
  105291. * @param offlineProvider defines the offline provider for caching
  105292. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  105293. * @param onError callback called when the file fails to load
  105294. * @returns a file request object
  105295. * @hidden
  105296. */
  105297. 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;
  105298. /**
  105299. * Reads pixels from the current frame buffer. Please note that this function can be slow
  105300. * @param x defines the x coordinate of the rectangle where pixels must be read
  105301. * @param y defines the y coordinate of the rectangle where pixels must be read
  105302. * @param width defines the width of the rectangle where pixels must be read
  105303. * @param height defines the height of the rectangle where pixels must be read
  105304. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  105305. * @returns a Uint8Array containing RGBA colors
  105306. */
  105307. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  105308. private static _isSupported;
  105309. /**
  105310. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  105311. * @returns true if the engine can be created
  105312. * @ignorenaming
  105313. */
  105314. static isSupported(): boolean;
  105315. /**
  105316. * Find the next highest power of two.
  105317. * @param x Number to start search from.
  105318. * @return Next highest power of two.
  105319. */
  105320. static CeilingPOT(x: number): number;
  105321. /**
  105322. * Find the next lowest power of two.
  105323. * @param x Number to start search from.
  105324. * @return Next lowest power of two.
  105325. */
  105326. static FloorPOT(x: number): number;
  105327. /**
  105328. * Find the nearest power of two.
  105329. * @param x Number to start search from.
  105330. * @return Next nearest power of two.
  105331. */
  105332. static NearestPOT(x: number): number;
  105333. /**
  105334. * Get the closest exponent of two
  105335. * @param value defines the value to approximate
  105336. * @param max defines the maximum value to return
  105337. * @param mode defines how to define the closest value
  105338. * @returns closest exponent of two of the given value
  105339. */
  105340. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  105341. /**
  105342. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  105343. * @param func - the function to be called
  105344. * @param requester - the object that will request the next frame. Falls back to window.
  105345. * @returns frame number
  105346. */
  105347. static QueueNewFrame(func: () => void, requester?: any): number;
  105348. /**
  105349. * Gets host document
  105350. * @returns the host document object
  105351. */
  105352. getHostDocument(): Nullable<Document>;
  105353. }
  105354. }
  105355. declare module BABYLON {
  105356. /**
  105357. * Class representing spherical harmonics coefficients to the 3rd degree
  105358. */
  105359. export class SphericalHarmonics {
  105360. /**
  105361. * Defines whether or not the harmonics have been prescaled for rendering.
  105362. */
  105363. preScaled: boolean;
  105364. /**
  105365. * The l0,0 coefficients of the spherical harmonics
  105366. */
  105367. l00: Vector3;
  105368. /**
  105369. * The l1,-1 coefficients of the spherical harmonics
  105370. */
  105371. l1_1: Vector3;
  105372. /**
  105373. * The l1,0 coefficients of the spherical harmonics
  105374. */
  105375. l10: Vector3;
  105376. /**
  105377. * The l1,1 coefficients of the spherical harmonics
  105378. */
  105379. l11: Vector3;
  105380. /**
  105381. * The l2,-2 coefficients of the spherical harmonics
  105382. */
  105383. l2_2: Vector3;
  105384. /**
  105385. * The l2,-1 coefficients of the spherical harmonics
  105386. */
  105387. l2_1: Vector3;
  105388. /**
  105389. * The l2,0 coefficients of the spherical harmonics
  105390. */
  105391. l20: Vector3;
  105392. /**
  105393. * The l2,1 coefficients of the spherical harmonics
  105394. */
  105395. l21: Vector3;
  105396. /**
  105397. * The l2,2 coefficients of the spherical harmonics
  105398. */
  105399. l22: Vector3;
  105400. /**
  105401. * Adds a light to the spherical harmonics
  105402. * @param direction the direction of the light
  105403. * @param color the color of the light
  105404. * @param deltaSolidAngle the delta solid angle of the light
  105405. */
  105406. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  105407. /**
  105408. * Scales the spherical harmonics by the given amount
  105409. * @param scale the amount to scale
  105410. */
  105411. scaleInPlace(scale: number): void;
  105412. /**
  105413. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  105414. *
  105415. * ```
  105416. * E_lm = A_l * L_lm
  105417. * ```
  105418. *
  105419. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  105420. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  105421. * the scaling factors are given in equation 9.
  105422. */
  105423. convertIncidentRadianceToIrradiance(): void;
  105424. /**
  105425. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  105426. *
  105427. * ```
  105428. * L = (1/pi) * E * rho
  105429. * ```
  105430. *
  105431. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  105432. */
  105433. convertIrradianceToLambertianRadiance(): void;
  105434. /**
  105435. * Integrates the reconstruction coefficients directly in to the SH preventing further
  105436. * required operations at run time.
  105437. *
  105438. * This is simply done by scaling back the SH with Ylm constants parameter.
  105439. * The trigonometric part being applied by the shader at run time.
  105440. */
  105441. preScaleForRendering(): void;
  105442. /**
  105443. * Constructs a spherical harmonics from an array.
  105444. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  105445. * @returns the spherical harmonics
  105446. */
  105447. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  105448. /**
  105449. * Gets the spherical harmonics from polynomial
  105450. * @param polynomial the spherical polynomial
  105451. * @returns the spherical harmonics
  105452. */
  105453. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  105454. }
  105455. /**
  105456. * Class representing spherical polynomial coefficients to the 3rd degree
  105457. */
  105458. export class SphericalPolynomial {
  105459. private _harmonics;
  105460. /**
  105461. * The spherical harmonics used to create the polynomials.
  105462. */
  105463. get preScaledHarmonics(): SphericalHarmonics;
  105464. /**
  105465. * The x coefficients of the spherical polynomial
  105466. */
  105467. x: Vector3;
  105468. /**
  105469. * The y coefficients of the spherical polynomial
  105470. */
  105471. y: Vector3;
  105472. /**
  105473. * The z coefficients of the spherical polynomial
  105474. */
  105475. z: Vector3;
  105476. /**
  105477. * The xx coefficients of the spherical polynomial
  105478. */
  105479. xx: Vector3;
  105480. /**
  105481. * The yy coefficients of the spherical polynomial
  105482. */
  105483. yy: Vector3;
  105484. /**
  105485. * The zz coefficients of the spherical polynomial
  105486. */
  105487. zz: Vector3;
  105488. /**
  105489. * The xy coefficients of the spherical polynomial
  105490. */
  105491. xy: Vector3;
  105492. /**
  105493. * The yz coefficients of the spherical polynomial
  105494. */
  105495. yz: Vector3;
  105496. /**
  105497. * The zx coefficients of the spherical polynomial
  105498. */
  105499. zx: Vector3;
  105500. /**
  105501. * Adds an ambient color to the spherical polynomial
  105502. * @param color the color to add
  105503. */
  105504. addAmbient(color: Color3): void;
  105505. /**
  105506. * Scales the spherical polynomial by the given amount
  105507. * @param scale the amount to scale
  105508. */
  105509. scaleInPlace(scale: number): void;
  105510. /**
  105511. * Gets the spherical polynomial from harmonics
  105512. * @param harmonics the spherical harmonics
  105513. * @returns the spherical polynomial
  105514. */
  105515. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  105516. /**
  105517. * Constructs a spherical polynomial from an array.
  105518. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  105519. * @returns the spherical polynomial
  105520. */
  105521. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  105522. }
  105523. }
  105524. declare module BABYLON {
  105525. /**
  105526. * Defines the source of the internal texture
  105527. */
  105528. export enum InternalTextureSource {
  105529. /**
  105530. * The source of the texture data is unknown
  105531. */
  105532. Unknown = 0,
  105533. /**
  105534. * Texture data comes from an URL
  105535. */
  105536. Url = 1,
  105537. /**
  105538. * Texture data is only used for temporary storage
  105539. */
  105540. Temp = 2,
  105541. /**
  105542. * Texture data comes from raw data (ArrayBuffer)
  105543. */
  105544. Raw = 3,
  105545. /**
  105546. * Texture content is dynamic (video or dynamic texture)
  105547. */
  105548. Dynamic = 4,
  105549. /**
  105550. * Texture content is generated by rendering to it
  105551. */
  105552. RenderTarget = 5,
  105553. /**
  105554. * Texture content is part of a multi render target process
  105555. */
  105556. MultiRenderTarget = 6,
  105557. /**
  105558. * Texture data comes from a cube data file
  105559. */
  105560. Cube = 7,
  105561. /**
  105562. * Texture data comes from a raw cube data
  105563. */
  105564. CubeRaw = 8,
  105565. /**
  105566. * Texture data come from a prefiltered cube data file
  105567. */
  105568. CubePrefiltered = 9,
  105569. /**
  105570. * Texture content is raw 3D data
  105571. */
  105572. Raw3D = 10,
  105573. /**
  105574. * Texture content is raw 2D array data
  105575. */
  105576. Raw2DArray = 11,
  105577. /**
  105578. * Texture content is a depth texture
  105579. */
  105580. Depth = 12,
  105581. /**
  105582. * Texture data comes from a raw cube data encoded with RGBD
  105583. */
  105584. CubeRawRGBD = 13
  105585. }
  105586. /**
  105587. * Class used to store data associated with WebGL texture data for the engine
  105588. * This class should not be used directly
  105589. */
  105590. export class InternalTexture {
  105591. /** @hidden */
  105592. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  105593. /**
  105594. * Defines if the texture is ready
  105595. */
  105596. isReady: boolean;
  105597. /**
  105598. * Defines if the texture is a cube texture
  105599. */
  105600. isCube: boolean;
  105601. /**
  105602. * Defines if the texture contains 3D data
  105603. */
  105604. is3D: boolean;
  105605. /**
  105606. * Defines if the texture contains 2D array data
  105607. */
  105608. is2DArray: boolean;
  105609. /**
  105610. * Defines if the texture contains multiview data
  105611. */
  105612. isMultiview: boolean;
  105613. /**
  105614. * Gets the URL used to load this texture
  105615. */
  105616. url: string;
  105617. /**
  105618. * Gets the sampling mode of the texture
  105619. */
  105620. samplingMode: number;
  105621. /**
  105622. * Gets a boolean indicating if the texture needs mipmaps generation
  105623. */
  105624. generateMipMaps: boolean;
  105625. /**
  105626. * Gets the number of samples used by the texture (WebGL2+ only)
  105627. */
  105628. samples: number;
  105629. /**
  105630. * Gets the type of the texture (int, float...)
  105631. */
  105632. type: number;
  105633. /**
  105634. * Gets the format of the texture (RGB, RGBA...)
  105635. */
  105636. format: number;
  105637. /**
  105638. * Observable called when the texture is loaded
  105639. */
  105640. onLoadedObservable: Observable<InternalTexture>;
  105641. /**
  105642. * Gets the width of the texture
  105643. */
  105644. width: number;
  105645. /**
  105646. * Gets the height of the texture
  105647. */
  105648. height: number;
  105649. /**
  105650. * Gets the depth of the texture
  105651. */
  105652. depth: number;
  105653. /**
  105654. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  105655. */
  105656. baseWidth: number;
  105657. /**
  105658. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  105659. */
  105660. baseHeight: number;
  105661. /**
  105662. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  105663. */
  105664. baseDepth: number;
  105665. /**
  105666. * Gets a boolean indicating if the texture is inverted on Y axis
  105667. */
  105668. invertY: boolean;
  105669. /** @hidden */
  105670. _invertVScale: boolean;
  105671. /** @hidden */
  105672. _associatedChannel: number;
  105673. /** @hidden */
  105674. _source: InternalTextureSource;
  105675. /** @hidden */
  105676. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  105677. /** @hidden */
  105678. _bufferView: Nullable<ArrayBufferView>;
  105679. /** @hidden */
  105680. _bufferViewArray: Nullable<ArrayBufferView[]>;
  105681. /** @hidden */
  105682. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  105683. /** @hidden */
  105684. _size: number;
  105685. /** @hidden */
  105686. _extension: string;
  105687. /** @hidden */
  105688. _files: Nullable<string[]>;
  105689. /** @hidden */
  105690. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  105691. /** @hidden */
  105692. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  105693. /** @hidden */
  105694. _framebuffer: Nullable<WebGLFramebuffer>;
  105695. /** @hidden */
  105696. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  105697. /** @hidden */
  105698. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  105699. /** @hidden */
  105700. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  105701. /** @hidden */
  105702. _attachments: Nullable<number[]>;
  105703. /** @hidden */
  105704. _cachedCoordinatesMode: Nullable<number>;
  105705. /** @hidden */
  105706. _cachedWrapU: Nullable<number>;
  105707. /** @hidden */
  105708. _cachedWrapV: Nullable<number>;
  105709. /** @hidden */
  105710. _cachedWrapR: Nullable<number>;
  105711. /** @hidden */
  105712. _cachedAnisotropicFilteringLevel: Nullable<number>;
  105713. /** @hidden */
  105714. _isDisabled: boolean;
  105715. /** @hidden */
  105716. _compression: Nullable<string>;
  105717. /** @hidden */
  105718. _generateStencilBuffer: boolean;
  105719. /** @hidden */
  105720. _generateDepthBuffer: boolean;
  105721. /** @hidden */
  105722. _comparisonFunction: number;
  105723. /** @hidden */
  105724. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  105725. /** @hidden */
  105726. _lodGenerationScale: number;
  105727. /** @hidden */
  105728. _lodGenerationOffset: number;
  105729. /** @hidden */
  105730. _depthStencilTexture: Nullable<InternalTexture>;
  105731. /** @hidden */
  105732. _colorTextureArray: Nullable<WebGLTexture>;
  105733. /** @hidden */
  105734. _depthStencilTextureArray: Nullable<WebGLTexture>;
  105735. /** @hidden */
  105736. _lodTextureHigh: Nullable<BaseTexture>;
  105737. /** @hidden */
  105738. _lodTextureMid: Nullable<BaseTexture>;
  105739. /** @hidden */
  105740. _lodTextureLow: Nullable<BaseTexture>;
  105741. /** @hidden */
  105742. _isRGBD: boolean;
  105743. /** @hidden */
  105744. _linearSpecularLOD: boolean;
  105745. /** @hidden */
  105746. _irradianceTexture: Nullable<BaseTexture>;
  105747. /** @hidden */
  105748. _webGLTexture: Nullable<WebGLTexture>;
  105749. /** @hidden */
  105750. _references: number;
  105751. private _engine;
  105752. /**
  105753. * Gets the Engine the texture belongs to.
  105754. * @returns The babylon engine
  105755. */
  105756. getEngine(): ThinEngine;
  105757. /**
  105758. * Gets the data source type of the texture
  105759. */
  105760. get source(): InternalTextureSource;
  105761. /**
  105762. * Creates a new InternalTexture
  105763. * @param engine defines the engine to use
  105764. * @param source defines the type of data that will be used
  105765. * @param delayAllocation if the texture allocation should be delayed (default: false)
  105766. */
  105767. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  105768. /**
  105769. * Increments the number of references (ie. the number of Texture that point to it)
  105770. */
  105771. incrementReferences(): void;
  105772. /**
  105773. * Change the size of the texture (not the size of the content)
  105774. * @param width defines the new width
  105775. * @param height defines the new height
  105776. * @param depth defines the new depth (1 by default)
  105777. */
  105778. updateSize(width: int, height: int, depth?: int): void;
  105779. /** @hidden */
  105780. _rebuild(): void;
  105781. /** @hidden */
  105782. _swapAndDie(target: InternalTexture): void;
  105783. /**
  105784. * Dispose the current allocated resources
  105785. */
  105786. dispose(): void;
  105787. }
  105788. }
  105789. declare module BABYLON {
  105790. /**
  105791. * Class used to work with sound analyzer using fast fourier transform (FFT)
  105792. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105793. */
  105794. export class Analyser {
  105795. /**
  105796. * Gets or sets the smoothing
  105797. * @ignorenaming
  105798. */
  105799. SMOOTHING: number;
  105800. /**
  105801. * Gets or sets the FFT table size
  105802. * @ignorenaming
  105803. */
  105804. FFT_SIZE: number;
  105805. /**
  105806. * Gets or sets the bar graph amplitude
  105807. * @ignorenaming
  105808. */
  105809. BARGRAPHAMPLITUDE: number;
  105810. /**
  105811. * Gets or sets the position of the debug canvas
  105812. * @ignorenaming
  105813. */
  105814. DEBUGCANVASPOS: {
  105815. x: number;
  105816. y: number;
  105817. };
  105818. /**
  105819. * Gets or sets the debug canvas size
  105820. * @ignorenaming
  105821. */
  105822. DEBUGCANVASSIZE: {
  105823. width: number;
  105824. height: number;
  105825. };
  105826. private _byteFreqs;
  105827. private _byteTime;
  105828. private _floatFreqs;
  105829. private _webAudioAnalyser;
  105830. private _debugCanvas;
  105831. private _debugCanvasContext;
  105832. private _scene;
  105833. private _registerFunc;
  105834. private _audioEngine;
  105835. /**
  105836. * Creates a new analyser
  105837. * @param scene defines hosting scene
  105838. */
  105839. constructor(scene: Scene);
  105840. /**
  105841. * Get the number of data values you will have to play with for the visualization
  105842. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  105843. * @returns a number
  105844. */
  105845. getFrequencyBinCount(): number;
  105846. /**
  105847. * Gets the current frequency data as a byte array
  105848. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  105849. * @returns a Uint8Array
  105850. */
  105851. getByteFrequencyData(): Uint8Array;
  105852. /**
  105853. * Gets the current waveform as a byte array
  105854. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  105855. * @returns a Uint8Array
  105856. */
  105857. getByteTimeDomainData(): Uint8Array;
  105858. /**
  105859. * Gets the current frequency data as a float array
  105860. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  105861. * @returns a Float32Array
  105862. */
  105863. getFloatFrequencyData(): Float32Array;
  105864. /**
  105865. * Renders the debug canvas
  105866. */
  105867. drawDebugCanvas(): void;
  105868. /**
  105869. * Stops rendering the debug canvas and removes it
  105870. */
  105871. stopDebugCanvas(): void;
  105872. /**
  105873. * Connects two audio nodes
  105874. * @param inputAudioNode defines first node to connect
  105875. * @param outputAudioNode defines second node to connect
  105876. */
  105877. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  105878. /**
  105879. * Releases all associated resources
  105880. */
  105881. dispose(): void;
  105882. }
  105883. }
  105884. declare module BABYLON {
  105885. /**
  105886. * This represents an audio engine and it is responsible
  105887. * to play, synchronize and analyse sounds throughout the application.
  105888. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105889. */
  105890. export interface IAudioEngine extends IDisposable {
  105891. /**
  105892. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  105893. */
  105894. readonly canUseWebAudio: boolean;
  105895. /**
  105896. * Gets the current AudioContext if available.
  105897. */
  105898. readonly audioContext: Nullable<AudioContext>;
  105899. /**
  105900. * The master gain node defines the global audio volume of your audio engine.
  105901. */
  105902. readonly masterGain: GainNode;
  105903. /**
  105904. * Gets whether or not mp3 are supported by your browser.
  105905. */
  105906. readonly isMP3supported: boolean;
  105907. /**
  105908. * Gets whether or not ogg are supported by your browser.
  105909. */
  105910. readonly isOGGsupported: boolean;
  105911. /**
  105912. * Defines if Babylon should emit a warning if WebAudio is not supported.
  105913. * @ignoreNaming
  105914. */
  105915. WarnedWebAudioUnsupported: boolean;
  105916. /**
  105917. * Defines if the audio engine relies on a custom unlocked button.
  105918. * In this case, the embedded button will not be displayed.
  105919. */
  105920. useCustomUnlockedButton: boolean;
  105921. /**
  105922. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  105923. */
  105924. readonly unlocked: boolean;
  105925. /**
  105926. * Event raised when audio has been unlocked on the browser.
  105927. */
  105928. onAudioUnlockedObservable: Observable<AudioEngine>;
  105929. /**
  105930. * Event raised when audio has been locked on the browser.
  105931. */
  105932. onAudioLockedObservable: Observable<AudioEngine>;
  105933. /**
  105934. * Flags the audio engine in Locked state.
  105935. * This happens due to new browser policies preventing audio to autoplay.
  105936. */
  105937. lock(): void;
  105938. /**
  105939. * Unlocks the audio engine once a user action has been done on the dom.
  105940. * This is helpful to resume play once browser policies have been satisfied.
  105941. */
  105942. unlock(): void;
  105943. }
  105944. /**
  105945. * This represents the default audio engine used in babylon.
  105946. * It is responsible to play, synchronize and analyse sounds throughout the application.
  105947. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105948. */
  105949. export class AudioEngine implements IAudioEngine {
  105950. private _audioContext;
  105951. private _audioContextInitialized;
  105952. private _muteButton;
  105953. private _hostElement;
  105954. /**
  105955. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  105956. */
  105957. canUseWebAudio: boolean;
  105958. /**
  105959. * The master gain node defines the global audio volume of your audio engine.
  105960. */
  105961. masterGain: GainNode;
  105962. /**
  105963. * Defines if Babylon should emit a warning if WebAudio is not supported.
  105964. * @ignoreNaming
  105965. */
  105966. WarnedWebAudioUnsupported: boolean;
  105967. /**
  105968. * Gets whether or not mp3 are supported by your browser.
  105969. */
  105970. isMP3supported: boolean;
  105971. /**
  105972. * Gets whether or not ogg are supported by your browser.
  105973. */
  105974. isOGGsupported: boolean;
  105975. /**
  105976. * Gets whether audio has been unlocked on the device.
  105977. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  105978. * a user interaction has happened.
  105979. */
  105980. unlocked: boolean;
  105981. /**
  105982. * Defines if the audio engine relies on a custom unlocked button.
  105983. * In this case, the embedded button will not be displayed.
  105984. */
  105985. useCustomUnlockedButton: boolean;
  105986. /**
  105987. * Event raised when audio has been unlocked on the browser.
  105988. */
  105989. onAudioUnlockedObservable: Observable<AudioEngine>;
  105990. /**
  105991. * Event raised when audio has been locked on the browser.
  105992. */
  105993. onAudioLockedObservable: Observable<AudioEngine>;
  105994. /**
  105995. * Gets the current AudioContext if available.
  105996. */
  105997. get audioContext(): Nullable<AudioContext>;
  105998. private _connectedAnalyser;
  105999. /**
  106000. * Instantiates a new audio engine.
  106001. *
  106002. * There should be only one per page as some browsers restrict the number
  106003. * of audio contexts you can create.
  106004. * @param hostElement defines the host element where to display the mute icon if necessary
  106005. */
  106006. constructor(hostElement?: Nullable<HTMLElement>);
  106007. /**
  106008. * Flags the audio engine in Locked state.
  106009. * This happens due to new browser policies preventing audio to autoplay.
  106010. */
  106011. lock(): void;
  106012. /**
  106013. * Unlocks the audio engine once a user action has been done on the dom.
  106014. * This is helpful to resume play once browser policies have been satisfied.
  106015. */
  106016. unlock(): void;
  106017. private _resumeAudioContext;
  106018. private _initializeAudioContext;
  106019. private _tryToRun;
  106020. private _triggerRunningState;
  106021. private _triggerSuspendedState;
  106022. private _displayMuteButton;
  106023. private _moveButtonToTopLeft;
  106024. private _onResize;
  106025. private _hideMuteButton;
  106026. /**
  106027. * Destroy and release the resources associated with the audio ccontext.
  106028. */
  106029. dispose(): void;
  106030. /**
  106031. * Gets the global volume sets on the master gain.
  106032. * @returns the global volume if set or -1 otherwise
  106033. */
  106034. getGlobalVolume(): number;
  106035. /**
  106036. * Sets the global volume of your experience (sets on the master gain).
  106037. * @param newVolume Defines the new global volume of the application
  106038. */
  106039. setGlobalVolume(newVolume: number): void;
  106040. /**
  106041. * Connect the audio engine to an audio analyser allowing some amazing
  106042. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  106043. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  106044. * @param analyser The analyser to connect to the engine
  106045. */
  106046. connectToAnalyser(analyser: Analyser): void;
  106047. }
  106048. }
  106049. declare module BABYLON {
  106050. /**
  106051. * Interface used to present a loading screen while loading a scene
  106052. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106053. */
  106054. export interface ILoadingScreen {
  106055. /**
  106056. * Function called to display the loading screen
  106057. */
  106058. displayLoadingUI: () => void;
  106059. /**
  106060. * Function called to hide the loading screen
  106061. */
  106062. hideLoadingUI: () => void;
  106063. /**
  106064. * Gets or sets the color to use for the background
  106065. */
  106066. loadingUIBackgroundColor: string;
  106067. /**
  106068. * Gets or sets the text to display while loading
  106069. */
  106070. loadingUIText: string;
  106071. }
  106072. /**
  106073. * Class used for the default loading screen
  106074. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106075. */
  106076. export class DefaultLoadingScreen implements ILoadingScreen {
  106077. private _renderingCanvas;
  106078. private _loadingText;
  106079. private _loadingDivBackgroundColor;
  106080. private _loadingDiv;
  106081. private _loadingTextDiv;
  106082. /** Gets or sets the logo url to use for the default loading screen */
  106083. static DefaultLogoUrl: string;
  106084. /** Gets or sets the spinner url to use for the default loading screen */
  106085. static DefaultSpinnerUrl: string;
  106086. /**
  106087. * Creates a new default loading screen
  106088. * @param _renderingCanvas defines the canvas used to render the scene
  106089. * @param _loadingText defines the default text to display
  106090. * @param _loadingDivBackgroundColor defines the default background color
  106091. */
  106092. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  106093. /**
  106094. * Function called to display the loading screen
  106095. */
  106096. displayLoadingUI(): void;
  106097. /**
  106098. * Function called to hide the loading screen
  106099. */
  106100. hideLoadingUI(): void;
  106101. /**
  106102. * Gets or sets the text to display while loading
  106103. */
  106104. set loadingUIText(text: string);
  106105. get loadingUIText(): string;
  106106. /**
  106107. * Gets or sets the color to use for the background
  106108. */
  106109. get loadingUIBackgroundColor(): string;
  106110. set loadingUIBackgroundColor(color: string);
  106111. private _resizeLoadingUI;
  106112. }
  106113. }
  106114. declare module BABYLON {
  106115. /**
  106116. * Interface for any object that can request an animation frame
  106117. */
  106118. export interface ICustomAnimationFrameRequester {
  106119. /**
  106120. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  106121. */
  106122. renderFunction?: Function;
  106123. /**
  106124. * Called to request the next frame to render to
  106125. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  106126. */
  106127. requestAnimationFrame: Function;
  106128. /**
  106129. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  106130. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  106131. */
  106132. requestID?: number;
  106133. }
  106134. }
  106135. declare module BABYLON {
  106136. /**
  106137. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  106138. */
  106139. export class PerformanceMonitor {
  106140. private _enabled;
  106141. private _rollingFrameTime;
  106142. private _lastFrameTimeMs;
  106143. /**
  106144. * constructor
  106145. * @param frameSampleSize The number of samples required to saturate the sliding window
  106146. */
  106147. constructor(frameSampleSize?: number);
  106148. /**
  106149. * Samples current frame
  106150. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  106151. */
  106152. sampleFrame(timeMs?: number): void;
  106153. /**
  106154. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  106155. */
  106156. get averageFrameTime(): number;
  106157. /**
  106158. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  106159. */
  106160. get averageFrameTimeVariance(): number;
  106161. /**
  106162. * Returns the frame time of the most recent frame
  106163. */
  106164. get instantaneousFrameTime(): number;
  106165. /**
  106166. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  106167. */
  106168. get averageFPS(): number;
  106169. /**
  106170. * Returns the average framerate in frames per second using the most recent frame time
  106171. */
  106172. get instantaneousFPS(): number;
  106173. /**
  106174. * Returns true if enough samples have been taken to completely fill the sliding window
  106175. */
  106176. get isSaturated(): boolean;
  106177. /**
  106178. * Enables contributions to the sliding window sample set
  106179. */
  106180. enable(): void;
  106181. /**
  106182. * Disables contributions to the sliding window sample set
  106183. * Samples will not be interpolated over the disabled period
  106184. */
  106185. disable(): void;
  106186. /**
  106187. * Returns true if sampling is enabled
  106188. */
  106189. get isEnabled(): boolean;
  106190. /**
  106191. * Resets performance monitor
  106192. */
  106193. reset(): void;
  106194. }
  106195. /**
  106196. * RollingAverage
  106197. *
  106198. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  106199. */
  106200. export class RollingAverage {
  106201. /**
  106202. * Current average
  106203. */
  106204. average: number;
  106205. /**
  106206. * Current variance
  106207. */
  106208. variance: number;
  106209. protected _samples: Array<number>;
  106210. protected _sampleCount: number;
  106211. protected _pos: number;
  106212. protected _m2: number;
  106213. /**
  106214. * constructor
  106215. * @param length The number of samples required to saturate the sliding window
  106216. */
  106217. constructor(length: number);
  106218. /**
  106219. * Adds a sample to the sample set
  106220. * @param v The sample value
  106221. */
  106222. add(v: number): void;
  106223. /**
  106224. * Returns previously added values or null if outside of history or outside the sliding window domain
  106225. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  106226. * @return Value previously recorded with add() or null if outside of range
  106227. */
  106228. history(i: number): number;
  106229. /**
  106230. * Returns true if enough samples have been taken to completely fill the sliding window
  106231. * @return true if sample-set saturated
  106232. */
  106233. isSaturated(): boolean;
  106234. /**
  106235. * Resets the rolling average (equivalent to 0 samples taken so far)
  106236. */
  106237. reset(): void;
  106238. /**
  106239. * Wraps a value around the sample range boundaries
  106240. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  106241. * @return Wrapped position in sample range
  106242. */
  106243. protected _wrapPosition(i: number): number;
  106244. }
  106245. }
  106246. declare module BABYLON {
  106247. /**
  106248. * This class is used to track a performance counter which is number based.
  106249. * The user has access to many properties which give statistics of different nature.
  106250. *
  106251. * The implementer can track two kinds of Performance Counter: time and count.
  106252. * 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.
  106253. * 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.
  106254. */
  106255. export class PerfCounter {
  106256. /**
  106257. * Gets or sets a global boolean to turn on and off all the counters
  106258. */
  106259. static Enabled: boolean;
  106260. /**
  106261. * Returns the smallest value ever
  106262. */
  106263. get min(): number;
  106264. /**
  106265. * Returns the biggest value ever
  106266. */
  106267. get max(): number;
  106268. /**
  106269. * Returns the average value since the performance counter is running
  106270. */
  106271. get average(): number;
  106272. /**
  106273. * Returns the average value of the last second the counter was monitored
  106274. */
  106275. get lastSecAverage(): number;
  106276. /**
  106277. * Returns the current value
  106278. */
  106279. get current(): number;
  106280. /**
  106281. * Gets the accumulated total
  106282. */
  106283. get total(): number;
  106284. /**
  106285. * Gets the total value count
  106286. */
  106287. get count(): number;
  106288. /**
  106289. * Creates a new counter
  106290. */
  106291. constructor();
  106292. /**
  106293. * Call this method to start monitoring a new frame.
  106294. * 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.
  106295. */
  106296. fetchNewFrame(): void;
  106297. /**
  106298. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  106299. * @param newCount the count value to add to the monitored count
  106300. * @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.
  106301. */
  106302. addCount(newCount: number, fetchResult: boolean): void;
  106303. /**
  106304. * Start monitoring this performance counter
  106305. */
  106306. beginMonitoring(): void;
  106307. /**
  106308. * Compute the time lapsed since the previous beginMonitoring() call.
  106309. * @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
  106310. */
  106311. endMonitoring(newFrame?: boolean): void;
  106312. private _fetchResult;
  106313. private _startMonitoringTime;
  106314. private _min;
  106315. private _max;
  106316. private _average;
  106317. private _current;
  106318. private _totalValueCount;
  106319. private _totalAccumulated;
  106320. private _lastSecAverage;
  106321. private _lastSecAccumulated;
  106322. private _lastSecTime;
  106323. private _lastSecValueCount;
  106324. }
  106325. }
  106326. declare module BABYLON {
  106327. interface ThinEngine {
  106328. /**
  106329. * Sets alpha constants used by some alpha blending modes
  106330. * @param r defines the red component
  106331. * @param g defines the green component
  106332. * @param b defines the blue component
  106333. * @param a defines the alpha component
  106334. */
  106335. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  106336. /**
  106337. * Sets the current alpha mode
  106338. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  106339. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  106340. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  106341. */
  106342. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  106343. /**
  106344. * Gets the current alpha mode
  106345. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  106346. * @returns the current alpha mode
  106347. */
  106348. getAlphaMode(): number;
  106349. /**
  106350. * Sets the current alpha equation
  106351. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  106352. */
  106353. setAlphaEquation(equation: number): void;
  106354. /**
  106355. * Gets the current alpha equation.
  106356. * @returns the current alpha equation
  106357. */
  106358. getAlphaEquation(): number;
  106359. }
  106360. }
  106361. declare module BABYLON {
  106362. /**
  106363. * Defines the interface used by display changed events
  106364. */
  106365. export interface IDisplayChangedEventArgs {
  106366. /** Gets the vrDisplay object (if any) */
  106367. vrDisplay: Nullable<any>;
  106368. /** Gets a boolean indicating if webVR is supported */
  106369. vrSupported: boolean;
  106370. }
  106371. /**
  106372. * Defines the interface used by objects containing a viewport (like a camera)
  106373. */
  106374. interface IViewportOwnerLike {
  106375. /**
  106376. * Gets or sets the viewport
  106377. */
  106378. viewport: IViewportLike;
  106379. }
  106380. /**
  106381. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  106382. */
  106383. export class Engine extends ThinEngine {
  106384. /** Defines that alpha blending is disabled */
  106385. static readonly ALPHA_DISABLE: number;
  106386. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  106387. static readonly ALPHA_ADD: number;
  106388. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  106389. static readonly ALPHA_COMBINE: number;
  106390. /** Defines that alpha blending to DEST - SRC * DEST */
  106391. static readonly ALPHA_SUBTRACT: number;
  106392. /** Defines that alpha blending to SRC * DEST */
  106393. static readonly ALPHA_MULTIPLY: number;
  106394. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  106395. static readonly ALPHA_MAXIMIZED: number;
  106396. /** Defines that alpha blending to SRC + DEST */
  106397. static readonly ALPHA_ONEONE: number;
  106398. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  106399. static readonly ALPHA_PREMULTIPLIED: number;
  106400. /**
  106401. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  106402. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  106403. */
  106404. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  106405. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  106406. static readonly ALPHA_INTERPOLATE: number;
  106407. /**
  106408. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  106409. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  106410. */
  106411. static readonly ALPHA_SCREENMODE: number;
  106412. /** Defines that the ressource is not delayed*/
  106413. static readonly DELAYLOADSTATE_NONE: number;
  106414. /** Defines that the ressource was successfully delay loaded */
  106415. static readonly DELAYLOADSTATE_LOADED: number;
  106416. /** Defines that the ressource is currently delay loading */
  106417. static readonly DELAYLOADSTATE_LOADING: number;
  106418. /** Defines that the ressource is delayed and has not started loading */
  106419. static readonly DELAYLOADSTATE_NOTLOADED: number;
  106420. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  106421. static readonly NEVER: number;
  106422. /** 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 */
  106423. static readonly ALWAYS: number;
  106424. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  106425. static readonly LESS: number;
  106426. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  106427. static readonly EQUAL: number;
  106428. /** 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 */
  106429. static readonly LEQUAL: number;
  106430. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  106431. static readonly GREATER: number;
  106432. /** 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 */
  106433. static readonly GEQUAL: number;
  106434. /** 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 */
  106435. static readonly NOTEQUAL: number;
  106436. /** Passed to stencilOperation to specify that stencil value must be kept */
  106437. static readonly KEEP: number;
  106438. /** Passed to stencilOperation to specify that stencil value must be replaced */
  106439. static readonly REPLACE: number;
  106440. /** Passed to stencilOperation to specify that stencil value must be incremented */
  106441. static readonly INCR: number;
  106442. /** Passed to stencilOperation to specify that stencil value must be decremented */
  106443. static readonly DECR: number;
  106444. /** Passed to stencilOperation to specify that stencil value must be inverted */
  106445. static readonly INVERT: number;
  106446. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  106447. static readonly INCR_WRAP: number;
  106448. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  106449. static readonly DECR_WRAP: number;
  106450. /** Texture is not repeating outside of 0..1 UVs */
  106451. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  106452. /** Texture is repeating outside of 0..1 UVs */
  106453. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  106454. /** Texture is repeating and mirrored */
  106455. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  106456. /** ALPHA */
  106457. static readonly TEXTUREFORMAT_ALPHA: number;
  106458. /** LUMINANCE */
  106459. static readonly TEXTUREFORMAT_LUMINANCE: number;
  106460. /** LUMINANCE_ALPHA */
  106461. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  106462. /** RGB */
  106463. static readonly TEXTUREFORMAT_RGB: number;
  106464. /** RGBA */
  106465. static readonly TEXTUREFORMAT_RGBA: number;
  106466. /** RED */
  106467. static readonly TEXTUREFORMAT_RED: number;
  106468. /** RED (2nd reference) */
  106469. static readonly TEXTUREFORMAT_R: number;
  106470. /** RG */
  106471. static readonly TEXTUREFORMAT_RG: number;
  106472. /** RED_INTEGER */
  106473. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  106474. /** RED_INTEGER (2nd reference) */
  106475. static readonly TEXTUREFORMAT_R_INTEGER: number;
  106476. /** RG_INTEGER */
  106477. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  106478. /** RGB_INTEGER */
  106479. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  106480. /** RGBA_INTEGER */
  106481. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  106482. /** UNSIGNED_BYTE */
  106483. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  106484. /** UNSIGNED_BYTE (2nd reference) */
  106485. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  106486. /** FLOAT */
  106487. static readonly TEXTURETYPE_FLOAT: number;
  106488. /** HALF_FLOAT */
  106489. static readonly TEXTURETYPE_HALF_FLOAT: number;
  106490. /** BYTE */
  106491. static readonly TEXTURETYPE_BYTE: number;
  106492. /** SHORT */
  106493. static readonly TEXTURETYPE_SHORT: number;
  106494. /** UNSIGNED_SHORT */
  106495. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  106496. /** INT */
  106497. static readonly TEXTURETYPE_INT: number;
  106498. /** UNSIGNED_INT */
  106499. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  106500. /** UNSIGNED_SHORT_4_4_4_4 */
  106501. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  106502. /** UNSIGNED_SHORT_5_5_5_1 */
  106503. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  106504. /** UNSIGNED_SHORT_5_6_5 */
  106505. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  106506. /** UNSIGNED_INT_2_10_10_10_REV */
  106507. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  106508. /** UNSIGNED_INT_24_8 */
  106509. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  106510. /** UNSIGNED_INT_10F_11F_11F_REV */
  106511. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  106512. /** UNSIGNED_INT_5_9_9_9_REV */
  106513. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  106514. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  106515. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  106516. /** nearest is mag = nearest and min = nearest and mip = linear */
  106517. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  106518. /** Bilinear is mag = linear and min = linear and mip = nearest */
  106519. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  106520. /** Trilinear is mag = linear and min = linear and mip = linear */
  106521. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  106522. /** nearest is mag = nearest and min = nearest and mip = linear */
  106523. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  106524. /** Bilinear is mag = linear and min = linear and mip = nearest */
  106525. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  106526. /** Trilinear is mag = linear and min = linear and mip = linear */
  106527. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  106528. /** mag = nearest and min = nearest and mip = nearest */
  106529. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  106530. /** mag = nearest and min = linear and mip = nearest */
  106531. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  106532. /** mag = nearest and min = linear and mip = linear */
  106533. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  106534. /** mag = nearest and min = linear and mip = none */
  106535. static readonly TEXTURE_NEAREST_LINEAR: number;
  106536. /** mag = nearest and min = nearest and mip = none */
  106537. static readonly TEXTURE_NEAREST_NEAREST: number;
  106538. /** mag = linear and min = nearest and mip = nearest */
  106539. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  106540. /** mag = linear and min = nearest and mip = linear */
  106541. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  106542. /** mag = linear and min = linear and mip = none */
  106543. static readonly TEXTURE_LINEAR_LINEAR: number;
  106544. /** mag = linear and min = nearest and mip = none */
  106545. static readonly TEXTURE_LINEAR_NEAREST: number;
  106546. /** Explicit coordinates mode */
  106547. static readonly TEXTURE_EXPLICIT_MODE: number;
  106548. /** Spherical coordinates mode */
  106549. static readonly TEXTURE_SPHERICAL_MODE: number;
  106550. /** Planar coordinates mode */
  106551. static readonly TEXTURE_PLANAR_MODE: number;
  106552. /** Cubic coordinates mode */
  106553. static readonly TEXTURE_CUBIC_MODE: number;
  106554. /** Projection coordinates mode */
  106555. static readonly TEXTURE_PROJECTION_MODE: number;
  106556. /** Skybox coordinates mode */
  106557. static readonly TEXTURE_SKYBOX_MODE: number;
  106558. /** Inverse Cubic coordinates mode */
  106559. static readonly TEXTURE_INVCUBIC_MODE: number;
  106560. /** Equirectangular coordinates mode */
  106561. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  106562. /** Equirectangular Fixed coordinates mode */
  106563. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  106564. /** Equirectangular Fixed Mirrored coordinates mode */
  106565. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  106566. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  106567. static readonly SCALEMODE_FLOOR: number;
  106568. /** Defines that texture rescaling will look for the nearest power of 2 size */
  106569. static readonly SCALEMODE_NEAREST: number;
  106570. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  106571. static readonly SCALEMODE_CEILING: number;
  106572. /**
  106573. * Returns the current npm package of the sdk
  106574. */
  106575. static get NpmPackage(): string;
  106576. /**
  106577. * Returns the current version of the framework
  106578. */
  106579. static get Version(): string;
  106580. /** Gets the list of created engines */
  106581. static get Instances(): Engine[];
  106582. /**
  106583. * Gets the latest created engine
  106584. */
  106585. static get LastCreatedEngine(): Nullable<Engine>;
  106586. /**
  106587. * Gets the latest created scene
  106588. */
  106589. static get LastCreatedScene(): Nullable<Scene>;
  106590. /**
  106591. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  106592. * @param flag defines which part of the materials must be marked as dirty
  106593. * @param predicate defines a predicate used to filter which materials should be affected
  106594. */
  106595. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  106596. /**
  106597. * Method called to create the default loading screen.
  106598. * This can be overriden in your own app.
  106599. * @param canvas The rendering canvas element
  106600. * @returns The loading screen
  106601. */
  106602. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  106603. /**
  106604. * Method called to create the default rescale post process on each engine.
  106605. */
  106606. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  106607. /**
  106608. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  106609. **/
  106610. enableOfflineSupport: boolean;
  106611. /**
  106612. * 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)
  106613. **/
  106614. disableManifestCheck: boolean;
  106615. /**
  106616. * Gets the list of created scenes
  106617. */
  106618. scenes: Scene[];
  106619. /**
  106620. * Event raised when a new scene is created
  106621. */
  106622. onNewSceneAddedObservable: Observable<Scene>;
  106623. /**
  106624. * Gets the list of created postprocesses
  106625. */
  106626. postProcesses: PostProcess[];
  106627. /**
  106628. * Gets a boolean indicating if the pointer is currently locked
  106629. */
  106630. isPointerLock: boolean;
  106631. /**
  106632. * Observable event triggered each time the rendering canvas is resized
  106633. */
  106634. onResizeObservable: Observable<Engine>;
  106635. /**
  106636. * Observable event triggered each time the canvas loses focus
  106637. */
  106638. onCanvasBlurObservable: Observable<Engine>;
  106639. /**
  106640. * Observable event triggered each time the canvas gains focus
  106641. */
  106642. onCanvasFocusObservable: Observable<Engine>;
  106643. /**
  106644. * Observable event triggered each time the canvas receives pointerout event
  106645. */
  106646. onCanvasPointerOutObservable: Observable<PointerEvent>;
  106647. /**
  106648. * Observable raised when the engine begins a new frame
  106649. */
  106650. onBeginFrameObservable: Observable<Engine>;
  106651. /**
  106652. * If set, will be used to request the next animation frame for the render loop
  106653. */
  106654. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  106655. /**
  106656. * Observable raised when the engine ends the current frame
  106657. */
  106658. onEndFrameObservable: Observable<Engine>;
  106659. /**
  106660. * Observable raised when the engine is about to compile a shader
  106661. */
  106662. onBeforeShaderCompilationObservable: Observable<Engine>;
  106663. /**
  106664. * Observable raised when the engine has jsut compiled a shader
  106665. */
  106666. onAfterShaderCompilationObservable: Observable<Engine>;
  106667. /**
  106668. * Gets the audio engine
  106669. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106670. * @ignorenaming
  106671. */
  106672. static audioEngine: IAudioEngine;
  106673. /**
  106674. * Default AudioEngine factory responsible of creating the Audio Engine.
  106675. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  106676. */
  106677. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  106678. /**
  106679. * Default offline support factory responsible of creating a tool used to store data locally.
  106680. * By default, this will create a Database object if the workload has been embedded.
  106681. */
  106682. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  106683. private _loadingScreen;
  106684. private _pointerLockRequested;
  106685. private _dummyFramebuffer;
  106686. private _rescalePostProcess;
  106687. private _deterministicLockstep;
  106688. private _lockstepMaxSteps;
  106689. private _timeStep;
  106690. protected get _supportsHardwareTextureRescaling(): boolean;
  106691. private _fps;
  106692. private _deltaTime;
  106693. /** @hidden */
  106694. _drawCalls: PerfCounter;
  106695. /** 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 */
  106696. canvasTabIndex: number;
  106697. /**
  106698. * Turn this value on if you want to pause FPS computation when in background
  106699. */
  106700. disablePerformanceMonitorInBackground: boolean;
  106701. private _performanceMonitor;
  106702. /**
  106703. * Gets the performance monitor attached to this engine
  106704. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  106705. */
  106706. get performanceMonitor(): PerformanceMonitor;
  106707. private _onFocus;
  106708. private _onBlur;
  106709. private _onCanvasPointerOut;
  106710. private _onCanvasBlur;
  106711. private _onCanvasFocus;
  106712. private _onFullscreenChange;
  106713. private _onPointerLockChange;
  106714. /**
  106715. * Gets the HTML element used to attach event listeners
  106716. * @returns a HTML element
  106717. */
  106718. getInputElement(): Nullable<HTMLElement>;
  106719. /**
  106720. * Creates a new engine
  106721. * @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
  106722. * @param antialias defines enable antialiasing (default: false)
  106723. * @param options defines further options to be sent to the getContext() function
  106724. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  106725. */
  106726. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  106727. /**
  106728. * Gets current aspect ratio
  106729. * @param viewportOwner defines the camera to use to get the aspect ratio
  106730. * @param useScreen defines if screen size must be used (or the current render target if any)
  106731. * @returns a number defining the aspect ratio
  106732. */
  106733. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  106734. /**
  106735. * Gets current screen aspect ratio
  106736. * @returns a number defining the aspect ratio
  106737. */
  106738. getScreenAspectRatio(): number;
  106739. /**
  106740. * Gets the client rect of the HTML canvas attached with the current webGL context
  106741. * @returns a client rectanglee
  106742. */
  106743. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  106744. /**
  106745. * Gets the client rect of the HTML element used for events
  106746. * @returns a client rectanglee
  106747. */
  106748. getInputElementClientRect(): Nullable<ClientRect>;
  106749. /**
  106750. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  106751. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106752. * @returns true if engine is in deterministic lock step mode
  106753. */
  106754. isDeterministicLockStep(): boolean;
  106755. /**
  106756. * Gets the max steps when engine is running in deterministic lock step
  106757. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106758. * @returns the max steps
  106759. */
  106760. getLockstepMaxSteps(): number;
  106761. /**
  106762. * Returns the time in ms between steps when using deterministic lock step.
  106763. * @returns time step in (ms)
  106764. */
  106765. getTimeStep(): number;
  106766. /**
  106767. * Force the mipmap generation for the given render target texture
  106768. * @param texture defines the render target texture to use
  106769. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  106770. */
  106771. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  106772. /** States */
  106773. /**
  106774. * Set various states to the webGL context
  106775. * @param culling defines backface culling state
  106776. * @param zOffset defines the value to apply to zOffset (0 by default)
  106777. * @param force defines if states must be applied even if cache is up to date
  106778. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  106779. */
  106780. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  106781. /**
  106782. * Set the z offset to apply to current rendering
  106783. * @param value defines the offset to apply
  106784. */
  106785. setZOffset(value: number): void;
  106786. /**
  106787. * Gets the current value of the zOffset
  106788. * @returns the current zOffset state
  106789. */
  106790. getZOffset(): number;
  106791. /**
  106792. * Enable or disable depth buffering
  106793. * @param enable defines the state to set
  106794. */
  106795. setDepthBuffer(enable: boolean): void;
  106796. /**
  106797. * Gets a boolean indicating if depth writing is enabled
  106798. * @returns the current depth writing state
  106799. */
  106800. getDepthWrite(): boolean;
  106801. /**
  106802. * Enable or disable depth writing
  106803. * @param enable defines the state to set
  106804. */
  106805. setDepthWrite(enable: boolean): void;
  106806. /**
  106807. * Gets a boolean indicating if stencil buffer is enabled
  106808. * @returns the current stencil buffer state
  106809. */
  106810. getStencilBuffer(): boolean;
  106811. /**
  106812. * Enable or disable the stencil buffer
  106813. * @param enable defines if the stencil buffer must be enabled or disabled
  106814. */
  106815. setStencilBuffer(enable: boolean): void;
  106816. /**
  106817. * Gets the current stencil mask
  106818. * @returns a number defining the new stencil mask to use
  106819. */
  106820. getStencilMask(): number;
  106821. /**
  106822. * Sets the current stencil mask
  106823. * @param mask defines the new stencil mask to use
  106824. */
  106825. setStencilMask(mask: number): void;
  106826. /**
  106827. * Gets the current stencil function
  106828. * @returns a number defining the stencil function to use
  106829. */
  106830. getStencilFunction(): number;
  106831. /**
  106832. * Gets the current stencil reference value
  106833. * @returns a number defining the stencil reference value to use
  106834. */
  106835. getStencilFunctionReference(): number;
  106836. /**
  106837. * Gets the current stencil mask
  106838. * @returns a number defining the stencil mask to use
  106839. */
  106840. getStencilFunctionMask(): number;
  106841. /**
  106842. * Sets the current stencil function
  106843. * @param stencilFunc defines the new stencil function to use
  106844. */
  106845. setStencilFunction(stencilFunc: number): void;
  106846. /**
  106847. * Sets the current stencil reference
  106848. * @param reference defines the new stencil reference to use
  106849. */
  106850. setStencilFunctionReference(reference: number): void;
  106851. /**
  106852. * Sets the current stencil mask
  106853. * @param mask defines the new stencil mask to use
  106854. */
  106855. setStencilFunctionMask(mask: number): void;
  106856. /**
  106857. * Gets the current stencil operation when stencil fails
  106858. * @returns a number defining stencil operation to use when stencil fails
  106859. */
  106860. getStencilOperationFail(): number;
  106861. /**
  106862. * Gets the current stencil operation when depth fails
  106863. * @returns a number defining stencil operation to use when depth fails
  106864. */
  106865. getStencilOperationDepthFail(): number;
  106866. /**
  106867. * Gets the current stencil operation when stencil passes
  106868. * @returns a number defining stencil operation to use when stencil passes
  106869. */
  106870. getStencilOperationPass(): number;
  106871. /**
  106872. * Sets the stencil operation to use when stencil fails
  106873. * @param operation defines the stencil operation to use when stencil fails
  106874. */
  106875. setStencilOperationFail(operation: number): void;
  106876. /**
  106877. * Sets the stencil operation to use when depth fails
  106878. * @param operation defines the stencil operation to use when depth fails
  106879. */
  106880. setStencilOperationDepthFail(operation: number): void;
  106881. /**
  106882. * Sets the stencil operation to use when stencil passes
  106883. * @param operation defines the stencil operation to use when stencil passes
  106884. */
  106885. setStencilOperationPass(operation: number): void;
  106886. /**
  106887. * Sets a boolean indicating if the dithering state is enabled or disabled
  106888. * @param value defines the dithering state
  106889. */
  106890. setDitheringState(value: boolean): void;
  106891. /**
  106892. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  106893. * @param value defines the rasterizer state
  106894. */
  106895. setRasterizerState(value: boolean): void;
  106896. /**
  106897. * Gets the current depth function
  106898. * @returns a number defining the depth function
  106899. */
  106900. getDepthFunction(): Nullable<number>;
  106901. /**
  106902. * Sets the current depth function
  106903. * @param depthFunc defines the function to use
  106904. */
  106905. setDepthFunction(depthFunc: number): void;
  106906. /**
  106907. * Sets the current depth function to GREATER
  106908. */
  106909. setDepthFunctionToGreater(): void;
  106910. /**
  106911. * Sets the current depth function to GEQUAL
  106912. */
  106913. setDepthFunctionToGreaterOrEqual(): void;
  106914. /**
  106915. * Sets the current depth function to LESS
  106916. */
  106917. setDepthFunctionToLess(): void;
  106918. /**
  106919. * Sets the current depth function to LEQUAL
  106920. */
  106921. setDepthFunctionToLessOrEqual(): void;
  106922. private _cachedStencilBuffer;
  106923. private _cachedStencilFunction;
  106924. private _cachedStencilMask;
  106925. private _cachedStencilOperationPass;
  106926. private _cachedStencilOperationFail;
  106927. private _cachedStencilOperationDepthFail;
  106928. private _cachedStencilReference;
  106929. /**
  106930. * Caches the the state of the stencil buffer
  106931. */
  106932. cacheStencilState(): void;
  106933. /**
  106934. * Restores the state of the stencil buffer
  106935. */
  106936. restoreStencilState(): void;
  106937. /**
  106938. * Directly set the WebGL Viewport
  106939. * @param x defines the x coordinate of the viewport (in screen space)
  106940. * @param y defines the y coordinate of the viewport (in screen space)
  106941. * @param width defines the width of the viewport (in screen space)
  106942. * @param height defines the height of the viewport (in screen space)
  106943. * @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
  106944. */
  106945. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  106946. /**
  106947. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  106948. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  106949. * @param y defines the y-coordinate of the corner of the clear rectangle
  106950. * @param width defines the width of the clear rectangle
  106951. * @param height defines the height of the clear rectangle
  106952. * @param clearColor defines the clear color
  106953. */
  106954. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  106955. /**
  106956. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  106957. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  106958. * @param y defines the y-coordinate of the corner of the clear rectangle
  106959. * @param width defines the width of the clear rectangle
  106960. * @param height defines the height of the clear rectangle
  106961. */
  106962. enableScissor(x: number, y: number, width: number, height: number): void;
  106963. /**
  106964. * Disable previously set scissor test rectangle
  106965. */
  106966. disableScissor(): void;
  106967. protected _reportDrawCall(): void;
  106968. /**
  106969. * Initializes a webVR display and starts listening to display change events
  106970. * The onVRDisplayChangedObservable will be notified upon these changes
  106971. * @returns The onVRDisplayChangedObservable
  106972. */
  106973. initWebVR(): Observable<IDisplayChangedEventArgs>;
  106974. /** @hidden */
  106975. _prepareVRComponent(): void;
  106976. /** @hidden */
  106977. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  106978. /** @hidden */
  106979. _submitVRFrame(): void;
  106980. /**
  106981. * Call this function to leave webVR mode
  106982. * Will do nothing if webVR is not supported or if there is no webVR device
  106983. * @see http://doc.babylonjs.com/how_to/webvr_camera
  106984. */
  106985. disableVR(): void;
  106986. /**
  106987. * Gets a boolean indicating that the system is in VR mode and is presenting
  106988. * @returns true if VR mode is engaged
  106989. */
  106990. isVRPresenting(): boolean;
  106991. /** @hidden */
  106992. _requestVRFrame(): void;
  106993. /** @hidden */
  106994. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  106995. /**
  106996. * Gets the source code of the vertex shader associated with a specific webGL program
  106997. * @param program defines the program to use
  106998. * @returns a string containing the source code of the vertex shader associated with the program
  106999. */
  107000. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  107001. /**
  107002. * Gets the source code of the fragment shader associated with a specific webGL program
  107003. * @param program defines the program to use
  107004. * @returns a string containing the source code of the fragment shader associated with the program
  107005. */
  107006. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  107007. /**
  107008. * Sets a depth stencil texture from a render target to the according uniform.
  107009. * @param channel The texture channel
  107010. * @param uniform The uniform to set
  107011. * @param texture The render target texture containing the depth stencil texture to apply
  107012. */
  107013. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  107014. /**
  107015. * Sets a texture to the webGL context from a postprocess
  107016. * @param channel defines the channel to use
  107017. * @param postProcess defines the source postprocess
  107018. */
  107019. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  107020. /**
  107021. * Binds the output of the passed in post process to the texture channel specified
  107022. * @param channel The channel the texture should be bound to
  107023. * @param postProcess The post process which's output should be bound
  107024. */
  107025. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  107026. /** @hidden */
  107027. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  107028. protected _rebuildBuffers(): void;
  107029. /** @hidden */
  107030. _renderFrame(): void;
  107031. _renderLoop(): void;
  107032. /** @hidden */
  107033. _renderViews(): boolean;
  107034. /**
  107035. * Toggle full screen mode
  107036. * @param requestPointerLock defines if a pointer lock should be requested from the user
  107037. */
  107038. switchFullscreen(requestPointerLock: boolean): void;
  107039. /**
  107040. * Enters full screen mode
  107041. * @param requestPointerLock defines if a pointer lock should be requested from the user
  107042. */
  107043. enterFullscreen(requestPointerLock: boolean): void;
  107044. /**
  107045. * Exits full screen mode
  107046. */
  107047. exitFullscreen(): void;
  107048. /**
  107049. * Enters Pointerlock mode
  107050. */
  107051. enterPointerlock(): void;
  107052. /**
  107053. * Exits Pointerlock mode
  107054. */
  107055. exitPointerlock(): void;
  107056. /**
  107057. * Begin a new frame
  107058. */
  107059. beginFrame(): void;
  107060. /**
  107061. * Enf the current frame
  107062. */
  107063. endFrame(): void;
  107064. resize(): void;
  107065. /**
  107066. * Set the compressed texture format to use, based on the formats you have, and the formats
  107067. * supported by the hardware / browser.
  107068. *
  107069. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  107070. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  107071. * to API arguments needed to compressed textures. This puts the burden on the container
  107072. * generator to house the arcane code for determining these for current & future formats.
  107073. *
  107074. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  107075. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  107076. *
  107077. * Note: The result of this call is not taken into account when a texture is base64.
  107078. *
  107079. * @param formatsAvailable defines the list of those format families you have created
  107080. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  107081. *
  107082. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  107083. * @returns The extension selected.
  107084. */
  107085. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  107086. /**
  107087. * Set the compressed texture extensions or file names to skip.
  107088. *
  107089. * @param skippedFiles defines the list of those texture files you want to skip
  107090. * Example: [".dds", ".env", "myfile.png"]
  107091. */
  107092. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  107093. /**
  107094. * Force a specific size of the canvas
  107095. * @param width defines the new canvas' width
  107096. * @param height defines the new canvas' height
  107097. */
  107098. setSize(width: number, height: number): void;
  107099. /**
  107100. * Updates a dynamic vertex buffer.
  107101. * @param vertexBuffer the vertex buffer to update
  107102. * @param data the data used to update the vertex buffer
  107103. * @param byteOffset the byte offset of the data
  107104. * @param byteLength the byte length of the data
  107105. */
  107106. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  107107. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  107108. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  107109. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  107110. _releaseTexture(texture: InternalTexture): void;
  107111. /**
  107112. * @hidden
  107113. * Rescales a texture
  107114. * @param source input texutre
  107115. * @param destination destination texture
  107116. * @param scene scene to use to render the resize
  107117. * @param internalFormat format to use when resizing
  107118. * @param onComplete callback to be called when resize has completed
  107119. */
  107120. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  107121. /**
  107122. * Gets the current framerate
  107123. * @returns a number representing the framerate
  107124. */
  107125. getFps(): number;
  107126. /**
  107127. * Gets the time spent between current and previous frame
  107128. * @returns a number representing the delta time in ms
  107129. */
  107130. getDeltaTime(): number;
  107131. private _measureFps;
  107132. /** @hidden */
  107133. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  107134. /**
  107135. * Update a dynamic index buffer
  107136. * @param indexBuffer defines the target index buffer
  107137. * @param indices defines the data to update
  107138. * @param offset defines the offset in the target index buffer where update should start
  107139. */
  107140. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  107141. /**
  107142. * Updates the sample count of a render target texture
  107143. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  107144. * @param texture defines the texture to update
  107145. * @param samples defines the sample count to set
  107146. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  107147. */
  107148. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  107149. /**
  107150. * Updates a depth texture Comparison Mode and Function.
  107151. * If the comparison Function is equal to 0, the mode will be set to none.
  107152. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  107153. * @param texture The texture to set the comparison function for
  107154. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  107155. */
  107156. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  107157. /**
  107158. * Creates a webGL buffer to use with instanciation
  107159. * @param capacity defines the size of the buffer
  107160. * @returns the webGL buffer
  107161. */
  107162. createInstancesBuffer(capacity: number): DataBuffer;
  107163. /**
  107164. * Delete a webGL buffer used with instanciation
  107165. * @param buffer defines the webGL buffer to delete
  107166. */
  107167. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  107168. private _clientWaitAsync;
  107169. /** @hidden */
  107170. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  107171. /** @hidden */
  107172. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  107173. dispose(): void;
  107174. private _disableTouchAction;
  107175. /**
  107176. * Display the loading screen
  107177. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107178. */
  107179. displayLoadingUI(): void;
  107180. /**
  107181. * Hide the loading screen
  107182. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107183. */
  107184. hideLoadingUI(): void;
  107185. /**
  107186. * Gets the current loading screen object
  107187. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107188. */
  107189. get loadingScreen(): ILoadingScreen;
  107190. /**
  107191. * Sets the current loading screen object
  107192. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107193. */
  107194. set loadingScreen(loadingScreen: ILoadingScreen);
  107195. /**
  107196. * Sets the current loading screen text
  107197. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107198. */
  107199. set loadingUIText(text: string);
  107200. /**
  107201. * Sets the current loading screen background color
  107202. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107203. */
  107204. set loadingUIBackgroundColor(color: string);
  107205. /** Pointerlock and fullscreen */
  107206. /**
  107207. * Ask the browser to promote the current element to pointerlock mode
  107208. * @param element defines the DOM element to promote
  107209. */
  107210. static _RequestPointerlock(element: HTMLElement): void;
  107211. /**
  107212. * Asks the browser to exit pointerlock mode
  107213. */
  107214. static _ExitPointerlock(): void;
  107215. /**
  107216. * Ask the browser to promote the current element to fullscreen rendering mode
  107217. * @param element defines the DOM element to promote
  107218. */
  107219. static _RequestFullscreen(element: HTMLElement): void;
  107220. /**
  107221. * Asks the browser to exit fullscreen mode
  107222. */
  107223. static _ExitFullscreen(): void;
  107224. }
  107225. }
  107226. declare module BABYLON {
  107227. /**
  107228. * The engine store class is responsible to hold all the instances of Engine and Scene created
  107229. * during the life time of the application.
  107230. */
  107231. export class EngineStore {
  107232. /** Gets the list of created engines */
  107233. static Instances: Engine[];
  107234. /** @hidden */
  107235. static _LastCreatedScene: Nullable<Scene>;
  107236. /**
  107237. * Gets the latest created engine
  107238. */
  107239. static get LastCreatedEngine(): Nullable<Engine>;
  107240. /**
  107241. * Gets the latest created scene
  107242. */
  107243. static get LastCreatedScene(): Nullable<Scene>;
  107244. /**
  107245. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  107246. * @ignorenaming
  107247. */
  107248. static UseFallbackTexture: boolean;
  107249. /**
  107250. * Texture content used if a texture cannot loaded
  107251. * @ignorenaming
  107252. */
  107253. static FallbackTexture: string;
  107254. }
  107255. }
  107256. declare module BABYLON {
  107257. /**
  107258. * Helper class that provides a small promise polyfill
  107259. */
  107260. export class PromisePolyfill {
  107261. /**
  107262. * Static function used to check if the polyfill is required
  107263. * If this is the case then the function will inject the polyfill to window.Promise
  107264. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  107265. */
  107266. static Apply(force?: boolean): void;
  107267. }
  107268. }
  107269. declare module BABYLON {
  107270. /**
  107271. * Interface for screenshot methods with describe argument called `size` as object with options
  107272. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  107273. */
  107274. export interface IScreenshotSize {
  107275. /**
  107276. * number in pixels for canvas height
  107277. */
  107278. height?: number;
  107279. /**
  107280. * multiplier allowing render at a higher or lower resolution
  107281. * If value is defined then height and width will be ignored and taken from camera
  107282. */
  107283. precision?: number;
  107284. /**
  107285. * number in pixels for canvas width
  107286. */
  107287. width?: number;
  107288. }
  107289. }
  107290. declare module BABYLON {
  107291. interface IColor4Like {
  107292. r: float;
  107293. g: float;
  107294. b: float;
  107295. a: float;
  107296. }
  107297. /**
  107298. * Class containing a set of static utilities functions
  107299. */
  107300. export class Tools {
  107301. /**
  107302. * Gets or sets the base URL to use to load assets
  107303. */
  107304. static get BaseUrl(): string;
  107305. static set BaseUrl(value: string);
  107306. /**
  107307. * Enable/Disable Custom HTTP Request Headers globally.
  107308. * default = false
  107309. * @see CustomRequestHeaders
  107310. */
  107311. static UseCustomRequestHeaders: boolean;
  107312. /**
  107313. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  107314. * i.e. when loading files, where the server/service expects an Authorization header
  107315. */
  107316. static CustomRequestHeaders: {
  107317. [key: string]: string;
  107318. };
  107319. /**
  107320. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  107321. */
  107322. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  107323. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  107324. /**
  107325. * Default behaviour for cors in the application.
  107326. * It can be a string if the expected behavior is identical in the entire app.
  107327. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  107328. */
  107329. static CorsBehavior: string | ((url: string | string[]) => string);
  107330. /**
  107331. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  107332. * @ignorenaming
  107333. */
  107334. static get UseFallbackTexture(): boolean;
  107335. static set UseFallbackTexture(value: boolean);
  107336. /**
  107337. * Use this object to register external classes like custom textures or material
  107338. * to allow the laoders to instantiate them
  107339. */
  107340. static get RegisteredExternalClasses(): {
  107341. [key: string]: Object;
  107342. };
  107343. static set RegisteredExternalClasses(classes: {
  107344. [key: string]: Object;
  107345. });
  107346. /**
  107347. * Texture content used if a texture cannot loaded
  107348. * @ignorenaming
  107349. */
  107350. static get fallbackTexture(): string;
  107351. static set fallbackTexture(value: string);
  107352. /**
  107353. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  107354. * @param u defines the coordinate on X axis
  107355. * @param v defines the coordinate on Y axis
  107356. * @param width defines the width of the source data
  107357. * @param height defines the height of the source data
  107358. * @param pixels defines the source byte array
  107359. * @param color defines the output color
  107360. */
  107361. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  107362. /**
  107363. * Interpolates between a and b via alpha
  107364. * @param a The lower value (returned when alpha = 0)
  107365. * @param b The upper value (returned when alpha = 1)
  107366. * @param alpha The interpolation-factor
  107367. * @return The mixed value
  107368. */
  107369. static Mix(a: number, b: number, alpha: number): number;
  107370. /**
  107371. * Tries to instantiate a new object from a given class name
  107372. * @param className defines the class name to instantiate
  107373. * @returns the new object or null if the system was not able to do the instantiation
  107374. */
  107375. static Instantiate(className: string): any;
  107376. /**
  107377. * Provides a slice function that will work even on IE
  107378. * @param data defines the array to slice
  107379. * @param start defines the start of the data (optional)
  107380. * @param end defines the end of the data (optional)
  107381. * @returns the new sliced array
  107382. */
  107383. static Slice<T>(data: T, start?: number, end?: number): T;
  107384. /**
  107385. * Polyfill for setImmediate
  107386. * @param action defines the action to execute after the current execution block
  107387. */
  107388. static SetImmediate(action: () => void): void;
  107389. /**
  107390. * Function indicating if a number is an exponent of 2
  107391. * @param value defines the value to test
  107392. * @returns true if the value is an exponent of 2
  107393. */
  107394. static IsExponentOfTwo(value: number): boolean;
  107395. private static _tmpFloatArray;
  107396. /**
  107397. * Returns the nearest 32-bit single precision float representation of a Number
  107398. * @param value A Number. If the parameter is of a different type, it will get converted
  107399. * to a number or to NaN if it cannot be converted
  107400. * @returns number
  107401. */
  107402. static FloatRound(value: number): number;
  107403. /**
  107404. * Extracts the filename from a path
  107405. * @param path defines the path to use
  107406. * @returns the filename
  107407. */
  107408. static GetFilename(path: string): string;
  107409. /**
  107410. * Extracts the "folder" part of a path (everything before the filename).
  107411. * @param uri The URI to extract the info from
  107412. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  107413. * @returns The "folder" part of the path
  107414. */
  107415. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  107416. /**
  107417. * Extracts text content from a DOM element hierarchy
  107418. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  107419. */
  107420. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  107421. /**
  107422. * Convert an angle in radians to degrees
  107423. * @param angle defines the angle to convert
  107424. * @returns the angle in degrees
  107425. */
  107426. static ToDegrees(angle: number): number;
  107427. /**
  107428. * Convert an angle in degrees to radians
  107429. * @param angle defines the angle to convert
  107430. * @returns the angle in radians
  107431. */
  107432. static ToRadians(angle: number): number;
  107433. /**
  107434. * Returns an array if obj is not an array
  107435. * @param obj defines the object to evaluate as an array
  107436. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  107437. * @returns either obj directly if obj is an array or a new array containing obj
  107438. */
  107439. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  107440. /**
  107441. * Gets the pointer prefix to use
  107442. * @returns "pointer" if touch is enabled. Else returns "mouse"
  107443. */
  107444. static GetPointerPrefix(): string;
  107445. /**
  107446. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  107447. * @param url define the url we are trying
  107448. * @param element define the dom element where to configure the cors policy
  107449. */
  107450. static SetCorsBehavior(url: string | string[], element: {
  107451. crossOrigin: string | null;
  107452. }): void;
  107453. /**
  107454. * Removes unwanted characters from an url
  107455. * @param url defines the url to clean
  107456. * @returns the cleaned url
  107457. */
  107458. static CleanUrl(url: string): string;
  107459. /**
  107460. * Gets or sets a function used to pre-process url before using them to load assets
  107461. */
  107462. static get PreprocessUrl(): (url: string) => string;
  107463. static set PreprocessUrl(processor: (url: string) => string);
  107464. /**
  107465. * Loads an image as an HTMLImageElement.
  107466. * @param input url string, ArrayBuffer, or Blob to load
  107467. * @param onLoad callback called when the image successfully loads
  107468. * @param onError callback called when the image fails to load
  107469. * @param offlineProvider offline provider for caching
  107470. * @param mimeType optional mime type
  107471. * @returns the HTMLImageElement of the loaded image
  107472. */
  107473. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  107474. /**
  107475. * Loads a file from a url
  107476. * @param url url string, ArrayBuffer, or Blob to load
  107477. * @param onSuccess callback called when the file successfully loads
  107478. * @param onProgress callback called while file is loading (if the server supports this mode)
  107479. * @param offlineProvider defines the offline provider for caching
  107480. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  107481. * @param onError callback called when the file fails to load
  107482. * @returns a file request object
  107483. */
  107484. 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;
  107485. /**
  107486. * Loads a file from a url
  107487. * @param url the file url to load
  107488. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  107489. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  107490. */
  107491. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  107492. /**
  107493. * Load a script (identified by an url). When the url returns, the
  107494. * content of this file is added into a new script element, attached to the DOM (body element)
  107495. * @param scriptUrl defines the url of the script to laod
  107496. * @param onSuccess defines the callback called when the script is loaded
  107497. * @param onError defines the callback to call if an error occurs
  107498. * @param scriptId defines the id of the script element
  107499. */
  107500. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  107501. /**
  107502. * Load an asynchronous script (identified by an url). When the url returns, the
  107503. * content of this file is added into a new script element, attached to the DOM (body element)
  107504. * @param scriptUrl defines the url of the script to laod
  107505. * @param scriptId defines the id of the script element
  107506. * @returns a promise request object
  107507. */
  107508. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  107509. /**
  107510. * Loads a file from a blob
  107511. * @param fileToLoad defines the blob to use
  107512. * @param callback defines the callback to call when data is loaded
  107513. * @param progressCallback defines the callback to call during loading process
  107514. * @returns a file request object
  107515. */
  107516. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  107517. /**
  107518. * Reads a file from a File object
  107519. * @param file defines the file to load
  107520. * @param onSuccess defines the callback to call when data is loaded
  107521. * @param onProgress defines the callback to call during loading process
  107522. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  107523. * @param onError defines the callback to call when an error occurs
  107524. * @returns a file request object
  107525. */
  107526. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  107527. /**
  107528. * Creates a data url from a given string content
  107529. * @param content defines the content to convert
  107530. * @returns the new data url link
  107531. */
  107532. static FileAsURL(content: string): string;
  107533. /**
  107534. * Format the given number to a specific decimal format
  107535. * @param value defines the number to format
  107536. * @param decimals defines the number of decimals to use
  107537. * @returns the formatted string
  107538. */
  107539. static Format(value: number, decimals?: number): string;
  107540. /**
  107541. * Tries to copy an object by duplicating every property
  107542. * @param source defines the source object
  107543. * @param destination defines the target object
  107544. * @param doNotCopyList defines a list of properties to avoid
  107545. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  107546. */
  107547. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  107548. /**
  107549. * Gets a boolean indicating if the given object has no own property
  107550. * @param obj defines the object to test
  107551. * @returns true if object has no own property
  107552. */
  107553. static IsEmpty(obj: any): boolean;
  107554. /**
  107555. * Function used to register events at window level
  107556. * @param windowElement defines the Window object to use
  107557. * @param events defines the events to register
  107558. */
  107559. static RegisterTopRootEvents(windowElement: Window, events: {
  107560. name: string;
  107561. handler: Nullable<(e: FocusEvent) => any>;
  107562. }[]): void;
  107563. /**
  107564. * Function used to unregister events from window level
  107565. * @param windowElement defines the Window object to use
  107566. * @param events defines the events to unregister
  107567. */
  107568. static UnregisterTopRootEvents(windowElement: Window, events: {
  107569. name: string;
  107570. handler: Nullable<(e: FocusEvent) => any>;
  107571. }[]): void;
  107572. /**
  107573. * @ignore
  107574. */
  107575. static _ScreenshotCanvas: HTMLCanvasElement;
  107576. /**
  107577. * Dumps the current bound framebuffer
  107578. * @param width defines the rendering width
  107579. * @param height defines the rendering height
  107580. * @param engine defines the hosting engine
  107581. * @param successCallback defines the callback triggered once the data are available
  107582. * @param mimeType defines the mime type of the result
  107583. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  107584. */
  107585. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  107586. /**
  107587. * Converts the canvas data to blob.
  107588. * This acts as a polyfill for browsers not supporting the to blob function.
  107589. * @param canvas Defines the canvas to extract the data from
  107590. * @param successCallback Defines the callback triggered once the data are available
  107591. * @param mimeType Defines the mime type of the result
  107592. */
  107593. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  107594. /**
  107595. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  107596. * @param successCallback defines the callback triggered once the data are available
  107597. * @param mimeType defines the mime type of the result
  107598. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  107599. */
  107600. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  107601. /**
  107602. * Downloads a blob in the browser
  107603. * @param blob defines the blob to download
  107604. * @param fileName defines the name of the downloaded file
  107605. */
  107606. static Download(blob: Blob, fileName: string): void;
  107607. /**
  107608. * Captures a screenshot of the current rendering
  107609. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107610. * @param engine defines the rendering engine
  107611. * @param camera defines the source camera
  107612. * @param size This parameter can be set to a single number or to an object with the
  107613. * following (optional) properties: precision, width, height. If a single number is passed,
  107614. * it will be used for both width and height. If an object is passed, the screenshot size
  107615. * will be derived from the parameters. The precision property is a multiplier allowing
  107616. * rendering at a higher or lower resolution
  107617. * @param successCallback defines the callback receives a single parameter which contains the
  107618. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  107619. * src parameter of an <img> to display it
  107620. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  107621. * Check your browser for supported MIME types
  107622. */
  107623. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  107624. /**
  107625. * Captures a screenshot of the current rendering
  107626. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107627. * @param engine defines the rendering engine
  107628. * @param camera defines the source camera
  107629. * @param size This parameter can be set to a single number or to an object with the
  107630. * following (optional) properties: precision, width, height. If a single number is passed,
  107631. * it will be used for both width and height. If an object is passed, the screenshot size
  107632. * will be derived from the parameters. The precision property is a multiplier allowing
  107633. * rendering at a higher or lower resolution
  107634. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  107635. * Check your browser for supported MIME types
  107636. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  107637. * to the src parameter of an <img> to display it
  107638. */
  107639. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  107640. /**
  107641. * Generates an image screenshot from the specified camera.
  107642. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107643. * @param engine The engine to use for rendering
  107644. * @param camera The camera to use for rendering
  107645. * @param size This parameter can be set to a single number or to an object with the
  107646. * following (optional) properties: precision, width, height. If a single number is passed,
  107647. * it will be used for both width and height. If an object is passed, the screenshot size
  107648. * will be derived from the parameters. The precision property is a multiplier allowing
  107649. * rendering at a higher or lower resolution
  107650. * @param successCallback The callback receives a single parameter which contains the
  107651. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  107652. * src parameter of an <img> to display it
  107653. * @param mimeType The MIME type of the screenshot image (default: image/png).
  107654. * Check your browser for supported MIME types
  107655. * @param samples Texture samples (default: 1)
  107656. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  107657. * @param fileName A name for for the downloaded file.
  107658. */
  107659. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  107660. /**
  107661. * Generates an image screenshot from the specified camera.
  107662. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107663. * @param engine The engine to use for rendering
  107664. * @param camera The camera to use for rendering
  107665. * @param size This parameter can be set to a single number or to an object with the
  107666. * following (optional) properties: precision, width, height. If a single number is passed,
  107667. * it will be used for both width and height. If an object is passed, the screenshot size
  107668. * will be derived from the parameters. The precision property is a multiplier allowing
  107669. * rendering at a higher or lower resolution
  107670. * @param mimeType The MIME type of the screenshot image (default: image/png).
  107671. * Check your browser for supported MIME types
  107672. * @param samples Texture samples (default: 1)
  107673. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  107674. * @param fileName A name for for the downloaded file.
  107675. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  107676. * to the src parameter of an <img> to display it
  107677. */
  107678. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  107679. /**
  107680. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  107681. * Be aware Math.random() could cause collisions, but:
  107682. * "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"
  107683. * @returns a pseudo random id
  107684. */
  107685. static RandomId(): string;
  107686. /**
  107687. * Test if the given uri is a base64 string
  107688. * @param uri The uri to test
  107689. * @return True if the uri is a base64 string or false otherwise
  107690. */
  107691. static IsBase64(uri: string): boolean;
  107692. /**
  107693. * Decode the given base64 uri.
  107694. * @param uri The uri to decode
  107695. * @return The decoded base64 data.
  107696. */
  107697. static DecodeBase64(uri: string): ArrayBuffer;
  107698. /**
  107699. * Gets the absolute url.
  107700. * @param url the input url
  107701. * @return the absolute url
  107702. */
  107703. static GetAbsoluteUrl(url: string): string;
  107704. /**
  107705. * No log
  107706. */
  107707. static readonly NoneLogLevel: number;
  107708. /**
  107709. * Only message logs
  107710. */
  107711. static readonly MessageLogLevel: number;
  107712. /**
  107713. * Only warning logs
  107714. */
  107715. static readonly WarningLogLevel: number;
  107716. /**
  107717. * Only error logs
  107718. */
  107719. static readonly ErrorLogLevel: number;
  107720. /**
  107721. * All logs
  107722. */
  107723. static readonly AllLogLevel: number;
  107724. /**
  107725. * Gets a value indicating the number of loading errors
  107726. * @ignorenaming
  107727. */
  107728. static get errorsCount(): number;
  107729. /**
  107730. * Callback called when a new log is added
  107731. */
  107732. static OnNewCacheEntry: (entry: string) => void;
  107733. /**
  107734. * Log a message to the console
  107735. * @param message defines the message to log
  107736. */
  107737. static Log(message: string): void;
  107738. /**
  107739. * Write a warning message to the console
  107740. * @param message defines the message to log
  107741. */
  107742. static Warn(message: string): void;
  107743. /**
  107744. * Write an error message to the console
  107745. * @param message defines the message to log
  107746. */
  107747. static Error(message: string): void;
  107748. /**
  107749. * Gets current log cache (list of logs)
  107750. */
  107751. static get LogCache(): string;
  107752. /**
  107753. * Clears the log cache
  107754. */
  107755. static ClearLogCache(): void;
  107756. /**
  107757. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  107758. */
  107759. static set LogLevels(level: number);
  107760. /**
  107761. * Checks if the window object exists
  107762. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  107763. */
  107764. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  107765. /**
  107766. * No performance log
  107767. */
  107768. static readonly PerformanceNoneLogLevel: number;
  107769. /**
  107770. * Use user marks to log performance
  107771. */
  107772. static readonly PerformanceUserMarkLogLevel: number;
  107773. /**
  107774. * Log performance to the console
  107775. */
  107776. static readonly PerformanceConsoleLogLevel: number;
  107777. private static _performance;
  107778. /**
  107779. * Sets the current performance log level
  107780. */
  107781. static set PerformanceLogLevel(level: number);
  107782. private static _StartPerformanceCounterDisabled;
  107783. private static _EndPerformanceCounterDisabled;
  107784. private static _StartUserMark;
  107785. private static _EndUserMark;
  107786. private static _StartPerformanceConsole;
  107787. private static _EndPerformanceConsole;
  107788. /**
  107789. * Starts a performance counter
  107790. */
  107791. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  107792. /**
  107793. * Ends a specific performance coutner
  107794. */
  107795. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  107796. /**
  107797. * Gets either window.performance.now() if supported or Date.now() else
  107798. */
  107799. static get Now(): number;
  107800. /**
  107801. * This method will return the name of the class used to create the instance of the given object.
  107802. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  107803. * @param object the object to get the class name from
  107804. * @param isType defines if the object is actually a type
  107805. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  107806. */
  107807. static GetClassName(object: any, isType?: boolean): string;
  107808. /**
  107809. * Gets the first element of an array satisfying a given predicate
  107810. * @param array defines the array to browse
  107811. * @param predicate defines the predicate to use
  107812. * @returns null if not found or the element
  107813. */
  107814. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  107815. /**
  107816. * This method will return the name of the full name of the class, including its owning module (if any).
  107817. * 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).
  107818. * @param object the object to get the class name from
  107819. * @param isType defines if the object is actually a type
  107820. * @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.
  107821. * @ignorenaming
  107822. */
  107823. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  107824. /**
  107825. * Returns a promise that resolves after the given amount of time.
  107826. * @param delay Number of milliseconds to delay
  107827. * @returns Promise that resolves after the given amount of time
  107828. */
  107829. static DelayAsync(delay: number): Promise<void>;
  107830. /**
  107831. * Utility function to detect if the current user agent is Safari
  107832. * @returns whether or not the current user agent is safari
  107833. */
  107834. static IsSafari(): boolean;
  107835. }
  107836. /**
  107837. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  107838. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  107839. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  107840. * @param name The name of the class, case should be preserved
  107841. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  107842. */
  107843. export function className(name: string, module?: string): (target: Object) => void;
  107844. /**
  107845. * An implementation of a loop for asynchronous functions.
  107846. */
  107847. export class AsyncLoop {
  107848. /**
  107849. * Defines the number of iterations for the loop
  107850. */
  107851. iterations: number;
  107852. /**
  107853. * Defines the current index of the loop.
  107854. */
  107855. index: number;
  107856. private _done;
  107857. private _fn;
  107858. private _successCallback;
  107859. /**
  107860. * Constructor.
  107861. * @param iterations the number of iterations.
  107862. * @param func the function to run each iteration
  107863. * @param successCallback the callback that will be called upon succesful execution
  107864. * @param offset starting offset.
  107865. */
  107866. constructor(
  107867. /**
  107868. * Defines the number of iterations for the loop
  107869. */
  107870. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  107871. /**
  107872. * Execute the next iteration. Must be called after the last iteration was finished.
  107873. */
  107874. executeNext(): void;
  107875. /**
  107876. * Break the loop and run the success callback.
  107877. */
  107878. breakLoop(): void;
  107879. /**
  107880. * Create and run an async loop.
  107881. * @param iterations the number of iterations.
  107882. * @param fn the function to run each iteration
  107883. * @param successCallback the callback that will be called upon succesful execution
  107884. * @param offset starting offset.
  107885. * @returns the created async loop object
  107886. */
  107887. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  107888. /**
  107889. * A for-loop that will run a given number of iterations synchronous and the rest async.
  107890. * @param iterations total number of iterations
  107891. * @param syncedIterations number of synchronous iterations in each async iteration.
  107892. * @param fn the function to call each iteration.
  107893. * @param callback a success call back that will be called when iterating stops.
  107894. * @param breakFunction a break condition (optional)
  107895. * @param timeout timeout settings for the setTimeout function. default - 0.
  107896. * @returns the created async loop object
  107897. */
  107898. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  107899. }
  107900. }
  107901. declare module BABYLON {
  107902. /**
  107903. * This class implement a typical dictionary using a string as key and the generic type T as value.
  107904. * The underlying implementation relies on an associative array to ensure the best performances.
  107905. * The value can be anything including 'null' but except 'undefined'
  107906. */
  107907. export class StringDictionary<T> {
  107908. /**
  107909. * This will clear this dictionary and copy the content from the 'source' one.
  107910. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  107911. * @param source the dictionary to take the content from and copy to this dictionary
  107912. */
  107913. copyFrom(source: StringDictionary<T>): void;
  107914. /**
  107915. * Get a value based from its key
  107916. * @param key the given key to get the matching value from
  107917. * @return the value if found, otherwise undefined is returned
  107918. */
  107919. get(key: string): T | undefined;
  107920. /**
  107921. * Get a value from its key or add it if it doesn't exist.
  107922. * This method will ensure you that a given key/data will be present in the dictionary.
  107923. * @param key the given key to get the matching value from
  107924. * @param factory the factory that will create the value if the key is not present in the dictionary.
  107925. * The factory will only be invoked if there's no data for the given key.
  107926. * @return the value corresponding to the key.
  107927. */
  107928. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  107929. /**
  107930. * Get a value from its key if present in the dictionary otherwise add it
  107931. * @param key the key to get the value from
  107932. * @param val if there's no such key/value pair in the dictionary add it with this value
  107933. * @return the value corresponding to the key
  107934. */
  107935. getOrAdd(key: string, val: T): T;
  107936. /**
  107937. * Check if there's a given key in the dictionary
  107938. * @param key the key to check for
  107939. * @return true if the key is present, false otherwise
  107940. */
  107941. contains(key: string): boolean;
  107942. /**
  107943. * Add a new key and its corresponding value
  107944. * @param key the key to add
  107945. * @param value the value corresponding to the key
  107946. * @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
  107947. */
  107948. add(key: string, value: T): boolean;
  107949. /**
  107950. * Update a specific value associated to a key
  107951. * @param key defines the key to use
  107952. * @param value defines the value to store
  107953. * @returns true if the value was updated (or false if the key was not found)
  107954. */
  107955. set(key: string, value: T): boolean;
  107956. /**
  107957. * Get the element of the given key and remove it from the dictionary
  107958. * @param key defines the key to search
  107959. * @returns the value associated with the key or null if not found
  107960. */
  107961. getAndRemove(key: string): Nullable<T>;
  107962. /**
  107963. * Remove a key/value from the dictionary.
  107964. * @param key the key to remove
  107965. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  107966. */
  107967. remove(key: string): boolean;
  107968. /**
  107969. * Clear the whole content of the dictionary
  107970. */
  107971. clear(): void;
  107972. /**
  107973. * Gets the current count
  107974. */
  107975. get count(): number;
  107976. /**
  107977. * Execute a callback on each key/val of the dictionary.
  107978. * Note that you can remove any element in this dictionary in the callback implementation
  107979. * @param callback the callback to execute on a given key/value pair
  107980. */
  107981. forEach(callback: (key: string, val: T) => void): void;
  107982. /**
  107983. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  107984. * If the callback returns null or undefined the method will iterate to the next key/value pair
  107985. * Note that you can remove any element in this dictionary in the callback implementation
  107986. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  107987. * @returns the first item
  107988. */
  107989. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  107990. private _count;
  107991. private _data;
  107992. }
  107993. }
  107994. declare module BABYLON {
  107995. /** @hidden */
  107996. export interface ICollisionCoordinator {
  107997. createCollider(): Collider;
  107998. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  107999. init(scene: Scene): void;
  108000. }
  108001. /** @hidden */
  108002. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  108003. private _scene;
  108004. private _scaledPosition;
  108005. private _scaledVelocity;
  108006. private _finalPosition;
  108007. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  108008. createCollider(): Collider;
  108009. init(scene: Scene): void;
  108010. private _collideWithWorld;
  108011. }
  108012. }
  108013. declare module BABYLON {
  108014. /**
  108015. * Class used to manage all inputs for the scene.
  108016. */
  108017. export class InputManager {
  108018. /** The distance in pixel that you have to move to prevent some events */
  108019. static DragMovementThreshold: number;
  108020. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  108021. static LongPressDelay: number;
  108022. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  108023. static DoubleClickDelay: number;
  108024. /** If you need to check double click without raising a single click at first click, enable this flag */
  108025. static ExclusiveDoubleClickMode: boolean;
  108026. private _wheelEventName;
  108027. private _onPointerMove;
  108028. private _onPointerDown;
  108029. private _onPointerUp;
  108030. private _initClickEvent;
  108031. private _initActionManager;
  108032. private _delayedSimpleClick;
  108033. private _delayedSimpleClickTimeout;
  108034. private _previousDelayedSimpleClickTimeout;
  108035. private _meshPickProceed;
  108036. private _previousButtonPressed;
  108037. private _currentPickResult;
  108038. private _previousPickResult;
  108039. private _totalPointersPressed;
  108040. private _doubleClickOccured;
  108041. private _pointerOverMesh;
  108042. private _pickedDownMesh;
  108043. private _pickedUpMesh;
  108044. private _pointerX;
  108045. private _pointerY;
  108046. private _unTranslatedPointerX;
  108047. private _unTranslatedPointerY;
  108048. private _startingPointerPosition;
  108049. private _previousStartingPointerPosition;
  108050. private _startingPointerTime;
  108051. private _previousStartingPointerTime;
  108052. private _pointerCaptures;
  108053. private _onKeyDown;
  108054. private _onKeyUp;
  108055. private _onCanvasFocusObserver;
  108056. private _onCanvasBlurObserver;
  108057. private _scene;
  108058. /**
  108059. * Creates a new InputManager
  108060. * @param scene defines the hosting scene
  108061. */
  108062. constructor(scene: Scene);
  108063. /**
  108064. * Gets the mesh that is currently under the pointer
  108065. */
  108066. get meshUnderPointer(): Nullable<AbstractMesh>;
  108067. /**
  108068. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  108069. */
  108070. get unTranslatedPointer(): Vector2;
  108071. /**
  108072. * Gets or sets the current on-screen X position of the pointer
  108073. */
  108074. get pointerX(): number;
  108075. set pointerX(value: number);
  108076. /**
  108077. * Gets or sets the current on-screen Y position of the pointer
  108078. */
  108079. get pointerY(): number;
  108080. set pointerY(value: number);
  108081. private _updatePointerPosition;
  108082. private _processPointerMove;
  108083. private _setRayOnPointerInfo;
  108084. private _checkPrePointerObservable;
  108085. /**
  108086. * Use this method to simulate a pointer move on a mesh
  108087. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108088. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108089. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108090. */
  108091. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  108092. /**
  108093. * Use this method to simulate a pointer down on a mesh
  108094. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108095. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108096. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108097. */
  108098. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  108099. private _processPointerDown;
  108100. /** @hidden */
  108101. _isPointerSwiping(): boolean;
  108102. /**
  108103. * Use this method to simulate a pointer up on a mesh
  108104. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108105. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108106. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108107. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  108108. */
  108109. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  108110. private _processPointerUp;
  108111. /**
  108112. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  108113. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  108114. * @returns true if the pointer was captured
  108115. */
  108116. isPointerCaptured(pointerId?: number): boolean;
  108117. /**
  108118. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  108119. * @param attachUp defines if you want to attach events to pointerup
  108120. * @param attachDown defines if you want to attach events to pointerdown
  108121. * @param attachMove defines if you want to attach events to pointermove
  108122. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  108123. */
  108124. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  108125. /**
  108126. * Detaches all event handlers
  108127. */
  108128. detachControl(): void;
  108129. /**
  108130. * Force the value of meshUnderPointer
  108131. * @param mesh defines the mesh to use
  108132. */
  108133. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  108134. /**
  108135. * Gets the mesh under the pointer
  108136. * @returns a Mesh or null if no mesh is under the pointer
  108137. */
  108138. getPointerOverMesh(): Nullable<AbstractMesh>;
  108139. }
  108140. }
  108141. declare module BABYLON {
  108142. /**
  108143. * Helper class used to generate session unique ID
  108144. */
  108145. export class UniqueIdGenerator {
  108146. private static _UniqueIdCounter;
  108147. /**
  108148. * Gets an unique (relatively to the current scene) Id
  108149. */
  108150. static get UniqueId(): number;
  108151. }
  108152. }
  108153. declare module BABYLON {
  108154. /**
  108155. * This class defines the direct association between an animation and a target
  108156. */
  108157. export class TargetedAnimation {
  108158. /**
  108159. * Animation to perform
  108160. */
  108161. animation: Animation;
  108162. /**
  108163. * Target to animate
  108164. */
  108165. target: any;
  108166. /**
  108167. * Serialize the object
  108168. * @returns the JSON object representing the current entity
  108169. */
  108170. serialize(): any;
  108171. }
  108172. /**
  108173. * Use this class to create coordinated animations on multiple targets
  108174. */
  108175. export class AnimationGroup implements IDisposable {
  108176. /** The name of the animation group */
  108177. name: string;
  108178. private _scene;
  108179. private _targetedAnimations;
  108180. private _animatables;
  108181. private _from;
  108182. private _to;
  108183. private _isStarted;
  108184. private _isPaused;
  108185. private _speedRatio;
  108186. private _loopAnimation;
  108187. /**
  108188. * Gets or sets the unique id of the node
  108189. */
  108190. uniqueId: number;
  108191. /**
  108192. * This observable will notify when one animation have ended
  108193. */
  108194. onAnimationEndObservable: Observable<TargetedAnimation>;
  108195. /**
  108196. * Observer raised when one animation loops
  108197. */
  108198. onAnimationLoopObservable: Observable<TargetedAnimation>;
  108199. /**
  108200. * Observer raised when all animations have looped
  108201. */
  108202. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  108203. /**
  108204. * This observable will notify when all animations have ended.
  108205. */
  108206. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  108207. /**
  108208. * This observable will notify when all animations have paused.
  108209. */
  108210. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  108211. /**
  108212. * This observable will notify when all animations are playing.
  108213. */
  108214. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  108215. /**
  108216. * Gets the first frame
  108217. */
  108218. get from(): number;
  108219. /**
  108220. * Gets the last frame
  108221. */
  108222. get to(): number;
  108223. /**
  108224. * Define if the animations are started
  108225. */
  108226. get isStarted(): boolean;
  108227. /**
  108228. * Gets a value indicating that the current group is playing
  108229. */
  108230. get isPlaying(): boolean;
  108231. /**
  108232. * Gets or sets the speed ratio to use for all animations
  108233. */
  108234. get speedRatio(): number;
  108235. /**
  108236. * Gets or sets the speed ratio to use for all animations
  108237. */
  108238. set speedRatio(value: number);
  108239. /**
  108240. * Gets or sets if all animations should loop or not
  108241. */
  108242. get loopAnimation(): boolean;
  108243. set loopAnimation(value: boolean);
  108244. /**
  108245. * Gets the targeted animations for this animation group
  108246. */
  108247. get targetedAnimations(): Array<TargetedAnimation>;
  108248. /**
  108249. * returning the list of animatables controlled by this animation group.
  108250. */
  108251. get animatables(): Array<Animatable>;
  108252. /**
  108253. * Instantiates a new Animation Group.
  108254. * This helps managing several animations at once.
  108255. * @see http://doc.babylonjs.com/how_to/group
  108256. * @param name Defines the name of the group
  108257. * @param scene Defines the scene the group belongs to
  108258. */
  108259. constructor(
  108260. /** The name of the animation group */
  108261. name: string, scene?: Nullable<Scene>);
  108262. /**
  108263. * Add an animation (with its target) in the group
  108264. * @param animation defines the animation we want to add
  108265. * @param target defines the target of the animation
  108266. * @returns the TargetedAnimation object
  108267. */
  108268. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  108269. /**
  108270. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  108271. * It can add constant keys at begin or end
  108272. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  108273. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  108274. * @returns the animation group
  108275. */
  108276. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  108277. private _animationLoopCount;
  108278. private _animationLoopFlags;
  108279. private _processLoop;
  108280. /**
  108281. * Start all animations on given targets
  108282. * @param loop defines if animations must loop
  108283. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  108284. * @param from defines the from key (optional)
  108285. * @param to defines the to key (optional)
  108286. * @returns the current animation group
  108287. */
  108288. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  108289. /**
  108290. * Pause all animations
  108291. * @returns the animation group
  108292. */
  108293. pause(): AnimationGroup;
  108294. /**
  108295. * Play all animations to initial state
  108296. * This function will start() the animations if they were not started or will restart() them if they were paused
  108297. * @param loop defines if animations must loop
  108298. * @returns the animation group
  108299. */
  108300. play(loop?: boolean): AnimationGroup;
  108301. /**
  108302. * Reset all animations to initial state
  108303. * @returns the animation group
  108304. */
  108305. reset(): AnimationGroup;
  108306. /**
  108307. * Restart animations from key 0
  108308. * @returns the animation group
  108309. */
  108310. restart(): AnimationGroup;
  108311. /**
  108312. * Stop all animations
  108313. * @returns the animation group
  108314. */
  108315. stop(): AnimationGroup;
  108316. /**
  108317. * Set animation weight for all animatables
  108318. * @param weight defines the weight to use
  108319. * @return the animationGroup
  108320. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  108321. */
  108322. setWeightForAllAnimatables(weight: number): AnimationGroup;
  108323. /**
  108324. * Synchronize and normalize all animatables with a source animatable
  108325. * @param root defines the root animatable to synchronize with
  108326. * @return the animationGroup
  108327. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  108328. */
  108329. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  108330. /**
  108331. * Goes to a specific frame in this animation group
  108332. * @param frame the frame number to go to
  108333. * @return the animationGroup
  108334. */
  108335. goToFrame(frame: number): AnimationGroup;
  108336. /**
  108337. * Dispose all associated resources
  108338. */
  108339. dispose(): void;
  108340. private _checkAnimationGroupEnded;
  108341. /**
  108342. * Clone the current animation group and returns a copy
  108343. * @param newName defines the name of the new group
  108344. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  108345. * @returns the new aniamtion group
  108346. */
  108347. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  108348. /**
  108349. * Serializes the animationGroup to an object
  108350. * @returns Serialized object
  108351. */
  108352. serialize(): any;
  108353. /**
  108354. * Returns a new AnimationGroup object parsed from the source provided.
  108355. * @param parsedAnimationGroup defines the source
  108356. * @param scene defines the scene that will receive the animationGroup
  108357. * @returns a new AnimationGroup
  108358. */
  108359. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  108360. /**
  108361. * Returns the string "AnimationGroup"
  108362. * @returns "AnimationGroup"
  108363. */
  108364. getClassName(): string;
  108365. /**
  108366. * Creates a detailled string about the object
  108367. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  108368. * @returns a string representing the object
  108369. */
  108370. toString(fullDetails?: boolean): string;
  108371. }
  108372. }
  108373. declare module BABYLON {
  108374. /**
  108375. * Define an interface for all classes that will hold resources
  108376. */
  108377. export interface IDisposable {
  108378. /**
  108379. * Releases all held resources
  108380. */
  108381. dispose(): void;
  108382. }
  108383. /** Interface defining initialization parameters for Scene class */
  108384. export interface SceneOptions {
  108385. /**
  108386. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  108387. * It will improve performance when the number of geometries becomes important.
  108388. */
  108389. useGeometryUniqueIdsMap?: boolean;
  108390. /**
  108391. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  108392. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  108393. */
  108394. useMaterialMeshMap?: boolean;
  108395. /**
  108396. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  108397. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  108398. */
  108399. useClonedMeshMap?: boolean;
  108400. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  108401. virtual?: boolean;
  108402. }
  108403. /**
  108404. * Represents a scene to be rendered by the engine.
  108405. * @see http://doc.babylonjs.com/features/scene
  108406. */
  108407. export class Scene extends AbstractScene implements IAnimatable {
  108408. /** The fog is deactivated */
  108409. static readonly FOGMODE_NONE: number;
  108410. /** The fog density is following an exponential function */
  108411. static readonly FOGMODE_EXP: number;
  108412. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  108413. static readonly FOGMODE_EXP2: number;
  108414. /** The fog density is following a linear function. */
  108415. static readonly FOGMODE_LINEAR: number;
  108416. /**
  108417. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  108418. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108419. */
  108420. static MinDeltaTime: number;
  108421. /**
  108422. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  108423. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108424. */
  108425. static MaxDeltaTime: number;
  108426. /**
  108427. * Factory used to create the default material.
  108428. * @param name The name of the material to create
  108429. * @param scene The scene to create the material for
  108430. * @returns The default material
  108431. */
  108432. static DefaultMaterialFactory(scene: Scene): Material;
  108433. /**
  108434. * Factory used to create the a collision coordinator.
  108435. * @returns The collision coordinator
  108436. */
  108437. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  108438. /** @hidden */
  108439. _inputManager: InputManager;
  108440. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  108441. cameraToUseForPointers: Nullable<Camera>;
  108442. /** @hidden */
  108443. readonly _isScene: boolean;
  108444. /** @hidden */
  108445. _blockEntityCollection: boolean;
  108446. /**
  108447. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  108448. */
  108449. autoClear: boolean;
  108450. /**
  108451. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  108452. */
  108453. autoClearDepthAndStencil: boolean;
  108454. /**
  108455. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  108456. */
  108457. clearColor: Color4;
  108458. /**
  108459. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  108460. */
  108461. ambientColor: Color3;
  108462. /**
  108463. * This is use to store the default BRDF lookup for PBR materials in your scene.
  108464. * It should only be one of the following (if not the default embedded one):
  108465. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  108466. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  108467. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  108468. * The material properties need to be setup according to the type of texture in use.
  108469. */
  108470. environmentBRDFTexture: BaseTexture;
  108471. /** @hidden */
  108472. protected _environmentTexture: Nullable<BaseTexture>;
  108473. /**
  108474. * Texture used in all pbr material as the reflection texture.
  108475. * As in the majority of the scene they are the same (exception for multi room and so on),
  108476. * this is easier to reference from here than from all the materials.
  108477. */
  108478. get environmentTexture(): Nullable<BaseTexture>;
  108479. /**
  108480. * Texture used in all pbr material as the reflection texture.
  108481. * As in the majority of the scene they are the same (exception for multi room and so on),
  108482. * this is easier to set here than in all the materials.
  108483. */
  108484. set environmentTexture(value: Nullable<BaseTexture>);
  108485. /** @hidden */
  108486. protected _environmentIntensity: number;
  108487. /**
  108488. * Intensity of the environment in all pbr material.
  108489. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  108490. * As in the majority of the scene they are the same (exception for multi room and so on),
  108491. * this is easier to reference from here than from all the materials.
  108492. */
  108493. get environmentIntensity(): number;
  108494. /**
  108495. * Intensity of the environment in all pbr material.
  108496. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  108497. * As in the majority of the scene they are the same (exception for multi room and so on),
  108498. * this is easier to set here than in all the materials.
  108499. */
  108500. set environmentIntensity(value: number);
  108501. /** @hidden */
  108502. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108503. /**
  108504. * Default image processing configuration used either in the rendering
  108505. * Forward main pass or through the imageProcessingPostProcess if present.
  108506. * As in the majority of the scene they are the same (exception for multi camera),
  108507. * this is easier to reference from here than from all the materials and post process.
  108508. *
  108509. * No setter as we it is a shared configuration, you can set the values instead.
  108510. */
  108511. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  108512. private _forceWireframe;
  108513. /**
  108514. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  108515. */
  108516. set forceWireframe(value: boolean);
  108517. get forceWireframe(): boolean;
  108518. private _skipFrustumClipping;
  108519. /**
  108520. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  108521. */
  108522. set skipFrustumClipping(value: boolean);
  108523. get skipFrustumClipping(): boolean;
  108524. private _forcePointsCloud;
  108525. /**
  108526. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  108527. */
  108528. set forcePointsCloud(value: boolean);
  108529. get forcePointsCloud(): boolean;
  108530. /**
  108531. * Gets or sets the active clipplane 1
  108532. */
  108533. clipPlane: Nullable<Plane>;
  108534. /**
  108535. * Gets or sets the active clipplane 2
  108536. */
  108537. clipPlane2: Nullable<Plane>;
  108538. /**
  108539. * Gets or sets the active clipplane 3
  108540. */
  108541. clipPlane3: Nullable<Plane>;
  108542. /**
  108543. * Gets or sets the active clipplane 4
  108544. */
  108545. clipPlane4: Nullable<Plane>;
  108546. /**
  108547. * Gets or sets the active clipplane 5
  108548. */
  108549. clipPlane5: Nullable<Plane>;
  108550. /**
  108551. * Gets or sets the active clipplane 6
  108552. */
  108553. clipPlane6: Nullable<Plane>;
  108554. /**
  108555. * Gets or sets a boolean indicating if animations are enabled
  108556. */
  108557. animationsEnabled: boolean;
  108558. private _animationPropertiesOverride;
  108559. /**
  108560. * Gets or sets the animation properties override
  108561. */
  108562. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  108563. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  108564. /**
  108565. * Gets or sets a boolean indicating if a constant deltatime has to be used
  108566. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  108567. */
  108568. useConstantAnimationDeltaTime: boolean;
  108569. /**
  108570. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  108571. * Please note that it requires to run a ray cast through the scene on every frame
  108572. */
  108573. constantlyUpdateMeshUnderPointer: boolean;
  108574. /**
  108575. * Defines the HTML cursor to use when hovering over interactive elements
  108576. */
  108577. hoverCursor: string;
  108578. /**
  108579. * Defines the HTML default cursor to use (empty by default)
  108580. */
  108581. defaultCursor: string;
  108582. /**
  108583. * Defines whether cursors are handled by the scene.
  108584. */
  108585. doNotHandleCursors: boolean;
  108586. /**
  108587. * This is used to call preventDefault() on pointer down
  108588. * in order to block unwanted artifacts like system double clicks
  108589. */
  108590. preventDefaultOnPointerDown: boolean;
  108591. /**
  108592. * This is used to call preventDefault() on pointer up
  108593. * in order to block unwanted artifacts like system double clicks
  108594. */
  108595. preventDefaultOnPointerUp: boolean;
  108596. /**
  108597. * Gets or sets user defined metadata
  108598. */
  108599. metadata: any;
  108600. /**
  108601. * For internal use only. Please do not use.
  108602. */
  108603. reservedDataStore: any;
  108604. /**
  108605. * Gets the name of the plugin used to load this scene (null by default)
  108606. */
  108607. loadingPluginName: string;
  108608. /**
  108609. * Use this array to add regular expressions used to disable offline support for specific urls
  108610. */
  108611. disableOfflineSupportExceptionRules: RegExp[];
  108612. /**
  108613. * An event triggered when the scene is disposed.
  108614. */
  108615. onDisposeObservable: Observable<Scene>;
  108616. private _onDisposeObserver;
  108617. /** Sets a function to be executed when this scene is disposed. */
  108618. set onDispose(callback: () => void);
  108619. /**
  108620. * An event triggered before rendering the scene (right after animations and physics)
  108621. */
  108622. onBeforeRenderObservable: Observable<Scene>;
  108623. private _onBeforeRenderObserver;
  108624. /** Sets a function to be executed before rendering this scene */
  108625. set beforeRender(callback: Nullable<() => void>);
  108626. /**
  108627. * An event triggered after rendering the scene
  108628. */
  108629. onAfterRenderObservable: Observable<Scene>;
  108630. /**
  108631. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  108632. */
  108633. onAfterRenderCameraObservable: Observable<Camera>;
  108634. private _onAfterRenderObserver;
  108635. /** Sets a function to be executed after rendering this scene */
  108636. set afterRender(callback: Nullable<() => void>);
  108637. /**
  108638. * An event triggered before animating the scene
  108639. */
  108640. onBeforeAnimationsObservable: Observable<Scene>;
  108641. /**
  108642. * An event triggered after animations processing
  108643. */
  108644. onAfterAnimationsObservable: Observable<Scene>;
  108645. /**
  108646. * An event triggered before draw calls are ready to be sent
  108647. */
  108648. onBeforeDrawPhaseObservable: Observable<Scene>;
  108649. /**
  108650. * An event triggered after draw calls have been sent
  108651. */
  108652. onAfterDrawPhaseObservable: Observable<Scene>;
  108653. /**
  108654. * An event triggered when the scene is ready
  108655. */
  108656. onReadyObservable: Observable<Scene>;
  108657. /**
  108658. * An event triggered before rendering a camera
  108659. */
  108660. onBeforeCameraRenderObservable: Observable<Camera>;
  108661. private _onBeforeCameraRenderObserver;
  108662. /** Sets a function to be executed before rendering a camera*/
  108663. set beforeCameraRender(callback: () => void);
  108664. /**
  108665. * An event triggered after rendering a camera
  108666. */
  108667. onAfterCameraRenderObservable: Observable<Camera>;
  108668. private _onAfterCameraRenderObserver;
  108669. /** Sets a function to be executed after rendering a camera*/
  108670. set afterCameraRender(callback: () => void);
  108671. /**
  108672. * An event triggered when active meshes evaluation is about to start
  108673. */
  108674. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  108675. /**
  108676. * An event triggered when active meshes evaluation is done
  108677. */
  108678. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  108679. /**
  108680. * An event triggered when particles rendering is about to start
  108681. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  108682. */
  108683. onBeforeParticlesRenderingObservable: Observable<Scene>;
  108684. /**
  108685. * An event triggered when particles rendering is done
  108686. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  108687. */
  108688. onAfterParticlesRenderingObservable: Observable<Scene>;
  108689. /**
  108690. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  108691. */
  108692. onDataLoadedObservable: Observable<Scene>;
  108693. /**
  108694. * An event triggered when a camera is created
  108695. */
  108696. onNewCameraAddedObservable: Observable<Camera>;
  108697. /**
  108698. * An event triggered when a camera is removed
  108699. */
  108700. onCameraRemovedObservable: Observable<Camera>;
  108701. /**
  108702. * An event triggered when a light is created
  108703. */
  108704. onNewLightAddedObservable: Observable<Light>;
  108705. /**
  108706. * An event triggered when a light is removed
  108707. */
  108708. onLightRemovedObservable: Observable<Light>;
  108709. /**
  108710. * An event triggered when a geometry is created
  108711. */
  108712. onNewGeometryAddedObservable: Observable<Geometry>;
  108713. /**
  108714. * An event triggered when a geometry is removed
  108715. */
  108716. onGeometryRemovedObservable: Observable<Geometry>;
  108717. /**
  108718. * An event triggered when a transform node is created
  108719. */
  108720. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  108721. /**
  108722. * An event triggered when a transform node is removed
  108723. */
  108724. onTransformNodeRemovedObservable: Observable<TransformNode>;
  108725. /**
  108726. * An event triggered when a mesh is created
  108727. */
  108728. onNewMeshAddedObservable: Observable<AbstractMesh>;
  108729. /**
  108730. * An event triggered when a mesh is removed
  108731. */
  108732. onMeshRemovedObservable: Observable<AbstractMesh>;
  108733. /**
  108734. * An event triggered when a skeleton is created
  108735. */
  108736. onNewSkeletonAddedObservable: Observable<Skeleton>;
  108737. /**
  108738. * An event triggered when a skeleton is removed
  108739. */
  108740. onSkeletonRemovedObservable: Observable<Skeleton>;
  108741. /**
  108742. * An event triggered when a material is created
  108743. */
  108744. onNewMaterialAddedObservable: Observable<Material>;
  108745. /**
  108746. * An event triggered when a material is removed
  108747. */
  108748. onMaterialRemovedObservable: Observable<Material>;
  108749. /**
  108750. * An event triggered when a texture is created
  108751. */
  108752. onNewTextureAddedObservable: Observable<BaseTexture>;
  108753. /**
  108754. * An event triggered when a texture is removed
  108755. */
  108756. onTextureRemovedObservable: Observable<BaseTexture>;
  108757. /**
  108758. * An event triggered when render targets are about to be rendered
  108759. * Can happen multiple times per frame.
  108760. */
  108761. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  108762. /**
  108763. * An event triggered when render targets were rendered.
  108764. * Can happen multiple times per frame.
  108765. */
  108766. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  108767. /**
  108768. * An event triggered before calculating deterministic simulation step
  108769. */
  108770. onBeforeStepObservable: Observable<Scene>;
  108771. /**
  108772. * An event triggered after calculating deterministic simulation step
  108773. */
  108774. onAfterStepObservable: Observable<Scene>;
  108775. /**
  108776. * An event triggered when the activeCamera property is updated
  108777. */
  108778. onActiveCameraChanged: Observable<Scene>;
  108779. /**
  108780. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  108781. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  108782. * 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)
  108783. */
  108784. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  108785. /**
  108786. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  108787. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  108788. * 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)
  108789. */
  108790. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  108791. /**
  108792. * This Observable will when a mesh has been imported into the scene.
  108793. */
  108794. onMeshImportedObservable: Observable<AbstractMesh>;
  108795. /**
  108796. * This Observable will when an animation file has been imported into the scene.
  108797. */
  108798. onAnimationFileImportedObservable: Observable<Scene>;
  108799. /**
  108800. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  108801. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  108802. */
  108803. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  108804. /** @hidden */
  108805. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  108806. /**
  108807. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  108808. */
  108809. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  108810. /**
  108811. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  108812. */
  108813. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  108814. /**
  108815. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  108816. */
  108817. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  108818. /** Callback called when a pointer move is detected */
  108819. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  108820. /** Callback called when a pointer down is detected */
  108821. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  108822. /** Callback called when a pointer up is detected */
  108823. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  108824. /** Callback called when a pointer pick is detected */
  108825. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  108826. /**
  108827. * 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).
  108828. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  108829. */
  108830. onPrePointerObservable: Observable<PointerInfoPre>;
  108831. /**
  108832. * Observable event triggered each time an input event is received from the rendering canvas
  108833. */
  108834. onPointerObservable: Observable<PointerInfo>;
  108835. /**
  108836. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  108837. */
  108838. get unTranslatedPointer(): Vector2;
  108839. /**
  108840. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  108841. */
  108842. static get DragMovementThreshold(): number;
  108843. static set DragMovementThreshold(value: number);
  108844. /**
  108845. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  108846. */
  108847. static get LongPressDelay(): number;
  108848. static set LongPressDelay(value: number);
  108849. /**
  108850. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  108851. */
  108852. static get DoubleClickDelay(): number;
  108853. static set DoubleClickDelay(value: number);
  108854. /** If you need to check double click without raising a single click at first click, enable this flag */
  108855. static get ExclusiveDoubleClickMode(): boolean;
  108856. static set ExclusiveDoubleClickMode(value: boolean);
  108857. /** @hidden */
  108858. _mirroredCameraPosition: Nullable<Vector3>;
  108859. /**
  108860. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  108861. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  108862. */
  108863. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  108864. /**
  108865. * Observable event triggered each time an keyboard event is received from the hosting window
  108866. */
  108867. onKeyboardObservable: Observable<KeyboardInfo>;
  108868. private _useRightHandedSystem;
  108869. /**
  108870. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  108871. */
  108872. set useRightHandedSystem(value: boolean);
  108873. get useRightHandedSystem(): boolean;
  108874. private _timeAccumulator;
  108875. private _currentStepId;
  108876. private _currentInternalStep;
  108877. /**
  108878. * Sets the step Id used by deterministic lock step
  108879. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108880. * @param newStepId defines the step Id
  108881. */
  108882. setStepId(newStepId: number): void;
  108883. /**
  108884. * Gets the step Id used by deterministic lock step
  108885. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108886. * @returns the step Id
  108887. */
  108888. getStepId(): number;
  108889. /**
  108890. * Gets the internal step used by deterministic lock step
  108891. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108892. * @returns the internal step
  108893. */
  108894. getInternalStep(): number;
  108895. private _fogEnabled;
  108896. /**
  108897. * Gets or sets a boolean indicating if fog is enabled on this scene
  108898. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108899. * (Default is true)
  108900. */
  108901. set fogEnabled(value: boolean);
  108902. get fogEnabled(): boolean;
  108903. private _fogMode;
  108904. /**
  108905. * Gets or sets the fog mode to use
  108906. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108907. * | mode | value |
  108908. * | --- | --- |
  108909. * | FOGMODE_NONE | 0 |
  108910. * | FOGMODE_EXP | 1 |
  108911. * | FOGMODE_EXP2 | 2 |
  108912. * | FOGMODE_LINEAR | 3 |
  108913. */
  108914. set fogMode(value: number);
  108915. get fogMode(): number;
  108916. /**
  108917. * Gets or sets the fog color to use
  108918. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108919. * (Default is Color3(0.2, 0.2, 0.3))
  108920. */
  108921. fogColor: Color3;
  108922. /**
  108923. * Gets or sets the fog density to use
  108924. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108925. * (Default is 0.1)
  108926. */
  108927. fogDensity: number;
  108928. /**
  108929. * Gets or sets the fog start distance to use
  108930. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108931. * (Default is 0)
  108932. */
  108933. fogStart: number;
  108934. /**
  108935. * Gets or sets the fog end distance to use
  108936. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108937. * (Default is 1000)
  108938. */
  108939. fogEnd: number;
  108940. private _shadowsEnabled;
  108941. /**
  108942. * Gets or sets a boolean indicating if shadows are enabled on this scene
  108943. */
  108944. set shadowsEnabled(value: boolean);
  108945. get shadowsEnabled(): boolean;
  108946. private _lightsEnabled;
  108947. /**
  108948. * Gets or sets a boolean indicating if lights are enabled on this scene
  108949. */
  108950. set lightsEnabled(value: boolean);
  108951. get lightsEnabled(): boolean;
  108952. /** All of the active cameras added to this scene. */
  108953. activeCameras: Camera[];
  108954. /** @hidden */
  108955. _activeCamera: Nullable<Camera>;
  108956. /** Gets or sets the current active camera */
  108957. get activeCamera(): Nullable<Camera>;
  108958. set activeCamera(value: Nullable<Camera>);
  108959. private _defaultMaterial;
  108960. /** The default material used on meshes when no material is affected */
  108961. get defaultMaterial(): Material;
  108962. /** The default material used on meshes when no material is affected */
  108963. set defaultMaterial(value: Material);
  108964. private _texturesEnabled;
  108965. /**
  108966. * Gets or sets a boolean indicating if textures are enabled on this scene
  108967. */
  108968. set texturesEnabled(value: boolean);
  108969. get texturesEnabled(): boolean;
  108970. /**
  108971. * Gets or sets a boolean indicating if particles are enabled on this scene
  108972. */
  108973. particlesEnabled: boolean;
  108974. /**
  108975. * Gets or sets a boolean indicating if sprites are enabled on this scene
  108976. */
  108977. spritesEnabled: boolean;
  108978. private _skeletonsEnabled;
  108979. /**
  108980. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  108981. */
  108982. set skeletonsEnabled(value: boolean);
  108983. get skeletonsEnabled(): boolean;
  108984. /**
  108985. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  108986. */
  108987. lensFlaresEnabled: boolean;
  108988. /**
  108989. * Gets or sets a boolean indicating if collisions are enabled on this scene
  108990. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108991. */
  108992. collisionsEnabled: boolean;
  108993. private _collisionCoordinator;
  108994. /** @hidden */
  108995. get collisionCoordinator(): ICollisionCoordinator;
  108996. /**
  108997. * Defines the gravity applied to this scene (used only for collisions)
  108998. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108999. */
  109000. gravity: Vector3;
  109001. /**
  109002. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  109003. */
  109004. postProcessesEnabled: boolean;
  109005. /**
  109006. * The list of postprocesses added to the scene
  109007. */
  109008. postProcesses: PostProcess[];
  109009. /**
  109010. * Gets the current postprocess manager
  109011. */
  109012. postProcessManager: PostProcessManager;
  109013. /**
  109014. * Gets or sets a boolean indicating if render targets are enabled on this scene
  109015. */
  109016. renderTargetsEnabled: boolean;
  109017. /**
  109018. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  109019. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  109020. */
  109021. dumpNextRenderTargets: boolean;
  109022. /**
  109023. * The list of user defined render targets added to the scene
  109024. */
  109025. customRenderTargets: RenderTargetTexture[];
  109026. /**
  109027. * Defines if texture loading must be delayed
  109028. * If true, textures will only be loaded when they need to be rendered
  109029. */
  109030. useDelayedTextureLoading: boolean;
  109031. /**
  109032. * Gets the list of meshes imported to the scene through SceneLoader
  109033. */
  109034. importedMeshesFiles: String[];
  109035. /**
  109036. * Gets or sets a boolean indicating if probes are enabled on this scene
  109037. */
  109038. probesEnabled: boolean;
  109039. /**
  109040. * Gets or sets the current offline provider to use to store scene data
  109041. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  109042. */
  109043. offlineProvider: IOfflineProvider;
  109044. /**
  109045. * Gets or sets the action manager associated with the scene
  109046. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  109047. */
  109048. actionManager: AbstractActionManager;
  109049. private _meshesForIntersections;
  109050. /**
  109051. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  109052. */
  109053. proceduralTexturesEnabled: boolean;
  109054. private _engine;
  109055. private _totalVertices;
  109056. /** @hidden */
  109057. _activeIndices: PerfCounter;
  109058. /** @hidden */
  109059. _activeParticles: PerfCounter;
  109060. /** @hidden */
  109061. _activeBones: PerfCounter;
  109062. private _animationRatio;
  109063. /** @hidden */
  109064. _animationTimeLast: number;
  109065. /** @hidden */
  109066. _animationTime: number;
  109067. /**
  109068. * Gets or sets a general scale for animation speed
  109069. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  109070. */
  109071. animationTimeScale: number;
  109072. /** @hidden */
  109073. _cachedMaterial: Nullable<Material>;
  109074. /** @hidden */
  109075. _cachedEffect: Nullable<Effect>;
  109076. /** @hidden */
  109077. _cachedVisibility: Nullable<number>;
  109078. private _renderId;
  109079. private _frameId;
  109080. private _executeWhenReadyTimeoutId;
  109081. private _intermediateRendering;
  109082. private _viewUpdateFlag;
  109083. private _projectionUpdateFlag;
  109084. /** @hidden */
  109085. _toBeDisposed: Nullable<IDisposable>[];
  109086. private _activeRequests;
  109087. /** @hidden */
  109088. _pendingData: any[];
  109089. private _isDisposed;
  109090. /**
  109091. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  109092. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  109093. */
  109094. dispatchAllSubMeshesOfActiveMeshes: boolean;
  109095. private _activeMeshes;
  109096. private _processedMaterials;
  109097. private _renderTargets;
  109098. /** @hidden */
  109099. _activeParticleSystems: SmartArray<IParticleSystem>;
  109100. private _activeSkeletons;
  109101. private _softwareSkinnedMeshes;
  109102. private _renderingManager;
  109103. /** @hidden */
  109104. _activeAnimatables: Animatable[];
  109105. private _transformMatrix;
  109106. private _sceneUbo;
  109107. /** @hidden */
  109108. _viewMatrix: Matrix;
  109109. private _projectionMatrix;
  109110. /** @hidden */
  109111. _forcedViewPosition: Nullable<Vector3>;
  109112. /** @hidden */
  109113. _frustumPlanes: Plane[];
  109114. /**
  109115. * Gets the list of frustum planes (built from the active camera)
  109116. */
  109117. get frustumPlanes(): Plane[];
  109118. /**
  109119. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  109120. * This is useful if there are more lights that the maximum simulteanous authorized
  109121. */
  109122. requireLightSorting: boolean;
  109123. /** @hidden */
  109124. readonly useMaterialMeshMap: boolean;
  109125. /** @hidden */
  109126. readonly useClonedMeshMap: boolean;
  109127. private _externalData;
  109128. private _uid;
  109129. /**
  109130. * @hidden
  109131. * Backing store of defined scene components.
  109132. */
  109133. _components: ISceneComponent[];
  109134. /**
  109135. * @hidden
  109136. * Backing store of defined scene components.
  109137. */
  109138. _serializableComponents: ISceneSerializableComponent[];
  109139. /**
  109140. * List of components to register on the next registration step.
  109141. */
  109142. private _transientComponents;
  109143. /**
  109144. * Registers the transient components if needed.
  109145. */
  109146. private _registerTransientComponents;
  109147. /**
  109148. * @hidden
  109149. * Add a component to the scene.
  109150. * Note that the ccomponent could be registered on th next frame if this is called after
  109151. * the register component stage.
  109152. * @param component Defines the component to add to the scene
  109153. */
  109154. _addComponent(component: ISceneComponent): void;
  109155. /**
  109156. * @hidden
  109157. * Gets a component from the scene.
  109158. * @param name defines the name of the component to retrieve
  109159. * @returns the component or null if not present
  109160. */
  109161. _getComponent(name: string): Nullable<ISceneComponent>;
  109162. /**
  109163. * @hidden
  109164. * Defines the actions happening before camera updates.
  109165. */
  109166. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  109167. /**
  109168. * @hidden
  109169. * Defines the actions happening before clear the canvas.
  109170. */
  109171. _beforeClearStage: Stage<SimpleStageAction>;
  109172. /**
  109173. * @hidden
  109174. * Defines the actions when collecting render targets for the frame.
  109175. */
  109176. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  109177. /**
  109178. * @hidden
  109179. * Defines the actions happening for one camera in the frame.
  109180. */
  109181. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  109182. /**
  109183. * @hidden
  109184. * Defines the actions happening during the per mesh ready checks.
  109185. */
  109186. _isReadyForMeshStage: Stage<MeshStageAction>;
  109187. /**
  109188. * @hidden
  109189. * Defines the actions happening before evaluate active mesh checks.
  109190. */
  109191. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  109192. /**
  109193. * @hidden
  109194. * Defines the actions happening during the evaluate sub mesh checks.
  109195. */
  109196. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  109197. /**
  109198. * @hidden
  109199. * Defines the actions happening during the active mesh stage.
  109200. */
  109201. _activeMeshStage: Stage<ActiveMeshStageAction>;
  109202. /**
  109203. * @hidden
  109204. * Defines the actions happening during the per camera render target step.
  109205. */
  109206. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  109207. /**
  109208. * @hidden
  109209. * Defines the actions happening just before the active camera is drawing.
  109210. */
  109211. _beforeCameraDrawStage: Stage<CameraStageAction>;
  109212. /**
  109213. * @hidden
  109214. * Defines the actions happening just before a render target is drawing.
  109215. */
  109216. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  109217. /**
  109218. * @hidden
  109219. * Defines the actions happening just before a rendering group is drawing.
  109220. */
  109221. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  109222. /**
  109223. * @hidden
  109224. * Defines the actions happening just before a mesh is drawing.
  109225. */
  109226. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  109227. /**
  109228. * @hidden
  109229. * Defines the actions happening just after a mesh has been drawn.
  109230. */
  109231. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  109232. /**
  109233. * @hidden
  109234. * Defines the actions happening just after a rendering group has been drawn.
  109235. */
  109236. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  109237. /**
  109238. * @hidden
  109239. * Defines the actions happening just after the active camera has been drawn.
  109240. */
  109241. _afterCameraDrawStage: Stage<CameraStageAction>;
  109242. /**
  109243. * @hidden
  109244. * Defines the actions happening just after a render target has been drawn.
  109245. */
  109246. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  109247. /**
  109248. * @hidden
  109249. * Defines the actions happening just after rendering all cameras and computing intersections.
  109250. */
  109251. _afterRenderStage: Stage<SimpleStageAction>;
  109252. /**
  109253. * @hidden
  109254. * Defines the actions happening when a pointer move event happens.
  109255. */
  109256. _pointerMoveStage: Stage<PointerMoveStageAction>;
  109257. /**
  109258. * @hidden
  109259. * Defines the actions happening when a pointer down event happens.
  109260. */
  109261. _pointerDownStage: Stage<PointerUpDownStageAction>;
  109262. /**
  109263. * @hidden
  109264. * Defines the actions happening when a pointer up event happens.
  109265. */
  109266. _pointerUpStage: Stage<PointerUpDownStageAction>;
  109267. /**
  109268. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  109269. */
  109270. private geometriesByUniqueId;
  109271. /**
  109272. * Creates a new Scene
  109273. * @param engine defines the engine to use to render this scene
  109274. * @param options defines the scene options
  109275. */
  109276. constructor(engine: Engine, options?: SceneOptions);
  109277. /**
  109278. * Gets a string idenfifying the name of the class
  109279. * @returns "Scene" string
  109280. */
  109281. getClassName(): string;
  109282. private _defaultMeshCandidates;
  109283. /**
  109284. * @hidden
  109285. */
  109286. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  109287. private _defaultSubMeshCandidates;
  109288. /**
  109289. * @hidden
  109290. */
  109291. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  109292. /**
  109293. * Sets the default candidate providers for the scene.
  109294. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  109295. * and getCollidingSubMeshCandidates to their default function
  109296. */
  109297. setDefaultCandidateProviders(): void;
  109298. /**
  109299. * Gets the mesh that is currently under the pointer
  109300. */
  109301. get meshUnderPointer(): Nullable<AbstractMesh>;
  109302. /**
  109303. * Gets or sets the current on-screen X position of the pointer
  109304. */
  109305. get pointerX(): number;
  109306. set pointerX(value: number);
  109307. /**
  109308. * Gets or sets the current on-screen Y position of the pointer
  109309. */
  109310. get pointerY(): number;
  109311. set pointerY(value: number);
  109312. /**
  109313. * Gets the cached material (ie. the latest rendered one)
  109314. * @returns the cached material
  109315. */
  109316. getCachedMaterial(): Nullable<Material>;
  109317. /**
  109318. * Gets the cached effect (ie. the latest rendered one)
  109319. * @returns the cached effect
  109320. */
  109321. getCachedEffect(): Nullable<Effect>;
  109322. /**
  109323. * Gets the cached visibility state (ie. the latest rendered one)
  109324. * @returns the cached visibility state
  109325. */
  109326. getCachedVisibility(): Nullable<number>;
  109327. /**
  109328. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  109329. * @param material defines the current material
  109330. * @param effect defines the current effect
  109331. * @param visibility defines the current visibility state
  109332. * @returns true if one parameter is not cached
  109333. */
  109334. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  109335. /**
  109336. * Gets the engine associated with the scene
  109337. * @returns an Engine
  109338. */
  109339. getEngine(): Engine;
  109340. /**
  109341. * Gets the total number of vertices rendered per frame
  109342. * @returns the total number of vertices rendered per frame
  109343. */
  109344. getTotalVertices(): number;
  109345. /**
  109346. * Gets the performance counter for total vertices
  109347. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109348. */
  109349. get totalVerticesPerfCounter(): PerfCounter;
  109350. /**
  109351. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  109352. * @returns the total number of active indices rendered per frame
  109353. */
  109354. getActiveIndices(): number;
  109355. /**
  109356. * Gets the performance counter for active indices
  109357. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109358. */
  109359. get totalActiveIndicesPerfCounter(): PerfCounter;
  109360. /**
  109361. * Gets the total number of active particles rendered per frame
  109362. * @returns the total number of active particles rendered per frame
  109363. */
  109364. getActiveParticles(): number;
  109365. /**
  109366. * Gets the performance counter for active particles
  109367. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109368. */
  109369. get activeParticlesPerfCounter(): PerfCounter;
  109370. /**
  109371. * Gets the total number of active bones rendered per frame
  109372. * @returns the total number of active bones rendered per frame
  109373. */
  109374. getActiveBones(): number;
  109375. /**
  109376. * Gets the performance counter for active bones
  109377. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109378. */
  109379. get activeBonesPerfCounter(): PerfCounter;
  109380. /**
  109381. * Gets the array of active meshes
  109382. * @returns an array of AbstractMesh
  109383. */
  109384. getActiveMeshes(): SmartArray<AbstractMesh>;
  109385. /**
  109386. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  109387. * @returns a number
  109388. */
  109389. getAnimationRatio(): number;
  109390. /**
  109391. * Gets an unique Id for the current render phase
  109392. * @returns a number
  109393. */
  109394. getRenderId(): number;
  109395. /**
  109396. * Gets an unique Id for the current frame
  109397. * @returns a number
  109398. */
  109399. getFrameId(): number;
  109400. /** Call this function if you want to manually increment the render Id*/
  109401. incrementRenderId(): void;
  109402. private _createUbo;
  109403. /**
  109404. * Use this method to simulate a pointer move on a mesh
  109405. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109406. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109407. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109408. * @returns the current scene
  109409. */
  109410. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  109411. /**
  109412. * Use this method to simulate a pointer down on a mesh
  109413. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109414. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109415. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109416. * @returns the current scene
  109417. */
  109418. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  109419. /**
  109420. * Use this method to simulate a pointer up on a mesh
  109421. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109422. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109423. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109424. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  109425. * @returns the current scene
  109426. */
  109427. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  109428. /**
  109429. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  109430. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  109431. * @returns true if the pointer was captured
  109432. */
  109433. isPointerCaptured(pointerId?: number): boolean;
  109434. /**
  109435. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  109436. * @param attachUp defines if you want to attach events to pointerup
  109437. * @param attachDown defines if you want to attach events to pointerdown
  109438. * @param attachMove defines if you want to attach events to pointermove
  109439. */
  109440. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  109441. /** Detaches all event handlers*/
  109442. detachControl(): void;
  109443. /**
  109444. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  109445. * Delay loaded resources are not taking in account
  109446. * @return true if all required resources are ready
  109447. */
  109448. isReady(): boolean;
  109449. /** Resets all cached information relative to material (including effect and visibility) */
  109450. resetCachedMaterial(): void;
  109451. /**
  109452. * Registers a function to be called before every frame render
  109453. * @param func defines the function to register
  109454. */
  109455. registerBeforeRender(func: () => void): void;
  109456. /**
  109457. * Unregisters a function called before every frame render
  109458. * @param func defines the function to unregister
  109459. */
  109460. unregisterBeforeRender(func: () => void): void;
  109461. /**
  109462. * Registers a function to be called after every frame render
  109463. * @param func defines the function to register
  109464. */
  109465. registerAfterRender(func: () => void): void;
  109466. /**
  109467. * Unregisters a function called after every frame render
  109468. * @param func defines the function to unregister
  109469. */
  109470. unregisterAfterRender(func: () => void): void;
  109471. private _executeOnceBeforeRender;
  109472. /**
  109473. * The provided function will run before render once and will be disposed afterwards.
  109474. * A timeout delay can be provided so that the function will be executed in N ms.
  109475. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  109476. * @param func The function to be executed.
  109477. * @param timeout optional delay in ms
  109478. */
  109479. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  109480. /** @hidden */
  109481. _addPendingData(data: any): void;
  109482. /** @hidden */
  109483. _removePendingData(data: any): void;
  109484. /**
  109485. * Returns the number of items waiting to be loaded
  109486. * @returns the number of items waiting to be loaded
  109487. */
  109488. getWaitingItemsCount(): number;
  109489. /**
  109490. * Returns a boolean indicating if the scene is still loading data
  109491. */
  109492. get isLoading(): boolean;
  109493. /**
  109494. * Registers a function to be executed when the scene is ready
  109495. * @param {Function} func - the function to be executed
  109496. */
  109497. executeWhenReady(func: () => void): void;
  109498. /**
  109499. * Returns a promise that resolves when the scene is ready
  109500. * @returns A promise that resolves when the scene is ready
  109501. */
  109502. whenReadyAsync(): Promise<void>;
  109503. /** @hidden */
  109504. _checkIsReady(): void;
  109505. /**
  109506. * Gets all animatable attached to the scene
  109507. */
  109508. get animatables(): Animatable[];
  109509. /**
  109510. * Resets the last animation time frame.
  109511. * Useful to override when animations start running when loading a scene for the first time.
  109512. */
  109513. resetLastAnimationTimeFrame(): void;
  109514. /**
  109515. * Gets the current view matrix
  109516. * @returns a Matrix
  109517. */
  109518. getViewMatrix(): Matrix;
  109519. /**
  109520. * Gets the current projection matrix
  109521. * @returns a Matrix
  109522. */
  109523. getProjectionMatrix(): Matrix;
  109524. /**
  109525. * Gets the current transform matrix
  109526. * @returns a Matrix made of View * Projection
  109527. */
  109528. getTransformMatrix(): Matrix;
  109529. /**
  109530. * Sets the current transform matrix
  109531. * @param viewL defines the View matrix to use
  109532. * @param projectionL defines the Projection matrix to use
  109533. * @param viewR defines the right View matrix to use (if provided)
  109534. * @param projectionR defines the right Projection matrix to use (if provided)
  109535. */
  109536. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  109537. /**
  109538. * Gets the uniform buffer used to store scene data
  109539. * @returns a UniformBuffer
  109540. */
  109541. getSceneUniformBuffer(): UniformBuffer;
  109542. /**
  109543. * Gets an unique (relatively to the current scene) Id
  109544. * @returns an unique number for the scene
  109545. */
  109546. getUniqueId(): number;
  109547. /**
  109548. * Add a mesh to the list of scene's meshes
  109549. * @param newMesh defines the mesh to add
  109550. * @param recursive if all child meshes should also be added to the scene
  109551. */
  109552. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  109553. /**
  109554. * Remove a mesh for the list of scene's meshes
  109555. * @param toRemove defines the mesh to remove
  109556. * @param recursive if all child meshes should also be removed from the scene
  109557. * @returns the index where the mesh was in the mesh list
  109558. */
  109559. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  109560. /**
  109561. * Add a transform node to the list of scene's transform nodes
  109562. * @param newTransformNode defines the transform node to add
  109563. */
  109564. addTransformNode(newTransformNode: TransformNode): void;
  109565. /**
  109566. * Remove a transform node for the list of scene's transform nodes
  109567. * @param toRemove defines the transform node to remove
  109568. * @returns the index where the transform node was in the transform node list
  109569. */
  109570. removeTransformNode(toRemove: TransformNode): number;
  109571. /**
  109572. * Remove a skeleton for the list of scene's skeletons
  109573. * @param toRemove defines the skeleton to remove
  109574. * @returns the index where the skeleton was in the skeleton list
  109575. */
  109576. removeSkeleton(toRemove: Skeleton): number;
  109577. /**
  109578. * Remove a morph target for the list of scene's morph targets
  109579. * @param toRemove defines the morph target to remove
  109580. * @returns the index where the morph target was in the morph target list
  109581. */
  109582. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  109583. /**
  109584. * Remove a light for the list of scene's lights
  109585. * @param toRemove defines the light to remove
  109586. * @returns the index where the light was in the light list
  109587. */
  109588. removeLight(toRemove: Light): number;
  109589. /**
  109590. * Remove a camera for the list of scene's cameras
  109591. * @param toRemove defines the camera to remove
  109592. * @returns the index where the camera was in the camera list
  109593. */
  109594. removeCamera(toRemove: Camera): number;
  109595. /**
  109596. * Remove a particle system for the list of scene's particle systems
  109597. * @param toRemove defines the particle system to remove
  109598. * @returns the index where the particle system was in the particle system list
  109599. */
  109600. removeParticleSystem(toRemove: IParticleSystem): number;
  109601. /**
  109602. * Remove a animation for the list of scene's animations
  109603. * @param toRemove defines the animation to remove
  109604. * @returns the index where the animation was in the animation list
  109605. */
  109606. removeAnimation(toRemove: Animation): number;
  109607. /**
  109608. * Will stop the animation of the given target
  109609. * @param target - the target
  109610. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  109611. * @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)
  109612. */
  109613. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  109614. /**
  109615. * Removes the given animation group from this scene.
  109616. * @param toRemove The animation group to remove
  109617. * @returns The index of the removed animation group
  109618. */
  109619. removeAnimationGroup(toRemove: AnimationGroup): number;
  109620. /**
  109621. * Removes the given multi-material from this scene.
  109622. * @param toRemove The multi-material to remove
  109623. * @returns The index of the removed multi-material
  109624. */
  109625. removeMultiMaterial(toRemove: MultiMaterial): number;
  109626. /**
  109627. * Removes the given material from this scene.
  109628. * @param toRemove The material to remove
  109629. * @returns The index of the removed material
  109630. */
  109631. removeMaterial(toRemove: Material): number;
  109632. /**
  109633. * Removes the given action manager from this scene.
  109634. * @param toRemove The action manager to remove
  109635. * @returns The index of the removed action manager
  109636. */
  109637. removeActionManager(toRemove: AbstractActionManager): number;
  109638. /**
  109639. * Removes the given texture from this scene.
  109640. * @param toRemove The texture to remove
  109641. * @returns The index of the removed texture
  109642. */
  109643. removeTexture(toRemove: BaseTexture): number;
  109644. /**
  109645. * Adds the given light to this scene
  109646. * @param newLight The light to add
  109647. */
  109648. addLight(newLight: Light): void;
  109649. /**
  109650. * Sorts the list list based on light priorities
  109651. */
  109652. sortLightsByPriority(): void;
  109653. /**
  109654. * Adds the given camera to this scene
  109655. * @param newCamera The camera to add
  109656. */
  109657. addCamera(newCamera: Camera): void;
  109658. /**
  109659. * Adds the given skeleton to this scene
  109660. * @param newSkeleton The skeleton to add
  109661. */
  109662. addSkeleton(newSkeleton: Skeleton): void;
  109663. /**
  109664. * Adds the given particle system to this scene
  109665. * @param newParticleSystem The particle system to add
  109666. */
  109667. addParticleSystem(newParticleSystem: IParticleSystem): void;
  109668. /**
  109669. * Adds the given animation to this scene
  109670. * @param newAnimation The animation to add
  109671. */
  109672. addAnimation(newAnimation: Animation): void;
  109673. /**
  109674. * Adds the given animation group to this scene.
  109675. * @param newAnimationGroup The animation group to add
  109676. */
  109677. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  109678. /**
  109679. * Adds the given multi-material to this scene
  109680. * @param newMultiMaterial The multi-material to add
  109681. */
  109682. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  109683. /**
  109684. * Adds the given material to this scene
  109685. * @param newMaterial The material to add
  109686. */
  109687. addMaterial(newMaterial: Material): void;
  109688. /**
  109689. * Adds the given morph target to this scene
  109690. * @param newMorphTargetManager The morph target to add
  109691. */
  109692. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  109693. /**
  109694. * Adds the given geometry to this scene
  109695. * @param newGeometry The geometry to add
  109696. */
  109697. addGeometry(newGeometry: Geometry): void;
  109698. /**
  109699. * Adds the given action manager to this scene
  109700. * @param newActionManager The action manager to add
  109701. */
  109702. addActionManager(newActionManager: AbstractActionManager): void;
  109703. /**
  109704. * Adds the given texture to this scene.
  109705. * @param newTexture The texture to add
  109706. */
  109707. addTexture(newTexture: BaseTexture): void;
  109708. /**
  109709. * Switch active camera
  109710. * @param newCamera defines the new active camera
  109711. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  109712. */
  109713. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  109714. /**
  109715. * sets the active camera of the scene using its ID
  109716. * @param id defines the camera's ID
  109717. * @return the new active camera or null if none found.
  109718. */
  109719. setActiveCameraByID(id: string): Nullable<Camera>;
  109720. /**
  109721. * sets the active camera of the scene using its name
  109722. * @param name defines the camera's name
  109723. * @returns the new active camera or null if none found.
  109724. */
  109725. setActiveCameraByName(name: string): Nullable<Camera>;
  109726. /**
  109727. * get an animation group using its name
  109728. * @param name defines the material's name
  109729. * @return the animation group or null if none found.
  109730. */
  109731. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  109732. /**
  109733. * Get a material using its unique id
  109734. * @param uniqueId defines the material's unique id
  109735. * @return the material or null if none found.
  109736. */
  109737. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  109738. /**
  109739. * get a material using its id
  109740. * @param id defines the material's ID
  109741. * @return the material or null if none found.
  109742. */
  109743. getMaterialByID(id: string): Nullable<Material>;
  109744. /**
  109745. * Gets a the last added material using a given id
  109746. * @param id defines the material's ID
  109747. * @return the last material with the given id or null if none found.
  109748. */
  109749. getLastMaterialByID(id: string): Nullable<Material>;
  109750. /**
  109751. * Gets a material using its name
  109752. * @param name defines the material's name
  109753. * @return the material or null if none found.
  109754. */
  109755. getMaterialByName(name: string): Nullable<Material>;
  109756. /**
  109757. * Get a texture using its unique id
  109758. * @param uniqueId defines the texture's unique id
  109759. * @return the texture or null if none found.
  109760. */
  109761. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  109762. /**
  109763. * Gets a camera using its id
  109764. * @param id defines the id to look for
  109765. * @returns the camera or null if not found
  109766. */
  109767. getCameraByID(id: string): Nullable<Camera>;
  109768. /**
  109769. * Gets a camera using its unique id
  109770. * @param uniqueId defines the unique id to look for
  109771. * @returns the camera or null if not found
  109772. */
  109773. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  109774. /**
  109775. * Gets a camera using its name
  109776. * @param name defines the camera's name
  109777. * @return the camera or null if none found.
  109778. */
  109779. getCameraByName(name: string): Nullable<Camera>;
  109780. /**
  109781. * Gets a bone using its id
  109782. * @param id defines the bone's id
  109783. * @return the bone or null if not found
  109784. */
  109785. getBoneByID(id: string): Nullable<Bone>;
  109786. /**
  109787. * Gets a bone using its id
  109788. * @param name defines the bone's name
  109789. * @return the bone or null if not found
  109790. */
  109791. getBoneByName(name: string): Nullable<Bone>;
  109792. /**
  109793. * Gets a light node using its name
  109794. * @param name defines the the light's name
  109795. * @return the light or null if none found.
  109796. */
  109797. getLightByName(name: string): Nullable<Light>;
  109798. /**
  109799. * Gets a light node using its id
  109800. * @param id defines the light's id
  109801. * @return the light or null if none found.
  109802. */
  109803. getLightByID(id: string): Nullable<Light>;
  109804. /**
  109805. * Gets a light node using its scene-generated unique ID
  109806. * @param uniqueId defines the light's unique id
  109807. * @return the light or null if none found.
  109808. */
  109809. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  109810. /**
  109811. * Gets a particle system by id
  109812. * @param id defines the particle system id
  109813. * @return the corresponding system or null if none found
  109814. */
  109815. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  109816. /**
  109817. * Gets a geometry using its ID
  109818. * @param id defines the geometry's id
  109819. * @return the geometry or null if none found.
  109820. */
  109821. getGeometryByID(id: string): Nullable<Geometry>;
  109822. private _getGeometryByUniqueID;
  109823. /**
  109824. * Add a new geometry to this scene
  109825. * @param geometry defines the geometry to be added to the scene.
  109826. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  109827. * @return a boolean defining if the geometry was added or not
  109828. */
  109829. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  109830. /**
  109831. * Removes an existing geometry
  109832. * @param geometry defines the geometry to be removed from the scene
  109833. * @return a boolean defining if the geometry was removed or not
  109834. */
  109835. removeGeometry(geometry: Geometry): boolean;
  109836. /**
  109837. * Gets the list of geometries attached to the scene
  109838. * @returns an array of Geometry
  109839. */
  109840. getGeometries(): Geometry[];
  109841. /**
  109842. * Gets the first added mesh found of a given ID
  109843. * @param id defines the id to search for
  109844. * @return the mesh found or null if not found at all
  109845. */
  109846. getMeshByID(id: string): Nullable<AbstractMesh>;
  109847. /**
  109848. * Gets a list of meshes using their id
  109849. * @param id defines the id to search for
  109850. * @returns a list of meshes
  109851. */
  109852. getMeshesByID(id: string): Array<AbstractMesh>;
  109853. /**
  109854. * Gets the first added transform node found of a given ID
  109855. * @param id defines the id to search for
  109856. * @return the found transform node or null if not found at all.
  109857. */
  109858. getTransformNodeByID(id: string): Nullable<TransformNode>;
  109859. /**
  109860. * Gets a transform node with its auto-generated unique id
  109861. * @param uniqueId efines the unique id to search for
  109862. * @return the found transform node or null if not found at all.
  109863. */
  109864. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  109865. /**
  109866. * Gets a list of transform nodes using their id
  109867. * @param id defines the id to search for
  109868. * @returns a list of transform nodes
  109869. */
  109870. getTransformNodesByID(id: string): Array<TransformNode>;
  109871. /**
  109872. * Gets a mesh with its auto-generated unique id
  109873. * @param uniqueId defines the unique id to search for
  109874. * @return the found mesh or null if not found at all.
  109875. */
  109876. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  109877. /**
  109878. * Gets a the last added mesh using a given id
  109879. * @param id defines the id to search for
  109880. * @return the found mesh or null if not found at all.
  109881. */
  109882. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  109883. /**
  109884. * Gets a the last added node (Mesh, Camera, Light) using a given id
  109885. * @param id defines the id to search for
  109886. * @return the found node or null if not found at all
  109887. */
  109888. getLastEntryByID(id: string): Nullable<Node>;
  109889. /**
  109890. * Gets a node (Mesh, Camera, Light) using a given id
  109891. * @param id defines the id to search for
  109892. * @return the found node or null if not found at all
  109893. */
  109894. getNodeByID(id: string): Nullable<Node>;
  109895. /**
  109896. * Gets a node (Mesh, Camera, Light) using a given name
  109897. * @param name defines the name to search for
  109898. * @return the found node or null if not found at all.
  109899. */
  109900. getNodeByName(name: string): Nullable<Node>;
  109901. /**
  109902. * Gets a mesh using a given name
  109903. * @param name defines the name to search for
  109904. * @return the found mesh or null if not found at all.
  109905. */
  109906. getMeshByName(name: string): Nullable<AbstractMesh>;
  109907. /**
  109908. * Gets a transform node using a given name
  109909. * @param name defines the name to search for
  109910. * @return the found transform node or null if not found at all.
  109911. */
  109912. getTransformNodeByName(name: string): Nullable<TransformNode>;
  109913. /**
  109914. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  109915. * @param id defines the id to search for
  109916. * @return the found skeleton or null if not found at all.
  109917. */
  109918. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  109919. /**
  109920. * Gets a skeleton using a given auto generated unique id
  109921. * @param uniqueId defines the unique id to search for
  109922. * @return the found skeleton or null if not found at all.
  109923. */
  109924. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  109925. /**
  109926. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  109927. * @param id defines the id to search for
  109928. * @return the found skeleton or null if not found at all.
  109929. */
  109930. getSkeletonById(id: string): Nullable<Skeleton>;
  109931. /**
  109932. * Gets a skeleton using a given name
  109933. * @param name defines the name to search for
  109934. * @return the found skeleton or null if not found at all.
  109935. */
  109936. getSkeletonByName(name: string): Nullable<Skeleton>;
  109937. /**
  109938. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  109939. * @param id defines the id to search for
  109940. * @return the found morph target manager or null if not found at all.
  109941. */
  109942. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  109943. /**
  109944. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  109945. * @param id defines the id to search for
  109946. * @return the found morph target or null if not found at all.
  109947. */
  109948. getMorphTargetById(id: string): Nullable<MorphTarget>;
  109949. /**
  109950. * Gets a boolean indicating if the given mesh is active
  109951. * @param mesh defines the mesh to look for
  109952. * @returns true if the mesh is in the active list
  109953. */
  109954. isActiveMesh(mesh: AbstractMesh): boolean;
  109955. /**
  109956. * Return a unique id as a string which can serve as an identifier for the scene
  109957. */
  109958. get uid(): string;
  109959. /**
  109960. * Add an externaly attached data from its key.
  109961. * This method call will fail and return false, if such key already exists.
  109962. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  109963. * @param key the unique key that identifies the data
  109964. * @param data the data object to associate to the key for this Engine instance
  109965. * @return true if no such key were already present and the data was added successfully, false otherwise
  109966. */
  109967. addExternalData<T>(key: string, data: T): boolean;
  109968. /**
  109969. * Get an externaly attached data from its key
  109970. * @param key the unique key that identifies the data
  109971. * @return the associated data, if present (can be null), or undefined if not present
  109972. */
  109973. getExternalData<T>(key: string): Nullable<T>;
  109974. /**
  109975. * Get an externaly attached data from its key, create it using a factory if it's not already present
  109976. * @param key the unique key that identifies the data
  109977. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  109978. * @return the associated data, can be null if the factory returned null.
  109979. */
  109980. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  109981. /**
  109982. * Remove an externaly attached data from the Engine instance
  109983. * @param key the unique key that identifies the data
  109984. * @return true if the data was successfully removed, false if it doesn't exist
  109985. */
  109986. removeExternalData(key: string): boolean;
  109987. private _evaluateSubMesh;
  109988. /**
  109989. * Clear the processed materials smart array preventing retention point in material dispose.
  109990. */
  109991. freeProcessedMaterials(): void;
  109992. private _preventFreeActiveMeshesAndRenderingGroups;
  109993. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  109994. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  109995. * when disposing several meshes in a row or a hierarchy of meshes.
  109996. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  109997. */
  109998. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  109999. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  110000. /**
  110001. * Clear the active meshes smart array preventing retention point in mesh dispose.
  110002. */
  110003. freeActiveMeshes(): void;
  110004. /**
  110005. * Clear the info related to rendering groups preventing retention points during dispose.
  110006. */
  110007. freeRenderingGroups(): void;
  110008. /** @hidden */
  110009. _isInIntermediateRendering(): boolean;
  110010. /**
  110011. * Lambda returning the list of potentially active meshes.
  110012. */
  110013. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  110014. /**
  110015. * Lambda returning the list of potentially active sub meshes.
  110016. */
  110017. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  110018. /**
  110019. * Lambda returning the list of potentially intersecting sub meshes.
  110020. */
  110021. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  110022. /**
  110023. * Lambda returning the list of potentially colliding sub meshes.
  110024. */
  110025. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  110026. private _activeMeshesFrozen;
  110027. private _skipEvaluateActiveMeshesCompletely;
  110028. /**
  110029. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  110030. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  110031. * @returns the current scene
  110032. */
  110033. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  110034. /**
  110035. * Use this function to restart evaluating active meshes on every frame
  110036. * @returns the current scene
  110037. */
  110038. unfreezeActiveMeshes(): Scene;
  110039. private _evaluateActiveMeshes;
  110040. private _activeMesh;
  110041. /**
  110042. * Update the transform matrix to update from the current active camera
  110043. * @param force defines a boolean used to force the update even if cache is up to date
  110044. */
  110045. updateTransformMatrix(force?: boolean): void;
  110046. private _bindFrameBuffer;
  110047. /** @hidden */
  110048. _allowPostProcessClearColor: boolean;
  110049. /** @hidden */
  110050. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  110051. private _processSubCameras;
  110052. private _checkIntersections;
  110053. /** @hidden */
  110054. _advancePhysicsEngineStep(step: number): void;
  110055. /**
  110056. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  110057. */
  110058. getDeterministicFrameTime: () => number;
  110059. /** @hidden */
  110060. _animate(): void;
  110061. /** Execute all animations (for a frame) */
  110062. animate(): void;
  110063. /**
  110064. * Render the scene
  110065. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  110066. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  110067. */
  110068. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  110069. /**
  110070. * Freeze all materials
  110071. * A frozen material will not be updatable but should be faster to render
  110072. */
  110073. freezeMaterials(): void;
  110074. /**
  110075. * Unfreeze all materials
  110076. * A frozen material will not be updatable but should be faster to render
  110077. */
  110078. unfreezeMaterials(): void;
  110079. /**
  110080. * Releases all held ressources
  110081. */
  110082. dispose(): void;
  110083. /**
  110084. * Gets if the scene is already disposed
  110085. */
  110086. get isDisposed(): boolean;
  110087. /**
  110088. * Call this function to reduce memory footprint of the scene.
  110089. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  110090. */
  110091. clearCachedVertexData(): void;
  110092. /**
  110093. * This function will remove the local cached buffer data from texture.
  110094. * It will save memory but will prevent the texture from being rebuilt
  110095. */
  110096. cleanCachedTextureBuffer(): void;
  110097. /**
  110098. * Get the world extend vectors with an optional filter
  110099. *
  110100. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  110101. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  110102. */
  110103. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  110104. min: Vector3;
  110105. max: Vector3;
  110106. };
  110107. /**
  110108. * Creates a ray that can be used to pick in the scene
  110109. * @param x defines the x coordinate of the origin (on-screen)
  110110. * @param y defines the y coordinate of the origin (on-screen)
  110111. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  110112. * @param camera defines the camera to use for the picking
  110113. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  110114. * @returns a Ray
  110115. */
  110116. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  110117. /**
  110118. * Creates a ray that can be used to pick in the scene
  110119. * @param x defines the x coordinate of the origin (on-screen)
  110120. * @param y defines the y coordinate of the origin (on-screen)
  110121. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  110122. * @param result defines the ray where to store the picking ray
  110123. * @param camera defines the camera to use for the picking
  110124. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  110125. * @returns the current scene
  110126. */
  110127. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  110128. /**
  110129. * Creates a ray that can be used to pick in the scene
  110130. * @param x defines the x coordinate of the origin (on-screen)
  110131. * @param y defines the y coordinate of the origin (on-screen)
  110132. * @param camera defines the camera to use for the picking
  110133. * @returns a Ray
  110134. */
  110135. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  110136. /**
  110137. * Creates a ray that can be used to pick in the scene
  110138. * @param x defines the x coordinate of the origin (on-screen)
  110139. * @param y defines the y coordinate of the origin (on-screen)
  110140. * @param result defines the ray where to store the picking ray
  110141. * @param camera defines the camera to use for the picking
  110142. * @returns the current scene
  110143. */
  110144. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  110145. /** Launch a ray to try to pick a mesh in the scene
  110146. * @param x position on screen
  110147. * @param y position on screen
  110148. * @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
  110149. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  110150. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  110151. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110152. * @returns a PickingInfo
  110153. */
  110154. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  110155. /** Use the given ray to pick a mesh in the scene
  110156. * @param ray The ray to use to pick meshes
  110157. * @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
  110158. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  110159. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110160. * @returns a PickingInfo
  110161. */
  110162. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  110163. /**
  110164. * Launch a ray to try to pick a mesh in the scene
  110165. * @param x X position on screen
  110166. * @param y Y position on screen
  110167. * @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
  110168. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  110169. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110170. * @returns an array of PickingInfo
  110171. */
  110172. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  110173. /**
  110174. * Launch a ray to try to pick a mesh in the scene
  110175. * @param ray Ray to use
  110176. * @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
  110177. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110178. * @returns an array of PickingInfo
  110179. */
  110180. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  110181. /**
  110182. * Force the value of meshUnderPointer
  110183. * @param mesh defines the mesh to use
  110184. */
  110185. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  110186. /**
  110187. * Gets the mesh under the pointer
  110188. * @returns a Mesh or null if no mesh is under the pointer
  110189. */
  110190. getPointerOverMesh(): Nullable<AbstractMesh>;
  110191. /** @hidden */
  110192. _rebuildGeometries(): void;
  110193. /** @hidden */
  110194. _rebuildTextures(): void;
  110195. private _getByTags;
  110196. /**
  110197. * Get a list of meshes by tags
  110198. * @param tagsQuery defines the tags query to use
  110199. * @param forEach defines a predicate used to filter results
  110200. * @returns an array of Mesh
  110201. */
  110202. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  110203. /**
  110204. * Get a list of cameras by tags
  110205. * @param tagsQuery defines the tags query to use
  110206. * @param forEach defines a predicate used to filter results
  110207. * @returns an array of Camera
  110208. */
  110209. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  110210. /**
  110211. * Get a list of lights by tags
  110212. * @param tagsQuery defines the tags query to use
  110213. * @param forEach defines a predicate used to filter results
  110214. * @returns an array of Light
  110215. */
  110216. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  110217. /**
  110218. * Get a list of materials by tags
  110219. * @param tagsQuery defines the tags query to use
  110220. * @param forEach defines a predicate used to filter results
  110221. * @returns an array of Material
  110222. */
  110223. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  110224. /**
  110225. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  110226. * This allowed control for front to back rendering or reversly depending of the special needs.
  110227. *
  110228. * @param renderingGroupId The rendering group id corresponding to its index
  110229. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  110230. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  110231. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  110232. */
  110233. 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;
  110234. /**
  110235. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  110236. *
  110237. * @param renderingGroupId The rendering group id corresponding to its index
  110238. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  110239. * @param depth Automatically clears depth between groups if true and autoClear is true.
  110240. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  110241. */
  110242. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  110243. /**
  110244. * Gets the current auto clear configuration for one rendering group of the rendering
  110245. * manager.
  110246. * @param index the rendering group index to get the information for
  110247. * @returns The auto clear setup for the requested rendering group
  110248. */
  110249. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  110250. private _blockMaterialDirtyMechanism;
  110251. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  110252. get blockMaterialDirtyMechanism(): boolean;
  110253. set blockMaterialDirtyMechanism(value: boolean);
  110254. /**
  110255. * Will flag all materials as dirty to trigger new shader compilation
  110256. * @param flag defines the flag used to specify which material part must be marked as dirty
  110257. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  110258. */
  110259. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  110260. /** @hidden */
  110261. _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;
  110262. /** @hidden */
  110263. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  110264. /** @hidden */
  110265. _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;
  110266. /** @hidden */
  110267. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  110268. /** @hidden */
  110269. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  110270. /** @hidden */
  110271. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  110272. }
  110273. }
  110274. declare module BABYLON {
  110275. /**
  110276. * Set of assets to keep when moving a scene into an asset container.
  110277. */
  110278. export class KeepAssets extends AbstractScene {
  110279. }
  110280. /**
  110281. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  110282. */
  110283. export class InstantiatedEntries {
  110284. /**
  110285. * List of new root nodes (eg. nodes with no parent)
  110286. */
  110287. rootNodes: TransformNode[];
  110288. /**
  110289. * List of new skeletons
  110290. */
  110291. skeletons: Skeleton[];
  110292. /**
  110293. * List of new animation groups
  110294. */
  110295. animationGroups: AnimationGroup[];
  110296. }
  110297. /**
  110298. * Container with a set of assets that can be added or removed from a scene.
  110299. */
  110300. export class AssetContainer extends AbstractScene {
  110301. private _wasAddedToScene;
  110302. /**
  110303. * The scene the AssetContainer belongs to.
  110304. */
  110305. scene: Scene;
  110306. /**
  110307. * Instantiates an AssetContainer.
  110308. * @param scene The scene the AssetContainer belongs to.
  110309. */
  110310. constructor(scene: Scene);
  110311. /**
  110312. * Instantiate or clone all meshes and add the new ones to the scene.
  110313. * Skeletons and animation groups will all be cloned
  110314. * @param nameFunction defines an optional function used to get new names for clones
  110315. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  110316. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  110317. */
  110318. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  110319. /**
  110320. * Adds all the assets from the container to the scene.
  110321. */
  110322. addAllToScene(): void;
  110323. /**
  110324. * Removes all the assets in the container from the scene
  110325. */
  110326. removeAllFromScene(): void;
  110327. /**
  110328. * Disposes all the assets in the container
  110329. */
  110330. dispose(): void;
  110331. private _moveAssets;
  110332. /**
  110333. * Removes all the assets contained in the scene and adds them to the container.
  110334. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  110335. */
  110336. moveAllFromScene(keepAssets?: KeepAssets): void;
  110337. /**
  110338. * 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.
  110339. * @returns the root mesh
  110340. */
  110341. createRootMesh(): Mesh;
  110342. /**
  110343. * Merge animations from this asset container into a scene
  110344. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  110345. * @param animatables set of animatables to retarget to a node from the scene
  110346. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  110347. */
  110348. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  110349. }
  110350. }
  110351. declare module BABYLON {
  110352. /**
  110353. * Defines how the parser contract is defined.
  110354. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  110355. */
  110356. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  110357. /**
  110358. * Defines how the individual parser contract is defined.
  110359. * These parser can parse an individual asset
  110360. */
  110361. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  110362. /**
  110363. * Base class of the scene acting as a container for the different elements composing a scene.
  110364. * This class is dynamically extended by the different components of the scene increasing
  110365. * flexibility and reducing coupling
  110366. */
  110367. export abstract class AbstractScene {
  110368. /**
  110369. * Stores the list of available parsers in the application.
  110370. */
  110371. private static _BabylonFileParsers;
  110372. /**
  110373. * Stores the list of available individual parsers in the application.
  110374. */
  110375. private static _IndividualBabylonFileParsers;
  110376. /**
  110377. * Adds a parser in the list of available ones
  110378. * @param name Defines the name of the parser
  110379. * @param parser Defines the parser to add
  110380. */
  110381. static AddParser(name: string, parser: BabylonFileParser): void;
  110382. /**
  110383. * Gets a general parser from the list of avaialble ones
  110384. * @param name Defines the name of the parser
  110385. * @returns the requested parser or null
  110386. */
  110387. static GetParser(name: string): Nullable<BabylonFileParser>;
  110388. /**
  110389. * Adds n individual parser in the list of available ones
  110390. * @param name Defines the name of the parser
  110391. * @param parser Defines the parser to add
  110392. */
  110393. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  110394. /**
  110395. * Gets an individual parser from the list of avaialble ones
  110396. * @param name Defines the name of the parser
  110397. * @returns the requested parser or null
  110398. */
  110399. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  110400. /**
  110401. * Parser json data and populate both a scene and its associated container object
  110402. * @param jsonData Defines the data to parse
  110403. * @param scene Defines the scene to parse the data for
  110404. * @param container Defines the container attached to the parsing sequence
  110405. * @param rootUrl Defines the root url of the data
  110406. */
  110407. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  110408. /**
  110409. * Gets the list of root nodes (ie. nodes with no parent)
  110410. */
  110411. rootNodes: Node[];
  110412. /** All of the cameras added to this scene
  110413. * @see http://doc.babylonjs.com/babylon101/cameras
  110414. */
  110415. cameras: Camera[];
  110416. /**
  110417. * All of the lights added to this scene
  110418. * @see http://doc.babylonjs.com/babylon101/lights
  110419. */
  110420. lights: Light[];
  110421. /**
  110422. * All of the (abstract) meshes added to this scene
  110423. */
  110424. meshes: AbstractMesh[];
  110425. /**
  110426. * The list of skeletons added to the scene
  110427. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  110428. */
  110429. skeletons: Skeleton[];
  110430. /**
  110431. * All of the particle systems added to this scene
  110432. * @see http://doc.babylonjs.com/babylon101/particles
  110433. */
  110434. particleSystems: IParticleSystem[];
  110435. /**
  110436. * Gets a list of Animations associated with the scene
  110437. */
  110438. animations: Animation[];
  110439. /**
  110440. * All of the animation groups added to this scene
  110441. * @see http://doc.babylonjs.com/how_to/group
  110442. */
  110443. animationGroups: AnimationGroup[];
  110444. /**
  110445. * All of the multi-materials added to this scene
  110446. * @see http://doc.babylonjs.com/how_to/multi_materials
  110447. */
  110448. multiMaterials: MultiMaterial[];
  110449. /**
  110450. * All of the materials added to this scene
  110451. * In the context of a Scene, it is not supposed to be modified manually.
  110452. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  110453. * Note also that the order of the Material within the array is not significant and might change.
  110454. * @see http://doc.babylonjs.com/babylon101/materials
  110455. */
  110456. materials: Material[];
  110457. /**
  110458. * The list of morph target managers added to the scene
  110459. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  110460. */
  110461. morphTargetManagers: MorphTargetManager[];
  110462. /**
  110463. * The list of geometries used in the scene.
  110464. */
  110465. geometries: Geometry[];
  110466. /**
  110467. * All of the tranform nodes added to this scene
  110468. * In the context of a Scene, it is not supposed to be modified manually.
  110469. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  110470. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  110471. * @see http://doc.babylonjs.com/how_to/transformnode
  110472. */
  110473. transformNodes: TransformNode[];
  110474. /**
  110475. * ActionManagers available on the scene.
  110476. */
  110477. actionManagers: AbstractActionManager[];
  110478. /**
  110479. * Textures to keep.
  110480. */
  110481. textures: BaseTexture[];
  110482. /**
  110483. * Environment texture for the scene
  110484. */
  110485. environmentTexture: Nullable<BaseTexture>;
  110486. /**
  110487. * @returns all meshes, lights, cameras, transformNodes and bones
  110488. */
  110489. getNodes(): Array<Node>;
  110490. }
  110491. }
  110492. declare module BABYLON {
  110493. /**
  110494. * Interface used to define options for Sound class
  110495. */
  110496. export interface ISoundOptions {
  110497. /**
  110498. * Does the sound autoplay once loaded.
  110499. */
  110500. autoplay?: boolean;
  110501. /**
  110502. * Does the sound loop after it finishes playing once.
  110503. */
  110504. loop?: boolean;
  110505. /**
  110506. * Sound's volume
  110507. */
  110508. volume?: number;
  110509. /**
  110510. * Is it a spatial sound?
  110511. */
  110512. spatialSound?: boolean;
  110513. /**
  110514. * Maximum distance to hear that sound
  110515. */
  110516. maxDistance?: number;
  110517. /**
  110518. * Uses user defined attenuation function
  110519. */
  110520. useCustomAttenuation?: boolean;
  110521. /**
  110522. * Define the roll off factor of spatial sounds.
  110523. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110524. */
  110525. rolloffFactor?: number;
  110526. /**
  110527. * Define the reference distance the sound should be heard perfectly.
  110528. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110529. */
  110530. refDistance?: number;
  110531. /**
  110532. * Define the distance attenuation model the sound will follow.
  110533. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110534. */
  110535. distanceModel?: string;
  110536. /**
  110537. * Defines the playback speed (1 by default)
  110538. */
  110539. playbackRate?: number;
  110540. /**
  110541. * Defines if the sound is from a streaming source
  110542. */
  110543. streaming?: boolean;
  110544. /**
  110545. * Defines an optional length (in seconds) inside the sound file
  110546. */
  110547. length?: number;
  110548. /**
  110549. * Defines an optional offset (in seconds) inside the sound file
  110550. */
  110551. offset?: number;
  110552. /**
  110553. * If true, URLs will not be required to state the audio file codec to use.
  110554. */
  110555. skipCodecCheck?: boolean;
  110556. }
  110557. /**
  110558. * Defines a sound that can be played in the application.
  110559. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  110560. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110561. */
  110562. export class Sound {
  110563. /**
  110564. * The name of the sound in the scene.
  110565. */
  110566. name: string;
  110567. /**
  110568. * Does the sound autoplay once loaded.
  110569. */
  110570. autoplay: boolean;
  110571. /**
  110572. * Does the sound loop after it finishes playing once.
  110573. */
  110574. loop: boolean;
  110575. /**
  110576. * Does the sound use a custom attenuation curve to simulate the falloff
  110577. * happening when the source gets further away from the camera.
  110578. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  110579. */
  110580. useCustomAttenuation: boolean;
  110581. /**
  110582. * The sound track id this sound belongs to.
  110583. */
  110584. soundTrackId: number;
  110585. /**
  110586. * Is this sound currently played.
  110587. */
  110588. isPlaying: boolean;
  110589. /**
  110590. * Is this sound currently paused.
  110591. */
  110592. isPaused: boolean;
  110593. /**
  110594. * Does this sound enables spatial sound.
  110595. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110596. */
  110597. spatialSound: boolean;
  110598. /**
  110599. * Define the reference distance the sound should be heard perfectly.
  110600. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110601. */
  110602. refDistance: number;
  110603. /**
  110604. * Define the roll off factor of spatial sounds.
  110605. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110606. */
  110607. rolloffFactor: number;
  110608. /**
  110609. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  110610. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110611. */
  110612. maxDistance: number;
  110613. /**
  110614. * Define the distance attenuation model the sound will follow.
  110615. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110616. */
  110617. distanceModel: string;
  110618. /**
  110619. * @hidden
  110620. * Back Compat
  110621. **/
  110622. onended: () => any;
  110623. /**
  110624. * Observable event when the current playing sound finishes.
  110625. */
  110626. onEndedObservable: Observable<Sound>;
  110627. private _panningModel;
  110628. private _playbackRate;
  110629. private _streaming;
  110630. private _startTime;
  110631. private _startOffset;
  110632. private _position;
  110633. /** @hidden */
  110634. _positionInEmitterSpace: boolean;
  110635. private _localDirection;
  110636. private _volume;
  110637. private _isReadyToPlay;
  110638. private _isDirectional;
  110639. private _readyToPlayCallback;
  110640. private _audioBuffer;
  110641. private _soundSource;
  110642. private _streamingSource;
  110643. private _soundPanner;
  110644. private _soundGain;
  110645. private _inputAudioNode;
  110646. private _outputAudioNode;
  110647. private _coneInnerAngle;
  110648. private _coneOuterAngle;
  110649. private _coneOuterGain;
  110650. private _scene;
  110651. private _connectedTransformNode;
  110652. private _customAttenuationFunction;
  110653. private _registerFunc;
  110654. private _isOutputConnected;
  110655. private _htmlAudioElement;
  110656. private _urlType;
  110657. private _length?;
  110658. private _offset?;
  110659. /** @hidden */
  110660. static _SceneComponentInitialization: (scene: Scene) => void;
  110661. /**
  110662. * Create a sound and attach it to a scene
  110663. * @param name Name of your sound
  110664. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  110665. * @param scene defines the scene the sound belongs to
  110666. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  110667. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  110668. */
  110669. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  110670. /**
  110671. * Release the sound and its associated resources
  110672. */
  110673. dispose(): void;
  110674. /**
  110675. * Gets if the sounds is ready to be played or not.
  110676. * @returns true if ready, otherwise false
  110677. */
  110678. isReady(): boolean;
  110679. private _soundLoaded;
  110680. /**
  110681. * Sets the data of the sound from an audiobuffer
  110682. * @param audioBuffer The audioBuffer containing the data
  110683. */
  110684. setAudioBuffer(audioBuffer: AudioBuffer): void;
  110685. /**
  110686. * Updates the current sounds options such as maxdistance, loop...
  110687. * @param options A JSON object containing values named as the object properties
  110688. */
  110689. updateOptions(options: ISoundOptions): void;
  110690. private _createSpatialParameters;
  110691. private _updateSpatialParameters;
  110692. /**
  110693. * Switch the panning model to HRTF:
  110694. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  110695. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110696. */
  110697. switchPanningModelToHRTF(): void;
  110698. /**
  110699. * Switch the panning model to Equal Power:
  110700. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  110701. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110702. */
  110703. switchPanningModelToEqualPower(): void;
  110704. private _switchPanningModel;
  110705. /**
  110706. * Connect this sound to a sound track audio node like gain...
  110707. * @param soundTrackAudioNode the sound track audio node to connect to
  110708. */
  110709. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  110710. /**
  110711. * Transform this sound into a directional source
  110712. * @param coneInnerAngle Size of the inner cone in degree
  110713. * @param coneOuterAngle Size of the outer cone in degree
  110714. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  110715. */
  110716. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  110717. /**
  110718. * Gets or sets the inner angle for the directional cone.
  110719. */
  110720. get directionalConeInnerAngle(): number;
  110721. /**
  110722. * Gets or sets the inner angle for the directional cone.
  110723. */
  110724. set directionalConeInnerAngle(value: number);
  110725. /**
  110726. * Gets or sets the outer angle for the directional cone.
  110727. */
  110728. get directionalConeOuterAngle(): number;
  110729. /**
  110730. * Gets or sets the outer angle for the directional cone.
  110731. */
  110732. set directionalConeOuterAngle(value: number);
  110733. /**
  110734. * Sets the position of the emitter if spatial sound is enabled
  110735. * @param newPosition Defines the new posisiton
  110736. */
  110737. setPosition(newPosition: Vector3): void;
  110738. /**
  110739. * Sets the local direction of the emitter if spatial sound is enabled
  110740. * @param newLocalDirection Defines the new local direction
  110741. */
  110742. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  110743. private _updateDirection;
  110744. /** @hidden */
  110745. updateDistanceFromListener(): void;
  110746. /**
  110747. * Sets a new custom attenuation function for the sound.
  110748. * @param callback Defines the function used for the attenuation
  110749. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  110750. */
  110751. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  110752. /**
  110753. * Play the sound
  110754. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  110755. * @param offset (optional) Start the sound at a specific time in seconds
  110756. * @param length (optional) Sound duration (in seconds)
  110757. */
  110758. play(time?: number, offset?: number, length?: number): void;
  110759. private _onended;
  110760. /**
  110761. * Stop the sound
  110762. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  110763. */
  110764. stop(time?: number): void;
  110765. /**
  110766. * Put the sound in pause
  110767. */
  110768. pause(): void;
  110769. /**
  110770. * Sets a dedicated volume for this sounds
  110771. * @param newVolume Define the new volume of the sound
  110772. * @param time Define time for gradual change to new volume
  110773. */
  110774. setVolume(newVolume: number, time?: number): void;
  110775. /**
  110776. * Set the sound play back rate
  110777. * @param newPlaybackRate Define the playback rate the sound should be played at
  110778. */
  110779. setPlaybackRate(newPlaybackRate: number): void;
  110780. /**
  110781. * Gets the volume of the sound.
  110782. * @returns the volume of the sound
  110783. */
  110784. getVolume(): number;
  110785. /**
  110786. * Attach the sound to a dedicated mesh
  110787. * @param transformNode The transform node to connect the sound with
  110788. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  110789. */
  110790. attachToMesh(transformNode: TransformNode): void;
  110791. /**
  110792. * Detach the sound from the previously attached mesh
  110793. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  110794. */
  110795. detachFromMesh(): void;
  110796. private _onRegisterAfterWorldMatrixUpdate;
  110797. /**
  110798. * Clone the current sound in the scene.
  110799. * @returns the new sound clone
  110800. */
  110801. clone(): Nullable<Sound>;
  110802. /**
  110803. * Gets the current underlying audio buffer containing the data
  110804. * @returns the audio buffer
  110805. */
  110806. getAudioBuffer(): Nullable<AudioBuffer>;
  110807. /**
  110808. * Serializes the Sound in a JSON representation
  110809. * @returns the JSON representation of the sound
  110810. */
  110811. serialize(): any;
  110812. /**
  110813. * Parse a JSON representation of a sound to innstantiate in a given scene
  110814. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  110815. * @param scene Define the scene the new parsed sound should be created in
  110816. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  110817. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  110818. * @returns the newly parsed sound
  110819. */
  110820. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  110821. }
  110822. }
  110823. declare module BABYLON {
  110824. /**
  110825. * This defines an action helpful to play a defined sound on a triggered action.
  110826. */
  110827. export class PlaySoundAction extends Action {
  110828. private _sound;
  110829. /**
  110830. * Instantiate the action
  110831. * @param triggerOptions defines the trigger options
  110832. * @param sound defines the sound to play
  110833. * @param condition defines the trigger related conditions
  110834. */
  110835. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  110836. /** @hidden */
  110837. _prepare(): void;
  110838. /**
  110839. * Execute the action and play the sound.
  110840. */
  110841. execute(): void;
  110842. /**
  110843. * Serializes the actions and its related information.
  110844. * @param parent defines the object to serialize in
  110845. * @returns the serialized object
  110846. */
  110847. serialize(parent: any): any;
  110848. }
  110849. /**
  110850. * This defines an action helpful to stop a defined sound on a triggered action.
  110851. */
  110852. export class StopSoundAction extends Action {
  110853. private _sound;
  110854. /**
  110855. * Instantiate the action
  110856. * @param triggerOptions defines the trigger options
  110857. * @param sound defines the sound to stop
  110858. * @param condition defines the trigger related conditions
  110859. */
  110860. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  110861. /** @hidden */
  110862. _prepare(): void;
  110863. /**
  110864. * Execute the action and stop the sound.
  110865. */
  110866. execute(): void;
  110867. /**
  110868. * Serializes the actions and its related information.
  110869. * @param parent defines the object to serialize in
  110870. * @returns the serialized object
  110871. */
  110872. serialize(parent: any): any;
  110873. }
  110874. }
  110875. declare module BABYLON {
  110876. /**
  110877. * This defines an action responsible to change the value of a property
  110878. * by interpolating between its current value and the newly set one once triggered.
  110879. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  110880. */
  110881. export class InterpolateValueAction extends Action {
  110882. /**
  110883. * Defines the path of the property where the value should be interpolated
  110884. */
  110885. propertyPath: string;
  110886. /**
  110887. * Defines the target value at the end of the interpolation.
  110888. */
  110889. value: any;
  110890. /**
  110891. * Defines the time it will take for the property to interpolate to the value.
  110892. */
  110893. duration: number;
  110894. /**
  110895. * Defines if the other scene animations should be stopped when the action has been triggered
  110896. */
  110897. stopOtherAnimations?: boolean;
  110898. /**
  110899. * Defines a callback raised once the interpolation animation has been done.
  110900. */
  110901. onInterpolationDone?: () => void;
  110902. /**
  110903. * Observable triggered once the interpolation animation has been done.
  110904. */
  110905. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  110906. private _target;
  110907. private _effectiveTarget;
  110908. private _property;
  110909. /**
  110910. * Instantiate the action
  110911. * @param triggerOptions defines the trigger options
  110912. * @param target defines the object containing the value to interpolate
  110913. * @param propertyPath defines the path to the property in the target object
  110914. * @param value defines the target value at the end of the interpolation
  110915. * @param duration deines the time it will take for the property to interpolate to the value.
  110916. * @param condition defines the trigger related conditions
  110917. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  110918. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  110919. */
  110920. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  110921. /** @hidden */
  110922. _prepare(): void;
  110923. /**
  110924. * Execute the action starts the value interpolation.
  110925. */
  110926. execute(): void;
  110927. /**
  110928. * Serializes the actions and its related information.
  110929. * @param parent defines the object to serialize in
  110930. * @returns the serialized object
  110931. */
  110932. serialize(parent: any): any;
  110933. }
  110934. }
  110935. declare module BABYLON {
  110936. /**
  110937. * Options allowed during the creation of a sound track.
  110938. */
  110939. export interface ISoundTrackOptions {
  110940. /**
  110941. * The volume the sound track should take during creation
  110942. */
  110943. volume?: number;
  110944. /**
  110945. * Define if the sound track is the main sound track of the scene
  110946. */
  110947. mainTrack?: boolean;
  110948. }
  110949. /**
  110950. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  110951. * It will be also used in a future release to apply effects on a specific track.
  110952. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  110953. */
  110954. export class SoundTrack {
  110955. /**
  110956. * The unique identifier of the sound track in the scene.
  110957. */
  110958. id: number;
  110959. /**
  110960. * The list of sounds included in the sound track.
  110961. */
  110962. soundCollection: Array<Sound>;
  110963. private _outputAudioNode;
  110964. private _scene;
  110965. private _connectedAnalyser;
  110966. private _options;
  110967. private _isInitialized;
  110968. /**
  110969. * Creates a new sound track.
  110970. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  110971. * @param scene Define the scene the sound track belongs to
  110972. * @param options
  110973. */
  110974. constructor(scene: Scene, options?: ISoundTrackOptions);
  110975. private _initializeSoundTrackAudioGraph;
  110976. /**
  110977. * Release the sound track and its associated resources
  110978. */
  110979. dispose(): void;
  110980. /**
  110981. * Adds a sound to this sound track
  110982. * @param sound define the cound to add
  110983. * @ignoreNaming
  110984. */
  110985. AddSound(sound: Sound): void;
  110986. /**
  110987. * Removes a sound to this sound track
  110988. * @param sound define the cound to remove
  110989. * @ignoreNaming
  110990. */
  110991. RemoveSound(sound: Sound): void;
  110992. /**
  110993. * Set a global volume for the full sound track.
  110994. * @param newVolume Define the new volume of the sound track
  110995. */
  110996. setVolume(newVolume: number): void;
  110997. /**
  110998. * Switch the panning model to HRTF:
  110999. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  111000. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111001. */
  111002. switchPanningModelToHRTF(): void;
  111003. /**
  111004. * Switch the panning model to Equal Power:
  111005. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  111006. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111007. */
  111008. switchPanningModelToEqualPower(): void;
  111009. /**
  111010. * Connect the sound track to an audio analyser allowing some amazing
  111011. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  111012. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  111013. * @param analyser The analyser to connect to the engine
  111014. */
  111015. connectToAnalyser(analyser: Analyser): void;
  111016. }
  111017. }
  111018. declare module BABYLON {
  111019. interface AbstractScene {
  111020. /**
  111021. * The list of sounds used in the scene.
  111022. */
  111023. sounds: Nullable<Array<Sound>>;
  111024. }
  111025. interface Scene {
  111026. /**
  111027. * @hidden
  111028. * Backing field
  111029. */
  111030. _mainSoundTrack: SoundTrack;
  111031. /**
  111032. * The main sound track played by the scene.
  111033. * It cotains your primary collection of sounds.
  111034. */
  111035. mainSoundTrack: SoundTrack;
  111036. /**
  111037. * The list of sound tracks added to the scene
  111038. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111039. */
  111040. soundTracks: Nullable<Array<SoundTrack>>;
  111041. /**
  111042. * Gets a sound using a given name
  111043. * @param name defines the name to search for
  111044. * @return the found sound or null if not found at all.
  111045. */
  111046. getSoundByName(name: string): Nullable<Sound>;
  111047. /**
  111048. * Gets or sets if audio support is enabled
  111049. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111050. */
  111051. audioEnabled: boolean;
  111052. /**
  111053. * Gets or sets if audio will be output to headphones
  111054. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111055. */
  111056. headphone: boolean;
  111057. /**
  111058. * Gets or sets custom audio listener position provider
  111059. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111060. */
  111061. audioListenerPositionProvider: Nullable<() => Vector3>;
  111062. /**
  111063. * Gets or sets a refresh rate when using 3D audio positioning
  111064. */
  111065. audioPositioningRefreshRate: number;
  111066. }
  111067. /**
  111068. * Defines the sound scene component responsible to manage any sounds
  111069. * in a given scene.
  111070. */
  111071. export class AudioSceneComponent implements ISceneSerializableComponent {
  111072. /**
  111073. * The component name helpfull to identify the component in the list of scene components.
  111074. */
  111075. readonly name: string;
  111076. /**
  111077. * The scene the component belongs to.
  111078. */
  111079. scene: Scene;
  111080. private _audioEnabled;
  111081. /**
  111082. * Gets whether audio is enabled or not.
  111083. * Please use related enable/disable method to switch state.
  111084. */
  111085. get audioEnabled(): boolean;
  111086. private _headphone;
  111087. /**
  111088. * Gets whether audio is outputing to headphone or not.
  111089. * Please use the according Switch methods to change output.
  111090. */
  111091. get headphone(): boolean;
  111092. /**
  111093. * Gets or sets a refresh rate when using 3D audio positioning
  111094. */
  111095. audioPositioningRefreshRate: number;
  111096. private _audioListenerPositionProvider;
  111097. /**
  111098. * Gets the current audio listener position provider
  111099. */
  111100. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  111101. /**
  111102. * Sets a custom listener position for all sounds in the scene
  111103. * By default, this is the position of the first active camera
  111104. */
  111105. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  111106. /**
  111107. * Creates a new instance of the component for the given scene
  111108. * @param scene Defines the scene to register the component in
  111109. */
  111110. constructor(scene: Scene);
  111111. /**
  111112. * Registers the component in a given scene
  111113. */
  111114. register(): void;
  111115. /**
  111116. * Rebuilds the elements related to this component in case of
  111117. * context lost for instance.
  111118. */
  111119. rebuild(): void;
  111120. /**
  111121. * Serializes the component data to the specified json object
  111122. * @param serializationObject The object to serialize to
  111123. */
  111124. serialize(serializationObject: any): void;
  111125. /**
  111126. * Adds all the elements from the container to the scene
  111127. * @param container the container holding the elements
  111128. */
  111129. addFromContainer(container: AbstractScene): void;
  111130. /**
  111131. * Removes all the elements in the container from the scene
  111132. * @param container contains the elements to remove
  111133. * @param dispose if the removed element should be disposed (default: false)
  111134. */
  111135. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111136. /**
  111137. * Disposes the component and the associated ressources.
  111138. */
  111139. dispose(): void;
  111140. /**
  111141. * Disables audio in the associated scene.
  111142. */
  111143. disableAudio(): void;
  111144. /**
  111145. * Enables audio in the associated scene.
  111146. */
  111147. enableAudio(): void;
  111148. /**
  111149. * Switch audio to headphone output.
  111150. */
  111151. switchAudioModeForHeadphones(): void;
  111152. /**
  111153. * Switch audio to normal speakers.
  111154. */
  111155. switchAudioModeForNormalSpeakers(): void;
  111156. private _cachedCameraDirection;
  111157. private _cachedCameraPosition;
  111158. private _lastCheck;
  111159. private _afterRender;
  111160. }
  111161. }
  111162. declare module BABYLON {
  111163. /**
  111164. * Wraps one or more Sound objects and selects one with random weight for playback.
  111165. */
  111166. export class WeightedSound {
  111167. /** When true a Sound will be selected and played when the current playing Sound completes. */
  111168. loop: boolean;
  111169. private _coneInnerAngle;
  111170. private _coneOuterAngle;
  111171. private _volume;
  111172. /** A Sound is currently playing. */
  111173. isPlaying: boolean;
  111174. /** A Sound is currently paused. */
  111175. isPaused: boolean;
  111176. private _sounds;
  111177. private _weights;
  111178. private _currentIndex?;
  111179. /**
  111180. * Creates a new WeightedSound from the list of sounds given.
  111181. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  111182. * @param sounds Array of Sounds that will be selected from.
  111183. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  111184. */
  111185. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  111186. /**
  111187. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  111188. */
  111189. get directionalConeInnerAngle(): number;
  111190. /**
  111191. * The size of cone in degress for a directional sound in which there will be no attenuation.
  111192. */
  111193. set directionalConeInnerAngle(value: number);
  111194. /**
  111195. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  111196. * Listener angles between innerAngle and outerAngle will falloff linearly.
  111197. */
  111198. get directionalConeOuterAngle(): number;
  111199. /**
  111200. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  111201. * Listener angles between innerAngle and outerAngle will falloff linearly.
  111202. */
  111203. set directionalConeOuterAngle(value: number);
  111204. /**
  111205. * Playback volume.
  111206. */
  111207. get volume(): number;
  111208. /**
  111209. * Playback volume.
  111210. */
  111211. set volume(value: number);
  111212. private _onended;
  111213. /**
  111214. * Suspend playback
  111215. */
  111216. pause(): void;
  111217. /**
  111218. * Stop playback
  111219. */
  111220. stop(): void;
  111221. /**
  111222. * Start playback.
  111223. * @param startOffset Position the clip head at a specific time in seconds.
  111224. */
  111225. play(startOffset?: number): void;
  111226. }
  111227. }
  111228. declare module BABYLON {
  111229. /**
  111230. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  111231. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  111232. */
  111233. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  111234. /**
  111235. * Gets the name of the behavior.
  111236. */
  111237. get name(): string;
  111238. /**
  111239. * The easing function used by animations
  111240. */
  111241. static EasingFunction: BackEase;
  111242. /**
  111243. * The easing mode used by animations
  111244. */
  111245. static EasingMode: number;
  111246. /**
  111247. * The duration of the animation, in milliseconds
  111248. */
  111249. transitionDuration: number;
  111250. /**
  111251. * Length of the distance animated by the transition when lower radius is reached
  111252. */
  111253. lowerRadiusTransitionRange: number;
  111254. /**
  111255. * Length of the distance animated by the transition when upper radius is reached
  111256. */
  111257. upperRadiusTransitionRange: number;
  111258. private _autoTransitionRange;
  111259. /**
  111260. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  111261. */
  111262. get autoTransitionRange(): boolean;
  111263. /**
  111264. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  111265. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  111266. */
  111267. set autoTransitionRange(value: boolean);
  111268. private _attachedCamera;
  111269. private _onAfterCheckInputsObserver;
  111270. private _onMeshTargetChangedObserver;
  111271. /**
  111272. * Initializes the behavior.
  111273. */
  111274. init(): void;
  111275. /**
  111276. * Attaches the behavior to its arc rotate camera.
  111277. * @param camera Defines the camera to attach the behavior to
  111278. */
  111279. attach(camera: ArcRotateCamera): void;
  111280. /**
  111281. * Detaches the behavior from its current arc rotate camera.
  111282. */
  111283. detach(): void;
  111284. private _radiusIsAnimating;
  111285. private _radiusBounceTransition;
  111286. private _animatables;
  111287. private _cachedWheelPrecision;
  111288. /**
  111289. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  111290. * @param radiusLimit The limit to check against.
  111291. * @return Bool to indicate if at limit.
  111292. */
  111293. private _isRadiusAtLimit;
  111294. /**
  111295. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  111296. * @param radiusDelta The delta by which to animate to. Can be negative.
  111297. */
  111298. private _applyBoundRadiusAnimation;
  111299. /**
  111300. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  111301. */
  111302. protected _clearAnimationLocks(): void;
  111303. /**
  111304. * Stops and removes all animations that have been applied to the camera
  111305. */
  111306. stopAllAnimations(): void;
  111307. }
  111308. }
  111309. declare module BABYLON {
  111310. /**
  111311. * 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.
  111312. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  111313. */
  111314. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  111315. /**
  111316. * Gets the name of the behavior.
  111317. */
  111318. get name(): string;
  111319. private _mode;
  111320. private _radiusScale;
  111321. private _positionScale;
  111322. private _defaultElevation;
  111323. private _elevationReturnTime;
  111324. private _elevationReturnWaitTime;
  111325. private _zoomStopsAnimation;
  111326. private _framingTime;
  111327. /**
  111328. * The easing function used by animations
  111329. */
  111330. static EasingFunction: ExponentialEase;
  111331. /**
  111332. * The easing mode used by animations
  111333. */
  111334. static EasingMode: number;
  111335. /**
  111336. * Sets the current mode used by the behavior
  111337. */
  111338. set mode(mode: number);
  111339. /**
  111340. * Gets current mode used by the behavior.
  111341. */
  111342. get mode(): number;
  111343. /**
  111344. * Sets the scale applied to the radius (1 by default)
  111345. */
  111346. set radiusScale(radius: number);
  111347. /**
  111348. * Gets the scale applied to the radius
  111349. */
  111350. get radiusScale(): number;
  111351. /**
  111352. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  111353. */
  111354. set positionScale(scale: number);
  111355. /**
  111356. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  111357. */
  111358. get positionScale(): number;
  111359. /**
  111360. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  111361. * behaviour is triggered, in radians.
  111362. */
  111363. set defaultElevation(elevation: number);
  111364. /**
  111365. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  111366. * behaviour is triggered, in radians.
  111367. */
  111368. get defaultElevation(): number;
  111369. /**
  111370. * Sets the time (in milliseconds) taken to return to the default beta position.
  111371. * Negative value indicates camera should not return to default.
  111372. */
  111373. set elevationReturnTime(speed: number);
  111374. /**
  111375. * Gets the time (in milliseconds) taken to return to the default beta position.
  111376. * Negative value indicates camera should not return to default.
  111377. */
  111378. get elevationReturnTime(): number;
  111379. /**
  111380. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  111381. */
  111382. set elevationReturnWaitTime(time: number);
  111383. /**
  111384. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  111385. */
  111386. get elevationReturnWaitTime(): number;
  111387. /**
  111388. * Sets the flag that indicates if user zooming should stop animation.
  111389. */
  111390. set zoomStopsAnimation(flag: boolean);
  111391. /**
  111392. * Gets the flag that indicates if user zooming should stop animation.
  111393. */
  111394. get zoomStopsAnimation(): boolean;
  111395. /**
  111396. * Sets the transition time when framing the mesh, in milliseconds
  111397. */
  111398. set framingTime(time: number);
  111399. /**
  111400. * Gets the transition time when framing the mesh, in milliseconds
  111401. */
  111402. get framingTime(): number;
  111403. /**
  111404. * Define if the behavior should automatically change the configured
  111405. * camera limits and sensibilities.
  111406. */
  111407. autoCorrectCameraLimitsAndSensibility: boolean;
  111408. private _onPrePointerObservableObserver;
  111409. private _onAfterCheckInputsObserver;
  111410. private _onMeshTargetChangedObserver;
  111411. private _attachedCamera;
  111412. private _isPointerDown;
  111413. private _lastInteractionTime;
  111414. /**
  111415. * Initializes the behavior.
  111416. */
  111417. init(): void;
  111418. /**
  111419. * Attaches the behavior to its arc rotate camera.
  111420. * @param camera Defines the camera to attach the behavior to
  111421. */
  111422. attach(camera: ArcRotateCamera): void;
  111423. /**
  111424. * Detaches the behavior from its current arc rotate camera.
  111425. */
  111426. detach(): void;
  111427. private _animatables;
  111428. private _betaIsAnimating;
  111429. private _betaTransition;
  111430. private _radiusTransition;
  111431. private _vectorTransition;
  111432. /**
  111433. * Targets the given mesh and updates zoom level accordingly.
  111434. * @param mesh The mesh to target.
  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. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111439. /**
  111440. * Targets the given mesh with its children and updates zoom level accordingly.
  111441. * @param mesh The mesh to target.
  111442. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111443. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111444. */
  111445. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111446. /**
  111447. * Targets the given meshes with their children and updates zoom level accordingly.
  111448. * @param meshes The mesh to target.
  111449. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111450. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111451. */
  111452. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111453. /**
  111454. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  111455. * @param minimumWorld Determines the smaller position of the bounding box extend
  111456. * @param maximumWorld Determines the bigger position of the bounding box extend
  111457. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111458. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111459. */
  111460. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111461. /**
  111462. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  111463. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  111464. * frustum width.
  111465. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  111466. * to fully enclose the mesh in the viewing frustum.
  111467. */
  111468. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  111469. /**
  111470. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  111471. * is automatically returned to its default position (expected to be above ground plane).
  111472. */
  111473. private _maintainCameraAboveGround;
  111474. /**
  111475. * Returns the frustum slope based on the canvas ratio and camera FOV
  111476. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  111477. */
  111478. private _getFrustumSlope;
  111479. /**
  111480. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  111481. */
  111482. private _clearAnimationLocks;
  111483. /**
  111484. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  111485. */
  111486. private _applyUserInteraction;
  111487. /**
  111488. * Stops and removes all animations that have been applied to the camera
  111489. */
  111490. stopAllAnimations(): void;
  111491. /**
  111492. * Gets a value indicating if the user is moving the camera
  111493. */
  111494. get isUserIsMoving(): boolean;
  111495. /**
  111496. * The camera can move all the way towards the mesh.
  111497. */
  111498. static IgnoreBoundsSizeMode: number;
  111499. /**
  111500. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  111501. */
  111502. static FitFrustumSidesMode: number;
  111503. }
  111504. }
  111505. declare module BABYLON {
  111506. /**
  111507. * Base class for Camera Pointer Inputs.
  111508. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  111509. * for example usage.
  111510. */
  111511. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  111512. /**
  111513. * Defines the camera the input is attached to.
  111514. */
  111515. abstract camera: Camera;
  111516. /**
  111517. * Whether keyboard modifier keys are pressed at time of last mouse event.
  111518. */
  111519. protected _altKey: boolean;
  111520. protected _ctrlKey: boolean;
  111521. protected _metaKey: boolean;
  111522. protected _shiftKey: boolean;
  111523. /**
  111524. * Which mouse buttons were pressed at time of last mouse event.
  111525. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  111526. */
  111527. protected _buttonsPressed: number;
  111528. /**
  111529. * Defines the buttons associated with the input to handle camera move.
  111530. */
  111531. buttons: number[];
  111532. /**
  111533. * Attach the input controls to a specific dom element to get the input from.
  111534. * @param element Defines the element the controls should be listened from
  111535. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111536. */
  111537. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111538. /**
  111539. * Detach the current controls from the specified dom element.
  111540. * @param element Defines the element to stop listening the inputs from
  111541. */
  111542. detachControl(element: Nullable<HTMLElement>): void;
  111543. /**
  111544. * Gets the class name of the current input.
  111545. * @returns the class name
  111546. */
  111547. getClassName(): string;
  111548. /**
  111549. * Get the friendly name associated with the input class.
  111550. * @returns the input friendly name
  111551. */
  111552. getSimpleName(): string;
  111553. /**
  111554. * Called on pointer POINTERDOUBLETAP event.
  111555. * Override this method to provide functionality on POINTERDOUBLETAP event.
  111556. */
  111557. protected onDoubleTap(type: string): void;
  111558. /**
  111559. * Called on pointer POINTERMOVE event if only a single touch is active.
  111560. * Override this method to provide functionality.
  111561. */
  111562. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  111563. /**
  111564. * Called on pointer POINTERMOVE event if multiple touches are active.
  111565. * Override this method to provide functionality.
  111566. */
  111567. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  111568. /**
  111569. * Called on JS contextmenu event.
  111570. * Override this method to provide functionality.
  111571. */
  111572. protected onContextMenu(evt: PointerEvent): void;
  111573. /**
  111574. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  111575. * press.
  111576. * Override this method to provide functionality.
  111577. */
  111578. protected onButtonDown(evt: PointerEvent): void;
  111579. /**
  111580. * Called each time a new POINTERUP event occurs. Ie, for each button
  111581. * release.
  111582. * Override this method to provide functionality.
  111583. */
  111584. protected onButtonUp(evt: PointerEvent): void;
  111585. /**
  111586. * Called when window becomes inactive.
  111587. * Override this method to provide functionality.
  111588. */
  111589. protected onLostFocus(): void;
  111590. private _pointerInput;
  111591. private _observer;
  111592. private _onLostFocus;
  111593. private pointA;
  111594. private pointB;
  111595. }
  111596. }
  111597. declare module BABYLON {
  111598. /**
  111599. * Manage the pointers inputs to control an arc rotate camera.
  111600. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111601. */
  111602. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  111603. /**
  111604. * Defines the camera the input is attached to.
  111605. */
  111606. camera: ArcRotateCamera;
  111607. /**
  111608. * Gets the class name of the current input.
  111609. * @returns the class name
  111610. */
  111611. getClassName(): string;
  111612. /**
  111613. * Defines the buttons associated with the input to handle camera move.
  111614. */
  111615. buttons: number[];
  111616. /**
  111617. * Defines the pointer angular sensibility along the X axis or how fast is
  111618. * the camera rotating.
  111619. */
  111620. angularSensibilityX: number;
  111621. /**
  111622. * Defines the pointer angular sensibility along the Y axis or how fast is
  111623. * the camera rotating.
  111624. */
  111625. angularSensibilityY: number;
  111626. /**
  111627. * Defines the pointer pinch precision or how fast is the camera zooming.
  111628. */
  111629. pinchPrecision: number;
  111630. /**
  111631. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  111632. * from 0.
  111633. * It defines the percentage of current camera.radius to use as delta when
  111634. * pinch zoom is used.
  111635. */
  111636. pinchDeltaPercentage: number;
  111637. /**
  111638. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  111639. * that any object in the plane at the camera's target point will scale
  111640. * perfectly with finger motion.
  111641. * Overrides pinchDeltaPercentage and pinchPrecision.
  111642. */
  111643. useNaturalPinchZoom: boolean;
  111644. /**
  111645. * Defines the pointer panning sensibility or how fast is the camera moving.
  111646. */
  111647. panningSensibility: number;
  111648. /**
  111649. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  111650. */
  111651. multiTouchPanning: boolean;
  111652. /**
  111653. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  111654. * zoom (pinch) through multitouch.
  111655. */
  111656. multiTouchPanAndZoom: boolean;
  111657. /**
  111658. * Revers pinch action direction.
  111659. */
  111660. pinchInwards: boolean;
  111661. private _isPanClick;
  111662. private _twoFingerActivityCount;
  111663. private _isPinching;
  111664. /**
  111665. * Called on pointer POINTERMOVE event if only a single touch is active.
  111666. */
  111667. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  111668. /**
  111669. * Called on pointer POINTERDOUBLETAP event.
  111670. */
  111671. protected onDoubleTap(type: string): void;
  111672. /**
  111673. * Called on pointer POINTERMOVE event if multiple touches are active.
  111674. */
  111675. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  111676. /**
  111677. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  111678. * press.
  111679. */
  111680. protected onButtonDown(evt: PointerEvent): void;
  111681. /**
  111682. * Called each time a new POINTERUP event occurs. Ie, for each button
  111683. * release.
  111684. */
  111685. protected onButtonUp(evt: PointerEvent): void;
  111686. /**
  111687. * Called when window becomes inactive.
  111688. */
  111689. protected onLostFocus(): void;
  111690. }
  111691. }
  111692. declare module BABYLON {
  111693. /**
  111694. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  111695. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111696. */
  111697. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  111698. /**
  111699. * Defines the camera the input is attached to.
  111700. */
  111701. camera: ArcRotateCamera;
  111702. /**
  111703. * Defines the list of key codes associated with the up action (increase alpha)
  111704. */
  111705. keysUp: number[];
  111706. /**
  111707. * Defines the list of key codes associated with the down action (decrease alpha)
  111708. */
  111709. keysDown: number[];
  111710. /**
  111711. * Defines the list of key codes associated with the left action (increase beta)
  111712. */
  111713. keysLeft: number[];
  111714. /**
  111715. * Defines the list of key codes associated with the right action (decrease beta)
  111716. */
  111717. keysRight: number[];
  111718. /**
  111719. * Defines the list of key codes associated with the reset action.
  111720. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  111721. */
  111722. keysReset: number[];
  111723. /**
  111724. * Defines the panning sensibility of the inputs.
  111725. * (How fast is the camera panning)
  111726. */
  111727. panningSensibility: number;
  111728. /**
  111729. * Defines the zooming sensibility of the inputs.
  111730. * (How fast is the camera zooming)
  111731. */
  111732. zoomingSensibility: number;
  111733. /**
  111734. * Defines whether maintaining the alt key down switch the movement mode from
  111735. * orientation to zoom.
  111736. */
  111737. useAltToZoom: boolean;
  111738. /**
  111739. * Rotation speed of the camera
  111740. */
  111741. angularSpeed: number;
  111742. private _keys;
  111743. private _ctrlPressed;
  111744. private _altPressed;
  111745. private _onCanvasBlurObserver;
  111746. private _onKeyboardObserver;
  111747. private _engine;
  111748. private _scene;
  111749. /**
  111750. * Attach the input controls to a specific dom element to get the input from.
  111751. * @param element Defines the element the controls should be listened from
  111752. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111753. */
  111754. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111755. /**
  111756. * Detach the current controls from the specified dom element.
  111757. * @param element Defines the element to stop listening the inputs from
  111758. */
  111759. detachControl(element: Nullable<HTMLElement>): void;
  111760. /**
  111761. * Update the current camera state depending on the inputs that have been used this frame.
  111762. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  111763. */
  111764. checkInputs(): void;
  111765. /**
  111766. * Gets the class name of the current intput.
  111767. * @returns the class name
  111768. */
  111769. getClassName(): string;
  111770. /**
  111771. * Get the friendly name associated with the input class.
  111772. * @returns the input friendly name
  111773. */
  111774. getSimpleName(): string;
  111775. }
  111776. }
  111777. declare module BABYLON {
  111778. /**
  111779. * Manage the mouse wheel inputs to control an arc rotate camera.
  111780. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111781. */
  111782. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  111783. /**
  111784. * Defines the camera the input is attached to.
  111785. */
  111786. camera: ArcRotateCamera;
  111787. /**
  111788. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  111789. */
  111790. wheelPrecision: number;
  111791. /**
  111792. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  111793. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  111794. */
  111795. wheelDeltaPercentage: number;
  111796. private _wheel;
  111797. private _observer;
  111798. private computeDeltaFromMouseWheelLegacyEvent;
  111799. /**
  111800. * Attach the input controls to a specific dom element to get the input from.
  111801. * @param element Defines the element the controls should be listened from
  111802. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111803. */
  111804. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111805. /**
  111806. * Detach the current controls from the specified dom element.
  111807. * @param element Defines the element to stop listening the inputs from
  111808. */
  111809. detachControl(element: Nullable<HTMLElement>): void;
  111810. /**
  111811. * Gets the class name of the current intput.
  111812. * @returns the class name
  111813. */
  111814. getClassName(): string;
  111815. /**
  111816. * Get the friendly name associated with the input class.
  111817. * @returns the input friendly name
  111818. */
  111819. getSimpleName(): string;
  111820. }
  111821. }
  111822. declare module BABYLON {
  111823. /**
  111824. * Default Inputs manager for the ArcRotateCamera.
  111825. * It groups all the default supported inputs for ease of use.
  111826. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111827. */
  111828. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  111829. /**
  111830. * Instantiates a new ArcRotateCameraInputsManager.
  111831. * @param camera Defines the camera the inputs belong to
  111832. */
  111833. constructor(camera: ArcRotateCamera);
  111834. /**
  111835. * Add mouse wheel input support to the input manager.
  111836. * @returns the current input manager
  111837. */
  111838. addMouseWheel(): ArcRotateCameraInputsManager;
  111839. /**
  111840. * Add pointers input support to the input manager.
  111841. * @returns the current input manager
  111842. */
  111843. addPointers(): ArcRotateCameraInputsManager;
  111844. /**
  111845. * Add keyboard input support to the input manager.
  111846. * @returns the current input manager
  111847. */
  111848. addKeyboard(): ArcRotateCameraInputsManager;
  111849. }
  111850. }
  111851. declare module BABYLON {
  111852. /**
  111853. * This represents an orbital type of camera.
  111854. *
  111855. * 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.
  111856. * 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.
  111857. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  111858. */
  111859. export class ArcRotateCamera extends TargetCamera {
  111860. /**
  111861. * Defines the rotation angle of the camera along the longitudinal axis.
  111862. */
  111863. alpha: number;
  111864. /**
  111865. * Defines the rotation angle of the camera along the latitudinal axis.
  111866. */
  111867. beta: number;
  111868. /**
  111869. * Defines the radius of the camera from it s target point.
  111870. */
  111871. radius: number;
  111872. protected _target: Vector3;
  111873. protected _targetHost: Nullable<AbstractMesh>;
  111874. /**
  111875. * Defines the target point of the camera.
  111876. * The camera looks towards it form the radius distance.
  111877. */
  111878. get target(): Vector3;
  111879. set target(value: Vector3);
  111880. /**
  111881. * Define the current local position of the camera in the scene
  111882. */
  111883. get position(): Vector3;
  111884. set position(newPosition: Vector3);
  111885. protected _upVector: Vector3;
  111886. protected _upToYMatrix: Matrix;
  111887. protected _YToUpMatrix: Matrix;
  111888. /**
  111889. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  111890. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  111891. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  111892. */
  111893. set upVector(vec: Vector3);
  111894. get upVector(): Vector3;
  111895. /**
  111896. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  111897. */
  111898. setMatUp(): void;
  111899. /**
  111900. * Current inertia value on the longitudinal axis.
  111901. * The bigger this number the longer it will take for the camera to stop.
  111902. */
  111903. inertialAlphaOffset: number;
  111904. /**
  111905. * Current inertia value on the latitudinal axis.
  111906. * The bigger this number the longer it will take for the camera to stop.
  111907. */
  111908. inertialBetaOffset: number;
  111909. /**
  111910. * Current inertia value on the radius axis.
  111911. * The bigger this number the longer it will take for the camera to stop.
  111912. */
  111913. inertialRadiusOffset: number;
  111914. /**
  111915. * Minimum allowed angle on the longitudinal axis.
  111916. * This can help limiting how the Camera is able to move in the scene.
  111917. */
  111918. lowerAlphaLimit: Nullable<number>;
  111919. /**
  111920. * Maximum allowed angle on the longitudinal axis.
  111921. * This can help limiting how the Camera is able to move in the scene.
  111922. */
  111923. upperAlphaLimit: Nullable<number>;
  111924. /**
  111925. * Minimum allowed angle on the latitudinal axis.
  111926. * This can help limiting how the Camera is able to move in the scene.
  111927. */
  111928. lowerBetaLimit: number;
  111929. /**
  111930. * Maximum allowed angle on the latitudinal axis.
  111931. * This can help limiting how the Camera is able to move in the scene.
  111932. */
  111933. upperBetaLimit: number;
  111934. /**
  111935. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  111936. * This can help limiting how the Camera is able to move in the scene.
  111937. */
  111938. lowerRadiusLimit: Nullable<number>;
  111939. /**
  111940. * Maximum allowed distance of the camera to the target (The camera can not get further).
  111941. * This can help limiting how the Camera is able to move in the scene.
  111942. */
  111943. upperRadiusLimit: Nullable<number>;
  111944. /**
  111945. * Defines the current inertia value used during panning of the camera along the X axis.
  111946. */
  111947. inertialPanningX: number;
  111948. /**
  111949. * Defines the current inertia value used during panning of the camera along the Y axis.
  111950. */
  111951. inertialPanningY: number;
  111952. /**
  111953. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  111954. * Basically if your fingers moves away from more than this distance you will be considered
  111955. * in pinch mode.
  111956. */
  111957. pinchToPanMaxDistance: number;
  111958. /**
  111959. * Defines the maximum distance the camera can pan.
  111960. * This could help keeping the cammera always in your scene.
  111961. */
  111962. panningDistanceLimit: Nullable<number>;
  111963. /**
  111964. * Defines the target of the camera before paning.
  111965. */
  111966. panningOriginTarget: Vector3;
  111967. /**
  111968. * Defines the value of the inertia used during panning.
  111969. * 0 would mean stop inertia and one would mean no decelleration at all.
  111970. */
  111971. panningInertia: number;
  111972. /**
  111973. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  111974. */
  111975. get angularSensibilityX(): number;
  111976. set angularSensibilityX(value: number);
  111977. /**
  111978. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  111979. */
  111980. get angularSensibilityY(): number;
  111981. set angularSensibilityY(value: number);
  111982. /**
  111983. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  111984. */
  111985. get pinchPrecision(): number;
  111986. set pinchPrecision(value: number);
  111987. /**
  111988. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  111989. * It will be used instead of pinchDeltaPrecision if different from 0.
  111990. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  111991. */
  111992. get pinchDeltaPercentage(): number;
  111993. set pinchDeltaPercentage(value: number);
  111994. /**
  111995. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  111996. * and pinch delta percentage.
  111997. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  111998. * that any object in the plane at the camera's target point will scale
  111999. * perfectly with finger motion.
  112000. */
  112001. get useNaturalPinchZoom(): boolean;
  112002. set useNaturalPinchZoom(value: boolean);
  112003. /**
  112004. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  112005. */
  112006. get panningSensibility(): number;
  112007. set panningSensibility(value: number);
  112008. /**
  112009. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  112010. */
  112011. get keysUp(): number[];
  112012. set keysUp(value: number[]);
  112013. /**
  112014. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  112015. */
  112016. get keysDown(): number[];
  112017. set keysDown(value: number[]);
  112018. /**
  112019. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  112020. */
  112021. get keysLeft(): number[];
  112022. set keysLeft(value: number[]);
  112023. /**
  112024. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  112025. */
  112026. get keysRight(): number[];
  112027. set keysRight(value: number[]);
  112028. /**
  112029. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  112030. */
  112031. get wheelPrecision(): number;
  112032. set wheelPrecision(value: number);
  112033. /**
  112034. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  112035. * It will be used instead of pinchDeltaPrecision if different from 0.
  112036. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  112037. */
  112038. get wheelDeltaPercentage(): number;
  112039. set wheelDeltaPercentage(value: number);
  112040. /**
  112041. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  112042. */
  112043. zoomOnFactor: number;
  112044. /**
  112045. * Defines a screen offset for the camera position.
  112046. */
  112047. targetScreenOffset: Vector2;
  112048. /**
  112049. * Allows the camera to be completely reversed.
  112050. * If false the camera can not arrive upside down.
  112051. */
  112052. allowUpsideDown: boolean;
  112053. /**
  112054. * Define if double tap/click is used to restore the previously saved state of the camera.
  112055. */
  112056. useInputToRestoreState: boolean;
  112057. /** @hidden */
  112058. _viewMatrix: Matrix;
  112059. /** @hidden */
  112060. _useCtrlForPanning: boolean;
  112061. /** @hidden */
  112062. _panningMouseButton: number;
  112063. /**
  112064. * Defines the input associated to the camera.
  112065. */
  112066. inputs: ArcRotateCameraInputsManager;
  112067. /** @hidden */
  112068. _reset: () => void;
  112069. /**
  112070. * Defines the allowed panning axis.
  112071. */
  112072. panningAxis: Vector3;
  112073. protected _localDirection: Vector3;
  112074. protected _transformedDirection: Vector3;
  112075. private _bouncingBehavior;
  112076. /**
  112077. * Gets the bouncing behavior of the camera if it has been enabled.
  112078. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  112079. */
  112080. get bouncingBehavior(): Nullable<BouncingBehavior>;
  112081. /**
  112082. * Defines if the bouncing behavior of the camera is enabled on the camera.
  112083. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  112084. */
  112085. get useBouncingBehavior(): boolean;
  112086. set useBouncingBehavior(value: boolean);
  112087. private _framingBehavior;
  112088. /**
  112089. * Gets the framing behavior of the camera if it has been enabled.
  112090. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  112091. */
  112092. get framingBehavior(): Nullable<FramingBehavior>;
  112093. /**
  112094. * Defines if the framing behavior of the camera is enabled on the camera.
  112095. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  112096. */
  112097. get useFramingBehavior(): boolean;
  112098. set useFramingBehavior(value: boolean);
  112099. private _autoRotationBehavior;
  112100. /**
  112101. * Gets the auto rotation behavior of the camera if it has been enabled.
  112102. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  112103. */
  112104. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  112105. /**
  112106. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  112107. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  112108. */
  112109. get useAutoRotationBehavior(): boolean;
  112110. set useAutoRotationBehavior(value: boolean);
  112111. /**
  112112. * Observable triggered when the mesh target has been changed on the camera.
  112113. */
  112114. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  112115. /**
  112116. * Event raised when the camera is colliding with a mesh.
  112117. */
  112118. onCollide: (collidedMesh: AbstractMesh) => void;
  112119. /**
  112120. * Defines whether the camera should check collision with the objects oh the scene.
  112121. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  112122. */
  112123. checkCollisions: boolean;
  112124. /**
  112125. * Defines the collision radius of the camera.
  112126. * This simulates a sphere around the camera.
  112127. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  112128. */
  112129. collisionRadius: Vector3;
  112130. protected _collider: Collider;
  112131. protected _previousPosition: Vector3;
  112132. protected _collisionVelocity: Vector3;
  112133. protected _newPosition: Vector3;
  112134. protected _previousAlpha: number;
  112135. protected _previousBeta: number;
  112136. protected _previousRadius: number;
  112137. protected _collisionTriggered: boolean;
  112138. protected _targetBoundingCenter: Nullable<Vector3>;
  112139. private _computationVector;
  112140. /**
  112141. * Instantiates a new ArcRotateCamera in a given scene
  112142. * @param name Defines the name of the camera
  112143. * @param alpha Defines the camera rotation along the logitudinal axis
  112144. * @param beta Defines the camera rotation along the latitudinal axis
  112145. * @param radius Defines the camera distance from its target
  112146. * @param target Defines the camera target
  112147. * @param scene Defines the scene the camera belongs to
  112148. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  112149. */
  112150. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  112151. /** @hidden */
  112152. _initCache(): void;
  112153. /** @hidden */
  112154. _updateCache(ignoreParentClass?: boolean): void;
  112155. protected _getTargetPosition(): Vector3;
  112156. private _storedAlpha;
  112157. private _storedBeta;
  112158. private _storedRadius;
  112159. private _storedTarget;
  112160. private _storedTargetScreenOffset;
  112161. /**
  112162. * Stores the current state of the camera (alpha, beta, radius and target)
  112163. * @returns the camera itself
  112164. */
  112165. storeState(): Camera;
  112166. /**
  112167. * @hidden
  112168. * Restored camera state. You must call storeState() first
  112169. */
  112170. _restoreStateValues(): boolean;
  112171. /** @hidden */
  112172. _isSynchronizedViewMatrix(): boolean;
  112173. /**
  112174. * Attached controls to the current camera.
  112175. * @param element Defines the element the controls should be listened from
  112176. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112177. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  112178. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  112179. */
  112180. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  112181. /**
  112182. * Detach the current controls from the camera.
  112183. * The camera will stop reacting to inputs.
  112184. * @param element Defines the element to stop listening the inputs from
  112185. */
  112186. detachControl(element: HTMLElement): void;
  112187. /** @hidden */
  112188. _checkInputs(): void;
  112189. protected _checkLimits(): void;
  112190. /**
  112191. * Rebuilds angles (alpha, beta) and radius from the give position and target
  112192. */
  112193. rebuildAnglesAndRadius(): void;
  112194. /**
  112195. * Use a position to define the current camera related information like alpha, beta and radius
  112196. * @param position Defines the position to set the camera at
  112197. */
  112198. setPosition(position: Vector3): void;
  112199. /**
  112200. * Defines the target the camera should look at.
  112201. * This will automatically adapt alpha beta and radius to fit within the new target.
  112202. * @param target Defines the new target as a Vector or a mesh
  112203. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  112204. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  112205. */
  112206. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  112207. /** @hidden */
  112208. _getViewMatrix(): Matrix;
  112209. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  112210. /**
  112211. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  112212. * @param meshes Defines the mesh to zoom on
  112213. * @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)
  112214. */
  112215. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  112216. /**
  112217. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  112218. * The target will be changed but the radius
  112219. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  112220. * @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)
  112221. */
  112222. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  112223. min: Vector3;
  112224. max: Vector3;
  112225. distance: number;
  112226. }, doNotUpdateMaxZ?: boolean): void;
  112227. /**
  112228. * @override
  112229. * Override Camera.createRigCamera
  112230. */
  112231. createRigCamera(name: string, cameraIndex: number): Camera;
  112232. /**
  112233. * @hidden
  112234. * @override
  112235. * Override Camera._updateRigCameras
  112236. */
  112237. _updateRigCameras(): void;
  112238. /**
  112239. * Destroy the camera and release the current resources hold by it.
  112240. */
  112241. dispose(): void;
  112242. /**
  112243. * Gets the current object class name.
  112244. * @return the class name
  112245. */
  112246. getClassName(): string;
  112247. }
  112248. }
  112249. declare module BABYLON {
  112250. /**
  112251. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  112252. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  112253. */
  112254. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  112255. /**
  112256. * Gets the name of the behavior.
  112257. */
  112258. get name(): string;
  112259. private _zoomStopsAnimation;
  112260. private _idleRotationSpeed;
  112261. private _idleRotationWaitTime;
  112262. private _idleRotationSpinupTime;
  112263. /**
  112264. * Sets the flag that indicates if user zooming should stop animation.
  112265. */
  112266. set zoomStopsAnimation(flag: boolean);
  112267. /**
  112268. * Gets the flag that indicates if user zooming should stop animation.
  112269. */
  112270. get zoomStopsAnimation(): boolean;
  112271. /**
  112272. * Sets the default speed at which the camera rotates around the model.
  112273. */
  112274. set idleRotationSpeed(speed: number);
  112275. /**
  112276. * Gets the default speed at which the camera rotates around the model.
  112277. */
  112278. get idleRotationSpeed(): number;
  112279. /**
  112280. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  112281. */
  112282. set idleRotationWaitTime(time: number);
  112283. /**
  112284. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  112285. */
  112286. get idleRotationWaitTime(): number;
  112287. /**
  112288. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  112289. */
  112290. set idleRotationSpinupTime(time: number);
  112291. /**
  112292. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  112293. */
  112294. get idleRotationSpinupTime(): number;
  112295. /**
  112296. * Gets a value indicating if the camera is currently rotating because of this behavior
  112297. */
  112298. get rotationInProgress(): boolean;
  112299. private _onPrePointerObservableObserver;
  112300. private _onAfterCheckInputsObserver;
  112301. private _attachedCamera;
  112302. private _isPointerDown;
  112303. private _lastFrameTime;
  112304. private _lastInteractionTime;
  112305. private _cameraRotationSpeed;
  112306. /**
  112307. * Initializes the behavior.
  112308. */
  112309. init(): void;
  112310. /**
  112311. * Attaches the behavior to its arc rotate camera.
  112312. * @param camera Defines the camera to attach the behavior to
  112313. */
  112314. attach(camera: ArcRotateCamera): void;
  112315. /**
  112316. * Detaches the behavior from its current arc rotate camera.
  112317. */
  112318. detach(): void;
  112319. /**
  112320. * Returns true if user is scrolling.
  112321. * @return true if user is scrolling.
  112322. */
  112323. private _userIsZooming;
  112324. private _lastFrameRadius;
  112325. private _shouldAnimationStopForInteraction;
  112326. /**
  112327. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  112328. */
  112329. private _applyUserInteraction;
  112330. private _userIsMoving;
  112331. }
  112332. }
  112333. declare module BABYLON {
  112334. /**
  112335. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  112336. */
  112337. export class AttachToBoxBehavior implements Behavior<Mesh> {
  112338. private ui;
  112339. /**
  112340. * The name of the behavior
  112341. */
  112342. name: string;
  112343. /**
  112344. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  112345. */
  112346. distanceAwayFromFace: number;
  112347. /**
  112348. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  112349. */
  112350. distanceAwayFromBottomOfFace: number;
  112351. private _faceVectors;
  112352. private _target;
  112353. private _scene;
  112354. private _onRenderObserver;
  112355. private _tmpMatrix;
  112356. private _tmpVector;
  112357. /**
  112358. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  112359. * @param ui The transform node that should be attched to the mesh
  112360. */
  112361. constructor(ui: TransformNode);
  112362. /**
  112363. * Initializes the behavior
  112364. */
  112365. init(): void;
  112366. private _closestFace;
  112367. private _zeroVector;
  112368. private _lookAtTmpMatrix;
  112369. private _lookAtToRef;
  112370. /**
  112371. * Attaches the AttachToBoxBehavior to the passed in mesh
  112372. * @param target The mesh that the specified node will be attached to
  112373. */
  112374. attach(target: Mesh): void;
  112375. /**
  112376. * Detaches the behavior from the mesh
  112377. */
  112378. detach(): void;
  112379. }
  112380. }
  112381. declare module BABYLON {
  112382. /**
  112383. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  112384. */
  112385. export class FadeInOutBehavior implements Behavior<Mesh> {
  112386. /**
  112387. * Time in milliseconds to delay before fading in (Default: 0)
  112388. */
  112389. delay: number;
  112390. /**
  112391. * Time in milliseconds for the mesh to fade in (Default: 300)
  112392. */
  112393. fadeInTime: number;
  112394. private _millisecondsPerFrame;
  112395. private _hovered;
  112396. private _hoverValue;
  112397. private _ownerNode;
  112398. /**
  112399. * Instatiates the FadeInOutBehavior
  112400. */
  112401. constructor();
  112402. /**
  112403. * The name of the behavior
  112404. */
  112405. get name(): string;
  112406. /**
  112407. * Initializes the behavior
  112408. */
  112409. init(): void;
  112410. /**
  112411. * Attaches the fade behavior on the passed in mesh
  112412. * @param ownerNode The mesh that will be faded in/out once attached
  112413. */
  112414. attach(ownerNode: Mesh): void;
  112415. /**
  112416. * Detaches the behavior from the mesh
  112417. */
  112418. detach(): void;
  112419. /**
  112420. * Triggers the mesh to begin fading in or out
  112421. * @param value if the object should fade in or out (true to fade in)
  112422. */
  112423. fadeIn(value: boolean): void;
  112424. private _update;
  112425. private _setAllVisibility;
  112426. }
  112427. }
  112428. declare module BABYLON {
  112429. /**
  112430. * Class containing a set of static utilities functions for managing Pivots
  112431. * @hidden
  112432. */
  112433. export class PivotTools {
  112434. private static _PivotCached;
  112435. private static _OldPivotPoint;
  112436. private static _PivotTranslation;
  112437. private static _PivotTmpVector;
  112438. /** @hidden */
  112439. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  112440. /** @hidden */
  112441. static _RestorePivotPoint(mesh: AbstractMesh): void;
  112442. }
  112443. }
  112444. declare module BABYLON {
  112445. /**
  112446. * Class containing static functions to help procedurally build meshes
  112447. */
  112448. export class PlaneBuilder {
  112449. /**
  112450. * Creates a plane mesh
  112451. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  112452. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  112453. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  112454. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112455. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112456. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112457. * @param name defines the name of the mesh
  112458. * @param options defines the options used to create the mesh
  112459. * @param scene defines the hosting scene
  112460. * @returns the plane mesh
  112461. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  112462. */
  112463. static CreatePlane(name: string, options: {
  112464. size?: number;
  112465. width?: number;
  112466. height?: number;
  112467. sideOrientation?: number;
  112468. frontUVs?: Vector4;
  112469. backUVs?: Vector4;
  112470. updatable?: boolean;
  112471. sourcePlane?: Plane;
  112472. }, scene?: Nullable<Scene>): Mesh;
  112473. }
  112474. }
  112475. declare module BABYLON {
  112476. /**
  112477. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  112478. */
  112479. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  112480. private static _AnyMouseID;
  112481. /**
  112482. * Abstract mesh the behavior is set on
  112483. */
  112484. attachedNode: AbstractMesh;
  112485. private _dragPlane;
  112486. private _scene;
  112487. private _pointerObserver;
  112488. private _beforeRenderObserver;
  112489. private static _planeScene;
  112490. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  112491. /**
  112492. * 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)
  112493. */
  112494. maxDragAngle: number;
  112495. /**
  112496. * @hidden
  112497. */
  112498. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  112499. /**
  112500. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  112501. */
  112502. currentDraggingPointerID: number;
  112503. /**
  112504. * The last position where the pointer hit the drag plane in world space
  112505. */
  112506. lastDragPosition: Vector3;
  112507. /**
  112508. * If the behavior is currently in a dragging state
  112509. */
  112510. dragging: boolean;
  112511. /**
  112512. * 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)
  112513. */
  112514. dragDeltaRatio: number;
  112515. /**
  112516. * If the drag plane orientation should be updated during the dragging (Default: true)
  112517. */
  112518. updateDragPlane: boolean;
  112519. private _debugMode;
  112520. private _moving;
  112521. /**
  112522. * Fires each time the attached mesh is dragged with the pointer
  112523. * * delta between last drag position and current drag position in world space
  112524. * * dragDistance along the drag axis
  112525. * * dragPlaneNormal normal of the current drag plane used during the drag
  112526. * * dragPlanePoint in world space where the drag intersects the drag plane
  112527. */
  112528. onDragObservable: Observable<{
  112529. delta: Vector3;
  112530. dragPlanePoint: Vector3;
  112531. dragPlaneNormal: Vector3;
  112532. dragDistance: number;
  112533. pointerId: number;
  112534. }>;
  112535. /**
  112536. * Fires each time a drag begins (eg. mouse down on mesh)
  112537. */
  112538. onDragStartObservable: Observable<{
  112539. dragPlanePoint: Vector3;
  112540. pointerId: number;
  112541. }>;
  112542. /**
  112543. * Fires each time a drag ends (eg. mouse release after drag)
  112544. */
  112545. onDragEndObservable: Observable<{
  112546. dragPlanePoint: Vector3;
  112547. pointerId: number;
  112548. }>;
  112549. /**
  112550. * If the attached mesh should be moved when dragged
  112551. */
  112552. moveAttached: boolean;
  112553. /**
  112554. * If the drag behavior will react to drag events (Default: true)
  112555. */
  112556. enabled: boolean;
  112557. /**
  112558. * If pointer events should start and release the drag (Default: true)
  112559. */
  112560. startAndReleaseDragOnPointerEvents: boolean;
  112561. /**
  112562. * If camera controls should be detached during the drag
  112563. */
  112564. detachCameraControls: boolean;
  112565. /**
  112566. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  112567. */
  112568. useObjectOrientationForDragging: boolean;
  112569. private _options;
  112570. /**
  112571. * Gets the options used by the behavior
  112572. */
  112573. get options(): {
  112574. dragAxis?: Vector3;
  112575. dragPlaneNormal?: Vector3;
  112576. };
  112577. /**
  112578. * Sets the options used by the behavior
  112579. */
  112580. set options(options: {
  112581. dragAxis?: Vector3;
  112582. dragPlaneNormal?: Vector3;
  112583. });
  112584. /**
  112585. * Creates a pointer drag behavior that can be attached to a mesh
  112586. * @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)
  112587. */
  112588. constructor(options?: {
  112589. dragAxis?: Vector3;
  112590. dragPlaneNormal?: Vector3;
  112591. });
  112592. /**
  112593. * Predicate to determine if it is valid to move the object to a new position when it is moved
  112594. */
  112595. validateDrag: (targetPosition: Vector3) => boolean;
  112596. /**
  112597. * The name of the behavior
  112598. */
  112599. get name(): string;
  112600. /**
  112601. * Initializes the behavior
  112602. */
  112603. init(): void;
  112604. private _tmpVector;
  112605. private _alternatePickedPoint;
  112606. private _worldDragAxis;
  112607. private _targetPosition;
  112608. private _attachedElement;
  112609. /**
  112610. * Attaches the drag behavior the passed in mesh
  112611. * @param ownerNode The mesh that will be dragged around once attached
  112612. * @param predicate Predicate to use for pick filtering
  112613. */
  112614. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  112615. /**
  112616. * Force relase the drag action by code.
  112617. */
  112618. releaseDrag(): void;
  112619. private _startDragRay;
  112620. private _lastPointerRay;
  112621. /**
  112622. * Simulates the start of a pointer drag event on the behavior
  112623. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  112624. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  112625. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  112626. */
  112627. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  112628. private _startDrag;
  112629. private _dragDelta;
  112630. private _moveDrag;
  112631. private _pickWithRayOnDragPlane;
  112632. private _pointA;
  112633. private _pointB;
  112634. private _pointC;
  112635. private _lineA;
  112636. private _lineB;
  112637. private _localAxis;
  112638. private _lookAt;
  112639. private _updateDragPlanePosition;
  112640. /**
  112641. * Detaches the behavior from the mesh
  112642. */
  112643. detach(): void;
  112644. }
  112645. }
  112646. declare module BABYLON {
  112647. /**
  112648. * A behavior that when attached to a mesh will allow the mesh to be scaled
  112649. */
  112650. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  112651. private _dragBehaviorA;
  112652. private _dragBehaviorB;
  112653. private _startDistance;
  112654. private _initialScale;
  112655. private _targetScale;
  112656. private _ownerNode;
  112657. private _sceneRenderObserver;
  112658. /**
  112659. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  112660. */
  112661. constructor();
  112662. /**
  112663. * The name of the behavior
  112664. */
  112665. get name(): string;
  112666. /**
  112667. * Initializes the behavior
  112668. */
  112669. init(): void;
  112670. private _getCurrentDistance;
  112671. /**
  112672. * Attaches the scale behavior the passed in mesh
  112673. * @param ownerNode The mesh that will be scaled around once attached
  112674. */
  112675. attach(ownerNode: Mesh): void;
  112676. /**
  112677. * Detaches the behavior from the mesh
  112678. */
  112679. detach(): void;
  112680. }
  112681. }
  112682. declare module BABYLON {
  112683. /**
  112684. * 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
  112685. */
  112686. export class SixDofDragBehavior implements Behavior<Mesh> {
  112687. private static _virtualScene;
  112688. private _ownerNode;
  112689. private _sceneRenderObserver;
  112690. private _scene;
  112691. private _targetPosition;
  112692. private _virtualOriginMesh;
  112693. private _virtualDragMesh;
  112694. private _pointerObserver;
  112695. private _moving;
  112696. private _startingOrientation;
  112697. /**
  112698. * 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)
  112699. */
  112700. private zDragFactor;
  112701. /**
  112702. * If the object should rotate to face the drag origin
  112703. */
  112704. rotateDraggedObject: boolean;
  112705. /**
  112706. * If the behavior is currently in a dragging state
  112707. */
  112708. dragging: boolean;
  112709. /**
  112710. * 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)
  112711. */
  112712. dragDeltaRatio: number;
  112713. /**
  112714. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  112715. */
  112716. currentDraggingPointerID: number;
  112717. /**
  112718. * If camera controls should be detached during the drag
  112719. */
  112720. detachCameraControls: boolean;
  112721. /**
  112722. * Fires each time a drag starts
  112723. */
  112724. onDragStartObservable: Observable<{}>;
  112725. /**
  112726. * Fires each time a drag ends (eg. mouse release after drag)
  112727. */
  112728. onDragEndObservable: Observable<{}>;
  112729. /**
  112730. * 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
  112731. */
  112732. constructor();
  112733. /**
  112734. * The name of the behavior
  112735. */
  112736. get name(): string;
  112737. /**
  112738. * Initializes the behavior
  112739. */
  112740. init(): void;
  112741. /**
  112742. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  112743. */
  112744. private get _pointerCamera();
  112745. /**
  112746. * Attaches the scale behavior the passed in mesh
  112747. * @param ownerNode The mesh that will be scaled around once attached
  112748. */
  112749. attach(ownerNode: Mesh): void;
  112750. /**
  112751. * Detaches the behavior from the mesh
  112752. */
  112753. detach(): void;
  112754. }
  112755. }
  112756. declare module BABYLON {
  112757. /**
  112758. * Class used to apply inverse kinematics to bones
  112759. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  112760. */
  112761. export class BoneIKController {
  112762. private static _tmpVecs;
  112763. private static _tmpQuat;
  112764. private static _tmpMats;
  112765. /**
  112766. * Gets or sets the target mesh
  112767. */
  112768. targetMesh: AbstractMesh;
  112769. /** Gets or sets the mesh used as pole */
  112770. poleTargetMesh: AbstractMesh;
  112771. /**
  112772. * Gets or sets the bone used as pole
  112773. */
  112774. poleTargetBone: Nullable<Bone>;
  112775. /**
  112776. * Gets or sets the target position
  112777. */
  112778. targetPosition: Vector3;
  112779. /**
  112780. * Gets or sets the pole target position
  112781. */
  112782. poleTargetPosition: Vector3;
  112783. /**
  112784. * Gets or sets the pole target local offset
  112785. */
  112786. poleTargetLocalOffset: Vector3;
  112787. /**
  112788. * Gets or sets the pole angle
  112789. */
  112790. poleAngle: number;
  112791. /**
  112792. * Gets or sets the mesh associated with the controller
  112793. */
  112794. mesh: AbstractMesh;
  112795. /**
  112796. * 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)
  112797. */
  112798. slerpAmount: number;
  112799. private _bone1Quat;
  112800. private _bone1Mat;
  112801. private _bone2Ang;
  112802. private _bone1;
  112803. private _bone2;
  112804. private _bone1Length;
  112805. private _bone2Length;
  112806. private _maxAngle;
  112807. private _maxReach;
  112808. private _rightHandedSystem;
  112809. private _bendAxis;
  112810. private _slerping;
  112811. private _adjustRoll;
  112812. /**
  112813. * Gets or sets maximum allowed angle
  112814. */
  112815. get maxAngle(): number;
  112816. set maxAngle(value: number);
  112817. /**
  112818. * Creates a new BoneIKController
  112819. * @param mesh defines the mesh to control
  112820. * @param bone defines the bone to control
  112821. * @param options defines options to set up the controller
  112822. */
  112823. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  112824. targetMesh?: AbstractMesh;
  112825. poleTargetMesh?: AbstractMesh;
  112826. poleTargetBone?: Bone;
  112827. poleTargetLocalOffset?: Vector3;
  112828. poleAngle?: number;
  112829. bendAxis?: Vector3;
  112830. maxAngle?: number;
  112831. slerpAmount?: number;
  112832. });
  112833. private _setMaxAngle;
  112834. /**
  112835. * Force the controller to update the bones
  112836. */
  112837. update(): void;
  112838. }
  112839. }
  112840. declare module BABYLON {
  112841. /**
  112842. * Class used to make a bone look toward a point in space
  112843. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  112844. */
  112845. export class BoneLookController {
  112846. private static _tmpVecs;
  112847. private static _tmpQuat;
  112848. private static _tmpMats;
  112849. /**
  112850. * The target Vector3 that the bone will look at
  112851. */
  112852. target: Vector3;
  112853. /**
  112854. * The mesh that the bone is attached to
  112855. */
  112856. mesh: AbstractMesh;
  112857. /**
  112858. * The bone that will be looking to the target
  112859. */
  112860. bone: Bone;
  112861. /**
  112862. * The up axis of the coordinate system that is used when the bone is rotated
  112863. */
  112864. upAxis: Vector3;
  112865. /**
  112866. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  112867. */
  112868. upAxisSpace: Space;
  112869. /**
  112870. * Used to make an adjustment to the yaw of the bone
  112871. */
  112872. adjustYaw: number;
  112873. /**
  112874. * Used to make an adjustment to the pitch of the bone
  112875. */
  112876. adjustPitch: number;
  112877. /**
  112878. * Used to make an adjustment to the roll of the bone
  112879. */
  112880. adjustRoll: number;
  112881. /**
  112882. * 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)
  112883. */
  112884. slerpAmount: number;
  112885. private _minYaw;
  112886. private _maxYaw;
  112887. private _minPitch;
  112888. private _maxPitch;
  112889. private _minYawSin;
  112890. private _minYawCos;
  112891. private _maxYawSin;
  112892. private _maxYawCos;
  112893. private _midYawConstraint;
  112894. private _minPitchTan;
  112895. private _maxPitchTan;
  112896. private _boneQuat;
  112897. private _slerping;
  112898. private _transformYawPitch;
  112899. private _transformYawPitchInv;
  112900. private _firstFrameSkipped;
  112901. private _yawRange;
  112902. private _fowardAxis;
  112903. /**
  112904. * Gets or sets the minimum yaw angle that the bone can look to
  112905. */
  112906. get minYaw(): number;
  112907. set minYaw(value: number);
  112908. /**
  112909. * Gets or sets the maximum yaw angle that the bone can look to
  112910. */
  112911. get maxYaw(): number;
  112912. set maxYaw(value: number);
  112913. /**
  112914. * Gets or sets the minimum pitch angle that the bone can look to
  112915. */
  112916. get minPitch(): number;
  112917. set minPitch(value: number);
  112918. /**
  112919. * Gets or sets the maximum pitch angle that the bone can look to
  112920. */
  112921. get maxPitch(): number;
  112922. set maxPitch(value: number);
  112923. /**
  112924. * Create a BoneLookController
  112925. * @param mesh the mesh that the bone belongs to
  112926. * @param bone the bone that will be looking to the target
  112927. * @param target the target Vector3 to look at
  112928. * @param options optional settings:
  112929. * * maxYaw: the maximum angle the bone will yaw to
  112930. * * minYaw: the minimum angle the bone will yaw to
  112931. * * maxPitch: the maximum angle the bone will pitch to
  112932. * * minPitch: the minimum angle the bone will yaw to
  112933. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  112934. * * upAxis: the up axis of the coordinate system
  112935. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  112936. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  112937. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  112938. * * adjustYaw: used to make an adjustment to the yaw of the bone
  112939. * * adjustPitch: used to make an adjustment to the pitch of the bone
  112940. * * adjustRoll: used to make an adjustment to the roll of the bone
  112941. **/
  112942. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  112943. maxYaw?: number;
  112944. minYaw?: number;
  112945. maxPitch?: number;
  112946. minPitch?: number;
  112947. slerpAmount?: number;
  112948. upAxis?: Vector3;
  112949. upAxisSpace?: Space;
  112950. yawAxis?: Vector3;
  112951. pitchAxis?: Vector3;
  112952. adjustYaw?: number;
  112953. adjustPitch?: number;
  112954. adjustRoll?: number;
  112955. });
  112956. /**
  112957. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  112958. */
  112959. update(): void;
  112960. private _getAngleDiff;
  112961. private _getAngleBetween;
  112962. private _isAngleBetween;
  112963. }
  112964. }
  112965. declare module BABYLON {
  112966. /**
  112967. * Manage the gamepad inputs to control an arc rotate camera.
  112968. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112969. */
  112970. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  112971. /**
  112972. * Defines the camera the input is attached to.
  112973. */
  112974. camera: ArcRotateCamera;
  112975. /**
  112976. * Defines the gamepad the input is gathering event from.
  112977. */
  112978. gamepad: Nullable<Gamepad>;
  112979. /**
  112980. * Defines the gamepad rotation sensiblity.
  112981. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  112982. */
  112983. gamepadRotationSensibility: number;
  112984. /**
  112985. * Defines the gamepad move sensiblity.
  112986. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  112987. */
  112988. gamepadMoveSensibility: number;
  112989. private _yAxisScale;
  112990. /**
  112991. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  112992. */
  112993. get invertYAxis(): boolean;
  112994. set invertYAxis(value: boolean);
  112995. private _onGamepadConnectedObserver;
  112996. private _onGamepadDisconnectedObserver;
  112997. /**
  112998. * Attach the input controls to a specific dom element to get the input from.
  112999. * @param element Defines the element the controls should be listened from
  113000. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113001. */
  113002. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113003. /**
  113004. * Detach the current controls from the specified dom element.
  113005. * @param element Defines the element to stop listening the inputs from
  113006. */
  113007. detachControl(element: Nullable<HTMLElement>): void;
  113008. /**
  113009. * Update the current camera state depending on the inputs that have been used this frame.
  113010. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113011. */
  113012. checkInputs(): void;
  113013. /**
  113014. * Gets the class name of the current intput.
  113015. * @returns the class name
  113016. */
  113017. getClassName(): string;
  113018. /**
  113019. * Get the friendly name associated with the input class.
  113020. * @returns the input friendly name
  113021. */
  113022. getSimpleName(): string;
  113023. }
  113024. }
  113025. declare module BABYLON {
  113026. interface ArcRotateCameraInputsManager {
  113027. /**
  113028. * Add orientation input support to the input manager.
  113029. * @returns the current input manager
  113030. */
  113031. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  113032. }
  113033. /**
  113034. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  113035. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113036. */
  113037. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  113038. /**
  113039. * Defines the camera the input is attached to.
  113040. */
  113041. camera: ArcRotateCamera;
  113042. /**
  113043. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  113044. */
  113045. alphaCorrection: number;
  113046. /**
  113047. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  113048. */
  113049. gammaCorrection: number;
  113050. private _alpha;
  113051. private _gamma;
  113052. private _dirty;
  113053. private _deviceOrientationHandler;
  113054. /**
  113055. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  113056. */
  113057. constructor();
  113058. /**
  113059. * Attach the input controls to a specific dom element to get the input from.
  113060. * @param element Defines the element the controls should be listened from
  113061. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113062. */
  113063. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113064. /** @hidden */
  113065. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  113066. /**
  113067. * Update the current camera state depending on the inputs that have been used this frame.
  113068. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113069. */
  113070. checkInputs(): void;
  113071. /**
  113072. * Detach the current controls from the specified dom element.
  113073. * @param element Defines the element to stop listening the inputs from
  113074. */
  113075. detachControl(element: Nullable<HTMLElement>): void;
  113076. /**
  113077. * Gets the class name of the current intput.
  113078. * @returns the class name
  113079. */
  113080. getClassName(): string;
  113081. /**
  113082. * Get the friendly name associated with the input class.
  113083. * @returns the input friendly name
  113084. */
  113085. getSimpleName(): string;
  113086. }
  113087. }
  113088. declare module BABYLON {
  113089. /**
  113090. * Listen to mouse events to control the camera.
  113091. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113092. */
  113093. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  113094. /**
  113095. * Defines the camera the input is attached to.
  113096. */
  113097. camera: FlyCamera;
  113098. /**
  113099. * Defines if touch is enabled. (Default is true.)
  113100. */
  113101. touchEnabled: boolean;
  113102. /**
  113103. * Defines the buttons associated with the input to handle camera rotation.
  113104. */
  113105. buttons: number[];
  113106. /**
  113107. * Assign buttons for Yaw control.
  113108. */
  113109. buttonsYaw: number[];
  113110. /**
  113111. * Assign buttons for Pitch control.
  113112. */
  113113. buttonsPitch: number[];
  113114. /**
  113115. * Assign buttons for Roll control.
  113116. */
  113117. buttonsRoll: number[];
  113118. /**
  113119. * Detect if any button is being pressed while mouse is moved.
  113120. * -1 = Mouse locked.
  113121. * 0 = Left button.
  113122. * 1 = Middle Button.
  113123. * 2 = Right Button.
  113124. */
  113125. activeButton: number;
  113126. /**
  113127. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  113128. * Higher values reduce its sensitivity.
  113129. */
  113130. angularSensibility: number;
  113131. private _mousemoveCallback;
  113132. private _observer;
  113133. private _rollObserver;
  113134. private previousPosition;
  113135. private noPreventDefault;
  113136. private element;
  113137. /**
  113138. * Listen to mouse events to control the camera.
  113139. * @param touchEnabled Define if touch is enabled. (Default is true.)
  113140. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113141. */
  113142. constructor(touchEnabled?: boolean);
  113143. /**
  113144. * Attach the mouse control to the HTML DOM element.
  113145. * @param element Defines the element that listens to the input events.
  113146. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  113147. */
  113148. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113149. /**
  113150. * Detach the current controls from the specified dom element.
  113151. * @param element Defines the element to stop listening the inputs from
  113152. */
  113153. detachControl(element: Nullable<HTMLElement>): void;
  113154. /**
  113155. * Gets the class name of the current input.
  113156. * @returns the class name.
  113157. */
  113158. getClassName(): string;
  113159. /**
  113160. * Get the friendly name associated with the input class.
  113161. * @returns the input's friendly name.
  113162. */
  113163. getSimpleName(): string;
  113164. private _pointerInput;
  113165. private _onMouseMove;
  113166. /**
  113167. * Rotate camera by mouse offset.
  113168. */
  113169. private rotateCamera;
  113170. }
  113171. }
  113172. declare module BABYLON {
  113173. /**
  113174. * Default Inputs manager for the FlyCamera.
  113175. * It groups all the default supported inputs for ease of use.
  113176. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113177. */
  113178. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  113179. /**
  113180. * Instantiates a new FlyCameraInputsManager.
  113181. * @param camera Defines the camera the inputs belong to.
  113182. */
  113183. constructor(camera: FlyCamera);
  113184. /**
  113185. * Add keyboard input support to the input manager.
  113186. * @returns the new FlyCameraKeyboardMoveInput().
  113187. */
  113188. addKeyboard(): FlyCameraInputsManager;
  113189. /**
  113190. * Add mouse input support to the input manager.
  113191. * @param touchEnabled Enable touch screen support.
  113192. * @returns the new FlyCameraMouseInput().
  113193. */
  113194. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  113195. }
  113196. }
  113197. declare module BABYLON {
  113198. /**
  113199. * This is a flying camera, designed for 3D movement and rotation in all directions,
  113200. * such as in a 3D Space Shooter or a Flight Simulator.
  113201. */
  113202. export class FlyCamera extends TargetCamera {
  113203. /**
  113204. * Define the collision ellipsoid of the camera.
  113205. * This is helpful for simulating a camera body, like a player's body.
  113206. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  113207. */
  113208. ellipsoid: Vector3;
  113209. /**
  113210. * Define an offset for the position of the ellipsoid around the camera.
  113211. * This can be helpful if the camera is attached away from the player's body center,
  113212. * such as at its head.
  113213. */
  113214. ellipsoidOffset: Vector3;
  113215. /**
  113216. * Enable or disable collisions of the camera with the rest of the scene objects.
  113217. */
  113218. checkCollisions: boolean;
  113219. /**
  113220. * Enable or disable gravity on the camera.
  113221. */
  113222. applyGravity: boolean;
  113223. /**
  113224. * Define the current direction the camera is moving to.
  113225. */
  113226. cameraDirection: Vector3;
  113227. /**
  113228. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  113229. * This overrides and empties cameraRotation.
  113230. */
  113231. rotationQuaternion: Quaternion;
  113232. /**
  113233. * Track Roll to maintain the wanted Rolling when looking around.
  113234. */
  113235. _trackRoll: number;
  113236. /**
  113237. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  113238. */
  113239. rollCorrect: number;
  113240. /**
  113241. * Mimic a banked turn, Rolling the camera when Yawing.
  113242. * It's recommended to use rollCorrect = 10 for faster banking correction.
  113243. */
  113244. bankedTurn: boolean;
  113245. /**
  113246. * Limit in radians for how much Roll banking will add. (Default: 90°)
  113247. */
  113248. bankedTurnLimit: number;
  113249. /**
  113250. * Value of 0 disables the banked Roll.
  113251. * Value of 1 is equal to the Yaw angle in radians.
  113252. */
  113253. bankedTurnMultiplier: number;
  113254. /**
  113255. * The inputs manager loads all the input sources, such as keyboard and mouse.
  113256. */
  113257. inputs: FlyCameraInputsManager;
  113258. /**
  113259. * Gets the input sensibility for mouse input.
  113260. * Higher values reduce sensitivity.
  113261. */
  113262. get angularSensibility(): number;
  113263. /**
  113264. * Sets the input sensibility for a mouse input.
  113265. * Higher values reduce sensitivity.
  113266. */
  113267. set angularSensibility(value: number);
  113268. /**
  113269. * Get the keys for camera movement forward.
  113270. */
  113271. get keysForward(): number[];
  113272. /**
  113273. * Set the keys for camera movement forward.
  113274. */
  113275. set keysForward(value: number[]);
  113276. /**
  113277. * Get the keys for camera movement backward.
  113278. */
  113279. get keysBackward(): number[];
  113280. set keysBackward(value: number[]);
  113281. /**
  113282. * Get the keys for camera movement up.
  113283. */
  113284. get keysUp(): number[];
  113285. /**
  113286. * Set the keys for camera movement up.
  113287. */
  113288. set keysUp(value: number[]);
  113289. /**
  113290. * Get the keys for camera movement down.
  113291. */
  113292. get keysDown(): number[];
  113293. /**
  113294. * Set the keys for camera movement down.
  113295. */
  113296. set keysDown(value: number[]);
  113297. /**
  113298. * Get the keys for camera movement left.
  113299. */
  113300. get keysLeft(): number[];
  113301. /**
  113302. * Set the keys for camera movement left.
  113303. */
  113304. set keysLeft(value: number[]);
  113305. /**
  113306. * Set the keys for camera movement right.
  113307. */
  113308. get keysRight(): number[];
  113309. /**
  113310. * Set the keys for camera movement right.
  113311. */
  113312. set keysRight(value: number[]);
  113313. /**
  113314. * Event raised when the camera collides with a mesh in the scene.
  113315. */
  113316. onCollide: (collidedMesh: AbstractMesh) => void;
  113317. private _collider;
  113318. private _needMoveForGravity;
  113319. private _oldPosition;
  113320. private _diffPosition;
  113321. private _newPosition;
  113322. /** @hidden */
  113323. _localDirection: Vector3;
  113324. /** @hidden */
  113325. _transformedDirection: Vector3;
  113326. /**
  113327. * Instantiates a FlyCamera.
  113328. * This is a flying camera, designed for 3D movement and rotation in all directions,
  113329. * such as in a 3D Space Shooter or a Flight Simulator.
  113330. * @param name Define the name of the camera in the scene.
  113331. * @param position Define the starting position of the camera in the scene.
  113332. * @param scene Define the scene the camera belongs to.
  113333. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  113334. */
  113335. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  113336. /**
  113337. * Attach a control to the HTML DOM element.
  113338. * @param element Defines the element that listens to the input events.
  113339. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  113340. */
  113341. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113342. /**
  113343. * Detach a control from the HTML DOM element.
  113344. * The camera will stop reacting to that input.
  113345. * @param element Defines the element that listens to the input events.
  113346. */
  113347. detachControl(element: HTMLElement): void;
  113348. private _collisionMask;
  113349. /**
  113350. * Get the mask that the camera ignores in collision events.
  113351. */
  113352. get collisionMask(): number;
  113353. /**
  113354. * Set the mask that the camera ignores in collision events.
  113355. */
  113356. set collisionMask(mask: number);
  113357. /** @hidden */
  113358. _collideWithWorld(displacement: Vector3): void;
  113359. /** @hidden */
  113360. private _onCollisionPositionChange;
  113361. /** @hidden */
  113362. _checkInputs(): void;
  113363. /** @hidden */
  113364. _decideIfNeedsToMove(): boolean;
  113365. /** @hidden */
  113366. _updatePosition(): void;
  113367. /**
  113368. * Restore the Roll to its target value at the rate specified.
  113369. * @param rate - Higher means slower restoring.
  113370. * @hidden
  113371. */
  113372. restoreRoll(rate: number): void;
  113373. /**
  113374. * Destroy the camera and release the current resources held by it.
  113375. */
  113376. dispose(): void;
  113377. /**
  113378. * Get the current object class name.
  113379. * @returns the class name.
  113380. */
  113381. getClassName(): string;
  113382. }
  113383. }
  113384. declare module BABYLON {
  113385. /**
  113386. * Listen to keyboard events to control the camera.
  113387. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113388. */
  113389. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  113390. /**
  113391. * Defines the camera the input is attached to.
  113392. */
  113393. camera: FlyCamera;
  113394. /**
  113395. * The list of keyboard keys used to control the forward move of the camera.
  113396. */
  113397. keysForward: number[];
  113398. /**
  113399. * The list of keyboard keys used to control the backward move of the camera.
  113400. */
  113401. keysBackward: number[];
  113402. /**
  113403. * The list of keyboard keys used to control the forward move of the camera.
  113404. */
  113405. keysUp: number[];
  113406. /**
  113407. * The list of keyboard keys used to control the backward move of the camera.
  113408. */
  113409. keysDown: number[];
  113410. /**
  113411. * The list of keyboard keys used to control the right strafe move of the camera.
  113412. */
  113413. keysRight: number[];
  113414. /**
  113415. * The list of keyboard keys used to control the left strafe move of the camera.
  113416. */
  113417. keysLeft: number[];
  113418. private _keys;
  113419. private _onCanvasBlurObserver;
  113420. private _onKeyboardObserver;
  113421. private _engine;
  113422. private _scene;
  113423. /**
  113424. * Attach the input controls to a specific dom element to get the input from.
  113425. * @param element Defines the element the controls should be listened from
  113426. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113427. */
  113428. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113429. /**
  113430. * Detach the current controls from the specified dom element.
  113431. * @param element Defines the element to stop listening the inputs from
  113432. */
  113433. detachControl(element: Nullable<HTMLElement>): void;
  113434. /**
  113435. * Gets the class name of the current intput.
  113436. * @returns the class name
  113437. */
  113438. getClassName(): string;
  113439. /** @hidden */
  113440. _onLostFocus(e: FocusEvent): void;
  113441. /**
  113442. * Get the friendly name associated with the input class.
  113443. * @returns the input friendly name
  113444. */
  113445. getSimpleName(): string;
  113446. /**
  113447. * Update the current camera state depending on the inputs that have been used this frame.
  113448. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113449. */
  113450. checkInputs(): void;
  113451. }
  113452. }
  113453. declare module BABYLON {
  113454. /**
  113455. * Manage the mouse wheel inputs to control a follow camera.
  113456. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113457. */
  113458. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  113459. /**
  113460. * Defines the camera the input is attached to.
  113461. */
  113462. camera: FollowCamera;
  113463. /**
  113464. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  113465. */
  113466. axisControlRadius: boolean;
  113467. /**
  113468. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  113469. */
  113470. axisControlHeight: boolean;
  113471. /**
  113472. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  113473. */
  113474. axisControlRotation: boolean;
  113475. /**
  113476. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  113477. * relation to mouseWheel events.
  113478. */
  113479. wheelPrecision: number;
  113480. /**
  113481. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  113482. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  113483. */
  113484. wheelDeltaPercentage: number;
  113485. private _wheel;
  113486. private _observer;
  113487. /**
  113488. * Attach the input controls to a specific dom element to get the input from.
  113489. * @param element Defines the element the controls should be listened from
  113490. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113491. */
  113492. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113493. /**
  113494. * Detach the current controls from the specified dom element.
  113495. * @param element Defines the element to stop listening the inputs from
  113496. */
  113497. detachControl(element: Nullable<HTMLElement>): void;
  113498. /**
  113499. * Gets the class name of the current intput.
  113500. * @returns the class name
  113501. */
  113502. getClassName(): string;
  113503. /**
  113504. * Get the friendly name associated with the input class.
  113505. * @returns the input friendly name
  113506. */
  113507. getSimpleName(): string;
  113508. }
  113509. }
  113510. declare module BABYLON {
  113511. /**
  113512. * Manage the pointers inputs to control an follow camera.
  113513. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113514. */
  113515. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  113516. /**
  113517. * Defines the camera the input is attached to.
  113518. */
  113519. camera: FollowCamera;
  113520. /**
  113521. * Gets the class name of the current input.
  113522. * @returns the class name
  113523. */
  113524. getClassName(): string;
  113525. /**
  113526. * Defines the pointer angular sensibility along the X axis or how fast is
  113527. * the camera rotating.
  113528. * A negative number will reverse the axis direction.
  113529. */
  113530. angularSensibilityX: number;
  113531. /**
  113532. * Defines the pointer angular sensibility along the Y axis or how fast is
  113533. * the camera rotating.
  113534. * A negative number will reverse the axis direction.
  113535. */
  113536. angularSensibilityY: number;
  113537. /**
  113538. * Defines the pointer pinch precision or how fast is the camera zooming.
  113539. * A negative number will reverse the axis direction.
  113540. */
  113541. pinchPrecision: number;
  113542. /**
  113543. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  113544. * from 0.
  113545. * It defines the percentage of current camera.radius to use as delta when
  113546. * pinch zoom is used.
  113547. */
  113548. pinchDeltaPercentage: number;
  113549. /**
  113550. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  113551. */
  113552. axisXControlRadius: boolean;
  113553. /**
  113554. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  113555. */
  113556. axisXControlHeight: boolean;
  113557. /**
  113558. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  113559. */
  113560. axisXControlRotation: boolean;
  113561. /**
  113562. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  113563. */
  113564. axisYControlRadius: boolean;
  113565. /**
  113566. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  113567. */
  113568. axisYControlHeight: boolean;
  113569. /**
  113570. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  113571. */
  113572. axisYControlRotation: boolean;
  113573. /**
  113574. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  113575. */
  113576. axisPinchControlRadius: boolean;
  113577. /**
  113578. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  113579. */
  113580. axisPinchControlHeight: boolean;
  113581. /**
  113582. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  113583. */
  113584. axisPinchControlRotation: boolean;
  113585. /**
  113586. * Log error messages if basic misconfiguration has occurred.
  113587. */
  113588. warningEnable: boolean;
  113589. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  113590. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  113591. private _warningCounter;
  113592. private _warning;
  113593. }
  113594. }
  113595. declare module BABYLON {
  113596. /**
  113597. * Default Inputs manager for the FollowCamera.
  113598. * It groups all the default supported inputs for ease of use.
  113599. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113600. */
  113601. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  113602. /**
  113603. * Instantiates a new FollowCameraInputsManager.
  113604. * @param camera Defines the camera the inputs belong to
  113605. */
  113606. constructor(camera: FollowCamera);
  113607. /**
  113608. * Add keyboard input support to the input manager.
  113609. * @returns the current input manager
  113610. */
  113611. addKeyboard(): FollowCameraInputsManager;
  113612. /**
  113613. * Add mouse wheel input support to the input manager.
  113614. * @returns the current input manager
  113615. */
  113616. addMouseWheel(): FollowCameraInputsManager;
  113617. /**
  113618. * Add pointers input support to the input manager.
  113619. * @returns the current input manager
  113620. */
  113621. addPointers(): FollowCameraInputsManager;
  113622. /**
  113623. * Add orientation input support to the input manager.
  113624. * @returns the current input manager
  113625. */
  113626. addVRDeviceOrientation(): FollowCameraInputsManager;
  113627. }
  113628. }
  113629. declare module BABYLON {
  113630. /**
  113631. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  113632. * an arc rotate version arcFollowCamera are available.
  113633. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113634. */
  113635. export class FollowCamera extends TargetCamera {
  113636. /**
  113637. * Distance the follow camera should follow an object at
  113638. */
  113639. radius: number;
  113640. /**
  113641. * Minimum allowed distance of the camera to the axis of rotation
  113642. * (The camera can not get closer).
  113643. * This can help limiting how the Camera is able to move in the scene.
  113644. */
  113645. lowerRadiusLimit: Nullable<number>;
  113646. /**
  113647. * Maximum allowed distance of the camera to the axis of rotation
  113648. * (The camera can not get further).
  113649. * This can help limiting how the Camera is able to move in the scene.
  113650. */
  113651. upperRadiusLimit: Nullable<number>;
  113652. /**
  113653. * Define a rotation offset between the camera and the object it follows
  113654. */
  113655. rotationOffset: number;
  113656. /**
  113657. * Minimum allowed angle to camera position relative to target object.
  113658. * This can help limiting how the Camera is able to move in the scene.
  113659. */
  113660. lowerRotationOffsetLimit: Nullable<number>;
  113661. /**
  113662. * Maximum allowed angle to camera position relative to target object.
  113663. * This can help limiting how the Camera is able to move in the scene.
  113664. */
  113665. upperRotationOffsetLimit: Nullable<number>;
  113666. /**
  113667. * Define a height offset between the camera and the object it follows.
  113668. * It can help following an object from the top (like a car chaing a plane)
  113669. */
  113670. heightOffset: number;
  113671. /**
  113672. * Minimum allowed height of camera position relative to target object.
  113673. * This can help limiting how the Camera is able to move in the scene.
  113674. */
  113675. lowerHeightOffsetLimit: Nullable<number>;
  113676. /**
  113677. * Maximum allowed height of camera position relative to target object.
  113678. * This can help limiting how the Camera is able to move in the scene.
  113679. */
  113680. upperHeightOffsetLimit: Nullable<number>;
  113681. /**
  113682. * Define how fast the camera can accelerate to follow it s target.
  113683. */
  113684. cameraAcceleration: number;
  113685. /**
  113686. * Define the speed limit of the camera following an object.
  113687. */
  113688. maxCameraSpeed: number;
  113689. /**
  113690. * Define the target of the camera.
  113691. */
  113692. lockedTarget: Nullable<AbstractMesh>;
  113693. /**
  113694. * Defines the input associated with the camera.
  113695. */
  113696. inputs: FollowCameraInputsManager;
  113697. /**
  113698. * Instantiates the follow camera.
  113699. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113700. * @param name Define the name of the camera in the scene
  113701. * @param position Define the position of the camera
  113702. * @param scene Define the scene the camera belong to
  113703. * @param lockedTarget Define the target of the camera
  113704. */
  113705. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  113706. private _follow;
  113707. /**
  113708. * Attached controls to the current camera.
  113709. * @param element Defines the element the controls should be listened from
  113710. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113711. */
  113712. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113713. /**
  113714. * Detach the current controls from the camera.
  113715. * The camera will stop reacting to inputs.
  113716. * @param element Defines the element to stop listening the inputs from
  113717. */
  113718. detachControl(element: HTMLElement): void;
  113719. /** @hidden */
  113720. _checkInputs(): void;
  113721. private _checkLimits;
  113722. /**
  113723. * Gets the camera class name.
  113724. * @returns the class name
  113725. */
  113726. getClassName(): string;
  113727. }
  113728. /**
  113729. * Arc Rotate version of the follow camera.
  113730. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  113731. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113732. */
  113733. export class ArcFollowCamera extends TargetCamera {
  113734. /** The longitudinal angle of the camera */
  113735. alpha: number;
  113736. /** The latitudinal angle of the camera */
  113737. beta: number;
  113738. /** The radius of the camera from its target */
  113739. radius: number;
  113740. /** Define the camera target (the messh it should follow) */
  113741. target: Nullable<AbstractMesh>;
  113742. private _cartesianCoordinates;
  113743. /**
  113744. * Instantiates a new ArcFollowCamera
  113745. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113746. * @param name Define the name of the camera
  113747. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  113748. * @param beta Define the rotation angle of the camera around the elevation axis
  113749. * @param radius Define the radius of the camera from its target point
  113750. * @param target Define the target of the camera
  113751. * @param scene Define the scene the camera belongs to
  113752. */
  113753. constructor(name: string,
  113754. /** The longitudinal angle of the camera */
  113755. alpha: number,
  113756. /** The latitudinal angle of the camera */
  113757. beta: number,
  113758. /** The radius of the camera from its target */
  113759. radius: number,
  113760. /** Define the camera target (the messh it should follow) */
  113761. target: Nullable<AbstractMesh>, scene: Scene);
  113762. private _follow;
  113763. /** @hidden */
  113764. _checkInputs(): void;
  113765. /**
  113766. * Returns the class name of the object.
  113767. * It is mostly used internally for serialization purposes.
  113768. */
  113769. getClassName(): string;
  113770. }
  113771. }
  113772. declare module BABYLON {
  113773. /**
  113774. * Manage the keyboard inputs to control the movement of a follow camera.
  113775. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113776. */
  113777. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  113778. /**
  113779. * Defines the camera the input is attached to.
  113780. */
  113781. camera: FollowCamera;
  113782. /**
  113783. * Defines the list of key codes associated with the up action (increase heightOffset)
  113784. */
  113785. keysHeightOffsetIncr: number[];
  113786. /**
  113787. * Defines the list of key codes associated with the down action (decrease heightOffset)
  113788. */
  113789. keysHeightOffsetDecr: number[];
  113790. /**
  113791. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  113792. */
  113793. keysHeightOffsetModifierAlt: boolean;
  113794. /**
  113795. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  113796. */
  113797. keysHeightOffsetModifierCtrl: boolean;
  113798. /**
  113799. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  113800. */
  113801. keysHeightOffsetModifierShift: boolean;
  113802. /**
  113803. * Defines the list of key codes associated with the left action (increase rotationOffset)
  113804. */
  113805. keysRotationOffsetIncr: number[];
  113806. /**
  113807. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  113808. */
  113809. keysRotationOffsetDecr: number[];
  113810. /**
  113811. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  113812. */
  113813. keysRotationOffsetModifierAlt: boolean;
  113814. /**
  113815. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  113816. */
  113817. keysRotationOffsetModifierCtrl: boolean;
  113818. /**
  113819. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  113820. */
  113821. keysRotationOffsetModifierShift: boolean;
  113822. /**
  113823. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  113824. */
  113825. keysRadiusIncr: number[];
  113826. /**
  113827. * Defines the list of key codes associated with the zoom-out action (increase radius)
  113828. */
  113829. keysRadiusDecr: number[];
  113830. /**
  113831. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  113832. */
  113833. keysRadiusModifierAlt: boolean;
  113834. /**
  113835. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  113836. */
  113837. keysRadiusModifierCtrl: boolean;
  113838. /**
  113839. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  113840. */
  113841. keysRadiusModifierShift: boolean;
  113842. /**
  113843. * Defines the rate of change of heightOffset.
  113844. */
  113845. heightSensibility: number;
  113846. /**
  113847. * Defines the rate of change of rotationOffset.
  113848. */
  113849. rotationSensibility: number;
  113850. /**
  113851. * Defines the rate of change of radius.
  113852. */
  113853. radiusSensibility: number;
  113854. private _keys;
  113855. private _ctrlPressed;
  113856. private _altPressed;
  113857. private _shiftPressed;
  113858. private _onCanvasBlurObserver;
  113859. private _onKeyboardObserver;
  113860. private _engine;
  113861. private _scene;
  113862. /**
  113863. * Attach the input controls to a specific dom element to get the input from.
  113864. * @param element Defines the element the controls should be listened from
  113865. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113866. */
  113867. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113868. /**
  113869. * Detach the current controls from the specified dom element.
  113870. * @param element Defines the element to stop listening the inputs from
  113871. */
  113872. detachControl(element: Nullable<HTMLElement>): void;
  113873. /**
  113874. * Update the current camera state depending on the inputs that have been used this frame.
  113875. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113876. */
  113877. checkInputs(): void;
  113878. /**
  113879. * Gets the class name of the current input.
  113880. * @returns the class name
  113881. */
  113882. getClassName(): string;
  113883. /**
  113884. * Get the friendly name associated with the input class.
  113885. * @returns the input friendly name
  113886. */
  113887. getSimpleName(): string;
  113888. /**
  113889. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113890. * allow modification of the heightOffset value.
  113891. */
  113892. private _modifierHeightOffset;
  113893. /**
  113894. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113895. * allow modification of the rotationOffset value.
  113896. */
  113897. private _modifierRotationOffset;
  113898. /**
  113899. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113900. * allow modification of the radius value.
  113901. */
  113902. private _modifierRadius;
  113903. }
  113904. }
  113905. declare module BABYLON {
  113906. interface FreeCameraInputsManager {
  113907. /**
  113908. * @hidden
  113909. */
  113910. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  113911. /**
  113912. * Add orientation input support to the input manager.
  113913. * @returns the current input manager
  113914. */
  113915. addDeviceOrientation(): FreeCameraInputsManager;
  113916. }
  113917. /**
  113918. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  113919. * Screen rotation is taken into account.
  113920. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113921. */
  113922. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  113923. private _camera;
  113924. private _screenOrientationAngle;
  113925. private _constantTranform;
  113926. private _screenQuaternion;
  113927. private _alpha;
  113928. private _beta;
  113929. private _gamma;
  113930. /**
  113931. * Can be used to detect if a device orientation sensor is available on a device
  113932. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  113933. * @returns a promise that will resolve on orientation change
  113934. */
  113935. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  113936. /**
  113937. * @hidden
  113938. */
  113939. _onDeviceOrientationChangedObservable: Observable<void>;
  113940. /**
  113941. * Instantiates a new input
  113942. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113943. */
  113944. constructor();
  113945. /**
  113946. * Define the camera controlled by the input.
  113947. */
  113948. get camera(): FreeCamera;
  113949. set camera(camera: FreeCamera);
  113950. /**
  113951. * Attach the input controls to a specific dom element to get the input from.
  113952. * @param element Defines the element the controls should be listened from
  113953. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113954. */
  113955. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113956. private _orientationChanged;
  113957. private _deviceOrientation;
  113958. /**
  113959. * Detach the current controls from the specified dom element.
  113960. * @param element Defines the element to stop listening the inputs from
  113961. */
  113962. detachControl(element: Nullable<HTMLElement>): void;
  113963. /**
  113964. * Update the current camera state depending on the inputs that have been used this frame.
  113965. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113966. */
  113967. checkInputs(): void;
  113968. /**
  113969. * Gets the class name of the current intput.
  113970. * @returns the class name
  113971. */
  113972. getClassName(): string;
  113973. /**
  113974. * Get the friendly name associated with the input class.
  113975. * @returns the input friendly name
  113976. */
  113977. getSimpleName(): string;
  113978. }
  113979. }
  113980. declare module BABYLON {
  113981. /**
  113982. * Manage the gamepad inputs to control a free camera.
  113983. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113984. */
  113985. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  113986. /**
  113987. * Define the camera the input is attached to.
  113988. */
  113989. camera: FreeCamera;
  113990. /**
  113991. * Define the Gamepad controlling the input
  113992. */
  113993. gamepad: Nullable<Gamepad>;
  113994. /**
  113995. * Defines the gamepad rotation sensiblity.
  113996. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  113997. */
  113998. gamepadAngularSensibility: number;
  113999. /**
  114000. * Defines the gamepad move sensiblity.
  114001. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  114002. */
  114003. gamepadMoveSensibility: number;
  114004. private _yAxisScale;
  114005. /**
  114006. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  114007. */
  114008. get invertYAxis(): boolean;
  114009. set invertYAxis(value: boolean);
  114010. private _onGamepadConnectedObserver;
  114011. private _onGamepadDisconnectedObserver;
  114012. private _cameraTransform;
  114013. private _deltaTransform;
  114014. private _vector3;
  114015. private _vector2;
  114016. /**
  114017. * Attach the input controls to a specific dom element to get the input from.
  114018. * @param element Defines the element the controls should be listened from
  114019. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114020. */
  114021. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114022. /**
  114023. * Detach the current controls from the specified dom element.
  114024. * @param element Defines the element to stop listening the inputs from
  114025. */
  114026. detachControl(element: Nullable<HTMLElement>): void;
  114027. /**
  114028. * Update the current camera state depending on the inputs that have been used this frame.
  114029. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114030. */
  114031. checkInputs(): void;
  114032. /**
  114033. * Gets the class name of the current intput.
  114034. * @returns the class name
  114035. */
  114036. getClassName(): string;
  114037. /**
  114038. * Get the friendly name associated with the input class.
  114039. * @returns the input friendly name
  114040. */
  114041. getSimpleName(): string;
  114042. }
  114043. }
  114044. declare module BABYLON {
  114045. /**
  114046. * Defines the potential axis of a Joystick
  114047. */
  114048. export enum JoystickAxis {
  114049. /** X axis */
  114050. X = 0,
  114051. /** Y axis */
  114052. Y = 1,
  114053. /** Z axis */
  114054. Z = 2
  114055. }
  114056. /**
  114057. * Class used to define virtual joystick (used in touch mode)
  114058. */
  114059. export class VirtualJoystick {
  114060. /**
  114061. * Gets or sets a boolean indicating that left and right values must be inverted
  114062. */
  114063. reverseLeftRight: boolean;
  114064. /**
  114065. * Gets or sets a boolean indicating that up and down values must be inverted
  114066. */
  114067. reverseUpDown: boolean;
  114068. /**
  114069. * Gets the offset value for the position (ie. the change of the position value)
  114070. */
  114071. deltaPosition: Vector3;
  114072. /**
  114073. * Gets a boolean indicating if the virtual joystick was pressed
  114074. */
  114075. pressed: boolean;
  114076. /**
  114077. * Canvas the virtual joystick will render onto, default z-index of this is 5
  114078. */
  114079. static Canvas: Nullable<HTMLCanvasElement>;
  114080. private static _globalJoystickIndex;
  114081. private static vjCanvasContext;
  114082. private static vjCanvasWidth;
  114083. private static vjCanvasHeight;
  114084. private static halfWidth;
  114085. private _action;
  114086. private _axisTargetedByLeftAndRight;
  114087. private _axisTargetedByUpAndDown;
  114088. private _joystickSensibility;
  114089. private _inversedSensibility;
  114090. private _joystickPointerID;
  114091. private _joystickColor;
  114092. private _joystickPointerPos;
  114093. private _joystickPreviousPointerPos;
  114094. private _joystickPointerStartPos;
  114095. private _deltaJoystickVector;
  114096. private _leftJoystick;
  114097. private _touches;
  114098. private _onPointerDownHandlerRef;
  114099. private _onPointerMoveHandlerRef;
  114100. private _onPointerUpHandlerRef;
  114101. private _onResize;
  114102. /**
  114103. * Creates a new virtual joystick
  114104. * @param leftJoystick defines that the joystick is for left hand (false by default)
  114105. */
  114106. constructor(leftJoystick?: boolean);
  114107. /**
  114108. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  114109. * @param newJoystickSensibility defines the new sensibility
  114110. */
  114111. setJoystickSensibility(newJoystickSensibility: number): void;
  114112. private _onPointerDown;
  114113. private _onPointerMove;
  114114. private _onPointerUp;
  114115. /**
  114116. * Change the color of the virtual joystick
  114117. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  114118. */
  114119. setJoystickColor(newColor: string): void;
  114120. /**
  114121. * Defines a callback to call when the joystick is touched
  114122. * @param action defines the callback
  114123. */
  114124. setActionOnTouch(action: () => any): void;
  114125. /**
  114126. * Defines which axis you'd like to control for left & right
  114127. * @param axis defines the axis to use
  114128. */
  114129. setAxisForLeftRight(axis: JoystickAxis): void;
  114130. /**
  114131. * Defines which axis you'd like to control for up & down
  114132. * @param axis defines the axis to use
  114133. */
  114134. setAxisForUpDown(axis: JoystickAxis): void;
  114135. private _drawVirtualJoystick;
  114136. /**
  114137. * Release internal HTML canvas
  114138. */
  114139. releaseCanvas(): void;
  114140. }
  114141. }
  114142. declare module BABYLON {
  114143. interface FreeCameraInputsManager {
  114144. /**
  114145. * Add virtual joystick input support to the input manager.
  114146. * @returns the current input manager
  114147. */
  114148. addVirtualJoystick(): FreeCameraInputsManager;
  114149. }
  114150. /**
  114151. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  114152. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114153. */
  114154. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  114155. /**
  114156. * Defines the camera the input is attached to.
  114157. */
  114158. camera: FreeCamera;
  114159. private _leftjoystick;
  114160. private _rightjoystick;
  114161. /**
  114162. * Gets the left stick of the virtual joystick.
  114163. * @returns The virtual Joystick
  114164. */
  114165. getLeftJoystick(): VirtualJoystick;
  114166. /**
  114167. * Gets the right stick of the virtual joystick.
  114168. * @returns The virtual Joystick
  114169. */
  114170. getRightJoystick(): VirtualJoystick;
  114171. /**
  114172. * Update the current camera state depending on the inputs that have been used this frame.
  114173. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114174. */
  114175. checkInputs(): void;
  114176. /**
  114177. * Attach the input controls to a specific dom element to get the input from.
  114178. * @param element Defines the element the controls should be listened from
  114179. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114180. */
  114181. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114182. /**
  114183. * Detach the current controls from the specified dom element.
  114184. * @param element Defines the element to stop listening the inputs from
  114185. */
  114186. detachControl(element: Nullable<HTMLElement>): void;
  114187. /**
  114188. * Gets the class name of the current intput.
  114189. * @returns the class name
  114190. */
  114191. getClassName(): string;
  114192. /**
  114193. * Get the friendly name associated with the input class.
  114194. * @returns the input friendly name
  114195. */
  114196. getSimpleName(): string;
  114197. }
  114198. }
  114199. declare module BABYLON {
  114200. /**
  114201. * This represents a FPS type of camera controlled by touch.
  114202. * This is like a universal camera minus the Gamepad controls.
  114203. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114204. */
  114205. export class TouchCamera extends FreeCamera {
  114206. /**
  114207. * Defines the touch sensibility for rotation.
  114208. * The higher the faster.
  114209. */
  114210. get touchAngularSensibility(): number;
  114211. set touchAngularSensibility(value: number);
  114212. /**
  114213. * Defines the touch sensibility for move.
  114214. * The higher the faster.
  114215. */
  114216. get touchMoveSensibility(): number;
  114217. set touchMoveSensibility(value: number);
  114218. /**
  114219. * Instantiates a new touch camera.
  114220. * This represents a FPS type of camera controlled by touch.
  114221. * This is like a universal camera minus the Gamepad controls.
  114222. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114223. * @param name Define the name of the camera in the scene
  114224. * @param position Define the start position of the camera in the scene
  114225. * @param scene Define the scene the camera belongs to
  114226. */
  114227. constructor(name: string, position: Vector3, scene: Scene);
  114228. /**
  114229. * Gets the current object class name.
  114230. * @return the class name
  114231. */
  114232. getClassName(): string;
  114233. /** @hidden */
  114234. _setupInputs(): void;
  114235. }
  114236. }
  114237. declare module BABYLON {
  114238. /**
  114239. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  114240. * being tilted forward or back and left or right.
  114241. */
  114242. export class DeviceOrientationCamera extends FreeCamera {
  114243. private _initialQuaternion;
  114244. private _quaternionCache;
  114245. private _tmpDragQuaternion;
  114246. private _disablePointerInputWhenUsingDeviceOrientation;
  114247. /**
  114248. * Creates a new device orientation camera
  114249. * @param name The name of the camera
  114250. * @param position The start position camera
  114251. * @param scene The scene the camera belongs to
  114252. */
  114253. constructor(name: string, position: Vector3, scene: Scene);
  114254. /**
  114255. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  114256. */
  114257. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  114258. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  114259. private _dragFactor;
  114260. /**
  114261. * Enabled turning on the y axis when the orientation sensor is active
  114262. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  114263. */
  114264. enableHorizontalDragging(dragFactor?: number): void;
  114265. /**
  114266. * Gets the current instance class name ("DeviceOrientationCamera").
  114267. * This helps avoiding instanceof at run time.
  114268. * @returns the class name
  114269. */
  114270. getClassName(): string;
  114271. /**
  114272. * @hidden
  114273. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  114274. */
  114275. _checkInputs(): void;
  114276. /**
  114277. * Reset the camera to its default orientation on the specified axis only.
  114278. * @param axis The axis to reset
  114279. */
  114280. resetToCurrentRotation(axis?: Axis): void;
  114281. }
  114282. }
  114283. declare module BABYLON {
  114284. /**
  114285. * Defines supported buttons for XBox360 compatible gamepads
  114286. */
  114287. export enum Xbox360Button {
  114288. /** A */
  114289. A = 0,
  114290. /** B */
  114291. B = 1,
  114292. /** X */
  114293. X = 2,
  114294. /** Y */
  114295. Y = 3,
  114296. /** Start */
  114297. Start = 4,
  114298. /** Back */
  114299. Back = 5,
  114300. /** Left button */
  114301. LB = 6,
  114302. /** Right button */
  114303. RB = 7,
  114304. /** Left stick */
  114305. LeftStick = 8,
  114306. /** Right stick */
  114307. RightStick = 9
  114308. }
  114309. /** Defines values for XBox360 DPad */
  114310. export enum Xbox360Dpad {
  114311. /** Up */
  114312. Up = 0,
  114313. /** Down */
  114314. Down = 1,
  114315. /** Left */
  114316. Left = 2,
  114317. /** Right */
  114318. Right = 3
  114319. }
  114320. /**
  114321. * Defines a XBox360 gamepad
  114322. */
  114323. export class Xbox360Pad extends Gamepad {
  114324. private _leftTrigger;
  114325. private _rightTrigger;
  114326. private _onlefttriggerchanged;
  114327. private _onrighttriggerchanged;
  114328. private _onbuttondown;
  114329. private _onbuttonup;
  114330. private _ondpaddown;
  114331. private _ondpadup;
  114332. /** Observable raised when a button is pressed */
  114333. onButtonDownObservable: Observable<Xbox360Button>;
  114334. /** Observable raised when a button is released */
  114335. onButtonUpObservable: Observable<Xbox360Button>;
  114336. /** Observable raised when a pad is pressed */
  114337. onPadDownObservable: Observable<Xbox360Dpad>;
  114338. /** Observable raised when a pad is released */
  114339. onPadUpObservable: Observable<Xbox360Dpad>;
  114340. private _buttonA;
  114341. private _buttonB;
  114342. private _buttonX;
  114343. private _buttonY;
  114344. private _buttonBack;
  114345. private _buttonStart;
  114346. private _buttonLB;
  114347. private _buttonRB;
  114348. private _buttonLeftStick;
  114349. private _buttonRightStick;
  114350. private _dPadUp;
  114351. private _dPadDown;
  114352. private _dPadLeft;
  114353. private _dPadRight;
  114354. private _isXboxOnePad;
  114355. /**
  114356. * Creates a new XBox360 gamepad object
  114357. * @param id defines the id of this gamepad
  114358. * @param index defines its index
  114359. * @param gamepad defines the internal HTML gamepad object
  114360. * @param xboxOne defines if it is a XBox One gamepad
  114361. */
  114362. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  114363. /**
  114364. * Defines the callback to call when left trigger is pressed
  114365. * @param callback defines the callback to use
  114366. */
  114367. onlefttriggerchanged(callback: (value: number) => void): void;
  114368. /**
  114369. * Defines the callback to call when right trigger is pressed
  114370. * @param callback defines the callback to use
  114371. */
  114372. onrighttriggerchanged(callback: (value: number) => void): void;
  114373. /**
  114374. * Gets the left trigger value
  114375. */
  114376. get leftTrigger(): number;
  114377. /**
  114378. * Sets the left trigger value
  114379. */
  114380. set leftTrigger(newValue: number);
  114381. /**
  114382. * Gets the right trigger value
  114383. */
  114384. get rightTrigger(): number;
  114385. /**
  114386. * Sets the right trigger value
  114387. */
  114388. set rightTrigger(newValue: number);
  114389. /**
  114390. * Defines the callback to call when a button is pressed
  114391. * @param callback defines the callback to use
  114392. */
  114393. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  114394. /**
  114395. * Defines the callback to call when a button is released
  114396. * @param callback defines the callback to use
  114397. */
  114398. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  114399. /**
  114400. * Defines the callback to call when a pad is pressed
  114401. * @param callback defines the callback to use
  114402. */
  114403. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  114404. /**
  114405. * Defines the callback to call when a pad is released
  114406. * @param callback defines the callback to use
  114407. */
  114408. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  114409. private _setButtonValue;
  114410. private _setDPadValue;
  114411. /**
  114412. * Gets the value of the `A` button
  114413. */
  114414. get buttonA(): number;
  114415. /**
  114416. * Sets the value of the `A` button
  114417. */
  114418. set buttonA(value: number);
  114419. /**
  114420. * Gets the value of the `B` button
  114421. */
  114422. get buttonB(): number;
  114423. /**
  114424. * Sets the value of the `B` button
  114425. */
  114426. set buttonB(value: number);
  114427. /**
  114428. * Gets the value of the `X` button
  114429. */
  114430. get buttonX(): number;
  114431. /**
  114432. * Sets the value of the `X` button
  114433. */
  114434. set buttonX(value: number);
  114435. /**
  114436. * Gets the value of the `Y` button
  114437. */
  114438. get buttonY(): number;
  114439. /**
  114440. * Sets the value of the `Y` button
  114441. */
  114442. set buttonY(value: number);
  114443. /**
  114444. * Gets the value of the `Start` button
  114445. */
  114446. get buttonStart(): number;
  114447. /**
  114448. * Sets the value of the `Start` button
  114449. */
  114450. set buttonStart(value: number);
  114451. /**
  114452. * Gets the value of the `Back` button
  114453. */
  114454. get buttonBack(): number;
  114455. /**
  114456. * Sets the value of the `Back` button
  114457. */
  114458. set buttonBack(value: number);
  114459. /**
  114460. * Gets the value of the `Left` button
  114461. */
  114462. get buttonLB(): number;
  114463. /**
  114464. * Sets the value of the `Left` button
  114465. */
  114466. set buttonLB(value: number);
  114467. /**
  114468. * Gets the value of the `Right` button
  114469. */
  114470. get buttonRB(): number;
  114471. /**
  114472. * Sets the value of the `Right` button
  114473. */
  114474. set buttonRB(value: number);
  114475. /**
  114476. * Gets the value of the Left joystick
  114477. */
  114478. get buttonLeftStick(): number;
  114479. /**
  114480. * Sets the value of the Left joystick
  114481. */
  114482. set buttonLeftStick(value: number);
  114483. /**
  114484. * Gets the value of the Right joystick
  114485. */
  114486. get buttonRightStick(): number;
  114487. /**
  114488. * Sets the value of the Right joystick
  114489. */
  114490. set buttonRightStick(value: number);
  114491. /**
  114492. * Gets the value of D-pad up
  114493. */
  114494. get dPadUp(): number;
  114495. /**
  114496. * Sets the value of D-pad up
  114497. */
  114498. set dPadUp(value: number);
  114499. /**
  114500. * Gets the value of D-pad down
  114501. */
  114502. get dPadDown(): number;
  114503. /**
  114504. * Sets the value of D-pad down
  114505. */
  114506. set dPadDown(value: number);
  114507. /**
  114508. * Gets the value of D-pad left
  114509. */
  114510. get dPadLeft(): number;
  114511. /**
  114512. * Sets the value of D-pad left
  114513. */
  114514. set dPadLeft(value: number);
  114515. /**
  114516. * Gets the value of D-pad right
  114517. */
  114518. get dPadRight(): number;
  114519. /**
  114520. * Sets the value of D-pad right
  114521. */
  114522. set dPadRight(value: number);
  114523. /**
  114524. * Force the gamepad to synchronize with device values
  114525. */
  114526. update(): void;
  114527. /**
  114528. * Disposes the gamepad
  114529. */
  114530. dispose(): void;
  114531. }
  114532. }
  114533. declare module BABYLON {
  114534. /**
  114535. * Defines supported buttons for DualShock compatible gamepads
  114536. */
  114537. export enum DualShockButton {
  114538. /** Cross */
  114539. Cross = 0,
  114540. /** Circle */
  114541. Circle = 1,
  114542. /** Square */
  114543. Square = 2,
  114544. /** Triangle */
  114545. Triangle = 3,
  114546. /** Options */
  114547. Options = 4,
  114548. /** Share */
  114549. Share = 5,
  114550. /** L1 */
  114551. L1 = 6,
  114552. /** R1 */
  114553. R1 = 7,
  114554. /** Left stick */
  114555. LeftStick = 8,
  114556. /** Right stick */
  114557. RightStick = 9
  114558. }
  114559. /** Defines values for DualShock DPad */
  114560. export enum DualShockDpad {
  114561. /** Up */
  114562. Up = 0,
  114563. /** Down */
  114564. Down = 1,
  114565. /** Left */
  114566. Left = 2,
  114567. /** Right */
  114568. Right = 3
  114569. }
  114570. /**
  114571. * Defines a DualShock gamepad
  114572. */
  114573. export class DualShockPad extends Gamepad {
  114574. private _leftTrigger;
  114575. private _rightTrigger;
  114576. private _onlefttriggerchanged;
  114577. private _onrighttriggerchanged;
  114578. private _onbuttondown;
  114579. private _onbuttonup;
  114580. private _ondpaddown;
  114581. private _ondpadup;
  114582. /** Observable raised when a button is pressed */
  114583. onButtonDownObservable: Observable<DualShockButton>;
  114584. /** Observable raised when a button is released */
  114585. onButtonUpObservable: Observable<DualShockButton>;
  114586. /** Observable raised when a pad is pressed */
  114587. onPadDownObservable: Observable<DualShockDpad>;
  114588. /** Observable raised when a pad is released */
  114589. onPadUpObservable: Observable<DualShockDpad>;
  114590. private _buttonCross;
  114591. private _buttonCircle;
  114592. private _buttonSquare;
  114593. private _buttonTriangle;
  114594. private _buttonShare;
  114595. private _buttonOptions;
  114596. private _buttonL1;
  114597. private _buttonR1;
  114598. private _buttonLeftStick;
  114599. private _buttonRightStick;
  114600. private _dPadUp;
  114601. private _dPadDown;
  114602. private _dPadLeft;
  114603. private _dPadRight;
  114604. /**
  114605. * Creates a new DualShock gamepad object
  114606. * @param id defines the id of this gamepad
  114607. * @param index defines its index
  114608. * @param gamepad defines the internal HTML gamepad object
  114609. */
  114610. constructor(id: string, index: number, gamepad: any);
  114611. /**
  114612. * Defines the callback to call when left trigger is pressed
  114613. * @param callback defines the callback to use
  114614. */
  114615. onlefttriggerchanged(callback: (value: number) => void): void;
  114616. /**
  114617. * Defines the callback to call when right trigger is pressed
  114618. * @param callback defines the callback to use
  114619. */
  114620. onrighttriggerchanged(callback: (value: number) => void): void;
  114621. /**
  114622. * Gets the left trigger value
  114623. */
  114624. get leftTrigger(): number;
  114625. /**
  114626. * Sets the left trigger value
  114627. */
  114628. set leftTrigger(newValue: number);
  114629. /**
  114630. * Gets the right trigger value
  114631. */
  114632. get rightTrigger(): number;
  114633. /**
  114634. * Sets the right trigger value
  114635. */
  114636. set rightTrigger(newValue: number);
  114637. /**
  114638. * Defines the callback to call when a button is pressed
  114639. * @param callback defines the callback to use
  114640. */
  114641. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  114642. /**
  114643. * Defines the callback to call when a button is released
  114644. * @param callback defines the callback to use
  114645. */
  114646. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  114647. /**
  114648. * Defines the callback to call when a pad is pressed
  114649. * @param callback defines the callback to use
  114650. */
  114651. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  114652. /**
  114653. * Defines the callback to call when a pad is released
  114654. * @param callback defines the callback to use
  114655. */
  114656. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  114657. private _setButtonValue;
  114658. private _setDPadValue;
  114659. /**
  114660. * Gets the value of the `Cross` button
  114661. */
  114662. get buttonCross(): number;
  114663. /**
  114664. * Sets the value of the `Cross` button
  114665. */
  114666. set buttonCross(value: number);
  114667. /**
  114668. * Gets the value of the `Circle` button
  114669. */
  114670. get buttonCircle(): number;
  114671. /**
  114672. * Sets the value of the `Circle` button
  114673. */
  114674. set buttonCircle(value: number);
  114675. /**
  114676. * Gets the value of the `Square` button
  114677. */
  114678. get buttonSquare(): number;
  114679. /**
  114680. * Sets the value of the `Square` button
  114681. */
  114682. set buttonSquare(value: number);
  114683. /**
  114684. * Gets the value of the `Triangle` button
  114685. */
  114686. get buttonTriangle(): number;
  114687. /**
  114688. * Sets the value of the `Triangle` button
  114689. */
  114690. set buttonTriangle(value: number);
  114691. /**
  114692. * Gets the value of the `Options` button
  114693. */
  114694. get buttonOptions(): number;
  114695. /**
  114696. * Sets the value of the `Options` button
  114697. */
  114698. set buttonOptions(value: number);
  114699. /**
  114700. * Gets the value of the `Share` button
  114701. */
  114702. get buttonShare(): number;
  114703. /**
  114704. * Sets the value of the `Share` button
  114705. */
  114706. set buttonShare(value: number);
  114707. /**
  114708. * Gets the value of the `L1` button
  114709. */
  114710. get buttonL1(): number;
  114711. /**
  114712. * Sets the value of the `L1` button
  114713. */
  114714. set buttonL1(value: number);
  114715. /**
  114716. * Gets the value of the `R1` button
  114717. */
  114718. get buttonR1(): number;
  114719. /**
  114720. * Sets the value of the `R1` button
  114721. */
  114722. set buttonR1(value: number);
  114723. /**
  114724. * Gets the value of the Left joystick
  114725. */
  114726. get buttonLeftStick(): number;
  114727. /**
  114728. * Sets the value of the Left joystick
  114729. */
  114730. set buttonLeftStick(value: number);
  114731. /**
  114732. * Gets the value of the Right joystick
  114733. */
  114734. get buttonRightStick(): number;
  114735. /**
  114736. * Sets the value of the Right joystick
  114737. */
  114738. set buttonRightStick(value: number);
  114739. /**
  114740. * Gets the value of D-pad up
  114741. */
  114742. get dPadUp(): number;
  114743. /**
  114744. * Sets the value of D-pad up
  114745. */
  114746. set dPadUp(value: number);
  114747. /**
  114748. * Gets the value of D-pad down
  114749. */
  114750. get dPadDown(): number;
  114751. /**
  114752. * Sets the value of D-pad down
  114753. */
  114754. set dPadDown(value: number);
  114755. /**
  114756. * Gets the value of D-pad left
  114757. */
  114758. get dPadLeft(): number;
  114759. /**
  114760. * Sets the value of D-pad left
  114761. */
  114762. set dPadLeft(value: number);
  114763. /**
  114764. * Gets the value of D-pad right
  114765. */
  114766. get dPadRight(): number;
  114767. /**
  114768. * Sets the value of D-pad right
  114769. */
  114770. set dPadRight(value: number);
  114771. /**
  114772. * Force the gamepad to synchronize with device values
  114773. */
  114774. update(): void;
  114775. /**
  114776. * Disposes the gamepad
  114777. */
  114778. dispose(): void;
  114779. }
  114780. }
  114781. declare module BABYLON {
  114782. /**
  114783. * Manager for handling gamepads
  114784. */
  114785. export class GamepadManager {
  114786. private _scene?;
  114787. private _babylonGamepads;
  114788. private _oneGamepadConnected;
  114789. /** @hidden */
  114790. _isMonitoring: boolean;
  114791. private _gamepadEventSupported;
  114792. private _gamepadSupport?;
  114793. /**
  114794. * observable to be triggered when the gamepad controller has been connected
  114795. */
  114796. onGamepadConnectedObservable: Observable<Gamepad>;
  114797. /**
  114798. * observable to be triggered when the gamepad controller has been disconnected
  114799. */
  114800. onGamepadDisconnectedObservable: Observable<Gamepad>;
  114801. private _onGamepadConnectedEvent;
  114802. private _onGamepadDisconnectedEvent;
  114803. /**
  114804. * Initializes the gamepad manager
  114805. * @param _scene BabylonJS scene
  114806. */
  114807. constructor(_scene?: Scene | undefined);
  114808. /**
  114809. * The gamepads in the game pad manager
  114810. */
  114811. get gamepads(): Gamepad[];
  114812. /**
  114813. * Get the gamepad controllers based on type
  114814. * @param type The type of gamepad controller
  114815. * @returns Nullable gamepad
  114816. */
  114817. getGamepadByType(type?: number): Nullable<Gamepad>;
  114818. /**
  114819. * Disposes the gamepad manager
  114820. */
  114821. dispose(): void;
  114822. private _addNewGamepad;
  114823. private _startMonitoringGamepads;
  114824. private _stopMonitoringGamepads;
  114825. /** @hidden */
  114826. _checkGamepadsStatus(): void;
  114827. private _updateGamepadObjects;
  114828. }
  114829. }
  114830. declare module BABYLON {
  114831. interface Scene {
  114832. /** @hidden */
  114833. _gamepadManager: Nullable<GamepadManager>;
  114834. /**
  114835. * Gets the gamepad manager associated with the scene
  114836. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  114837. */
  114838. gamepadManager: GamepadManager;
  114839. }
  114840. /**
  114841. * Interface representing a free camera inputs manager
  114842. */
  114843. interface FreeCameraInputsManager {
  114844. /**
  114845. * Adds gamepad input support to the FreeCameraInputsManager.
  114846. * @returns the FreeCameraInputsManager
  114847. */
  114848. addGamepad(): FreeCameraInputsManager;
  114849. }
  114850. /**
  114851. * Interface representing an arc rotate camera inputs manager
  114852. */
  114853. interface ArcRotateCameraInputsManager {
  114854. /**
  114855. * Adds gamepad input support to the ArcRotateCamera InputManager.
  114856. * @returns the camera inputs manager
  114857. */
  114858. addGamepad(): ArcRotateCameraInputsManager;
  114859. }
  114860. /**
  114861. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  114862. */
  114863. export class GamepadSystemSceneComponent implements ISceneComponent {
  114864. /**
  114865. * The component name helpfull to identify the component in the list of scene components.
  114866. */
  114867. readonly name: string;
  114868. /**
  114869. * The scene the component belongs to.
  114870. */
  114871. scene: Scene;
  114872. /**
  114873. * Creates a new instance of the component for the given scene
  114874. * @param scene Defines the scene to register the component in
  114875. */
  114876. constructor(scene: Scene);
  114877. /**
  114878. * Registers the component in a given scene
  114879. */
  114880. register(): void;
  114881. /**
  114882. * Rebuilds the elements related to this component in case of
  114883. * context lost for instance.
  114884. */
  114885. rebuild(): void;
  114886. /**
  114887. * Disposes the component and the associated ressources
  114888. */
  114889. dispose(): void;
  114890. private _beforeCameraUpdate;
  114891. }
  114892. }
  114893. declare module BABYLON {
  114894. /**
  114895. * 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,
  114896. * which still works and will still be found in many Playgrounds.
  114897. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114898. */
  114899. export class UniversalCamera extends TouchCamera {
  114900. /**
  114901. * Defines the gamepad rotation sensiblity.
  114902. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  114903. */
  114904. get gamepadAngularSensibility(): number;
  114905. set gamepadAngularSensibility(value: number);
  114906. /**
  114907. * Defines the gamepad move sensiblity.
  114908. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  114909. */
  114910. get gamepadMoveSensibility(): number;
  114911. set gamepadMoveSensibility(value: number);
  114912. /**
  114913. * 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,
  114914. * which still works and will still be found in many Playgrounds.
  114915. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114916. * @param name Define the name of the camera in the scene
  114917. * @param position Define the start position of the camera in the scene
  114918. * @param scene Define the scene the camera belongs to
  114919. */
  114920. constructor(name: string, position: Vector3, scene: Scene);
  114921. /**
  114922. * Gets the current object class name.
  114923. * @return the class name
  114924. */
  114925. getClassName(): string;
  114926. }
  114927. }
  114928. declare module BABYLON {
  114929. /**
  114930. * This represents a FPS type of camera. This is only here for back compat purpose.
  114931. * Please use the UniversalCamera instead as both are identical.
  114932. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114933. */
  114934. export class GamepadCamera extends UniversalCamera {
  114935. /**
  114936. * Instantiates a new Gamepad Camera
  114937. * This represents a FPS type of camera. This is only here for back compat purpose.
  114938. * Please use the UniversalCamera instead as both are identical.
  114939. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114940. * @param name Define the name of the camera in the scene
  114941. * @param position Define the start position of the camera in the scene
  114942. * @param scene Define the scene the camera belongs to
  114943. */
  114944. constructor(name: string, position: Vector3, scene: Scene);
  114945. /**
  114946. * Gets the current object class name.
  114947. * @return the class name
  114948. */
  114949. getClassName(): string;
  114950. }
  114951. }
  114952. declare module BABYLON {
  114953. /** @hidden */
  114954. export var passPixelShader: {
  114955. name: string;
  114956. shader: string;
  114957. };
  114958. }
  114959. declare module BABYLON {
  114960. /** @hidden */
  114961. export var passCubePixelShader: {
  114962. name: string;
  114963. shader: string;
  114964. };
  114965. }
  114966. declare module BABYLON {
  114967. /**
  114968. * PassPostProcess which produces an output the same as it's input
  114969. */
  114970. export class PassPostProcess extends PostProcess {
  114971. /**
  114972. * Creates the PassPostProcess
  114973. * @param name The name of the effect.
  114974. * @param options The required width/height ratio to downsize to before computing the render pass.
  114975. * @param camera The camera to apply the render pass to.
  114976. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  114977. * @param engine The engine which the post process will be applied. (default: current engine)
  114978. * @param reusable If the post process can be reused on the same frame. (default: false)
  114979. * @param textureType The type of texture to be used when performing the post processing.
  114980. * @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)
  114981. */
  114982. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  114983. }
  114984. /**
  114985. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  114986. */
  114987. export class PassCubePostProcess extends PostProcess {
  114988. private _face;
  114989. /**
  114990. * Gets or sets the cube face to display.
  114991. * * 0 is +X
  114992. * * 1 is -X
  114993. * * 2 is +Y
  114994. * * 3 is -Y
  114995. * * 4 is +Z
  114996. * * 5 is -Z
  114997. */
  114998. get face(): number;
  114999. set face(value: number);
  115000. /**
  115001. * Creates the PassCubePostProcess
  115002. * @param name The name of the effect.
  115003. * @param options The required width/height ratio to downsize to before computing the render pass.
  115004. * @param camera The camera to apply the render pass to.
  115005. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115006. * @param engine The engine which the post process will be applied. (default: current engine)
  115007. * @param reusable If the post process can be reused on the same frame. (default: false)
  115008. * @param textureType The type of texture to be used when performing the post processing.
  115009. * @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)
  115010. */
  115011. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  115012. }
  115013. }
  115014. declare module BABYLON {
  115015. /** @hidden */
  115016. export var anaglyphPixelShader: {
  115017. name: string;
  115018. shader: string;
  115019. };
  115020. }
  115021. declare module BABYLON {
  115022. /**
  115023. * Postprocess used to generate anaglyphic rendering
  115024. */
  115025. export class AnaglyphPostProcess extends PostProcess {
  115026. private _passedProcess;
  115027. /**
  115028. * Creates a new AnaglyphPostProcess
  115029. * @param name defines postprocess name
  115030. * @param options defines creation options or target ratio scale
  115031. * @param rigCameras defines cameras using this postprocess
  115032. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  115033. * @param engine defines hosting engine
  115034. * @param reusable defines if the postprocess will be reused multiple times per frame
  115035. */
  115036. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  115037. }
  115038. }
  115039. declare module BABYLON {
  115040. /**
  115041. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  115042. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  115043. */
  115044. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  115045. /**
  115046. * Creates a new AnaglyphArcRotateCamera
  115047. * @param name defines camera name
  115048. * @param alpha defines alpha angle (in radians)
  115049. * @param beta defines beta angle (in radians)
  115050. * @param radius defines radius
  115051. * @param target defines camera target
  115052. * @param interaxialDistance defines distance between each color axis
  115053. * @param scene defines the hosting scene
  115054. */
  115055. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  115056. /**
  115057. * Gets camera class name
  115058. * @returns AnaglyphArcRotateCamera
  115059. */
  115060. getClassName(): string;
  115061. }
  115062. }
  115063. declare module BABYLON {
  115064. /**
  115065. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  115066. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  115067. */
  115068. export class AnaglyphFreeCamera extends FreeCamera {
  115069. /**
  115070. * Creates a new AnaglyphFreeCamera
  115071. * @param name defines camera name
  115072. * @param position defines initial position
  115073. * @param interaxialDistance defines distance between each color axis
  115074. * @param scene defines the hosting scene
  115075. */
  115076. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  115077. /**
  115078. * Gets camera class name
  115079. * @returns AnaglyphFreeCamera
  115080. */
  115081. getClassName(): string;
  115082. }
  115083. }
  115084. declare module BABYLON {
  115085. /**
  115086. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  115087. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  115088. */
  115089. export class AnaglyphGamepadCamera extends GamepadCamera {
  115090. /**
  115091. * Creates a new AnaglyphGamepadCamera
  115092. * @param name defines camera name
  115093. * @param position defines initial position
  115094. * @param interaxialDistance defines distance between each color axis
  115095. * @param scene defines the hosting scene
  115096. */
  115097. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  115098. /**
  115099. * Gets camera class name
  115100. * @returns AnaglyphGamepadCamera
  115101. */
  115102. getClassName(): string;
  115103. }
  115104. }
  115105. declare module BABYLON {
  115106. /**
  115107. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  115108. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  115109. */
  115110. export class AnaglyphUniversalCamera extends UniversalCamera {
  115111. /**
  115112. * Creates a new AnaglyphUniversalCamera
  115113. * @param name defines camera name
  115114. * @param position defines initial position
  115115. * @param interaxialDistance defines distance between each color axis
  115116. * @param scene defines the hosting scene
  115117. */
  115118. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  115119. /**
  115120. * Gets camera class name
  115121. * @returns AnaglyphUniversalCamera
  115122. */
  115123. getClassName(): string;
  115124. }
  115125. }
  115126. declare module BABYLON {
  115127. /** @hidden */
  115128. export var stereoscopicInterlacePixelShader: {
  115129. name: string;
  115130. shader: string;
  115131. };
  115132. }
  115133. declare module BABYLON {
  115134. /**
  115135. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  115136. */
  115137. export class StereoscopicInterlacePostProcessI extends PostProcess {
  115138. private _stepSize;
  115139. private _passedProcess;
  115140. /**
  115141. * Initializes a StereoscopicInterlacePostProcessI
  115142. * @param name The name of the effect.
  115143. * @param rigCameras The rig cameras to be appled to the post process
  115144. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  115145. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  115146. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115147. * @param engine The engine which the post process will be applied. (default: current engine)
  115148. * @param reusable If the post process can be reused on the same frame. (default: false)
  115149. */
  115150. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  115151. }
  115152. /**
  115153. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  115154. */
  115155. export class StereoscopicInterlacePostProcess extends PostProcess {
  115156. private _stepSize;
  115157. private _passedProcess;
  115158. /**
  115159. * Initializes a StereoscopicInterlacePostProcess
  115160. * @param name The name of the effect.
  115161. * @param rigCameras The rig cameras to be appled to the post process
  115162. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  115163. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115164. * @param engine The engine which the post process will be applied. (default: current engine)
  115165. * @param reusable If the post process can be reused on the same frame. (default: false)
  115166. */
  115167. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  115168. }
  115169. }
  115170. declare module BABYLON {
  115171. /**
  115172. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  115173. * @see http://doc.babylonjs.com/features/cameras
  115174. */
  115175. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  115176. /**
  115177. * Creates a new StereoscopicArcRotateCamera
  115178. * @param name defines camera name
  115179. * @param alpha defines alpha angle (in radians)
  115180. * @param beta defines beta angle (in radians)
  115181. * @param radius defines radius
  115182. * @param target defines camera target
  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, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115188. /**
  115189. * Gets camera class name
  115190. * @returns StereoscopicArcRotateCamera
  115191. */
  115192. getClassName(): string;
  115193. }
  115194. }
  115195. declare module BABYLON {
  115196. /**
  115197. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  115198. * @see http://doc.babylonjs.com/features/cameras
  115199. */
  115200. export class StereoscopicFreeCamera extends FreeCamera {
  115201. /**
  115202. * Creates a new StereoscopicFreeCamera
  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 StereoscopicFreeCamera
  115213. */
  115214. getClassName(): string;
  115215. }
  115216. }
  115217. declare module BABYLON {
  115218. /**
  115219. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  115220. * @see http://doc.babylonjs.com/features/cameras
  115221. */
  115222. export class StereoscopicGamepadCamera extends GamepadCamera {
  115223. /**
  115224. * Creates a new StereoscopicGamepadCamera
  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 StereoscopicGamepadCamera
  115235. */
  115236. getClassName(): string;
  115237. }
  115238. }
  115239. declare module BABYLON {
  115240. /**
  115241. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  115242. * @see http://doc.babylonjs.com/features/cameras
  115243. */
  115244. export class StereoscopicUniversalCamera extends UniversalCamera {
  115245. /**
  115246. * Creates a new StereoscopicUniversalCamera
  115247. * @param name defines camera name
  115248. * @param position defines initial position
  115249. * @param interaxialDistance defines distance between each color axis
  115250. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115251. * @param scene defines the hosting scene
  115252. */
  115253. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115254. /**
  115255. * Gets camera class name
  115256. * @returns StereoscopicUniversalCamera
  115257. */
  115258. getClassName(): string;
  115259. }
  115260. }
  115261. declare module BABYLON {
  115262. /**
  115263. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  115264. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  115265. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  115266. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  115267. */
  115268. export class VirtualJoysticksCamera extends FreeCamera {
  115269. /**
  115270. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  115271. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  115272. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  115273. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  115274. * @param name Define the name of the camera in the scene
  115275. * @param position Define the start position of the camera in the scene
  115276. * @param scene Define the scene the camera belongs to
  115277. */
  115278. constructor(name: string, position: Vector3, scene: Scene);
  115279. /**
  115280. * Gets the current object class name.
  115281. * @return the class name
  115282. */
  115283. getClassName(): string;
  115284. }
  115285. }
  115286. declare module BABYLON {
  115287. /**
  115288. * This represents all the required metrics to create a VR camera.
  115289. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  115290. */
  115291. export class VRCameraMetrics {
  115292. /**
  115293. * Define the horizontal resolution off the screen.
  115294. */
  115295. hResolution: number;
  115296. /**
  115297. * Define the vertical resolution off the screen.
  115298. */
  115299. vResolution: number;
  115300. /**
  115301. * Define the horizontal screen size.
  115302. */
  115303. hScreenSize: number;
  115304. /**
  115305. * Define the vertical screen size.
  115306. */
  115307. vScreenSize: number;
  115308. /**
  115309. * Define the vertical screen center position.
  115310. */
  115311. vScreenCenter: number;
  115312. /**
  115313. * Define the distance of the eyes to the screen.
  115314. */
  115315. eyeToScreenDistance: number;
  115316. /**
  115317. * Define the distance between both lenses
  115318. */
  115319. lensSeparationDistance: number;
  115320. /**
  115321. * Define the distance between both viewer's eyes.
  115322. */
  115323. interpupillaryDistance: number;
  115324. /**
  115325. * Define the distortion factor of the VR postprocess.
  115326. * Please, touch with care.
  115327. */
  115328. distortionK: number[];
  115329. /**
  115330. * Define the chromatic aberration correction factors for the VR post process.
  115331. */
  115332. chromaAbCorrection: number[];
  115333. /**
  115334. * Define the scale factor of the post process.
  115335. * The smaller the better but the slower.
  115336. */
  115337. postProcessScaleFactor: number;
  115338. /**
  115339. * Define an offset for the lens center.
  115340. */
  115341. lensCenterOffset: number;
  115342. /**
  115343. * Define if the current vr camera should compensate the distortion of the lense or not.
  115344. */
  115345. compensateDistortion: boolean;
  115346. /**
  115347. * Defines if multiview should be enabled when rendering (Default: false)
  115348. */
  115349. multiviewEnabled: boolean;
  115350. /**
  115351. * Gets the rendering aspect ratio based on the provided resolutions.
  115352. */
  115353. get aspectRatio(): number;
  115354. /**
  115355. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  115356. */
  115357. get aspectRatioFov(): number;
  115358. /**
  115359. * @hidden
  115360. */
  115361. get leftHMatrix(): Matrix;
  115362. /**
  115363. * @hidden
  115364. */
  115365. get rightHMatrix(): Matrix;
  115366. /**
  115367. * @hidden
  115368. */
  115369. get leftPreViewMatrix(): Matrix;
  115370. /**
  115371. * @hidden
  115372. */
  115373. get rightPreViewMatrix(): Matrix;
  115374. /**
  115375. * Get the default VRMetrics based on the most generic setup.
  115376. * @returns the default vr metrics
  115377. */
  115378. static GetDefault(): VRCameraMetrics;
  115379. }
  115380. }
  115381. declare module BABYLON {
  115382. /** @hidden */
  115383. export var vrDistortionCorrectionPixelShader: {
  115384. name: string;
  115385. shader: string;
  115386. };
  115387. }
  115388. declare module BABYLON {
  115389. /**
  115390. * VRDistortionCorrectionPostProcess used for mobile VR
  115391. */
  115392. export class VRDistortionCorrectionPostProcess extends PostProcess {
  115393. private _isRightEye;
  115394. private _distortionFactors;
  115395. private _postProcessScaleFactor;
  115396. private _lensCenterOffset;
  115397. private _scaleIn;
  115398. private _scaleFactor;
  115399. private _lensCenter;
  115400. /**
  115401. * Initializes the VRDistortionCorrectionPostProcess
  115402. * @param name The name of the effect.
  115403. * @param camera The camera to apply the render pass to.
  115404. * @param isRightEye If this is for the right eye distortion
  115405. * @param vrMetrics All the required metrics for the VR camera
  115406. */
  115407. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  115408. }
  115409. }
  115410. declare module BABYLON {
  115411. /**
  115412. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  115413. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115414. */
  115415. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  115416. /**
  115417. * Creates a new VRDeviceOrientationArcRotateCamera
  115418. * @param name defines camera name
  115419. * @param alpha defines the camera rotation along the logitudinal axis
  115420. * @param beta defines the camera rotation along the latitudinal axis
  115421. * @param radius defines the camera distance from its target
  115422. * @param target defines the camera target
  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, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115428. /**
  115429. * Gets camera class name
  115430. * @returns VRDeviceOrientationArcRotateCamera
  115431. */
  115432. getClassName(): string;
  115433. }
  115434. }
  115435. declare module BABYLON {
  115436. /**
  115437. * Camera used to simulate VR rendering (based on FreeCamera)
  115438. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115439. */
  115440. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  115441. /**
  115442. * Creates a new VRDeviceOrientationFreeCamera
  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 VRDeviceOrientationFreeCamera
  115453. */
  115454. getClassName(): string;
  115455. }
  115456. }
  115457. declare module BABYLON {
  115458. /**
  115459. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  115460. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115461. */
  115462. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  115463. /**
  115464. * Creates a new VRDeviceOrientationGamepadCamera
  115465. * @param name defines camera name
  115466. * @param position defines the start position of the camera
  115467. * @param scene defines the scene the camera belongs to
  115468. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115469. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115470. */
  115471. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115472. /**
  115473. * Gets camera class name
  115474. * @returns VRDeviceOrientationGamepadCamera
  115475. */
  115476. getClassName(): string;
  115477. }
  115478. }
  115479. declare module BABYLON {
  115480. /** @hidden */
  115481. export var imageProcessingPixelShader: {
  115482. name: string;
  115483. shader: string;
  115484. };
  115485. }
  115486. declare module BABYLON {
  115487. /**
  115488. * ImageProcessingPostProcess
  115489. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  115490. */
  115491. export class ImageProcessingPostProcess extends PostProcess {
  115492. /**
  115493. * Default configuration related to image processing available in the PBR Material.
  115494. */
  115495. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  115496. /**
  115497. * Gets the image processing configuration used either in this material.
  115498. */
  115499. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  115500. /**
  115501. * Sets the Default image processing configuration used either in the this material.
  115502. *
  115503. * If sets to null, the scene one is in use.
  115504. */
  115505. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  115506. /**
  115507. * Keep track of the image processing observer to allow dispose and replace.
  115508. */
  115509. private _imageProcessingObserver;
  115510. /**
  115511. * Attaches a new image processing configuration to the PBR Material.
  115512. * @param configuration
  115513. */
  115514. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  115515. /**
  115516. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  115517. */
  115518. get colorCurves(): Nullable<ColorCurves>;
  115519. /**
  115520. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  115521. */
  115522. set colorCurves(value: Nullable<ColorCurves>);
  115523. /**
  115524. * Gets wether the color curves effect is enabled.
  115525. */
  115526. get colorCurvesEnabled(): boolean;
  115527. /**
  115528. * Sets wether the color curves effect is enabled.
  115529. */
  115530. set colorCurvesEnabled(value: boolean);
  115531. /**
  115532. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  115533. */
  115534. get colorGradingTexture(): Nullable<BaseTexture>;
  115535. /**
  115536. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  115537. */
  115538. set colorGradingTexture(value: Nullable<BaseTexture>);
  115539. /**
  115540. * Gets wether the color grading effect is enabled.
  115541. */
  115542. get colorGradingEnabled(): boolean;
  115543. /**
  115544. * Gets wether the color grading effect is enabled.
  115545. */
  115546. set colorGradingEnabled(value: boolean);
  115547. /**
  115548. * Gets exposure used in the effect.
  115549. */
  115550. get exposure(): number;
  115551. /**
  115552. * Sets exposure used in the effect.
  115553. */
  115554. set exposure(value: number);
  115555. /**
  115556. * Gets wether tonemapping is enabled or not.
  115557. */
  115558. get toneMappingEnabled(): boolean;
  115559. /**
  115560. * Sets wether tonemapping is enabled or not
  115561. */
  115562. set toneMappingEnabled(value: boolean);
  115563. /**
  115564. * Gets the type of tone mapping effect.
  115565. */
  115566. get toneMappingType(): number;
  115567. /**
  115568. * Sets the type of tone mapping effect.
  115569. */
  115570. set toneMappingType(value: number);
  115571. /**
  115572. * Gets contrast used in the effect.
  115573. */
  115574. get contrast(): number;
  115575. /**
  115576. * Sets contrast used in the effect.
  115577. */
  115578. set contrast(value: number);
  115579. /**
  115580. * Gets Vignette stretch size.
  115581. */
  115582. get vignetteStretch(): number;
  115583. /**
  115584. * Sets Vignette stretch size.
  115585. */
  115586. set vignetteStretch(value: number);
  115587. /**
  115588. * Gets Vignette centre X Offset.
  115589. */
  115590. get vignetteCentreX(): number;
  115591. /**
  115592. * Sets Vignette centre X Offset.
  115593. */
  115594. set vignetteCentreX(value: number);
  115595. /**
  115596. * Gets Vignette centre Y Offset.
  115597. */
  115598. get vignetteCentreY(): number;
  115599. /**
  115600. * Sets Vignette centre Y Offset.
  115601. */
  115602. set vignetteCentreY(value: number);
  115603. /**
  115604. * Gets Vignette weight or intensity of the vignette effect.
  115605. */
  115606. get vignetteWeight(): number;
  115607. /**
  115608. * Sets Vignette weight or intensity of the vignette effect.
  115609. */
  115610. set vignetteWeight(value: number);
  115611. /**
  115612. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  115613. * if vignetteEnabled is set to true.
  115614. */
  115615. get vignetteColor(): Color4;
  115616. /**
  115617. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  115618. * if vignetteEnabled is set to true.
  115619. */
  115620. set vignetteColor(value: Color4);
  115621. /**
  115622. * Gets Camera field of view used by the Vignette effect.
  115623. */
  115624. get vignetteCameraFov(): number;
  115625. /**
  115626. * Sets Camera field of view used by the Vignette effect.
  115627. */
  115628. set vignetteCameraFov(value: number);
  115629. /**
  115630. * Gets the vignette blend mode allowing different kind of effect.
  115631. */
  115632. get vignetteBlendMode(): number;
  115633. /**
  115634. * Sets the vignette blend mode allowing different kind of effect.
  115635. */
  115636. set vignetteBlendMode(value: number);
  115637. /**
  115638. * Gets wether the vignette effect is enabled.
  115639. */
  115640. get vignetteEnabled(): boolean;
  115641. /**
  115642. * Sets wether the vignette effect is enabled.
  115643. */
  115644. set vignetteEnabled(value: boolean);
  115645. private _fromLinearSpace;
  115646. /**
  115647. * Gets wether the input of the processing is in Gamma or Linear Space.
  115648. */
  115649. get fromLinearSpace(): boolean;
  115650. /**
  115651. * Sets wether the input of the processing is in Gamma or Linear Space.
  115652. */
  115653. set fromLinearSpace(value: boolean);
  115654. /**
  115655. * Defines cache preventing GC.
  115656. */
  115657. private _defines;
  115658. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  115659. /**
  115660. * "ImageProcessingPostProcess"
  115661. * @returns "ImageProcessingPostProcess"
  115662. */
  115663. getClassName(): string;
  115664. protected _updateParameters(): void;
  115665. dispose(camera?: Camera): void;
  115666. }
  115667. }
  115668. declare module BABYLON {
  115669. /**
  115670. * Class containing static functions to help procedurally build meshes
  115671. */
  115672. export class GroundBuilder {
  115673. /**
  115674. * Creates a ground mesh
  115675. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  115676. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  115677. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115678. * @param name defines the name of the mesh
  115679. * @param options defines the options used to create the mesh
  115680. * @param scene defines the hosting scene
  115681. * @returns the ground mesh
  115682. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  115683. */
  115684. static CreateGround(name: string, options: {
  115685. width?: number;
  115686. height?: number;
  115687. subdivisions?: number;
  115688. subdivisionsX?: number;
  115689. subdivisionsY?: number;
  115690. updatable?: boolean;
  115691. }, scene: any): Mesh;
  115692. /**
  115693. * Creates a tiled ground mesh
  115694. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  115695. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  115696. * * 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
  115697. * * 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
  115698. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115699. * @param name defines the name of the mesh
  115700. * @param options defines the options used to create the mesh
  115701. * @param scene defines the hosting scene
  115702. * @returns the tiled ground mesh
  115703. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  115704. */
  115705. static CreateTiledGround(name: string, options: {
  115706. xmin: number;
  115707. zmin: number;
  115708. xmax: number;
  115709. zmax: number;
  115710. subdivisions?: {
  115711. w: number;
  115712. h: number;
  115713. };
  115714. precision?: {
  115715. w: number;
  115716. h: number;
  115717. };
  115718. updatable?: boolean;
  115719. }, scene?: Nullable<Scene>): Mesh;
  115720. /**
  115721. * Creates a ground mesh from a height map
  115722. * * The parameter `url` sets the URL of the height map image resource.
  115723. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  115724. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  115725. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  115726. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  115727. * * 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.
  115728. * * 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).
  115729. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  115730. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115731. * @param name defines the name of the mesh
  115732. * @param url defines the url to the height map
  115733. * @param options defines the options used to create the mesh
  115734. * @param scene defines the hosting scene
  115735. * @returns the ground mesh
  115736. * @see https://doc.babylonjs.com/babylon101/height_map
  115737. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  115738. */
  115739. static CreateGroundFromHeightMap(name: string, url: string, options: {
  115740. width?: number;
  115741. height?: number;
  115742. subdivisions?: number;
  115743. minHeight?: number;
  115744. maxHeight?: number;
  115745. colorFilter?: Color3;
  115746. alphaFilter?: number;
  115747. updatable?: boolean;
  115748. onReady?: (mesh: GroundMesh) => void;
  115749. }, scene?: Nullable<Scene>): GroundMesh;
  115750. }
  115751. }
  115752. declare module BABYLON {
  115753. /**
  115754. * Class containing static functions to help procedurally build meshes
  115755. */
  115756. export class TorusBuilder {
  115757. /**
  115758. * Creates a torus mesh
  115759. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  115760. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  115761. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  115762. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115763. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115764. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115765. * @param name defines the name of the mesh
  115766. * @param options defines the options used to create the mesh
  115767. * @param scene defines the hosting scene
  115768. * @returns the torus mesh
  115769. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  115770. */
  115771. static CreateTorus(name: string, options: {
  115772. diameter?: number;
  115773. thickness?: number;
  115774. tessellation?: number;
  115775. updatable?: boolean;
  115776. sideOrientation?: number;
  115777. frontUVs?: Vector4;
  115778. backUVs?: Vector4;
  115779. }, scene: any): Mesh;
  115780. }
  115781. }
  115782. declare module BABYLON {
  115783. /**
  115784. * Class containing static functions to help procedurally build meshes
  115785. */
  115786. export class CylinderBuilder {
  115787. /**
  115788. * Creates a cylinder or a cone mesh
  115789. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  115790. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  115791. * * 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.
  115792. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  115793. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  115794. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  115795. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  115796. * * 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).
  115797. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  115798. * * 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).
  115799. * * 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
  115800. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  115801. * * 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
  115802. * * 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.
  115803. * * If `enclose` is false, a ring surface is one element.
  115804. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  115805. * * 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
  115806. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115807. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115808. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115809. * @param name defines the name of the mesh
  115810. * @param options defines the options used to create the mesh
  115811. * @param scene defines the hosting scene
  115812. * @returns the cylinder mesh
  115813. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  115814. */
  115815. static CreateCylinder(name: string, options: {
  115816. height?: number;
  115817. diameterTop?: number;
  115818. diameterBottom?: number;
  115819. diameter?: number;
  115820. tessellation?: number;
  115821. subdivisions?: number;
  115822. arc?: number;
  115823. faceColors?: Color4[];
  115824. faceUV?: Vector4[];
  115825. updatable?: boolean;
  115826. hasRings?: boolean;
  115827. enclose?: boolean;
  115828. cap?: number;
  115829. sideOrientation?: number;
  115830. frontUVs?: Vector4;
  115831. backUVs?: Vector4;
  115832. }, scene: any): Mesh;
  115833. }
  115834. }
  115835. declare module BABYLON {
  115836. /**
  115837. * States of the webXR experience
  115838. */
  115839. export enum WebXRState {
  115840. /**
  115841. * Transitioning to being in XR mode
  115842. */
  115843. ENTERING_XR = 0,
  115844. /**
  115845. * Transitioning to non XR mode
  115846. */
  115847. EXITING_XR = 1,
  115848. /**
  115849. * In XR mode and presenting
  115850. */
  115851. IN_XR = 2,
  115852. /**
  115853. * Not entered XR mode
  115854. */
  115855. NOT_IN_XR = 3
  115856. }
  115857. /**
  115858. * Abstraction of the XR render target
  115859. */
  115860. export interface WebXRRenderTarget extends IDisposable {
  115861. /**
  115862. * xrpresent context of the canvas which can be used to display/mirror xr content
  115863. */
  115864. canvasContext: WebGLRenderingContext;
  115865. /**
  115866. * xr layer for the canvas
  115867. */
  115868. xrLayer: Nullable<XRWebGLLayer>;
  115869. /**
  115870. * Initializes the xr layer for the session
  115871. * @param xrSession xr session
  115872. * @returns a promise that will resolve once the XR Layer has been created
  115873. */
  115874. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  115875. }
  115876. }
  115877. declare module BABYLON {
  115878. /**
  115879. * COnfiguration object for WebXR output canvas
  115880. */
  115881. export class WebXRManagedOutputCanvasOptions {
  115882. /**
  115883. * Options for this XR Layer output
  115884. */
  115885. canvasOptions?: XRWebGLLayerOptions;
  115886. /**
  115887. * CSS styling for a newly created canvas (if not provided)
  115888. */
  115889. newCanvasCssStyle?: string;
  115890. /**
  115891. * An optional canvas in case you wish to create it yourself and provide it here.
  115892. * If not provided, a new canvas will be created
  115893. */
  115894. canvasElement?: HTMLCanvasElement;
  115895. /**
  115896. * Get the default values of the configuration object
  115897. * @returns default values of this configuration object
  115898. */
  115899. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  115900. }
  115901. /**
  115902. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  115903. */
  115904. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  115905. private _options;
  115906. private _engine;
  115907. private _canvas;
  115908. /**
  115909. * Rendering context of the canvas which can be used to display/mirror xr content
  115910. */
  115911. canvasContext: WebGLRenderingContext;
  115912. /**
  115913. * xr layer for the canvas
  115914. */
  115915. xrLayer: Nullable<XRWebGLLayer>;
  115916. /**
  115917. * Initializes the xr layer for the session
  115918. * @param xrSession xr session
  115919. * @returns a promise that will resolve once the XR Layer has been created
  115920. */
  115921. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  115922. /**
  115923. * Initializes the canvas to be added/removed upon entering/exiting xr
  115924. * @param _xrSessionManager The XR Session manager
  115925. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  115926. */
  115927. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  115928. /**
  115929. * Disposes of the object
  115930. */
  115931. dispose(): void;
  115932. private _setManagedOutputCanvas;
  115933. private _addCanvas;
  115934. private _removeCanvas;
  115935. }
  115936. }
  115937. declare module BABYLON {
  115938. /**
  115939. * Manages an XRSession to work with Babylon's engine
  115940. * @see https://doc.babylonjs.com/how_to/webxr
  115941. */
  115942. export class WebXRSessionManager implements IDisposable {
  115943. /** The scene which the session should be created for */
  115944. scene: Scene;
  115945. /**
  115946. * Fires every time a new xrFrame arrives which can be used to update the camera
  115947. */
  115948. onXRFrameObservable: Observable<XRFrame>;
  115949. /**
  115950. * Fires when the xr session is ended either by the device or manually done
  115951. */
  115952. onXRSessionEnded: Observable<any>;
  115953. /**
  115954. * Fires when the xr session is ended either by the device or manually done
  115955. */
  115956. onXRSessionInit: Observable<XRSession>;
  115957. /**
  115958. * Fires when the reference space changed
  115959. */
  115960. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  115961. /**
  115962. * Underlying xr session
  115963. */
  115964. session: XRSession;
  115965. /**
  115966. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  115967. * or get the offset the player is currently at.
  115968. */
  115969. viewerReferenceSpace: XRReferenceSpace;
  115970. private _referenceSpace;
  115971. /**
  115972. * The current reference space used in this session. This reference space can constantly change!
  115973. * It is mainly used to offset the camera's position.
  115974. */
  115975. get referenceSpace(): XRReferenceSpace;
  115976. /**
  115977. * Set a new reference space and triggers the observable
  115978. */
  115979. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  115980. /**
  115981. * The base reference space from which the session started. good if you want to reset your
  115982. * reference space
  115983. */
  115984. baseReferenceSpace: XRReferenceSpace;
  115985. /**
  115986. * Used just in case of a failure to initialize an immersive session.
  115987. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  115988. */
  115989. defaultHeightCompensation: number;
  115990. /**
  115991. * Current XR frame
  115992. */
  115993. currentFrame: Nullable<XRFrame>;
  115994. /** WebXR timestamp updated every frame */
  115995. currentTimestamp: number;
  115996. private _xrNavigator;
  115997. private baseLayer;
  115998. private _rttProvider;
  115999. private _sessionEnded;
  116000. /**
  116001. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  116002. * @param scene The scene which the session should be created for
  116003. */
  116004. constructor(
  116005. /** The scene which the session should be created for */
  116006. scene: Scene);
  116007. /**
  116008. * Initializes the manager
  116009. * After initialization enterXR can be called to start an XR session
  116010. * @returns Promise which resolves after it is initialized
  116011. */
  116012. initializeAsync(): Promise<void>;
  116013. /**
  116014. * Initializes an xr session
  116015. * @param xrSessionMode mode to initialize
  116016. * @param xrSessionInit defines optional and required values to pass to the session builder
  116017. * @returns a promise which will resolve once the session has been initialized
  116018. */
  116019. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  116020. /**
  116021. * Sets the reference space on the xr session
  116022. * @param referenceSpaceType space to set
  116023. * @returns a promise that will resolve once the reference space has been set
  116024. */
  116025. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  116026. /**
  116027. * Resets the reference space to the one started the session
  116028. */
  116029. resetReferenceSpace(): void;
  116030. /**
  116031. * Updates the render state of the session
  116032. * @param state state to set
  116033. * @returns a promise that resolves once the render state has been updated
  116034. */
  116035. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  116036. /**
  116037. * Starts rendering to the xr layer
  116038. */
  116039. runXRRenderLoop(): void;
  116040. /**
  116041. * Gets the correct render target texture to be rendered this frame for this eye
  116042. * @param eye the eye for which to get the render target
  116043. * @returns the render target for the specified eye
  116044. */
  116045. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  116046. /**
  116047. * Stops the xrSession and restores the renderloop
  116048. * @returns Promise which resolves after it exits XR
  116049. */
  116050. exitXRAsync(): Promise<void>;
  116051. /**
  116052. * Checks if a session would be supported for the creation options specified
  116053. * @param sessionMode session mode to check if supported eg. immersive-vr
  116054. * @returns A Promise that resolves to true if supported and false if not
  116055. */
  116056. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  116057. /**
  116058. * Creates a WebXRRenderTarget object for the XR session
  116059. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  116060. * @param options optional options to provide when creating a new render target
  116061. * @returns a WebXR render target to which the session can render
  116062. */
  116063. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  116064. /**
  116065. * @hidden
  116066. * Converts the render layer of xrSession to a render target
  116067. * @param session session to create render target for
  116068. * @param scene scene the new render target should be created for
  116069. * @param baseLayer the webgl layer to create the render target for
  116070. */
  116071. static _CreateRenderTargetTextureFromSession(_session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  116072. /**
  116073. * Disposes of the session manager
  116074. */
  116075. dispose(): void;
  116076. /**
  116077. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  116078. * @param sessionMode defines the session to test
  116079. * @returns a promise with boolean as final value
  116080. */
  116081. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  116082. }
  116083. }
  116084. declare module BABYLON {
  116085. /**
  116086. * WebXR Camera which holds the views for the xrSession
  116087. * @see https://doc.babylonjs.com/how_to/webxr_camera
  116088. */
  116089. export class WebXRCamera extends FreeCamera {
  116090. private _xrSessionManager;
  116091. private _firstFrame;
  116092. private _referenceQuaternion;
  116093. private _referencedPosition;
  116094. private _xrInvPositionCache;
  116095. private _xrInvQuaternionCache;
  116096. /**
  116097. * Should position compensation execute on first frame.
  116098. * This is used when copying the position from a native (non XR) camera
  116099. */
  116100. compensateOnFirstFrame: boolean;
  116101. /**
  116102. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  116103. * @param name the name of the camera
  116104. * @param scene the scene to add the camera to
  116105. * @param _xrSessionManager a constructed xr session manager
  116106. */
  116107. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  116108. /**
  116109. * Return the user's height, unrelated to the current ground.
  116110. * This will be the y position of this camera, when ground level is 0.
  116111. */
  116112. get realWorldHeight(): number;
  116113. /** @hidden */
  116114. _updateForDualEyeDebugging(): void;
  116115. /**
  116116. * Sets this camera's transformation based on a non-vr camera
  116117. * @param otherCamera the non-vr camera to copy the transformation from
  116118. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  116119. */
  116120. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  116121. private _updateFromXRSession;
  116122. private _updateNumberOfRigCameras;
  116123. private _updateReferenceSpace;
  116124. private _updateReferenceSpaceOffset;
  116125. }
  116126. }
  116127. declare module BABYLON {
  116128. /**
  116129. * Defining the interface required for a (webxr) feature
  116130. */
  116131. export interface IWebXRFeature extends IDisposable {
  116132. /**
  116133. * Is this feature attached
  116134. */
  116135. attached: boolean;
  116136. /**
  116137. * Should auto-attach be disabled?
  116138. */
  116139. disableAutoAttach: boolean;
  116140. /**
  116141. * Attach the feature to the session
  116142. * Will usually be called by the features manager
  116143. *
  116144. * @param force should attachment be forced (even when already attached)
  116145. * @returns true if successful.
  116146. */
  116147. attach(force?: boolean): boolean;
  116148. /**
  116149. * Detach the feature from the session
  116150. * Will usually be called by the features manager
  116151. *
  116152. * @returns true if successful.
  116153. */
  116154. detach(): boolean;
  116155. }
  116156. /**
  116157. * A list of the currently available features without referencing them
  116158. */
  116159. export class WebXRFeatureName {
  116160. /**
  116161. * The name of the hit test feature
  116162. */
  116163. static HIT_TEST: string;
  116164. /**
  116165. * The name of the anchor system feature
  116166. */
  116167. static ANCHOR_SYSTEM: string;
  116168. /**
  116169. * The name of the background remover feature
  116170. */
  116171. static BACKGROUND_REMOVER: string;
  116172. /**
  116173. * The name of the pointer selection feature
  116174. */
  116175. static POINTER_SELECTION: string;
  116176. /**
  116177. * The name of the teleportation feature
  116178. */
  116179. static TELEPORTATION: string;
  116180. /**
  116181. * The name of the plane detection feature
  116182. */
  116183. static PLANE_DETECTION: string;
  116184. /**
  116185. * physics impostors for xr controllers feature
  116186. */
  116187. static PHYSICS_CONTROLLERS: string;
  116188. }
  116189. /**
  116190. * Defining the constructor of a feature. Used to register the modules.
  116191. */
  116192. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  116193. /**
  116194. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  116195. * It is mainly used in AR sessions.
  116196. *
  116197. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  116198. */
  116199. export class WebXRFeaturesManager implements IDisposable {
  116200. private _xrSessionManager;
  116201. private static readonly _AvailableFeatures;
  116202. /**
  116203. * Used to register a module. After calling this function a developer can use this feature in the scene.
  116204. * Mainly used internally.
  116205. *
  116206. * @param featureName the name of the feature to register
  116207. * @param constructorFunction the function used to construct the module
  116208. * @param version the (babylon) version of the module
  116209. * @param stable is that a stable version of this module
  116210. */
  116211. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  116212. /**
  116213. * Returns a constructor of a specific feature.
  116214. *
  116215. * @param featureName the name of the feature to construct
  116216. * @param version the version of the feature to load
  116217. * @param xrSessionManager the xrSessionManager. Used to construct the module
  116218. * @param options optional options provided to the module.
  116219. * @returns a function that, when called, will return a new instance of this feature
  116220. */
  116221. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  116222. /**
  116223. * Return the latest unstable version of this feature
  116224. * @param featureName the name of the feature to search
  116225. * @returns the version number. if not found will return -1
  116226. */
  116227. static GetLatestVersionOfFeature(featureName: string): number;
  116228. /**
  116229. * Return the latest stable version of this feature
  116230. * @param featureName the name of the feature to search
  116231. * @returns the version number. if not found will return -1
  116232. */
  116233. static GetStableVersionOfFeature(featureName: string): number;
  116234. /**
  116235. * Can be used to return the list of features currently registered
  116236. *
  116237. * @returns an Array of available features
  116238. */
  116239. static GetAvailableFeatures(): string[];
  116240. /**
  116241. * Gets the versions available for a specific feature
  116242. * @param featureName the name of the feature
  116243. * @returns an array with the available versions
  116244. */
  116245. static GetAvailableVersions(featureName: string): string[];
  116246. private _features;
  116247. /**
  116248. * constructs a new features manages.
  116249. *
  116250. * @param _xrSessionManager an instance of WebXRSessionManager
  116251. */
  116252. constructor(_xrSessionManager: WebXRSessionManager);
  116253. /**
  116254. * 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.
  116255. * 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.
  116256. *
  116257. * @param featureName the name of the feature to load or the class of the feature
  116258. * @param version optional version to load. if not provided the latest version will be enabled
  116259. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  116260. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  116261. * @returns a new constructed feature or throws an error if feature not found.
  116262. */
  116263. enableFeature(featureName: string | {
  116264. Name: string;
  116265. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  116266. /**
  116267. * Used to disable an already-enabled feature
  116268. * The feature will be disposed and will be recreated once enabled.
  116269. * @param featureName the feature to disable
  116270. * @returns true if disable was successful
  116271. */
  116272. disableFeature(featureName: string | {
  116273. Name: string;
  116274. }): boolean;
  116275. /**
  116276. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  116277. * Can be used during a session to start a feature
  116278. * @param featureName the name of feature to attach
  116279. */
  116280. attachFeature(featureName: string): void;
  116281. /**
  116282. * Can be used inside a session or when the session ends to detach a specific feature
  116283. * @param featureName the name of the feature to detach
  116284. */
  116285. detachFeature(featureName: string): void;
  116286. /**
  116287. * Get the list of enabled features
  116288. * @returns an array of enabled features
  116289. */
  116290. getEnabledFeatures(): string[];
  116291. /**
  116292. * get the implementation of an enabled feature.
  116293. * @param featureName the name of the feature to load
  116294. * @returns the feature class, if found
  116295. */
  116296. getEnabledFeature(featureName: string): IWebXRFeature;
  116297. /**
  116298. * dispose this features manager
  116299. */
  116300. dispose(): void;
  116301. }
  116302. }
  116303. declare module BABYLON {
  116304. /**
  116305. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  116306. * @see https://doc.babylonjs.com/how_to/webxr
  116307. */
  116308. export class WebXRExperienceHelper implements IDisposable {
  116309. private scene;
  116310. /**
  116311. * Camera used to render xr content
  116312. */
  116313. camera: WebXRCamera;
  116314. /**
  116315. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  116316. */
  116317. state: WebXRState;
  116318. private _setState;
  116319. /**
  116320. * Fires when the state of the experience helper has changed
  116321. */
  116322. onStateChangedObservable: Observable<WebXRState>;
  116323. /**
  116324. * Observers registered here will be triggered after the camera's initial transformation is set
  116325. * This can be used to set a different ground level or an extra rotation.
  116326. *
  116327. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  116328. * to the position set after this observable is done executing.
  116329. */
  116330. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  116331. /** Session manager used to keep track of xr session */
  116332. sessionManager: WebXRSessionManager;
  116333. /** A features manager for this xr session */
  116334. featuresManager: WebXRFeaturesManager;
  116335. private _nonVRCamera;
  116336. private _originalSceneAutoClear;
  116337. private _supported;
  116338. /**
  116339. * Creates the experience helper
  116340. * @param scene the scene to attach the experience helper to
  116341. * @returns a promise for the experience helper
  116342. */
  116343. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  116344. /**
  116345. * Creates a WebXRExperienceHelper
  116346. * @param scene The scene the helper should be created in
  116347. */
  116348. private constructor();
  116349. /**
  116350. * Exits XR mode and returns the scene to its original state
  116351. * @returns promise that resolves after xr mode has exited
  116352. */
  116353. exitXRAsync(): Promise<void>;
  116354. /**
  116355. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  116356. * @param sessionMode options for the XR session
  116357. * @param referenceSpaceType frame of reference of the XR session
  116358. * @param renderTarget the output canvas that will be used to enter XR mode
  116359. * @returns promise that resolves after xr mode has entered
  116360. */
  116361. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  116362. /**
  116363. * Disposes of the experience helper
  116364. */
  116365. dispose(): void;
  116366. private _nonXRToXRCamera;
  116367. }
  116368. }
  116369. declare module BABYLON {
  116370. /**
  116371. * X-Y values for axes in WebXR
  116372. */
  116373. export interface IWebXRMotionControllerAxesValue {
  116374. /**
  116375. * The value of the x axis
  116376. */
  116377. x: number;
  116378. /**
  116379. * The value of the y-axis
  116380. */
  116381. y: number;
  116382. }
  116383. /**
  116384. * changed / previous values for the values of this component
  116385. */
  116386. export interface IWebXRMotionControllerComponentChangesValues<T> {
  116387. /**
  116388. * current (this frame) value
  116389. */
  116390. current: T;
  116391. /**
  116392. * previous (last change) value
  116393. */
  116394. previous: T;
  116395. }
  116396. /**
  116397. * Represents changes in the component between current frame and last values recorded
  116398. */
  116399. export interface IWebXRMotionControllerComponentChanges {
  116400. /**
  116401. * will be populated with previous and current values if touched changed
  116402. */
  116403. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  116404. /**
  116405. * will be populated with previous and current values if pressed changed
  116406. */
  116407. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  116408. /**
  116409. * will be populated with previous and current values if value changed
  116410. */
  116411. value?: IWebXRMotionControllerComponentChangesValues<number>;
  116412. /**
  116413. * will be populated with previous and current values if axes changed
  116414. */
  116415. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  116416. }
  116417. /**
  116418. * This class represents a single component (for example button or thumbstick) of a motion controller
  116419. */
  116420. export class WebXRControllerComponent implements IDisposable {
  116421. /**
  116422. * the id of this component
  116423. */
  116424. id: string;
  116425. /**
  116426. * the type of the component
  116427. */
  116428. type: MotionControllerComponentType;
  116429. private _buttonIndex;
  116430. private _axesIndices;
  116431. /**
  116432. * Thumbstick component type
  116433. */
  116434. static THUMBSTICK_TYPE: MotionControllerComponentType;
  116435. /**
  116436. * Touchpad component type
  116437. */
  116438. static TOUCHPAD_TYPE: MotionControllerComponentType;
  116439. /**
  116440. * trigger component type
  116441. */
  116442. static TRIGGER_TYPE: MotionControllerComponentType;
  116443. /**
  116444. * squeeze component type
  116445. */
  116446. static SQUEEZE_TYPE: MotionControllerComponentType;
  116447. /**
  116448. * button component type
  116449. */
  116450. static BUTTON_TYPE: MotionControllerComponentType;
  116451. /**
  116452. * Observers registered here will be triggered when the state of a button changes
  116453. * State change is either pressed / touched / value
  116454. */
  116455. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  116456. /**
  116457. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  116458. * the axes data changes
  116459. */
  116460. onAxisValueChangedObservable: Observable<{
  116461. x: number;
  116462. y: number;
  116463. }>;
  116464. private _currentValue;
  116465. private _touched;
  116466. private _pressed;
  116467. private _axes;
  116468. private _changes;
  116469. private _hasChanges;
  116470. /**
  116471. * Return whether or not the component changed the last frame
  116472. */
  116473. get hasChanges(): boolean;
  116474. /**
  116475. * Creates a new component for a motion controller.
  116476. * It is created by the motion controller itself
  116477. *
  116478. * @param id the id of this component
  116479. * @param type the type of the component
  116480. * @param _buttonIndex index in the buttons array of the gamepad
  116481. * @param _axesIndices indices of the values in the axes array of the gamepad
  116482. */
  116483. constructor(
  116484. /**
  116485. * the id of this component
  116486. */
  116487. id: string,
  116488. /**
  116489. * the type of the component
  116490. */
  116491. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  116492. /**
  116493. * Get the current value of this component
  116494. */
  116495. get value(): number;
  116496. /**
  116497. * is the button currently pressed
  116498. */
  116499. get pressed(): boolean;
  116500. /**
  116501. * is the button currently touched
  116502. */
  116503. get touched(): boolean;
  116504. /**
  116505. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  116506. */
  116507. get axes(): IWebXRMotionControllerAxesValue;
  116508. /**
  116509. * Get the changes. Elements will be populated only if they changed with their previous and current value
  116510. */
  116511. get changes(): IWebXRMotionControllerComponentChanges;
  116512. /**
  116513. * Is this component a button (hence - pressable)
  116514. * @returns true if can be pressed
  116515. */
  116516. isButton(): boolean;
  116517. /**
  116518. * Are there axes correlating to this component
  116519. * @return true is axes data is available
  116520. */
  116521. isAxes(): boolean;
  116522. /**
  116523. * update this component using the gamepad object it is in. Called on every frame
  116524. * @param nativeController the native gamepad controller object
  116525. */
  116526. update(nativeController: IMinimalMotionControllerObject): void;
  116527. /**
  116528. * Dispose this component
  116529. */
  116530. dispose(): void;
  116531. }
  116532. }
  116533. declare module BABYLON {
  116534. /**
  116535. * Class used to represent data loading progression
  116536. */
  116537. export class SceneLoaderProgressEvent {
  116538. /** defines if data length to load can be evaluated */
  116539. readonly lengthComputable: boolean;
  116540. /** defines the loaded data length */
  116541. readonly loaded: number;
  116542. /** defines the data length to load */
  116543. readonly total: number;
  116544. /**
  116545. * Create a new progress event
  116546. * @param lengthComputable defines if data length to load can be evaluated
  116547. * @param loaded defines the loaded data length
  116548. * @param total defines the data length to load
  116549. */
  116550. constructor(
  116551. /** defines if data length to load can be evaluated */
  116552. lengthComputable: boolean,
  116553. /** defines the loaded data length */
  116554. loaded: number,
  116555. /** defines the data length to load */
  116556. total: number);
  116557. /**
  116558. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  116559. * @param event defines the source event
  116560. * @returns a new SceneLoaderProgressEvent
  116561. */
  116562. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  116563. }
  116564. /**
  116565. * Interface used by SceneLoader plugins to define supported file extensions
  116566. */
  116567. export interface ISceneLoaderPluginExtensions {
  116568. /**
  116569. * Defines the list of supported extensions
  116570. */
  116571. [extension: string]: {
  116572. isBinary: boolean;
  116573. };
  116574. }
  116575. /**
  116576. * Interface used by SceneLoader plugin factory
  116577. */
  116578. export interface ISceneLoaderPluginFactory {
  116579. /**
  116580. * Defines the name of the factory
  116581. */
  116582. name: string;
  116583. /**
  116584. * Function called to create a new plugin
  116585. * @return the new plugin
  116586. */
  116587. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  116588. /**
  116589. * The callback that returns true if the data can be directly loaded.
  116590. * @param data string containing the file data
  116591. * @returns if the data can be loaded directly
  116592. */
  116593. canDirectLoad?(data: string): boolean;
  116594. }
  116595. /**
  116596. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  116597. */
  116598. export interface ISceneLoaderPluginBase {
  116599. /**
  116600. * The friendly name of this plugin.
  116601. */
  116602. name: string;
  116603. /**
  116604. * The file extensions supported by this plugin.
  116605. */
  116606. extensions: string | ISceneLoaderPluginExtensions;
  116607. /**
  116608. * The callback called when loading from a url.
  116609. * @param scene scene loading this url
  116610. * @param url url to load
  116611. * @param onSuccess callback called when the file successfully loads
  116612. * @param onProgress callback called while file is loading (if the server supports this mode)
  116613. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  116614. * @param onError callback called when the file fails to load
  116615. * @returns a file request object
  116616. */
  116617. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  116618. /**
  116619. * The callback called when loading from a file object.
  116620. * @param scene scene loading this file
  116621. * @param file defines the file to load
  116622. * @param onSuccess defines the callback to call when data is loaded
  116623. * @param onProgress defines the callback to call during loading process
  116624. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  116625. * @param onError defines the callback to call when an error occurs
  116626. * @returns a file request object
  116627. */
  116628. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  116629. /**
  116630. * The callback that returns true if the data can be directly loaded.
  116631. * @param data string containing the file data
  116632. * @returns if the data can be loaded directly
  116633. */
  116634. canDirectLoad?(data: string): boolean;
  116635. /**
  116636. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  116637. * @param scene scene loading this data
  116638. * @param data string containing the data
  116639. * @returns data to pass to the plugin
  116640. */
  116641. directLoad?(scene: Scene, data: string): any;
  116642. /**
  116643. * The callback that allows custom handling of the root url based on the response url.
  116644. * @param rootUrl the original root url
  116645. * @param responseURL the response url if available
  116646. * @returns the new root url
  116647. */
  116648. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  116649. }
  116650. /**
  116651. * Interface used to define a SceneLoader plugin
  116652. */
  116653. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  116654. /**
  116655. * Import meshes into a scene.
  116656. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116657. * @param scene The scene to import into
  116658. * @param data The data to import
  116659. * @param rootUrl The root url for scene and resources
  116660. * @param meshes The meshes array to import into
  116661. * @param particleSystems The particle systems array to import into
  116662. * @param skeletons The skeletons array to import into
  116663. * @param onError The callback when import fails
  116664. * @returns True if successful or false otherwise
  116665. */
  116666. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  116667. /**
  116668. * Load into a scene.
  116669. * @param scene The scene to load into
  116670. * @param data The data to import
  116671. * @param rootUrl The root url for scene and resources
  116672. * @param onError The callback when import fails
  116673. * @returns True if successful or false otherwise
  116674. */
  116675. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  116676. /**
  116677. * Load into an asset container.
  116678. * @param scene The scene to load into
  116679. * @param data The data to import
  116680. * @param rootUrl The root url for scene and resources
  116681. * @param onError The callback when import fails
  116682. * @returns The loaded asset container
  116683. */
  116684. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  116685. }
  116686. /**
  116687. * Interface used to define an async SceneLoader plugin
  116688. */
  116689. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  116690. /**
  116691. * Import meshes into a scene.
  116692. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116693. * @param scene The scene to import into
  116694. * @param data The data to import
  116695. * @param rootUrl The root url for scene and resources
  116696. * @param onProgress The callback when the load progresses
  116697. * @param fileName Defines the name of the file to load
  116698. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  116699. */
  116700. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  116701. meshes: AbstractMesh[];
  116702. particleSystems: IParticleSystem[];
  116703. skeletons: Skeleton[];
  116704. animationGroups: AnimationGroup[];
  116705. }>;
  116706. /**
  116707. * Load into a scene.
  116708. * @param scene The scene to load into
  116709. * @param data The data to import
  116710. * @param rootUrl The root url for scene and resources
  116711. * @param onProgress The callback when the load progresses
  116712. * @param fileName Defines the name of the file to load
  116713. * @returns Nothing
  116714. */
  116715. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  116716. /**
  116717. * Load into an asset container.
  116718. * @param scene The scene to load into
  116719. * @param data The data to import
  116720. * @param rootUrl The root url for scene and resources
  116721. * @param onProgress The callback when the load progresses
  116722. * @param fileName Defines the name of the file to load
  116723. * @returns The loaded asset container
  116724. */
  116725. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  116726. }
  116727. /**
  116728. * Mode that determines how to handle old animation groups before loading new ones.
  116729. */
  116730. export enum SceneLoaderAnimationGroupLoadingMode {
  116731. /**
  116732. * Reset all old animations to initial state then dispose them.
  116733. */
  116734. Clean = 0,
  116735. /**
  116736. * Stop all old animations.
  116737. */
  116738. Stop = 1,
  116739. /**
  116740. * Restart old animations from first frame.
  116741. */
  116742. Sync = 2,
  116743. /**
  116744. * Old animations remains untouched.
  116745. */
  116746. NoSync = 3
  116747. }
  116748. /**
  116749. * Class used to load scene from various file formats using registered plugins
  116750. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  116751. */
  116752. export class SceneLoader {
  116753. /**
  116754. * No logging while loading
  116755. */
  116756. static readonly NO_LOGGING: number;
  116757. /**
  116758. * Minimal logging while loading
  116759. */
  116760. static readonly MINIMAL_LOGGING: number;
  116761. /**
  116762. * Summary logging while loading
  116763. */
  116764. static readonly SUMMARY_LOGGING: number;
  116765. /**
  116766. * Detailled logging while loading
  116767. */
  116768. static readonly DETAILED_LOGGING: number;
  116769. /**
  116770. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  116771. */
  116772. static get ForceFullSceneLoadingForIncremental(): boolean;
  116773. static set ForceFullSceneLoadingForIncremental(value: boolean);
  116774. /**
  116775. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  116776. */
  116777. static get ShowLoadingScreen(): boolean;
  116778. static set ShowLoadingScreen(value: boolean);
  116779. /**
  116780. * Defines the current logging level (while loading the scene)
  116781. * @ignorenaming
  116782. */
  116783. static get loggingLevel(): number;
  116784. static set loggingLevel(value: number);
  116785. /**
  116786. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  116787. */
  116788. static get CleanBoneMatrixWeights(): boolean;
  116789. static set CleanBoneMatrixWeights(value: boolean);
  116790. /**
  116791. * Event raised when a plugin is used to load a scene
  116792. */
  116793. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  116794. private static _registeredPlugins;
  116795. private static _getDefaultPlugin;
  116796. private static _getPluginForExtension;
  116797. private static _getPluginForDirectLoad;
  116798. private static _getPluginForFilename;
  116799. private static _getDirectLoad;
  116800. private static _loadData;
  116801. private static _getFileInfo;
  116802. /**
  116803. * Gets a plugin that can load the given extension
  116804. * @param extension defines the extension to load
  116805. * @returns a plugin or null if none works
  116806. */
  116807. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  116808. /**
  116809. * Gets a boolean indicating that the given extension can be loaded
  116810. * @param extension defines the extension to load
  116811. * @returns true if the extension is supported
  116812. */
  116813. static IsPluginForExtensionAvailable(extension: string): boolean;
  116814. /**
  116815. * Adds a new plugin to the list of registered plugins
  116816. * @param plugin defines the plugin to add
  116817. */
  116818. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  116819. /**
  116820. * Import meshes into a scene
  116821. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116822. * @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)
  116823. * @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)
  116824. * @param scene the instance of BABYLON.Scene to append to
  116825. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  116826. * @param onProgress a callback with a progress event for each file being loaded
  116827. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116828. * @param pluginExtension the extension used to determine the plugin
  116829. * @returns The loaded plugin
  116830. */
  116831. 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>;
  116832. /**
  116833. * Import meshes into a scene
  116834. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116835. * @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)
  116836. * @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)
  116837. * @param scene the instance of BABYLON.Scene to append to
  116838. * @param onProgress a callback with a progress event for each file being loaded
  116839. * @param pluginExtension the extension used to determine the plugin
  116840. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  116841. */
  116842. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  116843. meshes: AbstractMesh[];
  116844. particleSystems: IParticleSystem[];
  116845. skeletons: Skeleton[];
  116846. animationGroups: AnimationGroup[];
  116847. }>;
  116848. /**
  116849. * Load 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 engine is the instance of BABYLON.Engine to use to create the scene
  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 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>;
  116860. /**
  116861. * Load 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 engine is the instance of BABYLON.Engine to use to create the scene
  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 loaded scene
  116868. */
  116869. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  116870. /**
  116871. * Append a scene
  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
  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 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>;
  116882. /**
  116883. * Append a scene
  116884. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  116885. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  116886. * @param scene is the instance of BABYLON.Scene to append to
  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 given scene
  116890. */
  116891. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  116892. /**
  116893. * Load a scene into an asset container
  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 onSuccess a callback with the scene when import succeeds
  116898. * @param onProgress a callback with a progress event for each file being loaded
  116899. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116900. * @param pluginExtension the extension used to determine the plugin
  116901. * @returns The loaded plugin
  116902. */
  116903. 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>;
  116904. /**
  116905. * Load a scene into an asset container
  116906. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  116907. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
  116908. * @param scene is the instance of Scene to append to
  116909. * @param onProgress a callback with a progress event for each file being loaded
  116910. * @param pluginExtension the extension used to determine the plugin
  116911. * @returns The loaded asset container
  116912. */
  116913. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  116914. /**
  116915. * Import animations from a file into a scene
  116916. * @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)
  116917. * @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)
  116918. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  116919. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  116920. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  116921. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  116922. * @param onSuccess a callback with the scene when import succeeds
  116923. * @param onProgress a callback with a progress event for each file being loaded
  116924. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116925. */
  116926. 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;
  116927. /**
  116928. * Import animations from a file into a scene
  116929. * @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)
  116930. * @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)
  116931. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  116932. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  116933. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  116934. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  116935. * @param onSuccess a callback with the scene when import succeeds
  116936. * @param onProgress a callback with a progress event for each file being loaded
  116937. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116938. * @returns the updated scene with imported animations
  116939. */
  116940. 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>;
  116941. }
  116942. }
  116943. declare module BABYLON {
  116944. /**
  116945. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  116946. */
  116947. export type MotionControllerHandness = "none" | "left" | "right";
  116948. /**
  116949. * The type of components available in motion controllers.
  116950. * This is not the name of the component.
  116951. */
  116952. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  116953. /**
  116954. * The state of a controller component
  116955. */
  116956. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  116957. /**
  116958. * The schema of motion controller layout.
  116959. * No object will be initialized using this interface
  116960. * This is used just to define the profile.
  116961. */
  116962. export interface IMotionControllerLayout {
  116963. /**
  116964. * Defines the main button component id
  116965. */
  116966. selectComponentId: string;
  116967. /**
  116968. * Available components (unsorted)
  116969. */
  116970. components: {
  116971. /**
  116972. * A map of component Ids
  116973. */
  116974. [componentId: string]: {
  116975. /**
  116976. * The type of input the component outputs
  116977. */
  116978. type: MotionControllerComponentType;
  116979. /**
  116980. * The indices of this component in the gamepad object
  116981. */
  116982. gamepadIndices: {
  116983. /**
  116984. * Index of button
  116985. */
  116986. button?: number;
  116987. /**
  116988. * If available, index of x-axis
  116989. */
  116990. xAxis?: number;
  116991. /**
  116992. * If available, index of y-axis
  116993. */
  116994. yAxis?: number;
  116995. };
  116996. /**
  116997. * The mesh's root node name
  116998. */
  116999. rootNodeName: string;
  117000. /**
  117001. * Animation definitions for this model
  117002. */
  117003. visualResponses: {
  117004. [stateKey: string]: {
  117005. /**
  117006. * What property will be animated
  117007. */
  117008. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  117009. /**
  117010. * What states influence this visual reponse
  117011. */
  117012. states: MotionControllerComponentStateType[];
  117013. /**
  117014. * Type of animation - movement or visibility
  117015. */
  117016. valueNodeProperty: "transform" | "visibility";
  117017. /**
  117018. * Base node name to move. Its position will be calculated according to the min and max nodes
  117019. */
  117020. valueNodeName?: string;
  117021. /**
  117022. * Minimum movement node
  117023. */
  117024. minNodeName?: string;
  117025. /**
  117026. * Max movement node
  117027. */
  117028. maxNodeName?: string;
  117029. };
  117030. };
  117031. /**
  117032. * If touch enabled, what is the name of node to display user feedback
  117033. */
  117034. touchPointNodeName?: string;
  117035. };
  117036. };
  117037. /**
  117038. * Is it xr standard mapping or not
  117039. */
  117040. gamepadMapping: "" | "xr-standard";
  117041. /**
  117042. * Base root node of this entire model
  117043. */
  117044. rootNodeName: string;
  117045. /**
  117046. * Path to load the assets. Usually relative to the base path
  117047. */
  117048. assetPath: string;
  117049. }
  117050. /**
  117051. * A definition for the layout map in the input profile
  117052. */
  117053. export interface IMotionControllerLayoutMap {
  117054. /**
  117055. * Layouts with handness type as a key
  117056. */
  117057. [handness: string]: IMotionControllerLayout;
  117058. }
  117059. /**
  117060. * The XR Input profile schema
  117061. * Profiles can be found here:
  117062. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  117063. */
  117064. export interface IMotionControllerProfile {
  117065. /**
  117066. * The id of this profile
  117067. * correlates to the profile(s) in the xrInput.profiles array
  117068. */
  117069. profileId: string;
  117070. /**
  117071. * fallback profiles for this profileId
  117072. */
  117073. fallbackProfileIds: string[];
  117074. /**
  117075. * The layout map, with handness as key
  117076. */
  117077. layouts: IMotionControllerLayoutMap;
  117078. }
  117079. /**
  117080. * A helper-interface for the 3 meshes needed for controller button animation
  117081. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  117082. */
  117083. export interface IMotionControllerButtonMeshMap {
  117084. /**
  117085. * The mesh that will be changed when value changes
  117086. */
  117087. valueMesh: AbstractMesh;
  117088. /**
  117089. * the mesh that defines the pressed value mesh position.
  117090. * This is used to find the max-position of this button
  117091. */
  117092. pressedMesh: AbstractMesh;
  117093. /**
  117094. * the mesh that defines the unpressed value mesh position.
  117095. * This is used to find the min (or initial) position of this button
  117096. */
  117097. unpressedMesh: AbstractMesh;
  117098. }
  117099. /**
  117100. * A helper-interface for the 3 meshes needed for controller axis animation.
  117101. * This will be expanded when touchpad animations are fully supported
  117102. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  117103. */
  117104. export interface IMotionControllerMeshMap {
  117105. /**
  117106. * The mesh that will be changed when axis value changes
  117107. */
  117108. valueMesh: AbstractMesh;
  117109. /**
  117110. * the mesh that defines the minimum value mesh position.
  117111. */
  117112. minMesh?: AbstractMesh;
  117113. /**
  117114. * the mesh that defines the maximum value mesh position.
  117115. */
  117116. maxMesh?: AbstractMesh;
  117117. }
  117118. /**
  117119. * The elements needed for change-detection of the gamepad objects in motion controllers
  117120. */
  117121. export interface IMinimalMotionControllerObject {
  117122. /**
  117123. * An array of available buttons
  117124. */
  117125. buttons: Array<{
  117126. /**
  117127. * Value of the button/trigger
  117128. */
  117129. value: number;
  117130. /**
  117131. * If the button/trigger is currently touched
  117132. */
  117133. touched: boolean;
  117134. /**
  117135. * If the button/trigger is currently pressed
  117136. */
  117137. pressed: boolean;
  117138. }>;
  117139. /**
  117140. * Available axes of this controller
  117141. */
  117142. axes: number[];
  117143. }
  117144. /**
  117145. * An Abstract Motion controller
  117146. * This class receives an xrInput and a profile layout and uses those to initialize the components
  117147. * Each component has an observable to check for changes in value and state
  117148. */
  117149. export abstract class WebXRAbstractMotionController implements IDisposable {
  117150. protected scene: Scene;
  117151. protected layout: IMotionControllerLayout;
  117152. /**
  117153. * The gamepad object correlating to this controller
  117154. */
  117155. gamepadObject: IMinimalMotionControllerObject;
  117156. /**
  117157. * handness (left/right/none) of this controller
  117158. */
  117159. handness: MotionControllerHandness;
  117160. /**
  117161. * The profile id of this motion controller
  117162. */
  117163. abstract profileId: string;
  117164. /**
  117165. * A map of components (WebXRControllerComponent) in this motion controller
  117166. * Components have a ComponentType and can also have both button and axis definitions
  117167. */
  117168. readonly components: {
  117169. [id: string]: WebXRControllerComponent;
  117170. };
  117171. /**
  117172. * Observers registered here will be triggered when the model of this controller is done loading
  117173. */
  117174. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  117175. /**
  117176. * The root mesh of the model. It is null if the model was not yet initialized
  117177. */
  117178. rootMesh: Nullable<AbstractMesh>;
  117179. /**
  117180. * Disable the model's animation. Can be set at any time.
  117181. */
  117182. disableAnimation: boolean;
  117183. private _modelReady;
  117184. /**
  117185. * constructs a new abstract motion controller
  117186. * @param scene the scene to which the model of the controller will be added
  117187. * @param layout The profile layout to load
  117188. * @param gamepadObject The gamepad object correlating to this controller
  117189. * @param handness handness (left/right/none) of this controller
  117190. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  117191. */
  117192. constructor(scene: Scene, layout: IMotionControllerLayout,
  117193. /**
  117194. * The gamepad object correlating to this controller
  117195. */
  117196. gamepadObject: IMinimalMotionControllerObject,
  117197. /**
  117198. * handness (left/right/none) of this controller
  117199. */
  117200. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  117201. private _initComponent;
  117202. /**
  117203. * Update this model using the current XRFrame
  117204. * @param xrFrame the current xr frame to use and update the model
  117205. */
  117206. updateFromXRFrame(xrFrame: XRFrame): void;
  117207. /**
  117208. * Get the list of components available in this motion controller
  117209. * @returns an array of strings correlating to available components
  117210. */
  117211. getComponentIds(): string[];
  117212. /**
  117213. * Get the main (Select) component of this controller as defined in the layout
  117214. * @returns the main component of this controller
  117215. */
  117216. getMainComponent(): WebXRControllerComponent;
  117217. /**
  117218. * get a component based an its component id as defined in layout.components
  117219. * @param id the id of the component
  117220. * @returns the component correlates to the id or undefined if not found
  117221. */
  117222. getComponent(id: string): WebXRControllerComponent;
  117223. /**
  117224. * Get the first component of specific type
  117225. * @param type type of component to find
  117226. * @return a controller component or null if not found
  117227. */
  117228. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  117229. /**
  117230. * Returns all components of specific type
  117231. * @param type the type to search for
  117232. * @return an array of components with this type
  117233. */
  117234. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  117235. /**
  117236. * Loads the model correlating to this controller
  117237. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  117238. * @returns A promise fulfilled with the result of the model loading
  117239. */
  117240. loadModel(): Promise<boolean>;
  117241. /**
  117242. * Update the model itself with the current frame data
  117243. * @param xrFrame the frame to use for updating the model mesh
  117244. */
  117245. protected updateModel(xrFrame: XRFrame): void;
  117246. /**
  117247. * Moves the axis on the controller mesh based on its current state
  117248. * @param axis the index of the axis
  117249. * @param axisValue the value of the axis which determines the meshes new position
  117250. * @hidden
  117251. */
  117252. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  117253. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  117254. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  117255. private _getGenericFilenameAndPath;
  117256. private _getGenericParentMesh;
  117257. /**
  117258. * Get the filename and path for this controller's model
  117259. * @returns a map of filename and path
  117260. */
  117261. protected abstract _getFilenameAndPath(): {
  117262. filename: string;
  117263. path: string;
  117264. };
  117265. /**
  117266. * This function will be called after the model was successfully loaded and can be used
  117267. * for mesh transformations before it is available for the user
  117268. * @param meshes the loaded meshes
  117269. */
  117270. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  117271. /**
  117272. * Set the root mesh for this controller. Important for the WebXR controller class
  117273. * @param meshes the loaded meshes
  117274. */
  117275. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  117276. /**
  117277. * A function executed each frame that updates the mesh (if needed)
  117278. * @param xrFrame the current xrFrame
  117279. */
  117280. protected abstract _updateModel(xrFrame: XRFrame): void;
  117281. /**
  117282. * This function is called before the mesh is loaded. It checks for loading constraints.
  117283. * For example, this function can check if the GLB loader is available
  117284. * If this function returns false, the generic controller will be loaded instead
  117285. * @returns Is the client ready to load the mesh
  117286. */
  117287. protected abstract _getModelLoadingConstraints(): boolean;
  117288. /**
  117289. * Dispose this controller, the model mesh and all its components
  117290. */
  117291. dispose(): void;
  117292. }
  117293. }
  117294. declare module BABYLON {
  117295. /**
  117296. * A generic trigger-only motion controller for WebXR
  117297. */
  117298. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  117299. /**
  117300. * Static version of the profile id of this controller
  117301. */
  117302. static ProfileId: string;
  117303. profileId: string;
  117304. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  117305. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  117306. protected _updateModel(): void;
  117307. protected _getFilenameAndPath(): {
  117308. filename: string;
  117309. path: string;
  117310. };
  117311. protected _setRootMesh(meshes: AbstractMesh[]): void;
  117312. protected _getModelLoadingConstraints(): boolean;
  117313. }
  117314. }
  117315. declare module BABYLON {
  117316. /**
  117317. * Class containing static functions to help procedurally build meshes
  117318. */
  117319. export class SphereBuilder {
  117320. /**
  117321. * Creates a sphere mesh
  117322. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  117323. * * 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`)
  117324. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  117325. * * 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
  117326. * * 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)
  117327. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117328. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117329. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117330. * @param name defines the name of the mesh
  117331. * @param options defines the options used to create the mesh
  117332. * @param scene defines the hosting scene
  117333. * @returns the sphere mesh
  117334. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  117335. */
  117336. static CreateSphere(name: string, options: {
  117337. segments?: number;
  117338. diameter?: number;
  117339. diameterX?: number;
  117340. diameterY?: number;
  117341. diameterZ?: number;
  117342. arc?: number;
  117343. slice?: number;
  117344. sideOrientation?: number;
  117345. frontUVs?: Vector4;
  117346. backUVs?: Vector4;
  117347. updatable?: boolean;
  117348. }, scene?: Nullable<Scene>): Mesh;
  117349. }
  117350. }
  117351. declare module BABYLON {
  117352. /**
  117353. * A profiled motion controller has its profile loaded from an online repository.
  117354. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  117355. */
  117356. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  117357. private _repositoryUrl;
  117358. /**
  117359. * The profile ID of this controller. Will be populated when the controller initializes.
  117360. */
  117361. profileId: string;
  117362. private _buttonMeshMapping;
  117363. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  117364. protected _getFilenameAndPath(): {
  117365. filename: string;
  117366. path: string;
  117367. };
  117368. private _touchDots;
  117369. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  117370. protected _setRootMesh(meshes: AbstractMesh[]): void;
  117371. protected _updateModel(_xrFrame: XRFrame): void;
  117372. protected _getModelLoadingConstraints(): boolean;
  117373. dispose(): void;
  117374. }
  117375. }
  117376. declare module BABYLON {
  117377. /**
  117378. * A construction function type to create a new controller based on an xrInput object
  117379. */
  117380. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  117381. /**
  117382. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  117383. *
  117384. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  117385. * it should be replaced with auto-loaded controllers.
  117386. *
  117387. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  117388. */
  117389. export class WebXRMotionControllerManager {
  117390. /**
  117391. * The base URL of the online controller repository. Can be changed at any time.
  117392. */
  117393. static BaseRepositoryUrl: string;
  117394. /**
  117395. * Use the online repository, or use only locally-defined controllers
  117396. */
  117397. static UseOnlineRepository: boolean;
  117398. /**
  117399. * Which repository gets priority - local or online
  117400. */
  117401. static PrioritizeOnlineRepository: boolean;
  117402. private static _AvailableControllers;
  117403. private static _Fallbacks;
  117404. /**
  117405. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  117406. *
  117407. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  117408. *
  117409. * @param type the profile type to register
  117410. * @param constructFunction the function to be called when loading this profile
  117411. */
  117412. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  117413. /**
  117414. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  117415. * The order of search:
  117416. *
  117417. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  117418. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  117419. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  117420. * 4) return the generic trigger controller if none were found
  117421. *
  117422. * @param xrInput the xrInput to which a new controller is initialized
  117423. * @param scene the scene to which the model will be added
  117424. * @param forceProfile force a certain profile for this controller
  117425. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  117426. */
  117427. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  117428. private static _LoadProfilesFromAvailableControllers;
  117429. private static _ProfilesList;
  117430. private static _ProfileLoadingPromises;
  117431. private static _LoadProfileFromRepository;
  117432. /**
  117433. * Clear the cache used for profile loading and reload when requested again
  117434. */
  117435. static ClearProfilesCache(): void;
  117436. /**
  117437. * Will update the list of profiles available in the repository
  117438. * @return a promise that resolves to a map of profiles available online
  117439. */
  117440. static UpdateProfilesList(): Promise<{
  117441. [profile: string]: string;
  117442. }>;
  117443. /**
  117444. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  117445. * @param profileId the profile to which a fallback needs to be found
  117446. * @return an array with corresponding fallback profiles
  117447. */
  117448. static FindFallbackWithProfileId(profileId: string): string[];
  117449. /**
  117450. * Register a fallback to a specific profile.
  117451. * @param profileId the profileId that will receive the fallbacks
  117452. * @param fallbacks A list of fallback profiles
  117453. */
  117454. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  117455. /**
  117456. * Register the default fallbacks.
  117457. * This function is called automatically when this file is imported.
  117458. */
  117459. static DefaultFallbacks(): void;
  117460. }
  117461. }
  117462. declare module BABYLON {
  117463. /**
  117464. * Configuration options for the WebXR controller creation
  117465. */
  117466. export interface IWebXRControllerOptions {
  117467. /**
  117468. * Force a specific controller type for this controller.
  117469. * This can be used when creating your own profile or when testing different controllers
  117470. */
  117471. forceControllerProfile?: string;
  117472. /**
  117473. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  117474. */
  117475. doNotLoadControllerMesh?: boolean;
  117476. /**
  117477. * Should the controller mesh be animated when a user interacts with it
  117478. * The pressed buttons / thumbstick and touchpad animations will be disabled
  117479. */
  117480. disableMotionControllerAnimation?: boolean;
  117481. }
  117482. /**
  117483. * Represents an XR controller
  117484. */
  117485. export class WebXRInputSource {
  117486. private _scene;
  117487. /** The underlying input source for the controller */
  117488. inputSource: XRInputSource;
  117489. private _options;
  117490. /**
  117491. * 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
  117492. */
  117493. grip?: AbstractMesh;
  117494. /**
  117495. * Pointer which can be used to select objects or attach a visible laser to
  117496. */
  117497. pointer: AbstractMesh;
  117498. /**
  117499. * If available, this is the gamepad object related to this controller.
  117500. * Using this object it is possible to get click events and trackpad changes of the
  117501. * webxr controller that is currently being used.
  117502. */
  117503. motionController?: WebXRAbstractMotionController;
  117504. /**
  117505. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  117506. */
  117507. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  117508. /**
  117509. * Will be triggered when the mesh associated with the motion controller is done loading.
  117510. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  117511. * A shortened version of controller -> motion controller -> on mesh loaded.
  117512. */
  117513. onMeshLoadedObservable: Observable<AbstractMesh>;
  117514. /**
  117515. * Event that fires when the controller is removed/disposed.
  117516. * The object provided as event data is this controller, after associated assets were disposed.
  117517. * uniqueId is still available.
  117518. */
  117519. onDisposeObservable: Observable<WebXRInputSource>;
  117520. private _tmpQuaternion;
  117521. private _tmpVector;
  117522. private _uniqueId;
  117523. /**
  117524. * Creates the controller
  117525. * @see https://doc.babylonjs.com/how_to/webxr
  117526. * @param _scene the scene which the controller should be associated to
  117527. * @param inputSource the underlying input source for the controller
  117528. * @param _options options for this controller creation
  117529. */
  117530. constructor(_scene: Scene,
  117531. /** The underlying input source for the controller */
  117532. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  117533. /**
  117534. * Get this controllers unique id
  117535. */
  117536. get uniqueId(): string;
  117537. /**
  117538. * Updates the controller pose based on the given XRFrame
  117539. * @param xrFrame xr frame to update the pose with
  117540. * @param referenceSpace reference space to use
  117541. */
  117542. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  117543. /**
  117544. * Gets a world space ray coming from the pointer or grip
  117545. * @param result the resulting ray
  117546. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  117547. */
  117548. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  117549. /**
  117550. * Disposes of the object
  117551. */
  117552. dispose(): void;
  117553. }
  117554. }
  117555. declare module BABYLON {
  117556. /**
  117557. * The schema for initialization options of the XR Input class
  117558. */
  117559. export interface IWebXRInputOptions {
  117560. /**
  117561. * If set to true no model will be automatically loaded
  117562. */
  117563. doNotLoadControllerMeshes?: boolean;
  117564. /**
  117565. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  117566. * If not found, the xr input profile data will be used.
  117567. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  117568. */
  117569. forceInputProfile?: string;
  117570. /**
  117571. * Do not send a request to the controlle repository to load the profile.
  117572. *
  117573. * Instead, use the controllers available in babylon itself.
  117574. */
  117575. disableOnlineControllerRepository?: boolean;
  117576. /**
  117577. * A custom URL for the controllers repository
  117578. */
  117579. customControllersRepositoryURL?: string;
  117580. /**
  117581. * Should the controller model's components not move according to the user input
  117582. */
  117583. disableControllerAnimation?: boolean;
  117584. }
  117585. /**
  117586. * XR input used to track XR inputs such as controllers/rays
  117587. */
  117588. export class WebXRInput implements IDisposable {
  117589. /**
  117590. * the xr session manager for this session
  117591. */
  117592. xrSessionManager: WebXRSessionManager;
  117593. /**
  117594. * the WebXR camera for this session. Mainly used for teleportation
  117595. */
  117596. xrCamera: WebXRCamera;
  117597. private readonly options;
  117598. /**
  117599. * XR controllers being tracked
  117600. */
  117601. controllers: Array<WebXRInputSource>;
  117602. private _frameObserver;
  117603. private _sessionEndedObserver;
  117604. private _sessionInitObserver;
  117605. /**
  117606. * Event when a controller has been connected/added
  117607. */
  117608. onControllerAddedObservable: Observable<WebXRInputSource>;
  117609. /**
  117610. * Event when a controller has been removed/disconnected
  117611. */
  117612. onControllerRemovedObservable: Observable<WebXRInputSource>;
  117613. /**
  117614. * Initializes the WebXRInput
  117615. * @param xrSessionManager the xr session manager for this session
  117616. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  117617. * @param options = initialization options for this xr input
  117618. */
  117619. constructor(
  117620. /**
  117621. * the xr session manager for this session
  117622. */
  117623. xrSessionManager: WebXRSessionManager,
  117624. /**
  117625. * the WebXR camera for this session. Mainly used for teleportation
  117626. */
  117627. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  117628. private _onInputSourcesChange;
  117629. private _addAndRemoveControllers;
  117630. /**
  117631. * Disposes of the object
  117632. */
  117633. dispose(): void;
  117634. }
  117635. }
  117636. declare module BABYLON {
  117637. /**
  117638. * This is the base class for all WebXR features.
  117639. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  117640. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  117641. */
  117642. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  117643. protected _xrSessionManager: WebXRSessionManager;
  117644. /**
  117645. * Construct a new (abstract) webxr feature
  117646. * @param _xrSessionManager the xr session manager for this feature
  117647. */
  117648. constructor(_xrSessionManager: WebXRSessionManager);
  117649. private _attached;
  117650. private _removeOnDetach;
  117651. /**
  117652. * Is this feature attached
  117653. */
  117654. get attached(): boolean;
  117655. /**
  117656. * Should auto-attach be disabled?
  117657. */
  117658. disableAutoAttach: boolean;
  117659. /**
  117660. * attach this feature
  117661. *
  117662. * @param force should attachment be forced (even when already attached)
  117663. * @returns true if successful, false is failed or already attached
  117664. */
  117665. attach(force?: boolean): boolean;
  117666. /**
  117667. * detach this feature.
  117668. *
  117669. * @returns true if successful, false if failed or already detached
  117670. */
  117671. detach(): boolean;
  117672. /**
  117673. * Dispose this feature and all of the resources attached
  117674. */
  117675. dispose(): void;
  117676. /**
  117677. * Code in this function will be executed on each xrFrame received from the browser.
  117678. * This function will not execute after the feature is detached.
  117679. * @param _xrFrame the current frame
  117680. */
  117681. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  117682. /**
  117683. * This is used to register callbacks that will automatically be removed when detach is called.
  117684. * @param observable the observable to which the observer will be attached
  117685. * @param callback the callback to register
  117686. */
  117687. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  117688. }
  117689. }
  117690. declare module BABYLON {
  117691. /**
  117692. * Renders a layer on top of an existing scene
  117693. */
  117694. export class UtilityLayerRenderer implements IDisposable {
  117695. /** the original scene that will be rendered on top of */
  117696. originalScene: Scene;
  117697. private _pointerCaptures;
  117698. private _lastPointerEvents;
  117699. private static _DefaultUtilityLayer;
  117700. private static _DefaultKeepDepthUtilityLayer;
  117701. private _sharedGizmoLight;
  117702. private _renderCamera;
  117703. /**
  117704. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  117705. * @returns the camera that is used when rendering the utility layer
  117706. */
  117707. getRenderCamera(): Camera;
  117708. /**
  117709. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  117710. * @param cam the camera that should be used when rendering the utility layer
  117711. */
  117712. setRenderCamera(cam: Nullable<Camera>): void;
  117713. /**
  117714. * @hidden
  117715. * Light which used by gizmos to get light shading
  117716. */
  117717. _getSharedGizmoLight(): HemisphericLight;
  117718. /**
  117719. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  117720. */
  117721. pickUtilitySceneFirst: boolean;
  117722. /**
  117723. * 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)
  117724. */
  117725. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  117726. /**
  117727. * 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)
  117728. */
  117729. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  117730. /**
  117731. * The scene that is rendered on top of the original scene
  117732. */
  117733. utilityLayerScene: Scene;
  117734. /**
  117735. * If the utility layer should automatically be rendered on top of existing scene
  117736. */
  117737. shouldRender: boolean;
  117738. /**
  117739. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  117740. */
  117741. onlyCheckPointerDownEvents: boolean;
  117742. /**
  117743. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  117744. */
  117745. processAllEvents: boolean;
  117746. /**
  117747. * Observable raised when the pointer move from the utility layer scene to the main scene
  117748. */
  117749. onPointerOutObservable: Observable<number>;
  117750. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  117751. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  117752. private _afterRenderObserver;
  117753. private _sceneDisposeObserver;
  117754. private _originalPointerObserver;
  117755. /**
  117756. * Instantiates a UtilityLayerRenderer
  117757. * @param originalScene the original scene that will be rendered on top of
  117758. * @param handleEvents boolean indicating if the utility layer should handle events
  117759. */
  117760. constructor(
  117761. /** the original scene that will be rendered on top of */
  117762. originalScene: Scene, handleEvents?: boolean);
  117763. private _notifyObservers;
  117764. /**
  117765. * Renders the utility layers scene on top of the original scene
  117766. */
  117767. render(): void;
  117768. /**
  117769. * Disposes of the renderer
  117770. */
  117771. dispose(): void;
  117772. private _updateCamera;
  117773. }
  117774. }
  117775. declare module BABYLON {
  117776. /**
  117777. * Options interface for the pointer selection module
  117778. */
  117779. export interface IWebXRControllerPointerSelectionOptions {
  117780. /**
  117781. * the xr input to use with this pointer selection
  117782. */
  117783. xrInput: WebXRInput;
  117784. /**
  117785. * Different button type to use instead of the main component
  117786. */
  117787. overrideButtonId?: string;
  117788. /**
  117789. * The amount of time in miliseconds it takes between pick found something to a pointer down event.
  117790. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  117791. * 3000 means 3 seconds between pointing at something and selecting it
  117792. */
  117793. timeToSelect?: number;
  117794. /**
  117795. * 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)
  117796. * If not disabled, the last picked point will be used to execute a pointer up event
  117797. * If disabled, pointer up event will be triggered right after the pointer down event.
  117798. * Used in screen and gaze target ray mode only
  117799. */
  117800. disablePointerUpOnTouchOut: boolean;
  117801. /**
  117802. * For gaze mode (time to select instead of press)
  117803. */
  117804. forceGazeMode: boolean;
  117805. /**
  117806. * 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
  117807. * to start a new countdown to the pointer down event.
  117808. * Defaults to 1.
  117809. */
  117810. gazeModePointerMovedFactor?: number;
  117811. /**
  117812. * Should meshes created here be added to a utility layer or the main scene
  117813. */
  117814. useUtilityLayer?: boolean;
  117815. /**
  117816. * if provided, this scene will be used to render meshes.
  117817. */
  117818. customUtilityLayerScene?: Scene;
  117819. /**
  117820. * use this rendering group id for the meshes (optional)
  117821. */
  117822. renderingGroupId?: number;
  117823. }
  117824. /**
  117825. * A module that will enable pointer selection for motion controllers of XR Input Sources
  117826. */
  117827. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  117828. private readonly _options;
  117829. /**
  117830. * The module's name
  117831. */
  117832. static readonly Name: string;
  117833. /**
  117834. * The (Babylon) version of this module.
  117835. * This is an integer representing the implementation version.
  117836. * This number does not correspond to the webxr specs version
  117837. */
  117838. static readonly Version: number;
  117839. /**
  117840. * This color will be set to the laser pointer when selection is triggered
  117841. */
  117842. laserPointerPickedColor: Color3;
  117843. /**
  117844. * This color will be applied to the selection ring when selection is triggered
  117845. */
  117846. selectionMeshPickedColor: Color3;
  117847. /**
  117848. * default color of the selection ring
  117849. */
  117850. selectionMeshDefaultColor: Color3;
  117851. /**
  117852. * Default color of the laser pointer
  117853. */
  117854. lasterPointerDefaultColor: Color3;
  117855. /**
  117856. * Should the laser pointer be displayed
  117857. */
  117858. displayLaserPointer: boolean;
  117859. /**
  117860. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  117861. */
  117862. displaySelectionMesh: boolean;
  117863. /**
  117864. * Disable lighting on the laser pointer (so it will always be visible)
  117865. */
  117866. disablePointerLighting: boolean;
  117867. /**
  117868. * Disable lighting on the selection mesh (so it will always be visible)
  117869. */
  117870. disableSelectionMeshLighting: boolean;
  117871. private static _idCounter;
  117872. private _controllers;
  117873. private _scene;
  117874. /**
  117875. * constructs a new background remover module
  117876. * @param _xrSessionManager the session manager for this module
  117877. * @param _options read-only options to be used in this module
  117878. */
  117879. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  117880. /**
  117881. * attach this feature
  117882. * Will usually be called by the features manager
  117883. *
  117884. * @returns true if successful.
  117885. */
  117886. attach(): boolean;
  117887. /**
  117888. * detach this feature.
  117889. * Will usually be called by the features manager
  117890. *
  117891. * @returns true if successful.
  117892. */
  117893. detach(): boolean;
  117894. /**
  117895. * Get the xr controller that correlates to the pointer id in the pointer event
  117896. *
  117897. * @param id the pointer id to search for
  117898. * @returns the controller that correlates to this id or null if not found
  117899. */
  117900. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  117901. /**
  117902. * Will get the mesh under a specific pointer.
  117903. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  117904. * @param controllerId the controllerId to check
  117905. * @returns The mesh under pointer or null if no mesh is under the pointer
  117906. */
  117907. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  117908. protected _onXRFrame(_xrFrame: XRFrame): void;
  117909. private _attachController;
  117910. private _attachScreenRayMode;
  117911. private _attachGazeMode;
  117912. private _tmpVectorForPickCompare;
  117913. private _pickingMoved;
  117914. private _attachTrackedPointerRayMode;
  117915. private _detachController;
  117916. private _generateNewMeshPair;
  117917. private _convertNormalToDirectionOfRay;
  117918. private _updatePointerDistance;
  117919. }
  117920. }
  117921. declare module BABYLON {
  117922. /**
  117923. * Button which can be used to enter a different mode of XR
  117924. */
  117925. export class WebXREnterExitUIButton {
  117926. /** button element */
  117927. element: HTMLElement;
  117928. /** XR initialization options for the button */
  117929. sessionMode: XRSessionMode;
  117930. /** Reference space type */
  117931. referenceSpaceType: XRReferenceSpaceType;
  117932. /**
  117933. * Creates a WebXREnterExitUIButton
  117934. * @param element button element
  117935. * @param sessionMode XR initialization session mode
  117936. * @param referenceSpaceType the type of reference space to be used
  117937. */
  117938. constructor(
  117939. /** button element */
  117940. element: HTMLElement,
  117941. /** XR initialization options for the button */
  117942. sessionMode: XRSessionMode,
  117943. /** Reference space type */
  117944. referenceSpaceType: XRReferenceSpaceType);
  117945. /**
  117946. * Overwritable function which can be used to update the button's visuals when the state changes
  117947. * @param activeButton the current active button in the UI
  117948. */
  117949. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  117950. }
  117951. /**
  117952. * Options to create the webXR UI
  117953. */
  117954. export class WebXREnterExitUIOptions {
  117955. /**
  117956. * Context to enter xr with
  117957. */
  117958. renderTarget?: Nullable<WebXRRenderTarget>;
  117959. /**
  117960. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  117961. */
  117962. customButtons?: Array<WebXREnterExitUIButton>;
  117963. /**
  117964. * A session mode to use when creating the default button.
  117965. * Default is immersive-vr
  117966. */
  117967. sessionMode?: XRSessionMode;
  117968. /**
  117969. * A reference space type to use when creating the default button.
  117970. * Default is local-floor
  117971. */
  117972. referenceSpaceType?: XRReferenceSpaceType;
  117973. }
  117974. /**
  117975. * UI to allow the user to enter/exit XR mode
  117976. */
  117977. export class WebXREnterExitUI implements IDisposable {
  117978. private scene;
  117979. /** version of the options passed to this UI */
  117980. options: WebXREnterExitUIOptions;
  117981. private _overlay;
  117982. private _buttons;
  117983. private _activeButton;
  117984. /**
  117985. * Fired every time the active button is changed.
  117986. *
  117987. * When xr is entered via a button that launches xr that button will be the callback parameter
  117988. *
  117989. * When exiting xr the callback parameter will be null)
  117990. */
  117991. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  117992. /**
  117993. * Creates UI to allow the user to enter/exit XR mode
  117994. * @param scene the scene to add the ui to
  117995. * @param helper the xr experience helper to enter/exit xr with
  117996. * @param options options to configure the UI
  117997. * @returns the created ui
  117998. */
  117999. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  118000. /**
  118001. *
  118002. * @param scene babylon scene object to use
  118003. * @param options (read-only) version of the options passed to this UI
  118004. */
  118005. private constructor();
  118006. private _updateButtons;
  118007. /**
  118008. * Disposes of the object
  118009. */
  118010. dispose(): void;
  118011. }
  118012. }
  118013. declare module BABYLON {
  118014. /**
  118015. * Class containing static functions to help procedurally build meshes
  118016. */
  118017. export class LinesBuilder {
  118018. /**
  118019. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  118020. * * 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
  118021. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  118022. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  118023. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  118024. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  118025. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  118026. * * 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
  118027. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  118028. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118029. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  118030. * @param name defines the name of the new line system
  118031. * @param options defines the options used to create the line system
  118032. * @param scene defines the hosting scene
  118033. * @returns a new line system mesh
  118034. */
  118035. static CreateLineSystem(name: string, options: {
  118036. lines: Vector3[][];
  118037. updatable?: boolean;
  118038. instance?: Nullable<LinesMesh>;
  118039. colors?: Nullable<Color4[][]>;
  118040. useVertexAlpha?: boolean;
  118041. }, scene: Nullable<Scene>): LinesMesh;
  118042. /**
  118043. * Creates a line mesh
  118044. * 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
  118045. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  118046. * * The parameter `points` is an array successive Vector3
  118047. * * 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
  118048. * * The optional parameter `colors` is an array of successive Color4, one per line point
  118049. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  118050. * * When updating an instance, remember that only point positions can change, not the number of points
  118051. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118052. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  118053. * @param name defines the name of the new line system
  118054. * @param options defines the options used to create the line system
  118055. * @param scene defines the hosting scene
  118056. * @returns a new line mesh
  118057. */
  118058. static CreateLines(name: string, options: {
  118059. points: Vector3[];
  118060. updatable?: boolean;
  118061. instance?: Nullable<LinesMesh>;
  118062. colors?: Color4[];
  118063. useVertexAlpha?: boolean;
  118064. }, scene?: Nullable<Scene>): LinesMesh;
  118065. /**
  118066. * Creates a dashed line mesh
  118067. * * 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
  118068. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  118069. * * The parameter `points` is an array successive Vector3
  118070. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  118071. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  118072. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  118073. * * 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
  118074. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  118075. * * When updating an instance, remember that only point positions can change, not the number of points
  118076. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118077. * @param name defines the name of the mesh
  118078. * @param options defines the options used to create the mesh
  118079. * @param scene defines the hosting scene
  118080. * @returns the dashed line mesh
  118081. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  118082. */
  118083. static CreateDashedLines(name: string, options: {
  118084. points: Vector3[];
  118085. dashSize?: number;
  118086. gapSize?: number;
  118087. dashNb?: number;
  118088. updatable?: boolean;
  118089. instance?: LinesMesh;
  118090. useVertexAlpha?: boolean;
  118091. }, scene?: Nullable<Scene>): LinesMesh;
  118092. }
  118093. }
  118094. declare module BABYLON {
  118095. /**
  118096. * The options container for the teleportation module
  118097. */
  118098. export interface IWebXRTeleportationOptions {
  118099. /**
  118100. * Babylon XR Input class for controller
  118101. */
  118102. xrInput: WebXRInput;
  118103. /**
  118104. * A list of meshes to use as floor meshes.
  118105. * Meshes can be added and removed after initializing the feature using the
  118106. * addFloorMesh and removeFloorMesh functions
  118107. * If empty, rotation will still work
  118108. */
  118109. floorMeshes?: AbstractMesh[];
  118110. /**
  118111. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  118112. * If you want to support rotation, make sure your mesh has a direction indicator.
  118113. *
  118114. * When left untouched, the default mesh will be initialized.
  118115. */
  118116. teleportationTargetMesh?: AbstractMesh;
  118117. /**
  118118. * An array of points to which the teleportation will snap to.
  118119. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  118120. */
  118121. snapPositions?: Vector3[];
  118122. /**
  118123. * How close should the teleportation ray be in order to snap to position.
  118124. * Default to 0.8 units (meters)
  118125. */
  118126. snapToPositionRadius?: number;
  118127. /**
  118128. * Should teleportation move only to snap points
  118129. */
  118130. snapPointsOnly?: boolean;
  118131. /**
  118132. * Values to configure the default target mesh
  118133. */
  118134. defaultTargetMeshOptions?: {
  118135. /**
  118136. * Fill color of the teleportation area
  118137. */
  118138. teleportationFillColor?: string;
  118139. /**
  118140. * Border color for the teleportation area
  118141. */
  118142. teleportationBorderColor?: string;
  118143. /**
  118144. * Disable the mesh's animation sequence
  118145. */
  118146. disableAnimation?: boolean;
  118147. /**
  118148. * Disable lighting on the material or the ring and arrow
  118149. */
  118150. disableLighting?: boolean;
  118151. /**
  118152. * Override the default material of the torus and arrow
  118153. */
  118154. torusArrowMaterial?: Material;
  118155. };
  118156. /**
  118157. * Disable using the thumbstick and use the main component (usuallly trigger) on long press.
  118158. * This will be automatically true if the controller doesnt have a thumbstick or touchpad.
  118159. */
  118160. useMainComponentOnly?: boolean;
  118161. /**
  118162. * If main component is used (no thumbstick), how long should the "long press" take before teleporting
  118163. */
  118164. timeToTeleport?: number;
  118165. /**
  118166. * Should meshes created here be added to a utility layer or the main scene
  118167. */
  118168. useUtilityLayer?: boolean;
  118169. /**
  118170. * if provided, this scene will be used to render meshes.
  118171. */
  118172. customUtilityLayerScene?: Scene;
  118173. /**
  118174. * use this rendering group id for the meshes (optional)
  118175. */
  118176. renderingGroupId?: number;
  118177. }
  118178. /**
  118179. * This is a teleportation feature to be used with webxr-enabled motion controllers.
  118180. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  118181. * the input of the attached controllers.
  118182. */
  118183. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  118184. private _options;
  118185. /**
  118186. * The module's name
  118187. */
  118188. static readonly Name: string;
  118189. /**
  118190. * The (Babylon) version of this module.
  118191. * This is an integer representing the implementation version.
  118192. * This number does not correspond to the webxr specs version
  118193. */
  118194. static readonly Version: number;
  118195. /**
  118196. * Is rotation enabled when moving forward?
  118197. * Disabling this feature will prevent the user from deciding the direction when teleporting
  118198. */
  118199. rotationEnabled: boolean;
  118200. /**
  118201. * Should the module support parabolic ray on top of direct ray
  118202. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  118203. * Very helpful when moving between floors / different heights
  118204. */
  118205. parabolicRayEnabled: boolean;
  118206. /**
  118207. * The distance from the user to the inspection point in the direction of the controller
  118208. * A higher number will allow the user to move further
  118209. * defaults to 5 (meters, in xr units)
  118210. */
  118211. parabolicCheckRadius: number;
  118212. /**
  118213. * How much rotation should be applied when rotating right and left
  118214. */
  118215. rotationAngle: number;
  118216. /**
  118217. * Is movement backwards enabled
  118218. */
  118219. backwardsMovementEnabled: boolean;
  118220. /**
  118221. * Distance to travel when moving backwards
  118222. */
  118223. backwardsTeleportationDistance: number;
  118224. /**
  118225. * Add a new mesh to the floor meshes array
  118226. * @param mesh the mesh to use as floor mesh
  118227. */
  118228. addFloorMesh(mesh: AbstractMesh): void;
  118229. /**
  118230. * Remove a mesh from the floor meshes array
  118231. * @param mesh the mesh to remove
  118232. */
  118233. removeFloorMesh(mesh: AbstractMesh): void;
  118234. /**
  118235. * Remove a mesh from the floor meshes array using its name
  118236. * @param name the mesh name to remove
  118237. */
  118238. removeFloorMeshByName(name: string): void;
  118239. private _tmpRay;
  118240. private _tmpVector;
  118241. private _floorMeshes;
  118242. private _snapToPositions;
  118243. private _controllers;
  118244. /**
  118245. * constructs a new anchor system
  118246. * @param _xrSessionManager an instance of WebXRSessionManager
  118247. * @param _options configuration object for this feature
  118248. */
  118249. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  118250. private _selectionFeature;
  118251. private _snappedToPoint;
  118252. private _teleportationRingMaterial?;
  118253. /**
  118254. * Get the snapPointsOnly flag
  118255. */
  118256. get snapPointsOnly(): boolean;
  118257. /**
  118258. * Sets the snapPointsOnly flag
  118259. * @param snapToPoints should teleportation be exclusively to snap points
  118260. */
  118261. set snapPointsOnly(snapToPoints: boolean);
  118262. /**
  118263. * Add a new snap-to point to fix teleportation to this position
  118264. * @param newSnapPoint The new Snap-To point
  118265. */
  118266. addSnapPoint(newSnapPoint: Vector3): void;
  118267. /**
  118268. * 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
  118269. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  118270. * @returns was the point found and removed or not
  118271. */
  118272. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  118273. /**
  118274. * This function sets a selection feature that will be disabled when
  118275. * the forward ray is shown and will be reattached when hidden.
  118276. * This is used to remove the selection rays when moving.
  118277. * @param selectionFeature the feature to disable when forward movement is enabled
  118278. */
  118279. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  118280. attach(): boolean;
  118281. detach(): boolean;
  118282. dispose(): void;
  118283. protected _onXRFrame(_xrFrame: XRFrame): void;
  118284. private _currentTeleportationControllerId;
  118285. private _attachController;
  118286. private _teleportForward;
  118287. private _detachController;
  118288. private _createDefaultTargetMesh;
  118289. private _setTargetMeshVisibility;
  118290. private _setTargetMeshPosition;
  118291. private _quadraticBezierCurve;
  118292. private _showParabolicPath;
  118293. private _findClosestSnapPointWithRadius;
  118294. }
  118295. }
  118296. declare module BABYLON {
  118297. /**
  118298. * Options for the default xr helper
  118299. */
  118300. export class WebXRDefaultExperienceOptions {
  118301. /**
  118302. * Floor meshes that will be used for teleporting
  118303. */
  118304. floorMeshes?: Array<AbstractMesh>;
  118305. /**
  118306. * Enable or disable default UI to enter XR
  118307. */
  118308. disableDefaultUI?: boolean;
  118309. /**
  118310. * optional configuration for the output canvas
  118311. */
  118312. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  118313. /**
  118314. * optional UI options. This can be used among other to change session mode and reference space type
  118315. */
  118316. uiOptions?: WebXREnterExitUIOptions;
  118317. /**
  118318. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  118319. */
  118320. inputOptions?: IWebXRInputOptions;
  118321. /**
  118322. * Should teleportation not initialize. defaults to false.
  118323. */
  118324. disableTeleportation?: boolean;
  118325. /**
  118326. * If set to true, the first frame will not be used to reset position
  118327. * The first frame is mainly used when copying transformation from the old camera
  118328. * Mainly used in AR
  118329. */
  118330. ignoreNativeCameraTransformation?: boolean;
  118331. /**
  118332. * When loading teleportation and pointer select, use stable versions instead of latest.
  118333. */
  118334. useStablePlugins?: boolean;
  118335. }
  118336. /**
  118337. * Default experience which provides a similar setup to the previous webVRExperience
  118338. */
  118339. export class WebXRDefaultExperience {
  118340. /**
  118341. * Base experience
  118342. */
  118343. baseExperience: WebXRExperienceHelper;
  118344. /**
  118345. * Input experience extension
  118346. */
  118347. input: WebXRInput;
  118348. /**
  118349. * Enables laser pointer and selection
  118350. */
  118351. pointerSelection: WebXRControllerPointerSelection;
  118352. /**
  118353. * Enables teleportation
  118354. */
  118355. teleportation: WebXRMotionControllerTeleportation;
  118356. /**
  118357. * Enables ui for entering/exiting xr
  118358. */
  118359. enterExitUI: WebXREnterExitUI;
  118360. /**
  118361. * Default target xr should render to
  118362. */
  118363. renderTarget: WebXRRenderTarget;
  118364. /**
  118365. * Creates the default xr experience
  118366. * @param scene scene
  118367. * @param options options for basic configuration
  118368. * @returns resulting WebXRDefaultExperience
  118369. */
  118370. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  118371. private constructor();
  118372. /**
  118373. * DIsposes of the experience helper
  118374. */
  118375. dispose(): void;
  118376. }
  118377. }
  118378. declare module BABYLON {
  118379. /**
  118380. * Options to modify the vr teleportation behavior.
  118381. */
  118382. export interface VRTeleportationOptions {
  118383. /**
  118384. * The name of the mesh which should be used as the teleportation floor. (default: null)
  118385. */
  118386. floorMeshName?: string;
  118387. /**
  118388. * A list of meshes to be used as the teleportation floor. (default: empty)
  118389. */
  118390. floorMeshes?: Mesh[];
  118391. /**
  118392. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  118393. */
  118394. teleportationMode?: number;
  118395. /**
  118396. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  118397. */
  118398. teleportationTime?: number;
  118399. /**
  118400. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  118401. */
  118402. teleportationSpeed?: number;
  118403. /**
  118404. * The easing function used in the animation or null for Linear. (default CircleEase)
  118405. */
  118406. easingFunction?: EasingFunction;
  118407. }
  118408. /**
  118409. * Options to modify the vr experience helper's behavior.
  118410. */
  118411. export interface VRExperienceHelperOptions extends WebVROptions {
  118412. /**
  118413. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  118414. */
  118415. createDeviceOrientationCamera?: boolean;
  118416. /**
  118417. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  118418. */
  118419. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  118420. /**
  118421. * Uses the main button on the controller to toggle the laser casted. (default: true)
  118422. */
  118423. laserToggle?: boolean;
  118424. /**
  118425. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  118426. */
  118427. floorMeshes?: Mesh[];
  118428. /**
  118429. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  118430. */
  118431. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  118432. /**
  118433. * Defines if WebXR should be used instead of WebVR (if available)
  118434. */
  118435. useXR?: boolean;
  118436. }
  118437. /**
  118438. * Event containing information after VR has been entered
  118439. */
  118440. export class OnAfterEnteringVRObservableEvent {
  118441. /**
  118442. * If entering vr was successful
  118443. */
  118444. success: boolean;
  118445. }
  118446. /**
  118447. * Helps to quickly add VR support to an existing scene.
  118448. * See http://doc.babylonjs.com/how_to/webvr_helper
  118449. */
  118450. export class VRExperienceHelper {
  118451. /** Options to modify the vr experience helper's behavior. */
  118452. webVROptions: VRExperienceHelperOptions;
  118453. private _scene;
  118454. private _position;
  118455. private _btnVR;
  118456. private _btnVRDisplayed;
  118457. private _webVRsupported;
  118458. private _webVRready;
  118459. private _webVRrequesting;
  118460. private _webVRpresenting;
  118461. private _hasEnteredVR;
  118462. private _fullscreenVRpresenting;
  118463. private _inputElement;
  118464. private _webVRCamera;
  118465. private _vrDeviceOrientationCamera;
  118466. private _deviceOrientationCamera;
  118467. private _existingCamera;
  118468. private _onKeyDown;
  118469. private _onVrDisplayPresentChange;
  118470. private _onVRDisplayChanged;
  118471. private _onVRRequestPresentStart;
  118472. private _onVRRequestPresentComplete;
  118473. /**
  118474. * 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)
  118475. */
  118476. enableGazeEvenWhenNoPointerLock: boolean;
  118477. /**
  118478. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  118479. */
  118480. exitVROnDoubleTap: boolean;
  118481. /**
  118482. * Observable raised right before entering VR.
  118483. */
  118484. onEnteringVRObservable: Observable<VRExperienceHelper>;
  118485. /**
  118486. * Observable raised when entering VR has completed.
  118487. */
  118488. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  118489. /**
  118490. * Observable raised when exiting VR.
  118491. */
  118492. onExitingVRObservable: Observable<VRExperienceHelper>;
  118493. /**
  118494. * Observable raised when controller mesh is loaded.
  118495. */
  118496. onControllerMeshLoadedObservable: Observable<WebVRController>;
  118497. /** Return this.onEnteringVRObservable
  118498. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  118499. */
  118500. get onEnteringVR(): Observable<VRExperienceHelper>;
  118501. /** Return this.onExitingVRObservable
  118502. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  118503. */
  118504. get onExitingVR(): Observable<VRExperienceHelper>;
  118505. /** Return this.onControllerMeshLoadedObservable
  118506. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  118507. */
  118508. get onControllerMeshLoaded(): Observable<WebVRController>;
  118509. private _rayLength;
  118510. private _useCustomVRButton;
  118511. private _teleportationRequested;
  118512. private _teleportActive;
  118513. private _floorMeshName;
  118514. private _floorMeshesCollection;
  118515. private _teleportationMode;
  118516. private _teleportationTime;
  118517. private _teleportationSpeed;
  118518. private _teleportationEasing;
  118519. private _rotationAllowed;
  118520. private _teleportBackwardsVector;
  118521. private _teleportationTarget;
  118522. private _isDefaultTeleportationTarget;
  118523. private _postProcessMove;
  118524. private _teleportationFillColor;
  118525. private _teleportationBorderColor;
  118526. private _rotationAngle;
  118527. private _haloCenter;
  118528. private _cameraGazer;
  118529. private _padSensibilityUp;
  118530. private _padSensibilityDown;
  118531. private _leftController;
  118532. private _rightController;
  118533. private _gazeColor;
  118534. private _laserColor;
  118535. private _pickedLaserColor;
  118536. private _pickedGazeColor;
  118537. /**
  118538. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  118539. */
  118540. onNewMeshSelected: Observable<AbstractMesh>;
  118541. /**
  118542. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  118543. * This observable will provide the mesh and the controller used to select the mesh
  118544. */
  118545. onMeshSelectedWithController: Observable<{
  118546. mesh: AbstractMesh;
  118547. controller: WebVRController;
  118548. }>;
  118549. /**
  118550. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  118551. */
  118552. onNewMeshPicked: Observable<PickingInfo>;
  118553. private _circleEase;
  118554. /**
  118555. * Observable raised before camera teleportation
  118556. */
  118557. onBeforeCameraTeleport: Observable<Vector3>;
  118558. /**
  118559. * Observable raised after camera teleportation
  118560. */
  118561. onAfterCameraTeleport: Observable<Vector3>;
  118562. /**
  118563. * Observable raised when current selected mesh gets unselected
  118564. */
  118565. onSelectedMeshUnselected: Observable<AbstractMesh>;
  118566. private _raySelectionPredicate;
  118567. /**
  118568. * To be optionaly changed by user to define custom ray selection
  118569. */
  118570. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  118571. /**
  118572. * To be optionaly changed by user to define custom selection logic (after ray selection)
  118573. */
  118574. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  118575. /**
  118576. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  118577. */
  118578. teleportationEnabled: boolean;
  118579. private _defaultHeight;
  118580. private _teleportationInitialized;
  118581. private _interactionsEnabled;
  118582. private _interactionsRequested;
  118583. private _displayGaze;
  118584. private _displayLaserPointer;
  118585. /**
  118586. * The mesh used to display where the user is going to teleport.
  118587. */
  118588. get teleportationTarget(): Mesh;
  118589. /**
  118590. * Sets the mesh to be used to display where the user is going to teleport.
  118591. */
  118592. set teleportationTarget(value: Mesh);
  118593. /**
  118594. * 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
  118595. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  118596. * See http://doc.babylonjs.com/resources/baking_transformations
  118597. */
  118598. get gazeTrackerMesh(): Mesh;
  118599. set gazeTrackerMesh(value: Mesh);
  118600. /**
  118601. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  118602. */
  118603. updateGazeTrackerScale: boolean;
  118604. /**
  118605. * If the gaze trackers color should be updated when selecting meshes
  118606. */
  118607. updateGazeTrackerColor: boolean;
  118608. /**
  118609. * If the controller laser color should be updated when selecting meshes
  118610. */
  118611. updateControllerLaserColor: boolean;
  118612. /**
  118613. * The gaze tracking mesh corresponding to the left controller
  118614. */
  118615. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  118616. /**
  118617. * The gaze tracking mesh corresponding to the right controller
  118618. */
  118619. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  118620. /**
  118621. * If the ray of the gaze should be displayed.
  118622. */
  118623. get displayGaze(): boolean;
  118624. /**
  118625. * Sets if the ray of the gaze should be displayed.
  118626. */
  118627. set displayGaze(value: boolean);
  118628. /**
  118629. * If the ray of the LaserPointer should be displayed.
  118630. */
  118631. get displayLaserPointer(): boolean;
  118632. /**
  118633. * Sets if the ray of the LaserPointer should be displayed.
  118634. */
  118635. set displayLaserPointer(value: boolean);
  118636. /**
  118637. * The deviceOrientationCamera used as the camera when not in VR.
  118638. */
  118639. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  118640. /**
  118641. * Based on the current WebVR support, returns the current VR camera used.
  118642. */
  118643. get currentVRCamera(): Nullable<Camera>;
  118644. /**
  118645. * The webVRCamera which is used when in VR.
  118646. */
  118647. get webVRCamera(): WebVRFreeCamera;
  118648. /**
  118649. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  118650. */
  118651. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  118652. /**
  118653. * The html button that is used to trigger entering into VR.
  118654. */
  118655. get vrButton(): Nullable<HTMLButtonElement>;
  118656. private get _teleportationRequestInitiated();
  118657. /**
  118658. * Defines whether or not Pointer lock should be requested when switching to
  118659. * full screen.
  118660. */
  118661. requestPointerLockOnFullScreen: boolean;
  118662. /**
  118663. * If asking to force XR, this will be populated with the default xr experience
  118664. */
  118665. xr: WebXRDefaultExperience;
  118666. /**
  118667. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  118668. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  118669. */
  118670. xrTestDone: boolean;
  118671. /**
  118672. * Instantiates a VRExperienceHelper.
  118673. * Helps to quickly add VR support to an existing scene.
  118674. * @param scene The scene the VRExperienceHelper belongs to.
  118675. * @param webVROptions Options to modify the vr experience helper's behavior.
  118676. */
  118677. constructor(scene: Scene,
  118678. /** Options to modify the vr experience helper's behavior. */
  118679. webVROptions?: VRExperienceHelperOptions);
  118680. private completeVRInit;
  118681. private _onDefaultMeshLoaded;
  118682. private _onResize;
  118683. private _onFullscreenChange;
  118684. /**
  118685. * Gets a value indicating if we are currently in VR mode.
  118686. */
  118687. get isInVRMode(): boolean;
  118688. private onVrDisplayPresentChange;
  118689. private onVRDisplayChanged;
  118690. private moveButtonToBottomRight;
  118691. private displayVRButton;
  118692. private updateButtonVisibility;
  118693. private _cachedAngularSensibility;
  118694. /**
  118695. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  118696. * Otherwise, will use the fullscreen API.
  118697. */
  118698. enterVR(): void;
  118699. /**
  118700. * Attempt to exit VR, or fullscreen.
  118701. */
  118702. exitVR(): void;
  118703. /**
  118704. * The position of the vr experience helper.
  118705. */
  118706. get position(): Vector3;
  118707. /**
  118708. * Sets the position of the vr experience helper.
  118709. */
  118710. set position(value: Vector3);
  118711. /**
  118712. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  118713. */
  118714. enableInteractions(): void;
  118715. private get _noControllerIsActive();
  118716. private beforeRender;
  118717. private _isTeleportationFloor;
  118718. /**
  118719. * Adds a floor mesh to be used for teleportation.
  118720. * @param floorMesh the mesh to be used for teleportation.
  118721. */
  118722. addFloorMesh(floorMesh: Mesh): void;
  118723. /**
  118724. * Removes a floor mesh from being used for teleportation.
  118725. * @param floorMesh the mesh to be removed.
  118726. */
  118727. removeFloorMesh(floorMesh: Mesh): void;
  118728. /**
  118729. * Enables interactions and teleportation using the VR controllers and gaze.
  118730. * @param vrTeleportationOptions options to modify teleportation behavior.
  118731. */
  118732. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  118733. private _onNewGamepadConnected;
  118734. private _tryEnableInteractionOnController;
  118735. private _onNewGamepadDisconnected;
  118736. private _enableInteractionOnController;
  118737. private _checkTeleportWithRay;
  118738. private _checkRotate;
  118739. private _checkTeleportBackwards;
  118740. private _enableTeleportationOnController;
  118741. private _createTeleportationCircles;
  118742. private _displayTeleportationTarget;
  118743. private _hideTeleportationTarget;
  118744. private _rotateCamera;
  118745. private _moveTeleportationSelectorTo;
  118746. private _workingVector;
  118747. private _workingQuaternion;
  118748. private _workingMatrix;
  118749. /**
  118750. * Time Constant Teleportation Mode
  118751. */
  118752. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  118753. /**
  118754. * Speed Constant Teleportation Mode
  118755. */
  118756. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  118757. /**
  118758. * Teleports the users feet to the desired location
  118759. * @param location The location where the user's feet should be placed
  118760. */
  118761. teleportCamera(location: Vector3): void;
  118762. private _convertNormalToDirectionOfRay;
  118763. private _castRayAndSelectObject;
  118764. private _notifySelectedMeshUnselected;
  118765. /**
  118766. * Permanently set new colors for the laser pointer
  118767. * @param color the new laser color
  118768. * @param pickedColor the new laser color when picked mesh detected
  118769. */
  118770. setLaserColor(color: Color3, pickedColor?: Color3): void;
  118771. /**
  118772. * Set lighting enabled / disabled on the laser pointer of both controllers
  118773. * @param enabled should the lighting be enabled on the laser pointer
  118774. */
  118775. setLaserLightingState(enabled?: boolean): void;
  118776. /**
  118777. * Permanently set new colors for the gaze pointer
  118778. * @param color the new gaze color
  118779. * @param pickedColor the new gaze color when picked mesh detected
  118780. */
  118781. setGazeColor(color: Color3, pickedColor?: Color3): void;
  118782. /**
  118783. * Sets the color of the laser ray from the vr controllers.
  118784. * @param color new color for the ray.
  118785. */
  118786. changeLaserColor(color: Color3): void;
  118787. /**
  118788. * Sets the color of the ray from the vr headsets gaze.
  118789. * @param color new color for the ray.
  118790. */
  118791. changeGazeColor(color: Color3): void;
  118792. /**
  118793. * Exits VR and disposes of the vr experience helper
  118794. */
  118795. dispose(): void;
  118796. /**
  118797. * Gets the name of the VRExperienceHelper class
  118798. * @returns "VRExperienceHelper"
  118799. */
  118800. getClassName(): string;
  118801. }
  118802. }
  118803. declare module BABYLON {
  118804. /**
  118805. * Contains an array of blocks representing the octree
  118806. */
  118807. export interface IOctreeContainer<T> {
  118808. /**
  118809. * Blocks within the octree
  118810. */
  118811. blocks: Array<OctreeBlock<T>>;
  118812. }
  118813. /**
  118814. * Class used to store a cell in an octree
  118815. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118816. */
  118817. export class OctreeBlock<T> {
  118818. /**
  118819. * Gets the content of the current block
  118820. */
  118821. entries: T[];
  118822. /**
  118823. * Gets the list of block children
  118824. */
  118825. blocks: Array<OctreeBlock<T>>;
  118826. private _depth;
  118827. private _maxDepth;
  118828. private _capacity;
  118829. private _minPoint;
  118830. private _maxPoint;
  118831. private _boundingVectors;
  118832. private _creationFunc;
  118833. /**
  118834. * Creates a new block
  118835. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  118836. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  118837. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  118838. * @param depth defines the current depth of this block in the octree
  118839. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  118840. * @param creationFunc defines a callback to call when an element is added to the block
  118841. */
  118842. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  118843. /**
  118844. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  118845. */
  118846. get capacity(): number;
  118847. /**
  118848. * Gets the minimum vector (in world space) of the block's bounding box
  118849. */
  118850. get minPoint(): Vector3;
  118851. /**
  118852. * Gets the maximum vector (in world space) of the block's bounding box
  118853. */
  118854. get maxPoint(): Vector3;
  118855. /**
  118856. * Add a new element to this block
  118857. * @param entry defines the element to add
  118858. */
  118859. addEntry(entry: T): void;
  118860. /**
  118861. * Remove an element from this block
  118862. * @param entry defines the element to remove
  118863. */
  118864. removeEntry(entry: T): void;
  118865. /**
  118866. * Add an array of elements to this block
  118867. * @param entries defines the array of elements to add
  118868. */
  118869. addEntries(entries: T[]): void;
  118870. /**
  118871. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  118872. * @param frustumPlanes defines the frustum planes to test
  118873. * @param selection defines the array to store current content if selection is positive
  118874. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118875. */
  118876. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  118877. /**
  118878. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  118879. * @param sphereCenter defines the bounding sphere center
  118880. * @param sphereRadius defines the bounding sphere radius
  118881. * @param selection defines the array to store current content if selection is positive
  118882. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118883. */
  118884. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  118885. /**
  118886. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  118887. * @param ray defines the ray to test with
  118888. * @param selection defines the array to store current content if selection is positive
  118889. */
  118890. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  118891. /**
  118892. * Subdivide the content into child blocks (this block will then be empty)
  118893. */
  118894. createInnerBlocks(): void;
  118895. /**
  118896. * @hidden
  118897. */
  118898. 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;
  118899. }
  118900. }
  118901. declare module BABYLON {
  118902. /**
  118903. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  118904. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118905. */
  118906. export class Octree<T> {
  118907. /** 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.) */
  118908. maxDepth: number;
  118909. /**
  118910. * Blocks within the octree containing objects
  118911. */
  118912. blocks: Array<OctreeBlock<T>>;
  118913. /**
  118914. * Content stored in the octree
  118915. */
  118916. dynamicContent: T[];
  118917. private _maxBlockCapacity;
  118918. private _selectionContent;
  118919. private _creationFunc;
  118920. /**
  118921. * Creates a octree
  118922. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118923. * @param creationFunc function to be used to instatiate the octree
  118924. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  118925. * @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.)
  118926. */
  118927. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  118928. /** 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.) */
  118929. maxDepth?: number);
  118930. /**
  118931. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  118932. * @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);
  118933. * @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);
  118934. * @param entries meshes to be added to the octree blocks
  118935. */
  118936. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  118937. /**
  118938. * Adds a mesh to the octree
  118939. * @param entry Mesh to add to the octree
  118940. */
  118941. addMesh(entry: T): void;
  118942. /**
  118943. * Remove an element from the octree
  118944. * @param entry defines the element to remove
  118945. */
  118946. removeMesh(entry: T): void;
  118947. /**
  118948. * Selects an array of meshes within the frustum
  118949. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  118950. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  118951. * @returns array of meshes within the frustum
  118952. */
  118953. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  118954. /**
  118955. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  118956. * @param sphereCenter defines the bounding sphere center
  118957. * @param sphereRadius defines the bounding sphere radius
  118958. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118959. * @returns an array of objects that intersect the sphere
  118960. */
  118961. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  118962. /**
  118963. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  118964. * @param ray defines the ray to test with
  118965. * @returns array of intersected objects
  118966. */
  118967. intersectsRay(ray: Ray): SmartArray<T>;
  118968. /**
  118969. * Adds a mesh into the octree block if it intersects the block
  118970. */
  118971. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  118972. /**
  118973. * Adds a submesh into the octree block if it intersects the block
  118974. */
  118975. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  118976. }
  118977. }
  118978. declare module BABYLON {
  118979. interface Scene {
  118980. /**
  118981. * @hidden
  118982. * Backing Filed
  118983. */
  118984. _selectionOctree: Octree<AbstractMesh>;
  118985. /**
  118986. * Gets the octree used to boost mesh selection (picking)
  118987. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118988. */
  118989. selectionOctree: Octree<AbstractMesh>;
  118990. /**
  118991. * Creates or updates the octree used to boost selection (picking)
  118992. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118993. * @param maxCapacity defines the maximum capacity per leaf
  118994. * @param maxDepth defines the maximum depth of the octree
  118995. * @returns an octree of AbstractMesh
  118996. */
  118997. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  118998. }
  118999. interface AbstractMesh {
  119000. /**
  119001. * @hidden
  119002. * Backing Field
  119003. */
  119004. _submeshesOctree: Octree<SubMesh>;
  119005. /**
  119006. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  119007. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  119008. * @param maxCapacity defines the maximum size of each block (64 by default)
  119009. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  119010. * @returns the new octree
  119011. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  119012. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  119013. */
  119014. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  119015. }
  119016. /**
  119017. * Defines the octree scene component responsible to manage any octrees
  119018. * in a given scene.
  119019. */
  119020. export class OctreeSceneComponent {
  119021. /**
  119022. * The component name help to identify the component in the list of scene components.
  119023. */
  119024. readonly name: string;
  119025. /**
  119026. * The scene the component belongs to.
  119027. */
  119028. scene: Scene;
  119029. /**
  119030. * Indicates if the meshes have been checked to make sure they are isEnabled()
  119031. */
  119032. readonly checksIsEnabled: boolean;
  119033. /**
  119034. * Creates a new instance of the component for the given scene
  119035. * @param scene Defines the scene to register the component in
  119036. */
  119037. constructor(scene: Scene);
  119038. /**
  119039. * Registers the component in a given scene
  119040. */
  119041. register(): void;
  119042. /**
  119043. * Return the list of active meshes
  119044. * @returns the list of active meshes
  119045. */
  119046. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  119047. /**
  119048. * Return the list of active sub meshes
  119049. * @param mesh The mesh to get the candidates sub meshes from
  119050. * @returns the list of active sub meshes
  119051. */
  119052. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  119053. private _tempRay;
  119054. /**
  119055. * Return the list of sub meshes intersecting with a given local ray
  119056. * @param mesh defines the mesh to find the submesh for
  119057. * @param localRay defines the ray in local space
  119058. * @returns the list of intersecting sub meshes
  119059. */
  119060. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  119061. /**
  119062. * Return the list of sub meshes colliding with a collider
  119063. * @param mesh defines the mesh to find the submesh for
  119064. * @param collider defines the collider to evaluate the collision against
  119065. * @returns the list of colliding sub meshes
  119066. */
  119067. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  119068. /**
  119069. * Rebuilds the elements related to this component in case of
  119070. * context lost for instance.
  119071. */
  119072. rebuild(): void;
  119073. /**
  119074. * Disposes the component and the associated ressources.
  119075. */
  119076. dispose(): void;
  119077. }
  119078. }
  119079. declare module BABYLON {
  119080. /**
  119081. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  119082. */
  119083. export class Gizmo implements IDisposable {
  119084. /** The utility layer the gizmo will be added to */
  119085. gizmoLayer: UtilityLayerRenderer;
  119086. /**
  119087. * The root mesh of the gizmo
  119088. */
  119089. _rootMesh: Mesh;
  119090. private _attachedMesh;
  119091. /**
  119092. * Ratio for the scale of the gizmo (Default: 1)
  119093. */
  119094. scaleRatio: number;
  119095. /**
  119096. * If a custom mesh has been set (Default: false)
  119097. */
  119098. protected _customMeshSet: boolean;
  119099. /**
  119100. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  119101. * * When set, interactions will be enabled
  119102. */
  119103. get attachedMesh(): Nullable<AbstractMesh>;
  119104. set attachedMesh(value: Nullable<AbstractMesh>);
  119105. /**
  119106. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  119107. * @param mesh The mesh to replace the default mesh of the gizmo
  119108. */
  119109. setCustomMesh(mesh: Mesh): void;
  119110. /**
  119111. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  119112. */
  119113. updateGizmoRotationToMatchAttachedMesh: boolean;
  119114. /**
  119115. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  119116. */
  119117. updateGizmoPositionToMatchAttachedMesh: boolean;
  119118. /**
  119119. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  119120. */
  119121. updateScale: boolean;
  119122. protected _interactionsEnabled: boolean;
  119123. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119124. private _beforeRenderObserver;
  119125. private _tempVector;
  119126. /**
  119127. * Creates a gizmo
  119128. * @param gizmoLayer The utility layer the gizmo will be added to
  119129. */
  119130. constructor(
  119131. /** The utility layer the gizmo will be added to */
  119132. gizmoLayer?: UtilityLayerRenderer);
  119133. /**
  119134. * Updates the gizmo to match the attached mesh's position/rotation
  119135. */
  119136. protected _update(): void;
  119137. /**
  119138. * Disposes of the gizmo
  119139. */
  119140. dispose(): void;
  119141. }
  119142. }
  119143. declare module BABYLON {
  119144. /**
  119145. * Single plane drag gizmo
  119146. */
  119147. export class PlaneDragGizmo extends Gizmo {
  119148. /**
  119149. * Drag behavior responsible for the gizmos dragging interactions
  119150. */
  119151. dragBehavior: PointerDragBehavior;
  119152. private _pointerObserver;
  119153. /**
  119154. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119155. */
  119156. snapDistance: number;
  119157. /**
  119158. * Event that fires each time the gizmo snaps to a new location.
  119159. * * snapDistance is the the change in distance
  119160. */
  119161. onSnapObservable: Observable<{
  119162. snapDistance: number;
  119163. }>;
  119164. private _plane;
  119165. private _coloredMaterial;
  119166. private _hoverMaterial;
  119167. private _isEnabled;
  119168. private _parent;
  119169. /** @hidden */
  119170. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  119171. /** @hidden */
  119172. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  119173. /**
  119174. * Creates a PlaneDragGizmo
  119175. * @param gizmoLayer The utility layer the gizmo will be added to
  119176. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  119177. * @param color The color of the gizmo
  119178. */
  119179. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  119180. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119181. /**
  119182. * If the gizmo is enabled
  119183. */
  119184. set isEnabled(value: boolean);
  119185. get isEnabled(): boolean;
  119186. /**
  119187. * Disposes of the gizmo
  119188. */
  119189. dispose(): void;
  119190. }
  119191. }
  119192. declare module BABYLON {
  119193. /**
  119194. * Gizmo that enables dragging a mesh along 3 axis
  119195. */
  119196. export class PositionGizmo extends Gizmo {
  119197. /**
  119198. * Internal gizmo used for interactions on the x axis
  119199. */
  119200. xGizmo: AxisDragGizmo;
  119201. /**
  119202. * Internal gizmo used for interactions on the y axis
  119203. */
  119204. yGizmo: AxisDragGizmo;
  119205. /**
  119206. * Internal gizmo used for interactions on the z axis
  119207. */
  119208. zGizmo: AxisDragGizmo;
  119209. /**
  119210. * Internal gizmo used for interactions on the yz plane
  119211. */
  119212. xPlaneGizmo: PlaneDragGizmo;
  119213. /**
  119214. * Internal gizmo used for interactions on the xz plane
  119215. */
  119216. yPlaneGizmo: PlaneDragGizmo;
  119217. /**
  119218. * Internal gizmo used for interactions on the xy plane
  119219. */
  119220. zPlaneGizmo: PlaneDragGizmo;
  119221. /**
  119222. * private variables
  119223. */
  119224. private _meshAttached;
  119225. private _updateGizmoRotationToMatchAttachedMesh;
  119226. private _snapDistance;
  119227. private _scaleRatio;
  119228. /** Fires an event when any of it's sub gizmos are dragged */
  119229. onDragStartObservable: Observable<unknown>;
  119230. /** Fires an event when any of it's sub gizmos are released from dragging */
  119231. onDragEndObservable: Observable<unknown>;
  119232. /**
  119233. * If set to true, planar drag is enabled
  119234. */
  119235. private _planarGizmoEnabled;
  119236. get attachedMesh(): Nullable<AbstractMesh>;
  119237. set attachedMesh(mesh: Nullable<AbstractMesh>);
  119238. /**
  119239. * Creates a PositionGizmo
  119240. * @param gizmoLayer The utility layer the gizmo will be added to
  119241. */
  119242. constructor(gizmoLayer?: UtilityLayerRenderer);
  119243. /**
  119244. * If the planar drag gizmo is enabled
  119245. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  119246. */
  119247. set planarGizmoEnabled(value: boolean);
  119248. get planarGizmoEnabled(): boolean;
  119249. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  119250. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  119251. /**
  119252. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119253. */
  119254. set snapDistance(value: number);
  119255. get snapDistance(): number;
  119256. /**
  119257. * Ratio for the scale of the gizmo (Default: 1)
  119258. */
  119259. set scaleRatio(value: number);
  119260. get scaleRatio(): number;
  119261. /**
  119262. * Disposes of the gizmo
  119263. */
  119264. dispose(): void;
  119265. /**
  119266. * CustomMeshes are not supported by this gizmo
  119267. * @param mesh The mesh to replace the default mesh of the gizmo
  119268. */
  119269. setCustomMesh(mesh: Mesh): void;
  119270. }
  119271. }
  119272. declare module BABYLON {
  119273. /**
  119274. * Single axis drag gizmo
  119275. */
  119276. export class AxisDragGizmo extends Gizmo {
  119277. /**
  119278. * Drag behavior responsible for the gizmos dragging interactions
  119279. */
  119280. dragBehavior: PointerDragBehavior;
  119281. private _pointerObserver;
  119282. /**
  119283. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119284. */
  119285. snapDistance: number;
  119286. /**
  119287. * Event that fires each time the gizmo snaps to a new location.
  119288. * * snapDistance is the the change in distance
  119289. */
  119290. onSnapObservable: Observable<{
  119291. snapDistance: number;
  119292. }>;
  119293. private _isEnabled;
  119294. private _parent;
  119295. private _arrow;
  119296. private _coloredMaterial;
  119297. private _hoverMaterial;
  119298. /** @hidden */
  119299. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  119300. /** @hidden */
  119301. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  119302. /**
  119303. * Creates an AxisDragGizmo
  119304. * @param gizmoLayer The utility layer the gizmo will be added to
  119305. * @param dragAxis The axis which the gizmo will be able to drag on
  119306. * @param color The color of the gizmo
  119307. */
  119308. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  119309. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119310. /**
  119311. * If the gizmo is enabled
  119312. */
  119313. set isEnabled(value: boolean);
  119314. get isEnabled(): boolean;
  119315. /**
  119316. * Disposes of the gizmo
  119317. */
  119318. dispose(): void;
  119319. }
  119320. }
  119321. declare module BABYLON.Debug {
  119322. /**
  119323. * The Axes viewer will show 3 axes in a specific point in space
  119324. */
  119325. export class AxesViewer {
  119326. private _xAxis;
  119327. private _yAxis;
  119328. private _zAxis;
  119329. private _scaleLinesFactor;
  119330. private _instanced;
  119331. /**
  119332. * Gets the hosting scene
  119333. */
  119334. scene: Scene;
  119335. /**
  119336. * Gets or sets a number used to scale line length
  119337. */
  119338. scaleLines: number;
  119339. /** Gets the node hierarchy used to render x-axis */
  119340. get xAxis(): TransformNode;
  119341. /** Gets the node hierarchy used to render y-axis */
  119342. get yAxis(): TransformNode;
  119343. /** Gets the node hierarchy used to render z-axis */
  119344. get zAxis(): TransformNode;
  119345. /**
  119346. * Creates a new AxesViewer
  119347. * @param scene defines the hosting scene
  119348. * @param scaleLines defines a number used to scale line length (1 by default)
  119349. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  119350. * @param xAxis defines the node hierarchy used to render the x-axis
  119351. * @param yAxis defines the node hierarchy used to render the y-axis
  119352. * @param zAxis defines the node hierarchy used to render the z-axis
  119353. */
  119354. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  119355. /**
  119356. * Force the viewer to update
  119357. * @param position defines the position of the viewer
  119358. * @param xaxis defines the x axis of the viewer
  119359. * @param yaxis defines the y axis of the viewer
  119360. * @param zaxis defines the z axis of the viewer
  119361. */
  119362. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  119363. /**
  119364. * Creates an instance of this axes viewer.
  119365. * @returns a new axes viewer with instanced meshes
  119366. */
  119367. createInstance(): AxesViewer;
  119368. /** Releases resources */
  119369. dispose(): void;
  119370. private static _SetRenderingGroupId;
  119371. }
  119372. }
  119373. declare module BABYLON.Debug {
  119374. /**
  119375. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  119376. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  119377. */
  119378. export class BoneAxesViewer extends AxesViewer {
  119379. /**
  119380. * Gets or sets the target mesh where to display the axes viewer
  119381. */
  119382. mesh: Nullable<Mesh>;
  119383. /**
  119384. * Gets or sets the target bone where to display the axes viewer
  119385. */
  119386. bone: Nullable<Bone>;
  119387. /** Gets current position */
  119388. pos: Vector3;
  119389. /** Gets direction of X axis */
  119390. xaxis: Vector3;
  119391. /** Gets direction of Y axis */
  119392. yaxis: Vector3;
  119393. /** Gets direction of Z axis */
  119394. zaxis: Vector3;
  119395. /**
  119396. * Creates a new BoneAxesViewer
  119397. * @param scene defines the hosting scene
  119398. * @param bone defines the target bone
  119399. * @param mesh defines the target mesh
  119400. * @param scaleLines defines a scaling factor for line length (1 by default)
  119401. */
  119402. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  119403. /**
  119404. * Force the viewer to update
  119405. */
  119406. update(): void;
  119407. /** Releases resources */
  119408. dispose(): void;
  119409. }
  119410. }
  119411. declare module BABYLON {
  119412. /**
  119413. * Interface used to define scene explorer extensibility option
  119414. */
  119415. export interface IExplorerExtensibilityOption {
  119416. /**
  119417. * Define the option label
  119418. */
  119419. label: string;
  119420. /**
  119421. * Defines the action to execute on click
  119422. */
  119423. action: (entity: any) => void;
  119424. }
  119425. /**
  119426. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  119427. */
  119428. export interface IExplorerExtensibilityGroup {
  119429. /**
  119430. * Defines a predicate to test if a given type mut be extended
  119431. */
  119432. predicate: (entity: any) => boolean;
  119433. /**
  119434. * Gets the list of options added to a type
  119435. */
  119436. entries: IExplorerExtensibilityOption[];
  119437. }
  119438. /**
  119439. * Interface used to define the options to use to create the Inspector
  119440. */
  119441. export interface IInspectorOptions {
  119442. /**
  119443. * Display in overlay mode (default: false)
  119444. */
  119445. overlay?: boolean;
  119446. /**
  119447. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  119448. */
  119449. globalRoot?: HTMLElement;
  119450. /**
  119451. * Display the Scene explorer
  119452. */
  119453. showExplorer?: boolean;
  119454. /**
  119455. * Display the property inspector
  119456. */
  119457. showInspector?: boolean;
  119458. /**
  119459. * Display in embed mode (both panes on the right)
  119460. */
  119461. embedMode?: boolean;
  119462. /**
  119463. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  119464. */
  119465. handleResize?: boolean;
  119466. /**
  119467. * Allow the panes to popup (default: true)
  119468. */
  119469. enablePopup?: boolean;
  119470. /**
  119471. * Allow the panes to be closed by users (default: true)
  119472. */
  119473. enableClose?: boolean;
  119474. /**
  119475. * Optional list of extensibility entries
  119476. */
  119477. explorerExtensibility?: IExplorerExtensibilityGroup[];
  119478. /**
  119479. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  119480. */
  119481. inspectorURL?: string;
  119482. /**
  119483. * Optional initial tab (default to DebugLayerTab.Properties)
  119484. */
  119485. initialTab?: DebugLayerTab;
  119486. }
  119487. interface Scene {
  119488. /**
  119489. * @hidden
  119490. * Backing field
  119491. */
  119492. _debugLayer: DebugLayer;
  119493. /**
  119494. * Gets the debug layer (aka Inspector) associated with the scene
  119495. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119496. */
  119497. debugLayer: DebugLayer;
  119498. }
  119499. /**
  119500. * Enum of inspector action tab
  119501. */
  119502. export enum DebugLayerTab {
  119503. /**
  119504. * Properties tag (default)
  119505. */
  119506. Properties = 0,
  119507. /**
  119508. * Debug tab
  119509. */
  119510. Debug = 1,
  119511. /**
  119512. * Statistics tab
  119513. */
  119514. Statistics = 2,
  119515. /**
  119516. * Tools tab
  119517. */
  119518. Tools = 3,
  119519. /**
  119520. * Settings tab
  119521. */
  119522. Settings = 4
  119523. }
  119524. /**
  119525. * The debug layer (aka Inspector) is the go to tool in order to better understand
  119526. * what is happening in your scene
  119527. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119528. */
  119529. export class DebugLayer {
  119530. /**
  119531. * Define the url to get the inspector script from.
  119532. * By default it uses the babylonjs CDN.
  119533. * @ignoreNaming
  119534. */
  119535. static InspectorURL: string;
  119536. private _scene;
  119537. private BJSINSPECTOR;
  119538. private _onPropertyChangedObservable?;
  119539. /**
  119540. * Observable triggered when a property is changed through the inspector.
  119541. */
  119542. get onPropertyChangedObservable(): any;
  119543. /**
  119544. * Instantiates a new debug layer.
  119545. * The debug layer (aka Inspector) is the go to tool in order to better understand
  119546. * what is happening in your scene
  119547. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119548. * @param scene Defines the scene to inspect
  119549. */
  119550. constructor(scene: Scene);
  119551. /** Creates the inspector window. */
  119552. private _createInspector;
  119553. /**
  119554. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  119555. * @param entity defines the entity to select
  119556. * @param lineContainerTitle defines the specific block to highlight
  119557. */
  119558. select(entity: any, lineContainerTitle?: string): void;
  119559. /** Get the inspector from bundle or global */
  119560. private _getGlobalInspector;
  119561. /**
  119562. * Get if the inspector is visible or not.
  119563. * @returns true if visible otherwise, false
  119564. */
  119565. isVisible(): boolean;
  119566. /**
  119567. * Hide the inspector and close its window.
  119568. */
  119569. hide(): void;
  119570. /**
  119571. * Launch the debugLayer.
  119572. * @param config Define the configuration of the inspector
  119573. * @return a promise fulfilled when the debug layer is visible
  119574. */
  119575. show(config?: IInspectorOptions): Promise<DebugLayer>;
  119576. }
  119577. }
  119578. declare module BABYLON {
  119579. /**
  119580. * Class containing static functions to help procedurally build meshes
  119581. */
  119582. export class BoxBuilder {
  119583. /**
  119584. * Creates a box mesh
  119585. * * The parameter `size` sets the size (float) of each box side (default 1)
  119586. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  119587. * * 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)
  119588. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  119589. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119590. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119591. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119592. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  119593. * @param name defines the name of the mesh
  119594. * @param options defines the options used to create the mesh
  119595. * @param scene defines the hosting scene
  119596. * @returns the box mesh
  119597. */
  119598. static CreateBox(name: string, options: {
  119599. size?: number;
  119600. width?: number;
  119601. height?: number;
  119602. depth?: number;
  119603. faceUV?: Vector4[];
  119604. faceColors?: Color4[];
  119605. sideOrientation?: number;
  119606. frontUVs?: Vector4;
  119607. backUVs?: Vector4;
  119608. wrap?: boolean;
  119609. topBaseAt?: number;
  119610. bottomBaseAt?: number;
  119611. updatable?: boolean;
  119612. }, scene?: Nullable<Scene>): Mesh;
  119613. }
  119614. }
  119615. declare module BABYLON.Debug {
  119616. /**
  119617. * Used to show the physics impostor around the specific mesh
  119618. */
  119619. export class PhysicsViewer {
  119620. /** @hidden */
  119621. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  119622. /** @hidden */
  119623. protected _meshes: Array<Nullable<AbstractMesh>>;
  119624. /** @hidden */
  119625. protected _scene: Nullable<Scene>;
  119626. /** @hidden */
  119627. protected _numMeshes: number;
  119628. /** @hidden */
  119629. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  119630. private _renderFunction;
  119631. private _utilityLayer;
  119632. private _debugBoxMesh;
  119633. private _debugSphereMesh;
  119634. private _debugCylinderMesh;
  119635. private _debugMaterial;
  119636. private _debugMeshMeshes;
  119637. /**
  119638. * Creates a new PhysicsViewer
  119639. * @param scene defines the hosting scene
  119640. */
  119641. constructor(scene: Scene);
  119642. /** @hidden */
  119643. protected _updateDebugMeshes(): void;
  119644. /**
  119645. * Renders a specified physic impostor
  119646. * @param impostor defines the impostor to render
  119647. * @param targetMesh defines the mesh represented by the impostor
  119648. * @returns the new debug mesh used to render the impostor
  119649. */
  119650. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  119651. /**
  119652. * Hides a specified physic impostor
  119653. * @param impostor defines the impostor to hide
  119654. */
  119655. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  119656. private _getDebugMaterial;
  119657. private _getDebugBoxMesh;
  119658. private _getDebugSphereMesh;
  119659. private _getDebugCylinderMesh;
  119660. private _getDebugMeshMesh;
  119661. private _getDebugMesh;
  119662. /** Releases all resources */
  119663. dispose(): void;
  119664. }
  119665. }
  119666. declare module BABYLON {
  119667. /**
  119668. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  119669. * in order to better appreciate the issue one might have.
  119670. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  119671. */
  119672. export class RayHelper {
  119673. /**
  119674. * Defines the ray we are currently tryin to visualize.
  119675. */
  119676. ray: Nullable<Ray>;
  119677. private _renderPoints;
  119678. private _renderLine;
  119679. private _renderFunction;
  119680. private _scene;
  119681. private _updateToMeshFunction;
  119682. private _attachedToMesh;
  119683. private _meshSpaceDirection;
  119684. private _meshSpaceOrigin;
  119685. /**
  119686. * Helper function to create a colored helper in a scene in one line.
  119687. * @param ray Defines the ray we are currently tryin to visualize
  119688. * @param scene Defines the scene the ray is used in
  119689. * @param color Defines the color we want to see the ray in
  119690. * @returns The newly created ray helper.
  119691. */
  119692. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  119693. /**
  119694. * Instantiate a new ray helper.
  119695. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  119696. * in order to better appreciate the issue one might have.
  119697. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  119698. * @param ray Defines the ray we are currently tryin to visualize
  119699. */
  119700. constructor(ray: Ray);
  119701. /**
  119702. * Shows the ray we are willing to debug.
  119703. * @param scene Defines the scene the ray needs to be rendered in
  119704. * @param color Defines the color the ray needs to be rendered in
  119705. */
  119706. show(scene: Scene, color?: Color3): void;
  119707. /**
  119708. * Hides the ray we are debugging.
  119709. */
  119710. hide(): void;
  119711. private _render;
  119712. /**
  119713. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  119714. * @param mesh Defines the mesh we want the helper attached to
  119715. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  119716. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  119717. * @param length Defines the length of the ray
  119718. */
  119719. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  119720. /**
  119721. * Detach the ray helper from the mesh it has previously been attached to.
  119722. */
  119723. detachFromMesh(): void;
  119724. private _updateToMesh;
  119725. /**
  119726. * Dispose the helper and release its associated resources.
  119727. */
  119728. dispose(): void;
  119729. }
  119730. }
  119731. declare module BABYLON.Debug {
  119732. /**
  119733. * Class used to render a debug view of a given skeleton
  119734. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  119735. */
  119736. export class SkeletonViewer {
  119737. /** defines the skeleton to render */
  119738. skeleton: Skeleton;
  119739. /** defines the mesh attached to the skeleton */
  119740. mesh: AbstractMesh;
  119741. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  119742. autoUpdateBonesMatrices: boolean;
  119743. /** defines the rendering group id to use with the viewer */
  119744. renderingGroupId: number;
  119745. /** Gets or sets the color used to render the skeleton */
  119746. color: Color3;
  119747. private _scene;
  119748. private _debugLines;
  119749. private _debugMesh;
  119750. private _isEnabled;
  119751. private _renderFunction;
  119752. private _utilityLayer;
  119753. /**
  119754. * Returns the mesh used to render the bones
  119755. */
  119756. get debugMesh(): Nullable<LinesMesh>;
  119757. /**
  119758. * Creates a new SkeletonViewer
  119759. * @param skeleton defines the skeleton to render
  119760. * @param mesh defines the mesh attached to the skeleton
  119761. * @param scene defines the hosting scene
  119762. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  119763. * @param renderingGroupId defines the rendering group id to use with the viewer
  119764. */
  119765. constructor(
  119766. /** defines the skeleton to render */
  119767. skeleton: Skeleton,
  119768. /** defines the mesh attached to the skeleton */
  119769. mesh: AbstractMesh, scene: Scene,
  119770. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  119771. autoUpdateBonesMatrices?: boolean,
  119772. /** defines the rendering group id to use with the viewer */
  119773. renderingGroupId?: number);
  119774. /** Gets or sets a boolean indicating if the viewer is enabled */
  119775. set isEnabled(value: boolean);
  119776. get isEnabled(): boolean;
  119777. private _getBonePosition;
  119778. private _getLinesForBonesWithLength;
  119779. private _getLinesForBonesNoLength;
  119780. /** Update the viewer to sync with current skeleton state */
  119781. update(): void;
  119782. /** Release associated resources */
  119783. dispose(): void;
  119784. }
  119785. }
  119786. declare module BABYLON {
  119787. /**
  119788. * Options to create the null engine
  119789. */
  119790. export class NullEngineOptions {
  119791. /**
  119792. * Render width (Default: 512)
  119793. */
  119794. renderWidth: number;
  119795. /**
  119796. * Render height (Default: 256)
  119797. */
  119798. renderHeight: number;
  119799. /**
  119800. * Texture size (Default: 512)
  119801. */
  119802. textureSize: number;
  119803. /**
  119804. * If delta time between frames should be constant
  119805. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119806. */
  119807. deterministicLockstep: boolean;
  119808. /**
  119809. * Maximum about of steps between frames (Default: 4)
  119810. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119811. */
  119812. lockstepMaxSteps: number;
  119813. }
  119814. /**
  119815. * The null engine class provides support for headless version of babylon.js.
  119816. * This can be used in server side scenario or for testing purposes
  119817. */
  119818. export class NullEngine extends Engine {
  119819. private _options;
  119820. /**
  119821. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  119822. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119823. * @returns true if engine is in deterministic lock step mode
  119824. */
  119825. isDeterministicLockStep(): boolean;
  119826. /**
  119827. * Gets the max steps when engine is running in deterministic lock step
  119828. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119829. * @returns the max steps
  119830. */
  119831. getLockstepMaxSteps(): number;
  119832. /**
  119833. * Gets the current hardware scaling level.
  119834. * By default the hardware scaling level is computed from the window device ratio.
  119835. * 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.
  119836. * @returns a number indicating the current hardware scaling level
  119837. */
  119838. getHardwareScalingLevel(): number;
  119839. constructor(options?: NullEngineOptions);
  119840. /**
  119841. * Creates a vertex buffer
  119842. * @param vertices the data for the vertex buffer
  119843. * @returns the new WebGL static buffer
  119844. */
  119845. createVertexBuffer(vertices: FloatArray): DataBuffer;
  119846. /**
  119847. * Creates a new index buffer
  119848. * @param indices defines the content of the index buffer
  119849. * @param updatable defines if the index buffer must be updatable
  119850. * @returns a new webGL buffer
  119851. */
  119852. createIndexBuffer(indices: IndicesArray): DataBuffer;
  119853. /**
  119854. * Clear the current render buffer or the current render target (if any is set up)
  119855. * @param color defines the color to use
  119856. * @param backBuffer defines if the back buffer must be cleared
  119857. * @param depth defines if the depth buffer must be cleared
  119858. * @param stencil defines if the stencil buffer must be cleared
  119859. */
  119860. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  119861. /**
  119862. * Gets the current render width
  119863. * @param useScreen defines if screen size must be used (or the current render target if any)
  119864. * @returns a number defining the current render width
  119865. */
  119866. getRenderWidth(useScreen?: boolean): number;
  119867. /**
  119868. * Gets the current render height
  119869. * @param useScreen defines if screen size must be used (or the current render target if any)
  119870. * @returns a number defining the current render height
  119871. */
  119872. getRenderHeight(useScreen?: boolean): number;
  119873. /**
  119874. * Set the WebGL's viewport
  119875. * @param viewport defines the viewport element to be used
  119876. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  119877. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  119878. */
  119879. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  119880. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  119881. /**
  119882. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  119883. * @param pipelineContext defines the pipeline context to use
  119884. * @param uniformsNames defines the list of uniform names
  119885. * @returns an array of webGL uniform locations
  119886. */
  119887. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  119888. /**
  119889. * Gets the lsit of active attributes for a given webGL program
  119890. * @param pipelineContext defines the pipeline context to use
  119891. * @param attributesNames defines the list of attribute names to get
  119892. * @returns an array of indices indicating the offset of each attribute
  119893. */
  119894. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  119895. /**
  119896. * Binds an effect to the webGL context
  119897. * @param effect defines the effect to bind
  119898. */
  119899. bindSamplers(effect: Effect): void;
  119900. /**
  119901. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  119902. * @param effect defines the effect to activate
  119903. */
  119904. enableEffect(effect: Effect): void;
  119905. /**
  119906. * Set various states to the webGL context
  119907. * @param culling defines backface culling state
  119908. * @param zOffset defines the value to apply to zOffset (0 by default)
  119909. * @param force defines if states must be applied even if cache is up to date
  119910. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  119911. */
  119912. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  119913. /**
  119914. * Set the value of an uniform to an array of int32
  119915. * @param uniform defines the webGL uniform location where to store the value
  119916. * @param array defines the array of int32 to store
  119917. */
  119918. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  119919. /**
  119920. * Set the value of an uniform to an array of int32 (stored as vec2)
  119921. * @param uniform defines the webGL uniform location where to store the value
  119922. * @param array defines the array of int32 to store
  119923. */
  119924. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  119925. /**
  119926. * Set the value of an uniform to an array of int32 (stored as vec3)
  119927. * @param uniform defines the webGL uniform location where to store the value
  119928. * @param array defines the array of int32 to store
  119929. */
  119930. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  119931. /**
  119932. * Set the value of an uniform to an array of int32 (stored as vec4)
  119933. * @param uniform defines the webGL uniform location where to store the value
  119934. * @param array defines the array of int32 to store
  119935. */
  119936. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  119937. /**
  119938. * Set the value of an uniform to an array of float32
  119939. * @param uniform defines the webGL uniform location where to store the value
  119940. * @param array defines the array of float32 to store
  119941. */
  119942. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  119943. /**
  119944. * Set the value of an uniform to an array of float32 (stored as vec2)
  119945. * @param uniform defines the webGL uniform location where to store the value
  119946. * @param array defines the array of float32 to store
  119947. */
  119948. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  119949. /**
  119950. * Set the value of an uniform to an array of float32 (stored as vec3)
  119951. * @param uniform defines the webGL uniform location where to store the value
  119952. * @param array defines the array of float32 to store
  119953. */
  119954. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  119955. /**
  119956. * Set the value of an uniform to an array of float32 (stored as vec4)
  119957. * @param uniform defines the webGL uniform location where to store the value
  119958. * @param array defines the array of float32 to store
  119959. */
  119960. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  119961. /**
  119962. * Set the value of an uniform to an array of number
  119963. * @param uniform defines the webGL uniform location where to store the value
  119964. * @param array defines the array of number to store
  119965. */
  119966. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  119967. /**
  119968. * Set the value of an uniform to an array of number (stored as vec2)
  119969. * @param uniform defines the webGL uniform location where to store the value
  119970. * @param array defines the array of number to store
  119971. */
  119972. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  119973. /**
  119974. * Set the value of an uniform to an array of number (stored as vec3)
  119975. * @param uniform defines the webGL uniform location where to store the value
  119976. * @param array defines the array of number to store
  119977. */
  119978. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  119979. /**
  119980. * Set the value of an uniform to an array of number (stored as vec4)
  119981. * @param uniform defines the webGL uniform location where to store the value
  119982. * @param array defines the array of number to store
  119983. */
  119984. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  119985. /**
  119986. * Set the value of an uniform to an array of float32 (stored as matrices)
  119987. * @param uniform defines the webGL uniform location where to store the value
  119988. * @param matrices defines the array of float32 to store
  119989. */
  119990. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  119991. /**
  119992. * Set the value of an uniform to a matrix (3x3)
  119993. * @param uniform defines the webGL uniform location where to store the value
  119994. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  119995. */
  119996. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  119997. /**
  119998. * Set the value of an uniform to a matrix (2x2)
  119999. * @param uniform defines the webGL uniform location where to store the value
  120000. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  120001. */
  120002. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  120003. /**
  120004. * Set the value of an uniform to a number (float)
  120005. * @param uniform defines the webGL uniform location where to store the value
  120006. * @param value defines the float number to store
  120007. */
  120008. setFloat(uniform: WebGLUniformLocation, value: number): void;
  120009. /**
  120010. * Set the value of an uniform to a vec2
  120011. * @param uniform defines the webGL uniform location where to store the value
  120012. * @param x defines the 1st component of the value
  120013. * @param y defines the 2nd component of the value
  120014. */
  120015. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  120016. /**
  120017. * Set the value of an uniform to a vec3
  120018. * @param uniform defines the webGL uniform location where to store the value
  120019. * @param x defines the 1st component of the value
  120020. * @param y defines the 2nd component of the value
  120021. * @param z defines the 3rd component of the value
  120022. */
  120023. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  120024. /**
  120025. * Set the value of an uniform to a boolean
  120026. * @param uniform defines the webGL uniform location where to store the value
  120027. * @param bool defines the boolean to store
  120028. */
  120029. setBool(uniform: WebGLUniformLocation, bool: number): void;
  120030. /**
  120031. * Set the value of an uniform to a vec4
  120032. * @param uniform defines the webGL uniform location where to store the value
  120033. * @param x defines the 1st component of the value
  120034. * @param y defines the 2nd component of the value
  120035. * @param z defines the 3rd component of the value
  120036. * @param w defines the 4th component of the value
  120037. */
  120038. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  120039. /**
  120040. * Sets the current alpha mode
  120041. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  120042. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  120043. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  120044. */
  120045. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  120046. /**
  120047. * Bind webGl buffers directly to the webGL context
  120048. * @param vertexBuffers defines the vertex buffer to bind
  120049. * @param indexBuffer defines the index buffer to bind
  120050. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  120051. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  120052. * @param effect defines the effect associated with the vertex buffer
  120053. */
  120054. bindBuffers(vertexBuffers: {
  120055. [key: string]: VertexBuffer;
  120056. }, indexBuffer: DataBuffer, effect: Effect): void;
  120057. /**
  120058. * Force the entire cache to be cleared
  120059. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  120060. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  120061. */
  120062. wipeCaches(bruteForce?: boolean): void;
  120063. /**
  120064. * Send a draw order
  120065. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  120066. * @param indexStart defines the starting index
  120067. * @param indexCount defines the number of index to draw
  120068. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120069. */
  120070. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  120071. /**
  120072. * Draw a list of indexed primitives
  120073. * @param fillMode defines the primitive to use
  120074. * @param indexStart defines the starting index
  120075. * @param indexCount defines the number of index to draw
  120076. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120077. */
  120078. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  120079. /**
  120080. * Draw a list of unindexed primitives
  120081. * @param fillMode defines the primitive to use
  120082. * @param verticesStart defines the index of first vertex to draw
  120083. * @param verticesCount defines the count of vertices to draw
  120084. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120085. */
  120086. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  120087. /** @hidden */
  120088. _createTexture(): WebGLTexture;
  120089. /** @hidden */
  120090. _releaseTexture(texture: InternalTexture): void;
  120091. /**
  120092. * Usually called from Texture.ts.
  120093. * Passed information to create a WebGLTexture
  120094. * @param urlArg defines a value which contains one of the following:
  120095. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  120096. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  120097. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  120098. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  120099. * @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)
  120100. * @param scene needed for loading to the correct scene
  120101. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  120102. * @param onLoad optional callback to be called upon successful completion
  120103. * @param onError optional callback to be called upon failure
  120104. * @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
  120105. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  120106. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  120107. * @param forcedExtension defines the extension to use to pick the right loader
  120108. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  120109. * @returns a InternalTexture for assignment back into BABYLON.Texture
  120110. */
  120111. 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;
  120112. /**
  120113. * Creates a new render target texture
  120114. * @param size defines the size of the texture
  120115. * @param options defines the options used to create the texture
  120116. * @returns a new render target texture stored in an InternalTexture
  120117. */
  120118. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  120119. /**
  120120. * Update the sampling mode of a given texture
  120121. * @param samplingMode defines the required sampling mode
  120122. * @param texture defines the texture to update
  120123. */
  120124. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  120125. /**
  120126. * Binds the frame buffer to the specified texture.
  120127. * @param texture The texture to render to or null for the default canvas
  120128. * @param faceIndex The face of the texture to render to in case of cube texture
  120129. * @param requiredWidth The width of the target to render to
  120130. * @param requiredHeight The height of the target to render to
  120131. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  120132. * @param lodLevel defines le lod level to bind to the frame buffer
  120133. */
  120134. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  120135. /**
  120136. * Unbind the current render target texture from the webGL context
  120137. * @param texture defines the render target texture to unbind
  120138. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  120139. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  120140. */
  120141. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  120142. /**
  120143. * Creates a dynamic vertex buffer
  120144. * @param vertices the data for the dynamic vertex buffer
  120145. * @returns the new WebGL dynamic buffer
  120146. */
  120147. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  120148. /**
  120149. * Update the content of a dynamic texture
  120150. * @param texture defines the texture to update
  120151. * @param canvas defines the canvas containing the source
  120152. * @param invertY defines if data must be stored with Y axis inverted
  120153. * @param premulAlpha defines if alpha is stored as premultiplied
  120154. * @param format defines the format of the data
  120155. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  120156. */
  120157. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  120158. /**
  120159. * Gets a boolean indicating if all created effects are ready
  120160. * @returns true if all effects are ready
  120161. */
  120162. areAllEffectsReady(): boolean;
  120163. /**
  120164. * @hidden
  120165. * Get the current error code of the webGL context
  120166. * @returns the error code
  120167. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  120168. */
  120169. getError(): number;
  120170. /** @hidden */
  120171. _getUnpackAlignement(): number;
  120172. /** @hidden */
  120173. _unpackFlipY(value: boolean): void;
  120174. /**
  120175. * Update a dynamic index buffer
  120176. * @param indexBuffer defines the target index buffer
  120177. * @param indices defines the data to update
  120178. * @param offset defines the offset in the target index buffer where update should start
  120179. */
  120180. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  120181. /**
  120182. * Updates a dynamic vertex buffer.
  120183. * @param vertexBuffer the vertex buffer to update
  120184. * @param vertices the data used to update the vertex buffer
  120185. * @param byteOffset the byte offset of the data (optional)
  120186. * @param byteLength the byte length of the data (optional)
  120187. */
  120188. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  120189. /** @hidden */
  120190. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  120191. /** @hidden */
  120192. _bindTexture(channel: number, texture: InternalTexture): void;
  120193. protected _deleteBuffer(buffer: WebGLBuffer): void;
  120194. /**
  120195. * 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
  120196. */
  120197. releaseEffects(): void;
  120198. displayLoadingUI(): void;
  120199. hideLoadingUI(): void;
  120200. /** @hidden */
  120201. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120202. /** @hidden */
  120203. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120204. /** @hidden */
  120205. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120206. /** @hidden */
  120207. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  120208. }
  120209. }
  120210. declare module BABYLON {
  120211. /**
  120212. * @hidden
  120213. **/
  120214. export class _TimeToken {
  120215. _startTimeQuery: Nullable<WebGLQuery>;
  120216. _endTimeQuery: Nullable<WebGLQuery>;
  120217. _timeElapsedQuery: Nullable<WebGLQuery>;
  120218. _timeElapsedQueryEnded: boolean;
  120219. }
  120220. }
  120221. declare module BABYLON {
  120222. /** @hidden */
  120223. export class _OcclusionDataStorage {
  120224. /** @hidden */
  120225. occlusionInternalRetryCounter: number;
  120226. /** @hidden */
  120227. isOcclusionQueryInProgress: boolean;
  120228. /** @hidden */
  120229. isOccluded: boolean;
  120230. /** @hidden */
  120231. occlusionRetryCount: number;
  120232. /** @hidden */
  120233. occlusionType: number;
  120234. /** @hidden */
  120235. occlusionQueryAlgorithmType: number;
  120236. }
  120237. interface Engine {
  120238. /**
  120239. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  120240. * @return the new query
  120241. */
  120242. createQuery(): WebGLQuery;
  120243. /**
  120244. * Delete and release a webGL query
  120245. * @param query defines the query to delete
  120246. * @return the current engine
  120247. */
  120248. deleteQuery(query: WebGLQuery): Engine;
  120249. /**
  120250. * Check if a given query has resolved and got its value
  120251. * @param query defines the query to check
  120252. * @returns true if the query got its value
  120253. */
  120254. isQueryResultAvailable(query: WebGLQuery): boolean;
  120255. /**
  120256. * Gets the value of a given query
  120257. * @param query defines the query to check
  120258. * @returns the value of the query
  120259. */
  120260. getQueryResult(query: WebGLQuery): number;
  120261. /**
  120262. * Initiates an occlusion query
  120263. * @param algorithmType defines the algorithm to use
  120264. * @param query defines the query to use
  120265. * @returns the current engine
  120266. * @see http://doc.babylonjs.com/features/occlusionquery
  120267. */
  120268. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  120269. /**
  120270. * Ends an occlusion query
  120271. * @see http://doc.babylonjs.com/features/occlusionquery
  120272. * @param algorithmType defines the algorithm to use
  120273. * @returns the current engine
  120274. */
  120275. endOcclusionQuery(algorithmType: number): Engine;
  120276. /**
  120277. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  120278. * Please note that only one query can be issued at a time
  120279. * @returns a time token used to track the time span
  120280. */
  120281. startTimeQuery(): Nullable<_TimeToken>;
  120282. /**
  120283. * Ends a time query
  120284. * @param token defines the token used to measure the time span
  120285. * @returns the time spent (in ns)
  120286. */
  120287. endTimeQuery(token: _TimeToken): int;
  120288. /** @hidden */
  120289. _currentNonTimestampToken: Nullable<_TimeToken>;
  120290. /** @hidden */
  120291. _createTimeQuery(): WebGLQuery;
  120292. /** @hidden */
  120293. _deleteTimeQuery(query: WebGLQuery): void;
  120294. /** @hidden */
  120295. _getGlAlgorithmType(algorithmType: number): number;
  120296. /** @hidden */
  120297. _getTimeQueryResult(query: WebGLQuery): any;
  120298. /** @hidden */
  120299. _getTimeQueryAvailability(query: WebGLQuery): any;
  120300. }
  120301. interface AbstractMesh {
  120302. /**
  120303. * Backing filed
  120304. * @hidden
  120305. */
  120306. __occlusionDataStorage: _OcclusionDataStorage;
  120307. /**
  120308. * Access property
  120309. * @hidden
  120310. */
  120311. _occlusionDataStorage: _OcclusionDataStorage;
  120312. /**
  120313. * 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.
  120314. * The default value is -1 which means don't break the query and wait till the result
  120315. * @see http://doc.babylonjs.com/features/occlusionquery
  120316. */
  120317. occlusionRetryCount: number;
  120318. /**
  120319. * 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:
  120320. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  120321. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  120322. * * 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.
  120323. * @see http://doc.babylonjs.com/features/occlusionquery
  120324. */
  120325. occlusionType: number;
  120326. /**
  120327. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  120328. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  120329. * * 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.
  120330. * @see http://doc.babylonjs.com/features/occlusionquery
  120331. */
  120332. occlusionQueryAlgorithmType: number;
  120333. /**
  120334. * 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
  120335. * @see http://doc.babylonjs.com/features/occlusionquery
  120336. */
  120337. isOccluded: boolean;
  120338. /**
  120339. * Flag to check the progress status of the query
  120340. * @see http://doc.babylonjs.com/features/occlusionquery
  120341. */
  120342. isOcclusionQueryInProgress: boolean;
  120343. }
  120344. }
  120345. declare module BABYLON {
  120346. /** @hidden */
  120347. export var _forceTransformFeedbackToBundle: boolean;
  120348. interface Engine {
  120349. /**
  120350. * Creates a webGL transform feedback object
  120351. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  120352. * @returns the webGL transform feedback object
  120353. */
  120354. createTransformFeedback(): WebGLTransformFeedback;
  120355. /**
  120356. * Delete a webGL transform feedback object
  120357. * @param value defines the webGL transform feedback object to delete
  120358. */
  120359. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  120360. /**
  120361. * Bind a webGL transform feedback object to the webgl context
  120362. * @param value defines the webGL transform feedback object to bind
  120363. */
  120364. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  120365. /**
  120366. * Begins a transform feedback operation
  120367. * @param usePoints defines if points or triangles must be used
  120368. */
  120369. beginTransformFeedback(usePoints: boolean): void;
  120370. /**
  120371. * Ends a transform feedback operation
  120372. */
  120373. endTransformFeedback(): void;
  120374. /**
  120375. * Specify the varyings to use with transform feedback
  120376. * @param program defines the associated webGL program
  120377. * @param value defines the list of strings representing the varying names
  120378. */
  120379. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  120380. /**
  120381. * Bind a webGL buffer for a transform feedback operation
  120382. * @param value defines the webGL buffer to bind
  120383. */
  120384. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  120385. }
  120386. }
  120387. declare module BABYLON {
  120388. /**
  120389. * Creation options of the multi render target texture.
  120390. */
  120391. export interface IMultiRenderTargetOptions {
  120392. /**
  120393. * Define if the texture needs to create mip maps after render.
  120394. */
  120395. generateMipMaps?: boolean;
  120396. /**
  120397. * Define the types of all the draw buffers we want to create
  120398. */
  120399. types?: number[];
  120400. /**
  120401. * Define the sampling modes of all the draw buffers we want to create
  120402. */
  120403. samplingModes?: number[];
  120404. /**
  120405. * Define if a depth buffer is required
  120406. */
  120407. generateDepthBuffer?: boolean;
  120408. /**
  120409. * Define if a stencil buffer is required
  120410. */
  120411. generateStencilBuffer?: boolean;
  120412. /**
  120413. * Define if a depth texture is required instead of a depth buffer
  120414. */
  120415. generateDepthTexture?: boolean;
  120416. /**
  120417. * Define the number of desired draw buffers
  120418. */
  120419. textureCount?: number;
  120420. /**
  120421. * Define if aspect ratio should be adapted to the texture or stay the scene one
  120422. */
  120423. doNotChangeAspectRatio?: boolean;
  120424. /**
  120425. * Define the default type of the buffers we are creating
  120426. */
  120427. defaultType?: number;
  120428. }
  120429. /**
  120430. * A multi render target, like a render target provides the ability to render to a texture.
  120431. * Unlike the render target, it can render to several draw buffers in one draw.
  120432. * This is specially interesting in deferred rendering or for any effects requiring more than
  120433. * just one color from a single pass.
  120434. */
  120435. export class MultiRenderTarget extends RenderTargetTexture {
  120436. private _internalTextures;
  120437. private _textures;
  120438. private _multiRenderTargetOptions;
  120439. /**
  120440. * Get if draw buffers are currently supported by the used hardware and browser.
  120441. */
  120442. get isSupported(): boolean;
  120443. /**
  120444. * Get the list of textures generated by the multi render target.
  120445. */
  120446. get textures(): Texture[];
  120447. /**
  120448. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  120449. */
  120450. get depthTexture(): Texture;
  120451. /**
  120452. * Set the wrapping mode on U of all the textures we are rendering to.
  120453. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  120454. */
  120455. set wrapU(wrap: number);
  120456. /**
  120457. * Set the wrapping mode on V of all the textures we are rendering to.
  120458. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  120459. */
  120460. set wrapV(wrap: number);
  120461. /**
  120462. * Instantiate a new multi render target texture.
  120463. * A multi render target, like a render target provides the ability to render to a texture.
  120464. * Unlike the render target, it can render to several draw buffers in one draw.
  120465. * This is specially interesting in deferred rendering or for any effects requiring more than
  120466. * just one color from a single pass.
  120467. * @param name Define the name of the texture
  120468. * @param size Define the size of the buffers to render to
  120469. * @param count Define the number of target we are rendering into
  120470. * @param scene Define the scene the texture belongs to
  120471. * @param options Define the options used to create the multi render target
  120472. */
  120473. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  120474. /** @hidden */
  120475. _rebuild(): void;
  120476. private _createInternalTextures;
  120477. private _createTextures;
  120478. /**
  120479. * Define the number of samples used if MSAA is enabled.
  120480. */
  120481. get samples(): number;
  120482. set samples(value: number);
  120483. /**
  120484. * Resize all the textures in the multi render target.
  120485. * Be carrefull as it will recreate all the data in the new texture.
  120486. * @param size Define the new size
  120487. */
  120488. resize(size: any): void;
  120489. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  120490. /**
  120491. * Dispose the render targets and their associated resources
  120492. */
  120493. dispose(): void;
  120494. /**
  120495. * Release all the underlying texture used as draw buffers.
  120496. */
  120497. releaseInternalTextures(): void;
  120498. }
  120499. }
  120500. declare module BABYLON {
  120501. interface ThinEngine {
  120502. /**
  120503. * Unbind a list of render target textures from the webGL context
  120504. * This is used only when drawBuffer extension or webGL2 are active
  120505. * @param textures defines the render target textures to unbind
  120506. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  120507. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  120508. */
  120509. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  120510. /**
  120511. * Create a multi render target texture
  120512. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  120513. * @param size defines the size of the texture
  120514. * @param options defines the creation options
  120515. * @returns the cube texture as an InternalTexture
  120516. */
  120517. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  120518. /**
  120519. * Update the sample count for a given multiple render target texture
  120520. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  120521. * @param textures defines the textures to update
  120522. * @param samples defines the sample count to set
  120523. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  120524. */
  120525. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  120526. }
  120527. }
  120528. declare module BABYLON {
  120529. /**
  120530. * Class used to define an additional view for the engine
  120531. * @see https://doc.babylonjs.com/how_to/multi_canvases
  120532. */
  120533. export class EngineView {
  120534. /** Defines the canvas where to render the view */
  120535. target: HTMLCanvasElement;
  120536. /** Defines an optional camera used to render the view (will use active camera else) */
  120537. camera?: Camera;
  120538. }
  120539. interface Engine {
  120540. /**
  120541. * Gets or sets the HTML element to use for attaching events
  120542. */
  120543. inputElement: Nullable<HTMLElement>;
  120544. /**
  120545. * Gets the current engine view
  120546. * @see https://doc.babylonjs.com/how_to/multi_canvases
  120547. */
  120548. activeView: Nullable<EngineView>;
  120549. /** Gets or sets the list of views */
  120550. views: EngineView[];
  120551. /**
  120552. * Register a new child canvas
  120553. * @param canvas defines the canvas to register
  120554. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  120555. * @returns the associated view
  120556. */
  120557. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  120558. /**
  120559. * Remove a registered child canvas
  120560. * @param canvas defines the canvas to remove
  120561. * @returns the current engine
  120562. */
  120563. unRegisterView(canvas: HTMLCanvasElement): Engine;
  120564. }
  120565. }
  120566. declare module BABYLON {
  120567. /**
  120568. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  120569. */
  120570. export interface CubeMapInfo {
  120571. /**
  120572. * The pixel array for the front face.
  120573. * This is stored in format, left to right, up to down format.
  120574. */
  120575. front: Nullable<ArrayBufferView>;
  120576. /**
  120577. * The pixel array for the back face.
  120578. * This is stored in format, left to right, up to down format.
  120579. */
  120580. back: Nullable<ArrayBufferView>;
  120581. /**
  120582. * The pixel array for the left face.
  120583. * This is stored in format, left to right, up to down format.
  120584. */
  120585. left: Nullable<ArrayBufferView>;
  120586. /**
  120587. * The pixel array for the right face.
  120588. * This is stored in format, left to right, up to down format.
  120589. */
  120590. right: Nullable<ArrayBufferView>;
  120591. /**
  120592. * The pixel array for the up face.
  120593. * This is stored in format, left to right, up to down format.
  120594. */
  120595. up: Nullable<ArrayBufferView>;
  120596. /**
  120597. * The pixel array for the down face.
  120598. * This is stored in format, left to right, up to down format.
  120599. */
  120600. down: Nullable<ArrayBufferView>;
  120601. /**
  120602. * The size of the cubemap stored.
  120603. *
  120604. * Each faces will be size * size pixels.
  120605. */
  120606. size: number;
  120607. /**
  120608. * The format of the texture.
  120609. *
  120610. * RGBA, RGB.
  120611. */
  120612. format: number;
  120613. /**
  120614. * The type of the texture data.
  120615. *
  120616. * UNSIGNED_INT, FLOAT.
  120617. */
  120618. type: number;
  120619. /**
  120620. * Specifies whether the texture is in gamma space.
  120621. */
  120622. gammaSpace: boolean;
  120623. }
  120624. /**
  120625. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  120626. */
  120627. export class PanoramaToCubeMapTools {
  120628. private static FACE_FRONT;
  120629. private static FACE_BACK;
  120630. private static FACE_RIGHT;
  120631. private static FACE_LEFT;
  120632. private static FACE_DOWN;
  120633. private static FACE_UP;
  120634. /**
  120635. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  120636. *
  120637. * @param float32Array The source data.
  120638. * @param inputWidth The width of the input panorama.
  120639. * @param inputHeight The height of the input panorama.
  120640. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  120641. * @return The cubemap data
  120642. */
  120643. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  120644. private static CreateCubemapTexture;
  120645. private static CalcProjectionSpherical;
  120646. }
  120647. }
  120648. declare module BABYLON {
  120649. /**
  120650. * Helper class dealing with the extraction of spherical polynomial dataArray
  120651. * from a cube map.
  120652. */
  120653. export class CubeMapToSphericalPolynomialTools {
  120654. private static FileFaces;
  120655. /**
  120656. * Converts a texture to the according Spherical Polynomial data.
  120657. * This extracts the first 3 orders only as they are the only one used in the lighting.
  120658. *
  120659. * @param texture The texture to extract the information from.
  120660. * @return The Spherical Polynomial data.
  120661. */
  120662. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  120663. /**
  120664. * Converts a cubemap to the according Spherical Polynomial data.
  120665. * This extracts the first 3 orders only as they are the only one used in the lighting.
  120666. *
  120667. * @param cubeInfo The Cube map to extract the information from.
  120668. * @return The Spherical Polynomial data.
  120669. */
  120670. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  120671. }
  120672. }
  120673. declare module BABYLON {
  120674. interface BaseTexture {
  120675. /**
  120676. * Get the polynomial representation of the texture data.
  120677. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  120678. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  120679. */
  120680. sphericalPolynomial: Nullable<SphericalPolynomial>;
  120681. }
  120682. }
  120683. declare module BABYLON {
  120684. /** @hidden */
  120685. export var rgbdEncodePixelShader: {
  120686. name: string;
  120687. shader: string;
  120688. };
  120689. }
  120690. declare module BABYLON {
  120691. /** @hidden */
  120692. export var rgbdDecodePixelShader: {
  120693. name: string;
  120694. shader: string;
  120695. };
  120696. }
  120697. declare module BABYLON {
  120698. /**
  120699. * Raw texture data and descriptor sufficient for WebGL texture upload
  120700. */
  120701. export interface EnvironmentTextureInfo {
  120702. /**
  120703. * Version of the environment map
  120704. */
  120705. version: number;
  120706. /**
  120707. * Width of image
  120708. */
  120709. width: number;
  120710. /**
  120711. * Irradiance information stored in the file.
  120712. */
  120713. irradiance: any;
  120714. /**
  120715. * Specular information stored in the file.
  120716. */
  120717. specular: any;
  120718. }
  120719. /**
  120720. * Defines One Image in the file. It requires only the position in the file
  120721. * as well as the length.
  120722. */
  120723. interface BufferImageData {
  120724. /**
  120725. * Length of the image data.
  120726. */
  120727. length: number;
  120728. /**
  120729. * Position of the data from the null terminator delimiting the end of the JSON.
  120730. */
  120731. position: number;
  120732. }
  120733. /**
  120734. * Defines the specular data enclosed in the file.
  120735. * This corresponds to the version 1 of the data.
  120736. */
  120737. export interface EnvironmentTextureSpecularInfoV1 {
  120738. /**
  120739. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  120740. */
  120741. specularDataPosition?: number;
  120742. /**
  120743. * This contains all the images data needed to reconstruct the cubemap.
  120744. */
  120745. mipmaps: Array<BufferImageData>;
  120746. /**
  120747. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  120748. */
  120749. lodGenerationScale: number;
  120750. }
  120751. /**
  120752. * Sets of helpers addressing the serialization and deserialization of environment texture
  120753. * stored in a BabylonJS env file.
  120754. * Those files are usually stored as .env files.
  120755. */
  120756. export class EnvironmentTextureTools {
  120757. /**
  120758. * Magic number identifying the env file.
  120759. */
  120760. private static _MagicBytes;
  120761. /**
  120762. * Gets the environment info from an env file.
  120763. * @param data The array buffer containing the .env bytes.
  120764. * @returns the environment file info (the json header) if successfully parsed.
  120765. */
  120766. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  120767. /**
  120768. * Creates an environment texture from a loaded cube texture.
  120769. * @param texture defines the cube texture to convert in env file
  120770. * @return a promise containing the environment data if succesfull.
  120771. */
  120772. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  120773. /**
  120774. * Creates a JSON representation of the spherical data.
  120775. * @param texture defines the texture containing the polynomials
  120776. * @return the JSON representation of the spherical info
  120777. */
  120778. private static _CreateEnvTextureIrradiance;
  120779. /**
  120780. * Creates the ArrayBufferViews used for initializing environment texture image data.
  120781. * @param data the image data
  120782. * @param info parameters that determine what views will be created for accessing the underlying buffer
  120783. * @return the views described by info providing access to the underlying buffer
  120784. */
  120785. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  120786. /**
  120787. * Uploads the texture info contained in the env file to the GPU.
  120788. * @param texture defines the internal texture to upload to
  120789. * @param data defines the data to load
  120790. * @param info defines the texture info retrieved through the GetEnvInfo method
  120791. * @returns a promise
  120792. */
  120793. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  120794. private static _OnImageReadyAsync;
  120795. /**
  120796. * Uploads the levels of image data to the GPU.
  120797. * @param texture defines the internal texture to upload to
  120798. * @param imageData defines the array buffer views of image data [mipmap][face]
  120799. * @returns a promise
  120800. */
  120801. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  120802. /**
  120803. * Uploads spherical polynomials information to the texture.
  120804. * @param texture defines the texture we are trying to upload the information to
  120805. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  120806. */
  120807. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  120808. /** @hidden */
  120809. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  120810. }
  120811. }
  120812. declare module BABYLON {
  120813. /**
  120814. * Contains position and normal vectors for a vertex
  120815. */
  120816. export class PositionNormalVertex {
  120817. /** the position of the vertex (defaut: 0,0,0) */
  120818. position: Vector3;
  120819. /** the normal of the vertex (defaut: 0,1,0) */
  120820. normal: Vector3;
  120821. /**
  120822. * Creates a PositionNormalVertex
  120823. * @param position the position of the vertex (defaut: 0,0,0)
  120824. * @param normal the normal of the vertex (defaut: 0,1,0)
  120825. */
  120826. constructor(
  120827. /** the position of the vertex (defaut: 0,0,0) */
  120828. position?: Vector3,
  120829. /** the normal of the vertex (defaut: 0,1,0) */
  120830. normal?: Vector3);
  120831. /**
  120832. * Clones the PositionNormalVertex
  120833. * @returns the cloned PositionNormalVertex
  120834. */
  120835. clone(): PositionNormalVertex;
  120836. }
  120837. /**
  120838. * Contains position, normal and uv vectors for a vertex
  120839. */
  120840. export class PositionNormalTextureVertex {
  120841. /** the position of the vertex (defaut: 0,0,0) */
  120842. position: Vector3;
  120843. /** the normal of the vertex (defaut: 0,1,0) */
  120844. normal: Vector3;
  120845. /** the uv of the vertex (default: 0,0) */
  120846. uv: Vector2;
  120847. /**
  120848. * Creates a PositionNormalTextureVertex
  120849. * @param position the position of the vertex (defaut: 0,0,0)
  120850. * @param normal the normal of the vertex (defaut: 0,1,0)
  120851. * @param uv the uv of the vertex (default: 0,0)
  120852. */
  120853. constructor(
  120854. /** the position of the vertex (defaut: 0,0,0) */
  120855. position?: Vector3,
  120856. /** the normal of the vertex (defaut: 0,1,0) */
  120857. normal?: Vector3,
  120858. /** the uv of the vertex (default: 0,0) */
  120859. uv?: Vector2);
  120860. /**
  120861. * Clones the PositionNormalTextureVertex
  120862. * @returns the cloned PositionNormalTextureVertex
  120863. */
  120864. clone(): PositionNormalTextureVertex;
  120865. }
  120866. }
  120867. declare module BABYLON {
  120868. /** @hidden */
  120869. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  120870. private _genericAttributeLocation;
  120871. private _varyingLocationCount;
  120872. private _varyingLocationMap;
  120873. private _replacements;
  120874. private _textureCount;
  120875. private _uniforms;
  120876. lineProcessor(line: string): string;
  120877. attributeProcessor(attribute: string): string;
  120878. varyingProcessor(varying: string, isFragment: boolean): string;
  120879. uniformProcessor(uniform: string): string;
  120880. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  120881. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  120882. }
  120883. }
  120884. declare module BABYLON {
  120885. /**
  120886. * Container for accessors for natively-stored mesh data buffers.
  120887. */
  120888. class NativeDataBuffer extends DataBuffer {
  120889. /**
  120890. * Accessor value used to identify/retrieve a natively-stored index buffer.
  120891. */
  120892. nativeIndexBuffer?: any;
  120893. /**
  120894. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  120895. */
  120896. nativeVertexBuffer?: any;
  120897. }
  120898. /** @hidden */
  120899. class NativeTexture extends InternalTexture {
  120900. getInternalTexture(): InternalTexture;
  120901. getViewCount(): number;
  120902. }
  120903. /** @hidden */
  120904. export class NativeEngine extends Engine {
  120905. private readonly _native;
  120906. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  120907. private readonly INVALID_HANDLE;
  120908. getHardwareScalingLevel(): number;
  120909. constructor();
  120910. /**
  120911. * Can be used to override the current requestAnimationFrame requester.
  120912. * @hidden
  120913. */
  120914. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  120915. /**
  120916. * Override default engine behavior.
  120917. * @param color
  120918. * @param backBuffer
  120919. * @param depth
  120920. * @param stencil
  120921. */
  120922. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  120923. /**
  120924. * Gets host document
  120925. * @returns the host document object
  120926. */
  120927. getHostDocument(): Nullable<Document>;
  120928. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  120929. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  120930. createVertexBuffer(data: DataArray): NativeDataBuffer;
  120931. recordVertexArrayObject(vertexBuffers: {
  120932. [key: string]: VertexBuffer;
  120933. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  120934. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  120935. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  120936. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  120937. /**
  120938. * Draw a list of indexed primitives
  120939. * @param fillMode defines the primitive to use
  120940. * @param indexStart defines the starting index
  120941. * @param indexCount defines the number of index to draw
  120942. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120943. */
  120944. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  120945. /**
  120946. * Draw a list of unindexed primitives
  120947. * @param fillMode defines the primitive to use
  120948. * @param verticesStart defines the index of first vertex to draw
  120949. * @param verticesCount defines the count of vertices to draw
  120950. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120951. */
  120952. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  120953. createPipelineContext(): IPipelineContext;
  120954. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  120955. /** @hidden */
  120956. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  120957. /** @hidden */
  120958. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  120959. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  120960. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  120961. protected _setProgram(program: WebGLProgram): void;
  120962. _releaseEffect(effect: Effect): void;
  120963. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  120964. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  120965. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  120966. bindSamplers(effect: Effect): void;
  120967. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  120968. getRenderWidth(useScreen?: boolean): number;
  120969. getRenderHeight(useScreen?: boolean): number;
  120970. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  120971. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  120972. /**
  120973. * Set the z offset to apply to current rendering
  120974. * @param value defines the offset to apply
  120975. */
  120976. setZOffset(value: number): void;
  120977. /**
  120978. * Gets the current value of the zOffset
  120979. * @returns the current zOffset state
  120980. */
  120981. getZOffset(): number;
  120982. /**
  120983. * Enable or disable depth buffering
  120984. * @param enable defines the state to set
  120985. */
  120986. setDepthBuffer(enable: boolean): void;
  120987. /**
  120988. * Gets a boolean indicating if depth writing is enabled
  120989. * @returns the current depth writing state
  120990. */
  120991. getDepthWrite(): boolean;
  120992. /**
  120993. * Enable or disable depth writing
  120994. * @param enable defines the state to set
  120995. */
  120996. setDepthWrite(enable: boolean): void;
  120997. /**
  120998. * Enable or disable color writing
  120999. * @param enable defines the state to set
  121000. */
  121001. setColorWrite(enable: boolean): void;
  121002. /**
  121003. * Gets a boolean indicating if color writing is enabled
  121004. * @returns the current color writing state
  121005. */
  121006. getColorWrite(): boolean;
  121007. /**
  121008. * Sets alpha constants used by some alpha blending modes
  121009. * @param r defines the red component
  121010. * @param g defines the green component
  121011. * @param b defines the blue component
  121012. * @param a defines the alpha component
  121013. */
  121014. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  121015. /**
  121016. * Sets the current alpha mode
  121017. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  121018. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  121019. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  121020. */
  121021. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  121022. /**
  121023. * Gets the current alpha mode
  121024. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  121025. * @returns the current alpha mode
  121026. */
  121027. getAlphaMode(): number;
  121028. setInt(uniform: WebGLUniformLocation, int: number): void;
  121029. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  121030. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  121031. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  121032. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  121033. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  121034. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  121035. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  121036. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  121037. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  121038. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  121039. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  121040. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  121041. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  121042. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  121043. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  121044. setFloat(uniform: WebGLUniformLocation, value: number): void;
  121045. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  121046. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  121047. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  121048. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  121049. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  121050. wipeCaches(bruteForce?: boolean): void;
  121051. _createTexture(): WebGLTexture;
  121052. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  121053. /**
  121054. * Usually called from BABYLON.Texture.ts.
  121055. * Passed information to create a WebGLTexture
  121056. * @param urlArg defines a value which contains one of the following:
  121057. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  121058. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  121059. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  121060. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  121061. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  121062. * @param scene needed for loading to the correct scene
  121063. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  121064. * @param onLoad optional callback to be called upon successful completion
  121065. * @param onError optional callback to be called upon failure
  121066. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  121067. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  121068. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  121069. * @param forcedExtension defines the extension to use to pick the right loader
  121070. * @returns a InternalTexture for assignment back into BABYLON.Texture
  121071. */
  121072. 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;
  121073. /**
  121074. * Creates a cube texture
  121075. * @param rootUrl defines the url where the files to load is located
  121076. * @param scene defines the current scene
  121077. * @param files defines the list of files to load (1 per face)
  121078. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  121079. * @param onLoad defines an optional callback raised when the texture is loaded
  121080. * @param onError defines an optional callback raised if there is an issue to load the texture
  121081. * @param format defines the format of the data
  121082. * @param forcedExtension defines the extension to use to pick the right loader
  121083. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  121084. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  121085. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  121086. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  121087. * @returns the cube texture as an InternalTexture
  121088. */
  121089. 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;
  121090. private _getSamplingFilter;
  121091. private static _GetNativeTextureFormat;
  121092. createRenderTargetTexture(size: number | {
  121093. width: number;
  121094. height: number;
  121095. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  121096. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  121097. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  121098. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  121099. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  121100. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  121101. /**
  121102. * Updates a dynamic vertex buffer.
  121103. * @param vertexBuffer the vertex buffer to update
  121104. * @param data the data used to update the vertex buffer
  121105. * @param byteOffset the byte offset of the data (optional)
  121106. * @param byteLength the byte length of the data (optional)
  121107. */
  121108. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  121109. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  121110. private _updateAnisotropicLevel;
  121111. private _getAddressMode;
  121112. /** @hidden */
  121113. _bindTexture(channel: number, texture: InternalTexture): void;
  121114. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  121115. releaseEffects(): void;
  121116. /** @hidden */
  121117. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121118. /** @hidden */
  121119. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121120. /** @hidden */
  121121. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121122. /** @hidden */
  121123. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  121124. }
  121125. }
  121126. declare module BABYLON {
  121127. /**
  121128. * Gather the list of clipboard event types as constants.
  121129. */
  121130. export class ClipboardEventTypes {
  121131. /**
  121132. * The clipboard event is fired when a copy command is active (pressed).
  121133. */
  121134. static readonly COPY: number;
  121135. /**
  121136. * The clipboard event is fired when a cut command is active (pressed).
  121137. */
  121138. static readonly CUT: number;
  121139. /**
  121140. * The clipboard event is fired when a paste command is active (pressed).
  121141. */
  121142. static readonly PASTE: number;
  121143. }
  121144. /**
  121145. * This class is used to store clipboard related info for the onClipboardObservable event.
  121146. */
  121147. export class ClipboardInfo {
  121148. /**
  121149. * Defines the type of event (BABYLON.ClipboardEventTypes)
  121150. */
  121151. type: number;
  121152. /**
  121153. * Defines the related dom event
  121154. */
  121155. event: ClipboardEvent;
  121156. /**
  121157. *Creates an instance of ClipboardInfo.
  121158. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  121159. * @param event Defines the related dom event
  121160. */
  121161. constructor(
  121162. /**
  121163. * Defines the type of event (BABYLON.ClipboardEventTypes)
  121164. */
  121165. type: number,
  121166. /**
  121167. * Defines the related dom event
  121168. */
  121169. event: ClipboardEvent);
  121170. /**
  121171. * Get the clipboard event's type from the keycode.
  121172. * @param keyCode Defines the keyCode for the current keyboard event.
  121173. * @return {number}
  121174. */
  121175. static GetTypeFromCharacter(keyCode: number): number;
  121176. }
  121177. }
  121178. declare module BABYLON {
  121179. /**
  121180. * Google Daydream controller
  121181. */
  121182. export class DaydreamController extends WebVRController {
  121183. /**
  121184. * Base Url for the controller model.
  121185. */
  121186. static MODEL_BASE_URL: string;
  121187. /**
  121188. * File name for the controller model.
  121189. */
  121190. static MODEL_FILENAME: string;
  121191. /**
  121192. * Gamepad Id prefix used to identify Daydream Controller.
  121193. */
  121194. static readonly GAMEPAD_ID_PREFIX: string;
  121195. /**
  121196. * Creates a new DaydreamController from a gamepad
  121197. * @param vrGamepad the gamepad that the controller should be created from
  121198. */
  121199. constructor(vrGamepad: any);
  121200. /**
  121201. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121202. * @param scene scene in which to add meshes
  121203. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121204. */
  121205. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121206. /**
  121207. * Called once for each button that changed state since the last frame
  121208. * @param buttonIdx Which button index changed
  121209. * @param state New state of the button
  121210. * @param changes Which properties on the state changed since last frame
  121211. */
  121212. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121213. }
  121214. }
  121215. declare module BABYLON {
  121216. /**
  121217. * Gear VR Controller
  121218. */
  121219. export class GearVRController extends WebVRController {
  121220. /**
  121221. * Base Url for the controller model.
  121222. */
  121223. static MODEL_BASE_URL: string;
  121224. /**
  121225. * File name for the controller model.
  121226. */
  121227. static MODEL_FILENAME: string;
  121228. /**
  121229. * Gamepad Id prefix used to identify this controller.
  121230. */
  121231. static readonly GAMEPAD_ID_PREFIX: string;
  121232. private readonly _buttonIndexToObservableNameMap;
  121233. /**
  121234. * Creates a new GearVRController from a gamepad
  121235. * @param vrGamepad the gamepad that the controller should be created from
  121236. */
  121237. constructor(vrGamepad: any);
  121238. /**
  121239. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121240. * @param scene scene in which to add meshes
  121241. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121242. */
  121243. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121244. /**
  121245. * Called once for each button that changed state since the last frame
  121246. * @param buttonIdx Which button index changed
  121247. * @param state New state of the button
  121248. * @param changes Which properties on the state changed since last frame
  121249. */
  121250. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121251. }
  121252. }
  121253. declare module BABYLON {
  121254. /**
  121255. * Generic Controller
  121256. */
  121257. export class GenericController extends WebVRController {
  121258. /**
  121259. * Base Url for the controller model.
  121260. */
  121261. static readonly MODEL_BASE_URL: string;
  121262. /**
  121263. * File name for the controller model.
  121264. */
  121265. static readonly MODEL_FILENAME: string;
  121266. /**
  121267. * Creates a new GenericController from a gamepad
  121268. * @param vrGamepad the gamepad that the controller should be created from
  121269. */
  121270. constructor(vrGamepad: any);
  121271. /**
  121272. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121273. * @param scene scene in which to add meshes
  121274. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121275. */
  121276. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121277. /**
  121278. * Called once for each button that changed state since the last frame
  121279. * @param buttonIdx Which button index changed
  121280. * @param state New state of the button
  121281. * @param changes Which properties on the state changed since last frame
  121282. */
  121283. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121284. }
  121285. }
  121286. declare module BABYLON {
  121287. /**
  121288. * Oculus Touch Controller
  121289. */
  121290. export class OculusTouchController extends WebVRController {
  121291. /**
  121292. * Base Url for the controller model.
  121293. */
  121294. static MODEL_BASE_URL: string;
  121295. /**
  121296. * File name for the left controller model.
  121297. */
  121298. static MODEL_LEFT_FILENAME: string;
  121299. /**
  121300. * File name for the right controller model.
  121301. */
  121302. static MODEL_RIGHT_FILENAME: string;
  121303. /**
  121304. * Base Url for the Quest controller model.
  121305. */
  121306. static QUEST_MODEL_BASE_URL: string;
  121307. /**
  121308. * @hidden
  121309. * If the controllers are running on a device that needs the updated Quest controller models
  121310. */
  121311. static _IsQuest: boolean;
  121312. /**
  121313. * Fired when the secondary trigger on this controller is modified
  121314. */
  121315. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  121316. /**
  121317. * Fired when the thumb rest on this controller is modified
  121318. */
  121319. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  121320. /**
  121321. * Creates a new OculusTouchController from a gamepad
  121322. * @param vrGamepad the gamepad that the controller should be created from
  121323. */
  121324. constructor(vrGamepad: any);
  121325. /**
  121326. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121327. * @param scene scene in which to add meshes
  121328. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121329. */
  121330. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121331. /**
  121332. * Fired when the A button on this controller is modified
  121333. */
  121334. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121335. /**
  121336. * Fired when the B button on this controller is modified
  121337. */
  121338. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121339. /**
  121340. * Fired when the X button on this controller is modified
  121341. */
  121342. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121343. /**
  121344. * Fired when the Y button on this controller is modified
  121345. */
  121346. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121347. /**
  121348. * Called once for each button that changed state since the last frame
  121349. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  121350. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  121351. * 2) secondary trigger (same)
  121352. * 3) A (right) X (left), touch, pressed = value
  121353. * 4) B / Y
  121354. * 5) thumb rest
  121355. * @param buttonIdx Which button index changed
  121356. * @param state New state of the button
  121357. * @param changes Which properties on the state changed since last frame
  121358. */
  121359. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121360. }
  121361. }
  121362. declare module BABYLON {
  121363. /**
  121364. * Vive Controller
  121365. */
  121366. export class ViveController extends WebVRController {
  121367. /**
  121368. * Base Url for the controller model.
  121369. */
  121370. static MODEL_BASE_URL: string;
  121371. /**
  121372. * File name for the controller model.
  121373. */
  121374. static MODEL_FILENAME: string;
  121375. /**
  121376. * Creates a new ViveController from a gamepad
  121377. * @param vrGamepad the gamepad that the controller should be created from
  121378. */
  121379. constructor(vrGamepad: any);
  121380. /**
  121381. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121382. * @param scene scene in which to add meshes
  121383. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121384. */
  121385. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121386. /**
  121387. * Fired when the left button on this controller is modified
  121388. */
  121389. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121390. /**
  121391. * Fired when the right button on this controller is modified
  121392. */
  121393. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121394. /**
  121395. * Fired when the menu button on this controller is modified
  121396. */
  121397. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121398. /**
  121399. * Called once for each button that changed state since the last frame
  121400. * Vive mapping:
  121401. * 0: touchpad
  121402. * 1: trigger
  121403. * 2: left AND right buttons
  121404. * 3: menu button
  121405. * @param buttonIdx Which button index changed
  121406. * @param state New state of the button
  121407. * @param changes Which properties on the state changed since last frame
  121408. */
  121409. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121410. }
  121411. }
  121412. declare module BABYLON {
  121413. /**
  121414. * Defines the WindowsMotionController object that the state of the windows motion controller
  121415. */
  121416. export class WindowsMotionController extends WebVRController {
  121417. /**
  121418. * The base url used to load the left and right controller models
  121419. */
  121420. static MODEL_BASE_URL: string;
  121421. /**
  121422. * The name of the left controller model file
  121423. */
  121424. static MODEL_LEFT_FILENAME: string;
  121425. /**
  121426. * The name of the right controller model file
  121427. */
  121428. static MODEL_RIGHT_FILENAME: string;
  121429. /**
  121430. * The controller name prefix for this controller type
  121431. */
  121432. static readonly GAMEPAD_ID_PREFIX: string;
  121433. /**
  121434. * The controller id pattern for this controller type
  121435. */
  121436. private static readonly GAMEPAD_ID_PATTERN;
  121437. private _loadedMeshInfo;
  121438. protected readonly _mapping: {
  121439. buttons: string[];
  121440. buttonMeshNames: {
  121441. 'trigger': string;
  121442. 'menu': string;
  121443. 'grip': string;
  121444. 'thumbstick': string;
  121445. 'trackpad': string;
  121446. };
  121447. buttonObservableNames: {
  121448. 'trigger': string;
  121449. 'menu': string;
  121450. 'grip': string;
  121451. 'thumbstick': string;
  121452. 'trackpad': string;
  121453. };
  121454. axisMeshNames: string[];
  121455. pointingPoseMeshName: string;
  121456. };
  121457. /**
  121458. * Fired when the trackpad on this controller is clicked
  121459. */
  121460. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  121461. /**
  121462. * Fired when the trackpad on this controller is modified
  121463. */
  121464. onTrackpadValuesChangedObservable: Observable<StickValues>;
  121465. /**
  121466. * The current x and y values of this controller's trackpad
  121467. */
  121468. trackpad: StickValues;
  121469. /**
  121470. * Creates a new WindowsMotionController from a gamepad
  121471. * @param vrGamepad the gamepad that the controller should be created from
  121472. */
  121473. constructor(vrGamepad: any);
  121474. /**
  121475. * Fired when the trigger on this controller is modified
  121476. */
  121477. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121478. /**
  121479. * Fired when the menu button on this controller is modified
  121480. */
  121481. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121482. /**
  121483. * Fired when the grip button on this controller is modified
  121484. */
  121485. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121486. /**
  121487. * Fired when the thumbstick button on this controller is modified
  121488. */
  121489. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121490. /**
  121491. * Fired when the touchpad button on this controller is modified
  121492. */
  121493. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121494. /**
  121495. * Fired when the touchpad values on this controller are modified
  121496. */
  121497. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  121498. protected _updateTrackpad(): void;
  121499. /**
  121500. * Called once per frame by the engine.
  121501. */
  121502. update(): void;
  121503. /**
  121504. * Called once for each button that changed state since the last frame
  121505. * @param buttonIdx Which button index changed
  121506. * @param state New state of the button
  121507. * @param changes Which properties on the state changed since last frame
  121508. */
  121509. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121510. /**
  121511. * Moves the buttons on the controller mesh based on their current state
  121512. * @param buttonName the name of the button to move
  121513. * @param buttonValue the value of the button which determines the buttons new position
  121514. */
  121515. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  121516. /**
  121517. * Moves the axis on the controller mesh based on its current state
  121518. * @param axis the index of the axis
  121519. * @param axisValue the value of the axis which determines the meshes new position
  121520. * @hidden
  121521. */
  121522. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  121523. /**
  121524. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121525. * @param scene scene in which to add meshes
  121526. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121527. */
  121528. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  121529. /**
  121530. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  121531. * can be transformed by button presses and axes values, based on this._mapping.
  121532. *
  121533. * @param scene scene in which the meshes exist
  121534. * @param meshes list of meshes that make up the controller model to process
  121535. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  121536. */
  121537. private processModel;
  121538. private createMeshInfo;
  121539. /**
  121540. * Gets the ray of the controller in the direction the controller is pointing
  121541. * @param length the length the resulting ray should be
  121542. * @returns a ray in the direction the controller is pointing
  121543. */
  121544. getForwardRay(length?: number): Ray;
  121545. /**
  121546. * Disposes of the controller
  121547. */
  121548. dispose(): void;
  121549. }
  121550. /**
  121551. * This class represents a new windows motion controller in XR.
  121552. */
  121553. export class XRWindowsMotionController extends WindowsMotionController {
  121554. /**
  121555. * Changing the original WIndowsMotionController mapping to fir the new mapping
  121556. */
  121557. protected readonly _mapping: {
  121558. buttons: string[];
  121559. buttonMeshNames: {
  121560. 'trigger': string;
  121561. 'menu': string;
  121562. 'grip': string;
  121563. 'thumbstick': string;
  121564. 'trackpad': string;
  121565. };
  121566. buttonObservableNames: {
  121567. 'trigger': string;
  121568. 'menu': string;
  121569. 'grip': string;
  121570. 'thumbstick': string;
  121571. 'trackpad': string;
  121572. };
  121573. axisMeshNames: string[];
  121574. pointingPoseMeshName: string;
  121575. };
  121576. /**
  121577. * Construct a new XR-Based windows motion controller
  121578. *
  121579. * @param gamepadInfo the gamepad object from the browser
  121580. */
  121581. constructor(gamepadInfo: any);
  121582. /**
  121583. * holds the thumbstick values (X,Y)
  121584. */
  121585. thumbstickValues: StickValues;
  121586. /**
  121587. * Fired when the thumbstick on this controller is clicked
  121588. */
  121589. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  121590. /**
  121591. * Fired when the thumbstick on this controller is modified
  121592. */
  121593. onThumbstickValuesChangedObservable: Observable<StickValues>;
  121594. /**
  121595. * Fired when the touchpad button on this controller is modified
  121596. */
  121597. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  121598. /**
  121599. * Fired when the touchpad values on this controller are modified
  121600. */
  121601. onTrackpadValuesChangedObservable: Observable<StickValues>;
  121602. /**
  121603. * Fired when the thumbstick button on this controller is modified
  121604. * here to prevent breaking changes
  121605. */
  121606. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121607. /**
  121608. * updating the thumbstick(!) and not the trackpad.
  121609. * This is named this way due to the difference between WebVR and XR and to avoid
  121610. * changing the parent class.
  121611. */
  121612. protected _updateTrackpad(): void;
  121613. /**
  121614. * Disposes the class with joy
  121615. */
  121616. dispose(): void;
  121617. }
  121618. }
  121619. declare module BABYLON {
  121620. /**
  121621. * Class containing static functions to help procedurally build meshes
  121622. */
  121623. export class PolyhedronBuilder {
  121624. /**
  121625. * Creates a polyhedron mesh
  121626. * * 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
  121627. * * The parameter `size` (positive float, default 1) sets the polygon size
  121628. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  121629. * * 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`
  121630. * * 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
  121631. * * 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)`)
  121632. * * 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
  121633. * * 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
  121634. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121635. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121636. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121637. * @param name defines the name of the mesh
  121638. * @param options defines the options used to create the mesh
  121639. * @param scene defines the hosting scene
  121640. * @returns the polyhedron mesh
  121641. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  121642. */
  121643. static CreatePolyhedron(name: string, options: {
  121644. type?: number;
  121645. size?: number;
  121646. sizeX?: number;
  121647. sizeY?: number;
  121648. sizeZ?: number;
  121649. custom?: any;
  121650. faceUV?: Vector4[];
  121651. faceColors?: Color4[];
  121652. flat?: boolean;
  121653. updatable?: boolean;
  121654. sideOrientation?: number;
  121655. frontUVs?: Vector4;
  121656. backUVs?: Vector4;
  121657. }, scene?: Nullable<Scene>): Mesh;
  121658. }
  121659. }
  121660. declare module BABYLON {
  121661. /**
  121662. * Gizmo that enables scaling a mesh along 3 axis
  121663. */
  121664. export class ScaleGizmo extends Gizmo {
  121665. /**
  121666. * Internal gizmo used for interactions on the x axis
  121667. */
  121668. xGizmo: AxisScaleGizmo;
  121669. /**
  121670. * Internal gizmo used for interactions on the y axis
  121671. */
  121672. yGizmo: AxisScaleGizmo;
  121673. /**
  121674. * Internal gizmo used for interactions on the z axis
  121675. */
  121676. zGizmo: AxisScaleGizmo;
  121677. /**
  121678. * Internal gizmo used to scale all axis equally
  121679. */
  121680. uniformScaleGizmo: AxisScaleGizmo;
  121681. private _meshAttached;
  121682. private _updateGizmoRotationToMatchAttachedMesh;
  121683. private _snapDistance;
  121684. private _scaleRatio;
  121685. private _uniformScalingMesh;
  121686. private _octahedron;
  121687. private _sensitivity;
  121688. /** Fires an event when any of it's sub gizmos are dragged */
  121689. onDragStartObservable: Observable<unknown>;
  121690. /** Fires an event when any of it's sub gizmos are released from dragging */
  121691. onDragEndObservable: Observable<unknown>;
  121692. get attachedMesh(): Nullable<AbstractMesh>;
  121693. set attachedMesh(mesh: Nullable<AbstractMesh>);
  121694. /**
  121695. * Creates a ScaleGizmo
  121696. * @param gizmoLayer The utility layer the gizmo will be added to
  121697. */
  121698. constructor(gizmoLayer?: UtilityLayerRenderer);
  121699. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  121700. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  121701. /**
  121702. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121703. */
  121704. set snapDistance(value: number);
  121705. get snapDistance(): number;
  121706. /**
  121707. * Ratio for the scale of the gizmo (Default: 1)
  121708. */
  121709. set scaleRatio(value: number);
  121710. get scaleRatio(): number;
  121711. /**
  121712. * Sensitivity factor for dragging (Default: 1)
  121713. */
  121714. set sensitivity(value: number);
  121715. get sensitivity(): number;
  121716. /**
  121717. * Disposes of the gizmo
  121718. */
  121719. dispose(): void;
  121720. }
  121721. }
  121722. declare module BABYLON {
  121723. /**
  121724. * Single axis scale gizmo
  121725. */
  121726. export class AxisScaleGizmo extends Gizmo {
  121727. /**
  121728. * Drag behavior responsible for the gizmos dragging interactions
  121729. */
  121730. dragBehavior: PointerDragBehavior;
  121731. private _pointerObserver;
  121732. /**
  121733. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121734. */
  121735. snapDistance: number;
  121736. /**
  121737. * Event that fires each time the gizmo snaps to a new location.
  121738. * * snapDistance is the the change in distance
  121739. */
  121740. onSnapObservable: Observable<{
  121741. snapDistance: number;
  121742. }>;
  121743. /**
  121744. * If the scaling operation should be done on all axis (default: false)
  121745. */
  121746. uniformScaling: boolean;
  121747. /**
  121748. * Custom sensitivity value for the drag strength
  121749. */
  121750. sensitivity: number;
  121751. private _isEnabled;
  121752. private _parent;
  121753. private _arrow;
  121754. private _coloredMaterial;
  121755. private _hoverMaterial;
  121756. /**
  121757. * Creates an AxisScaleGizmo
  121758. * @param gizmoLayer The utility layer the gizmo will be added to
  121759. * @param dragAxis The axis which the gizmo will be able to scale on
  121760. * @param color The color of the gizmo
  121761. */
  121762. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  121763. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121764. /**
  121765. * If the gizmo is enabled
  121766. */
  121767. set isEnabled(value: boolean);
  121768. get isEnabled(): boolean;
  121769. /**
  121770. * Disposes of the gizmo
  121771. */
  121772. dispose(): void;
  121773. /**
  121774. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  121775. * @param mesh The mesh to replace the default mesh of the gizmo
  121776. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  121777. */
  121778. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  121779. }
  121780. }
  121781. declare module BABYLON {
  121782. /**
  121783. * Bounding box gizmo
  121784. */
  121785. export class BoundingBoxGizmo extends Gizmo {
  121786. private _lineBoundingBox;
  121787. private _rotateSpheresParent;
  121788. private _scaleBoxesParent;
  121789. private _boundingDimensions;
  121790. private _renderObserver;
  121791. private _pointerObserver;
  121792. private _scaleDragSpeed;
  121793. private _tmpQuaternion;
  121794. private _tmpVector;
  121795. private _tmpRotationMatrix;
  121796. /**
  121797. * 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)
  121798. */
  121799. ignoreChildren: boolean;
  121800. /**
  121801. * 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)
  121802. */
  121803. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  121804. /**
  121805. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  121806. */
  121807. rotationSphereSize: number;
  121808. /**
  121809. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  121810. */
  121811. scaleBoxSize: number;
  121812. /**
  121813. * 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)
  121814. */
  121815. fixedDragMeshScreenSize: boolean;
  121816. /**
  121817. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  121818. */
  121819. fixedDragMeshScreenSizeDistanceFactor: number;
  121820. /**
  121821. * Fired when a rotation sphere or scale box is dragged
  121822. */
  121823. onDragStartObservable: Observable<{}>;
  121824. /**
  121825. * Fired when a scale box is dragged
  121826. */
  121827. onScaleBoxDragObservable: Observable<{}>;
  121828. /**
  121829. * Fired when a scale box drag is ended
  121830. */
  121831. onScaleBoxDragEndObservable: Observable<{}>;
  121832. /**
  121833. * Fired when a rotation sphere is dragged
  121834. */
  121835. onRotationSphereDragObservable: Observable<{}>;
  121836. /**
  121837. * Fired when a rotation sphere drag is ended
  121838. */
  121839. onRotationSphereDragEndObservable: Observable<{}>;
  121840. /**
  121841. * 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)
  121842. */
  121843. scalePivot: Nullable<Vector3>;
  121844. /**
  121845. * Mesh used as a pivot to rotate the attached mesh
  121846. */
  121847. private _anchorMesh;
  121848. private _existingMeshScale;
  121849. private _dragMesh;
  121850. private pointerDragBehavior;
  121851. private coloredMaterial;
  121852. private hoverColoredMaterial;
  121853. /**
  121854. * Sets the color of the bounding box gizmo
  121855. * @param color the color to set
  121856. */
  121857. setColor(color: Color3): void;
  121858. /**
  121859. * Creates an BoundingBoxGizmo
  121860. * @param gizmoLayer The utility layer the gizmo will be added to
  121861. * @param color The color of the gizmo
  121862. */
  121863. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  121864. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121865. private _selectNode;
  121866. /**
  121867. * Updates the bounding box information for the Gizmo
  121868. */
  121869. updateBoundingBox(): void;
  121870. private _updateRotationSpheres;
  121871. private _updateScaleBoxes;
  121872. /**
  121873. * Enables rotation on the specified axis and disables rotation on the others
  121874. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  121875. */
  121876. setEnabledRotationAxis(axis: string): void;
  121877. /**
  121878. * Enables/disables scaling
  121879. * @param enable if scaling should be enabled
  121880. */
  121881. setEnabledScaling(enable: boolean): void;
  121882. private _updateDummy;
  121883. /**
  121884. * Enables a pointer drag behavior on the bounding box of the gizmo
  121885. */
  121886. enableDragBehavior(): void;
  121887. /**
  121888. * Disposes of the gizmo
  121889. */
  121890. dispose(): void;
  121891. /**
  121892. * 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)
  121893. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  121894. * @returns the bounding box mesh with the passed in mesh as a child
  121895. */
  121896. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  121897. /**
  121898. * CustomMeshes are not supported by this gizmo
  121899. * @param mesh The mesh to replace the default mesh of the gizmo
  121900. */
  121901. setCustomMesh(mesh: Mesh): void;
  121902. }
  121903. }
  121904. declare module BABYLON {
  121905. /**
  121906. * Single plane rotation gizmo
  121907. */
  121908. export class PlaneRotationGizmo extends Gizmo {
  121909. /**
  121910. * Drag behavior responsible for the gizmos dragging interactions
  121911. */
  121912. dragBehavior: PointerDragBehavior;
  121913. private _pointerObserver;
  121914. /**
  121915. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  121916. */
  121917. snapDistance: number;
  121918. /**
  121919. * Event that fires each time the gizmo snaps to a new location.
  121920. * * snapDistance is the the change in distance
  121921. */
  121922. onSnapObservable: Observable<{
  121923. snapDistance: number;
  121924. }>;
  121925. private _isEnabled;
  121926. private _parent;
  121927. /**
  121928. * Creates a PlaneRotationGizmo
  121929. * @param gizmoLayer The utility layer the gizmo will be added to
  121930. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  121931. * @param color The color of the gizmo
  121932. * @param tessellation Amount of tessellation to be used when creating rotation circles
  121933. * @param useEulerRotation Use and update Euler angle instead of quaternion
  121934. */
  121935. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  121936. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121937. /**
  121938. * If the gizmo is enabled
  121939. */
  121940. set isEnabled(value: boolean);
  121941. get isEnabled(): boolean;
  121942. /**
  121943. * Disposes of the gizmo
  121944. */
  121945. dispose(): void;
  121946. }
  121947. }
  121948. declare module BABYLON {
  121949. /**
  121950. * Gizmo that enables rotating a mesh along 3 axis
  121951. */
  121952. export class RotationGizmo extends Gizmo {
  121953. /**
  121954. * Internal gizmo used for interactions on the x axis
  121955. */
  121956. xGizmo: PlaneRotationGizmo;
  121957. /**
  121958. * Internal gizmo used for interactions on the y axis
  121959. */
  121960. yGizmo: PlaneRotationGizmo;
  121961. /**
  121962. * Internal gizmo used for interactions on the z axis
  121963. */
  121964. zGizmo: PlaneRotationGizmo;
  121965. /** Fires an event when any of it's sub gizmos are dragged */
  121966. onDragStartObservable: Observable<unknown>;
  121967. /** Fires an event when any of it's sub gizmos are released from dragging */
  121968. onDragEndObservable: Observable<unknown>;
  121969. private _meshAttached;
  121970. get attachedMesh(): Nullable<AbstractMesh>;
  121971. set attachedMesh(mesh: Nullable<AbstractMesh>);
  121972. /**
  121973. * Creates a RotationGizmo
  121974. * @param gizmoLayer The utility layer the gizmo will be added to
  121975. * @param tessellation Amount of tessellation to be used when creating rotation circles
  121976. * @param useEulerRotation Use and update Euler angle instead of quaternion
  121977. */
  121978. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  121979. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  121980. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  121981. /**
  121982. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121983. */
  121984. set snapDistance(value: number);
  121985. get snapDistance(): number;
  121986. /**
  121987. * Ratio for the scale of the gizmo (Default: 1)
  121988. */
  121989. set scaleRatio(value: number);
  121990. get scaleRatio(): number;
  121991. /**
  121992. * Disposes of the gizmo
  121993. */
  121994. dispose(): void;
  121995. /**
  121996. * CustomMeshes are not supported by this gizmo
  121997. * @param mesh The mesh to replace the default mesh of the gizmo
  121998. */
  121999. setCustomMesh(mesh: Mesh): void;
  122000. }
  122001. }
  122002. declare module BABYLON {
  122003. /**
  122004. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  122005. */
  122006. export class GizmoManager implements IDisposable {
  122007. private scene;
  122008. /**
  122009. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  122010. */
  122011. gizmos: {
  122012. positionGizmo: Nullable<PositionGizmo>;
  122013. rotationGizmo: Nullable<RotationGizmo>;
  122014. scaleGizmo: Nullable<ScaleGizmo>;
  122015. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  122016. };
  122017. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  122018. clearGizmoOnEmptyPointerEvent: boolean;
  122019. /** Fires an event when the manager is attached to a mesh */
  122020. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  122021. private _gizmosEnabled;
  122022. private _pointerObserver;
  122023. private _attachedMesh;
  122024. private _boundingBoxColor;
  122025. private _defaultUtilityLayer;
  122026. private _defaultKeepDepthUtilityLayer;
  122027. /**
  122028. * When bounding box gizmo is enabled, this can be used to track drag/end events
  122029. */
  122030. boundingBoxDragBehavior: SixDofDragBehavior;
  122031. /**
  122032. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  122033. */
  122034. attachableMeshes: Nullable<Array<AbstractMesh>>;
  122035. /**
  122036. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  122037. */
  122038. usePointerToAttachGizmos: boolean;
  122039. /**
  122040. * Utility layer that the bounding box gizmo belongs to
  122041. */
  122042. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  122043. /**
  122044. * Utility layer that all gizmos besides bounding box belong to
  122045. */
  122046. get utilityLayer(): UtilityLayerRenderer;
  122047. /**
  122048. * Instatiates a gizmo manager
  122049. * @param scene the scene to overlay the gizmos on top of
  122050. */
  122051. constructor(scene: Scene);
  122052. /**
  122053. * Attaches a set of gizmos to the specified mesh
  122054. * @param mesh The mesh the gizmo's should be attached to
  122055. */
  122056. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  122057. /**
  122058. * If the position gizmo is enabled
  122059. */
  122060. set positionGizmoEnabled(value: boolean);
  122061. get positionGizmoEnabled(): boolean;
  122062. /**
  122063. * If the rotation gizmo is enabled
  122064. */
  122065. set rotationGizmoEnabled(value: boolean);
  122066. get rotationGizmoEnabled(): boolean;
  122067. /**
  122068. * If the scale gizmo is enabled
  122069. */
  122070. set scaleGizmoEnabled(value: boolean);
  122071. get scaleGizmoEnabled(): boolean;
  122072. /**
  122073. * If the boundingBox gizmo is enabled
  122074. */
  122075. set boundingBoxGizmoEnabled(value: boolean);
  122076. get boundingBoxGizmoEnabled(): boolean;
  122077. /**
  122078. * Disposes of the gizmo manager
  122079. */
  122080. dispose(): void;
  122081. }
  122082. }
  122083. declare module BABYLON {
  122084. /**
  122085. * A directional light is defined by a direction (what a surprise!).
  122086. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  122087. * 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.
  122088. * Documentation: https://doc.babylonjs.com/babylon101/lights
  122089. */
  122090. export class DirectionalLight extends ShadowLight {
  122091. private _shadowFrustumSize;
  122092. /**
  122093. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  122094. */
  122095. get shadowFrustumSize(): number;
  122096. /**
  122097. * Specifies a fix frustum size for the shadow generation.
  122098. */
  122099. set shadowFrustumSize(value: number);
  122100. private _shadowOrthoScale;
  122101. /**
  122102. * Gets the shadow projection scale against the optimal computed one.
  122103. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  122104. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  122105. */
  122106. get shadowOrthoScale(): number;
  122107. /**
  122108. * Sets the shadow projection scale against the optimal computed one.
  122109. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  122110. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  122111. */
  122112. set shadowOrthoScale(value: number);
  122113. /**
  122114. * Automatically compute the projection matrix to best fit (including all the casters)
  122115. * on each frame.
  122116. */
  122117. autoUpdateExtends: boolean;
  122118. /**
  122119. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  122120. * on each frame. autoUpdateExtends must be set to true for this to work
  122121. */
  122122. autoCalcShadowZBounds: boolean;
  122123. private _orthoLeft;
  122124. private _orthoRight;
  122125. private _orthoTop;
  122126. private _orthoBottom;
  122127. /**
  122128. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  122129. * The directional light is emitted from everywhere in the given direction.
  122130. * It can cast shadows.
  122131. * Documentation : https://doc.babylonjs.com/babylon101/lights
  122132. * @param name The friendly name of the light
  122133. * @param direction The direction of the light
  122134. * @param scene The scene the light belongs to
  122135. */
  122136. constructor(name: string, direction: Vector3, scene: Scene);
  122137. /**
  122138. * Returns the string "DirectionalLight".
  122139. * @return The class name
  122140. */
  122141. getClassName(): string;
  122142. /**
  122143. * Returns the integer 1.
  122144. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  122145. */
  122146. getTypeID(): number;
  122147. /**
  122148. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  122149. * Returns the DirectionalLight Shadow projection matrix.
  122150. */
  122151. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  122152. /**
  122153. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  122154. * Returns the DirectionalLight Shadow projection matrix.
  122155. */
  122156. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  122157. /**
  122158. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  122159. * Returns the DirectionalLight Shadow projection matrix.
  122160. */
  122161. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  122162. protected _buildUniformLayout(): void;
  122163. /**
  122164. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  122165. * @param effect The effect to update
  122166. * @param lightIndex The index of the light in the effect to update
  122167. * @returns The directional light
  122168. */
  122169. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  122170. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  122171. /**
  122172. * Gets the minZ used for shadow according to both the scene and the light.
  122173. *
  122174. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  122175. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  122176. * @param activeCamera The camera we are returning the min for
  122177. * @returns the depth min z
  122178. */
  122179. getDepthMinZ(activeCamera: Camera): number;
  122180. /**
  122181. * Gets the maxZ used for shadow according to both the scene and the light.
  122182. *
  122183. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  122184. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  122185. * @param activeCamera The camera we are returning the max for
  122186. * @returns the depth max z
  122187. */
  122188. getDepthMaxZ(activeCamera: Camera): number;
  122189. /**
  122190. * Prepares the list of defines specific to the light type.
  122191. * @param defines the list of defines
  122192. * @param lightIndex defines the index of the light for the effect
  122193. */
  122194. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  122195. }
  122196. }
  122197. declare module BABYLON {
  122198. /**
  122199. * Class containing static functions to help procedurally build meshes
  122200. */
  122201. export class HemisphereBuilder {
  122202. /**
  122203. * Creates a hemisphere mesh
  122204. * @param name defines the name of the mesh
  122205. * @param options defines the options used to create the mesh
  122206. * @param scene defines the hosting scene
  122207. * @returns the hemisphere mesh
  122208. */
  122209. static CreateHemisphere(name: string, options: {
  122210. segments?: number;
  122211. diameter?: number;
  122212. sideOrientation?: number;
  122213. }, scene: any): Mesh;
  122214. }
  122215. }
  122216. declare module BABYLON {
  122217. /**
  122218. * A spot light is defined by a position, a direction, an angle, and an exponent.
  122219. * These values define a cone of light starting from the position, emitting toward the direction.
  122220. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  122221. * and the exponent defines the speed of the decay of the light with distance (reach).
  122222. * Documentation: https://doc.babylonjs.com/babylon101/lights
  122223. */
  122224. export class SpotLight extends ShadowLight {
  122225. private _angle;
  122226. private _innerAngle;
  122227. private _cosHalfAngle;
  122228. private _lightAngleScale;
  122229. private _lightAngleOffset;
  122230. /**
  122231. * Gets the cone angle of the spot light in Radians.
  122232. */
  122233. get angle(): number;
  122234. /**
  122235. * Sets the cone angle of the spot light in Radians.
  122236. */
  122237. set angle(value: number);
  122238. /**
  122239. * Only used in gltf falloff mode, this defines the angle where
  122240. * the directional falloff will start before cutting at angle which could be seen
  122241. * as outer angle.
  122242. */
  122243. get innerAngle(): number;
  122244. /**
  122245. * Only used in gltf falloff mode, this defines the angle where
  122246. * the directional falloff will start before cutting at angle which could be seen
  122247. * as outer angle.
  122248. */
  122249. set innerAngle(value: number);
  122250. private _shadowAngleScale;
  122251. /**
  122252. * Allows scaling the angle of the light for shadow generation only.
  122253. */
  122254. get shadowAngleScale(): number;
  122255. /**
  122256. * Allows scaling the angle of the light for shadow generation only.
  122257. */
  122258. set shadowAngleScale(value: number);
  122259. /**
  122260. * The light decay speed with the distance from the emission spot.
  122261. */
  122262. exponent: number;
  122263. private _projectionTextureMatrix;
  122264. /**
  122265. * Allows reading the projecton texture
  122266. */
  122267. get projectionTextureMatrix(): Matrix;
  122268. protected _projectionTextureLightNear: number;
  122269. /**
  122270. * Gets the near clip of the Spotlight for texture projection.
  122271. */
  122272. get projectionTextureLightNear(): number;
  122273. /**
  122274. * Sets the near clip of the Spotlight for texture projection.
  122275. */
  122276. set projectionTextureLightNear(value: number);
  122277. protected _projectionTextureLightFar: number;
  122278. /**
  122279. * Gets the far clip of the Spotlight for texture projection.
  122280. */
  122281. get projectionTextureLightFar(): number;
  122282. /**
  122283. * Sets the far clip of the Spotlight for texture projection.
  122284. */
  122285. set projectionTextureLightFar(value: number);
  122286. protected _projectionTextureUpDirection: Vector3;
  122287. /**
  122288. * Gets the Up vector of the Spotlight for texture projection.
  122289. */
  122290. get projectionTextureUpDirection(): Vector3;
  122291. /**
  122292. * Sets the Up vector of the Spotlight for texture projection.
  122293. */
  122294. set projectionTextureUpDirection(value: Vector3);
  122295. private _projectionTexture;
  122296. /**
  122297. * Gets the projection texture of the light.
  122298. */
  122299. get projectionTexture(): Nullable<BaseTexture>;
  122300. /**
  122301. * Sets the projection texture of the light.
  122302. */
  122303. set projectionTexture(value: Nullable<BaseTexture>);
  122304. private _projectionTextureViewLightDirty;
  122305. private _projectionTextureProjectionLightDirty;
  122306. private _projectionTextureDirty;
  122307. private _projectionTextureViewTargetVector;
  122308. private _projectionTextureViewLightMatrix;
  122309. private _projectionTextureProjectionLightMatrix;
  122310. private _projectionTextureScalingMatrix;
  122311. /**
  122312. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  122313. * It can cast shadows.
  122314. * Documentation : https://doc.babylonjs.com/babylon101/lights
  122315. * @param name The light friendly name
  122316. * @param position The position of the spot light in the scene
  122317. * @param direction The direction of the light in the scene
  122318. * @param angle The cone angle of the light in Radians
  122319. * @param exponent The light decay speed with the distance from the emission spot
  122320. * @param scene The scene the lights belongs to
  122321. */
  122322. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  122323. /**
  122324. * Returns the string "SpotLight".
  122325. * @returns the class name
  122326. */
  122327. getClassName(): string;
  122328. /**
  122329. * Returns the integer 2.
  122330. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  122331. */
  122332. getTypeID(): number;
  122333. /**
  122334. * Overrides the direction setter to recompute the projection texture view light Matrix.
  122335. */
  122336. protected _setDirection(value: Vector3): void;
  122337. /**
  122338. * Overrides the position setter to recompute the projection texture view light Matrix.
  122339. */
  122340. protected _setPosition(value: Vector3): void;
  122341. /**
  122342. * 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.
  122343. * Returns the SpotLight.
  122344. */
  122345. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  122346. protected _computeProjectionTextureViewLightMatrix(): void;
  122347. protected _computeProjectionTextureProjectionLightMatrix(): void;
  122348. /**
  122349. * Main function for light texture projection matrix computing.
  122350. */
  122351. protected _computeProjectionTextureMatrix(): void;
  122352. protected _buildUniformLayout(): void;
  122353. private _computeAngleValues;
  122354. /**
  122355. * Sets the passed Effect "effect" with the Light textures.
  122356. * @param effect The effect to update
  122357. * @param lightIndex The index of the light in the effect to update
  122358. * @returns The light
  122359. */
  122360. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  122361. /**
  122362. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  122363. * @param effect The effect to update
  122364. * @param lightIndex The index of the light in the effect to update
  122365. * @returns The spot light
  122366. */
  122367. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  122368. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  122369. /**
  122370. * Disposes the light and the associated resources.
  122371. */
  122372. dispose(): void;
  122373. /**
  122374. * Prepares the list of defines specific to the light type.
  122375. * @param defines the list of defines
  122376. * @param lightIndex defines the index of the light for the effect
  122377. */
  122378. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  122379. }
  122380. }
  122381. declare module BABYLON {
  122382. /**
  122383. * Gizmo that enables viewing a light
  122384. */
  122385. export class LightGizmo extends Gizmo {
  122386. private _lightMesh;
  122387. private _material;
  122388. private _cachedPosition;
  122389. private _cachedForward;
  122390. private _attachedMeshParent;
  122391. /**
  122392. * Creates a LightGizmo
  122393. * @param gizmoLayer The utility layer the gizmo will be added to
  122394. */
  122395. constructor(gizmoLayer?: UtilityLayerRenderer);
  122396. private _light;
  122397. /**
  122398. * The light that the gizmo is attached to
  122399. */
  122400. set light(light: Nullable<Light>);
  122401. get light(): Nullable<Light>;
  122402. /**
  122403. * Gets the material used to render the light gizmo
  122404. */
  122405. get material(): StandardMaterial;
  122406. /**
  122407. * @hidden
  122408. * Updates the gizmo to match the attached mesh's position/rotation
  122409. */
  122410. protected _update(): void;
  122411. private static _Scale;
  122412. /**
  122413. * Creates the lines for a light mesh
  122414. */
  122415. private static _CreateLightLines;
  122416. /**
  122417. * Disposes of the light gizmo
  122418. */
  122419. dispose(): void;
  122420. private static _CreateHemisphericLightMesh;
  122421. private static _CreatePointLightMesh;
  122422. private static _CreateSpotLightMesh;
  122423. private static _CreateDirectionalLightMesh;
  122424. }
  122425. }
  122426. declare module BABYLON {
  122427. /** @hidden */
  122428. export var backgroundFragmentDeclaration: {
  122429. name: string;
  122430. shader: string;
  122431. };
  122432. }
  122433. declare module BABYLON {
  122434. /** @hidden */
  122435. export var backgroundUboDeclaration: {
  122436. name: string;
  122437. shader: string;
  122438. };
  122439. }
  122440. declare module BABYLON {
  122441. /** @hidden */
  122442. export var backgroundPixelShader: {
  122443. name: string;
  122444. shader: string;
  122445. };
  122446. }
  122447. declare module BABYLON {
  122448. /** @hidden */
  122449. export var backgroundVertexDeclaration: {
  122450. name: string;
  122451. shader: string;
  122452. };
  122453. }
  122454. declare module BABYLON {
  122455. /** @hidden */
  122456. export var backgroundVertexShader: {
  122457. name: string;
  122458. shader: string;
  122459. };
  122460. }
  122461. declare module BABYLON {
  122462. /**
  122463. * Background material used to create an efficient environement around your scene.
  122464. */
  122465. export class BackgroundMaterial extends PushMaterial {
  122466. /**
  122467. * Standard reflectance value at parallel view angle.
  122468. */
  122469. static StandardReflectance0: number;
  122470. /**
  122471. * Standard reflectance value at grazing angle.
  122472. */
  122473. static StandardReflectance90: number;
  122474. protected _primaryColor: Color3;
  122475. /**
  122476. * Key light Color (multiply against the environement texture)
  122477. */
  122478. primaryColor: Color3;
  122479. protected __perceptualColor: Nullable<Color3>;
  122480. /**
  122481. * Experimental Internal Use Only.
  122482. *
  122483. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  122484. * This acts as a helper to set the primary color to a more "human friendly" value.
  122485. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  122486. * output color as close as possible from the chosen value.
  122487. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  122488. * part of lighting setup.)
  122489. */
  122490. get _perceptualColor(): Nullable<Color3>;
  122491. set _perceptualColor(value: Nullable<Color3>);
  122492. protected _primaryColorShadowLevel: float;
  122493. /**
  122494. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  122495. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  122496. */
  122497. get primaryColorShadowLevel(): float;
  122498. set primaryColorShadowLevel(value: float);
  122499. protected _primaryColorHighlightLevel: float;
  122500. /**
  122501. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  122502. * The primary color is used at the level chosen to define what the white area would look.
  122503. */
  122504. get primaryColorHighlightLevel(): float;
  122505. set primaryColorHighlightLevel(value: float);
  122506. protected _reflectionTexture: Nullable<BaseTexture>;
  122507. /**
  122508. * Reflection Texture used in the material.
  122509. * Should be author in a specific way for the best result (refer to the documentation).
  122510. */
  122511. reflectionTexture: Nullable<BaseTexture>;
  122512. protected _reflectionBlur: float;
  122513. /**
  122514. * Reflection Texture level of blur.
  122515. *
  122516. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  122517. * texture twice.
  122518. */
  122519. reflectionBlur: float;
  122520. protected _diffuseTexture: Nullable<BaseTexture>;
  122521. /**
  122522. * Diffuse Texture used in the material.
  122523. * Should be author in a specific way for the best result (refer to the documentation).
  122524. */
  122525. diffuseTexture: Nullable<BaseTexture>;
  122526. protected _shadowLights: Nullable<IShadowLight[]>;
  122527. /**
  122528. * Specify the list of lights casting shadow on the material.
  122529. * All scene shadow lights will be included if null.
  122530. */
  122531. shadowLights: Nullable<IShadowLight[]>;
  122532. protected _shadowLevel: float;
  122533. /**
  122534. * Helps adjusting the shadow to a softer level if required.
  122535. * 0 means black shadows and 1 means no shadows.
  122536. */
  122537. shadowLevel: float;
  122538. protected _sceneCenter: Vector3;
  122539. /**
  122540. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  122541. * It is usually zero but might be interesting to modify according to your setup.
  122542. */
  122543. sceneCenter: Vector3;
  122544. protected _opacityFresnel: boolean;
  122545. /**
  122546. * This helps specifying that the material is falling off to the sky box at grazing angle.
  122547. * This helps ensuring a nice transition when the camera goes under the ground.
  122548. */
  122549. opacityFresnel: boolean;
  122550. protected _reflectionFresnel: boolean;
  122551. /**
  122552. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  122553. * This helps adding a mirror texture on the ground.
  122554. */
  122555. reflectionFresnel: boolean;
  122556. protected _reflectionFalloffDistance: number;
  122557. /**
  122558. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  122559. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  122560. */
  122561. reflectionFalloffDistance: number;
  122562. protected _reflectionAmount: number;
  122563. /**
  122564. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  122565. */
  122566. reflectionAmount: number;
  122567. protected _reflectionReflectance0: number;
  122568. /**
  122569. * This specifies the weight of the reflection at grazing angle.
  122570. */
  122571. reflectionReflectance0: number;
  122572. protected _reflectionReflectance90: number;
  122573. /**
  122574. * This specifies the weight of the reflection at a perpendicular point of view.
  122575. */
  122576. reflectionReflectance90: number;
  122577. /**
  122578. * Sets the reflection reflectance fresnel values according to the default standard
  122579. * empirically know to work well :-)
  122580. */
  122581. set reflectionStandardFresnelWeight(value: number);
  122582. protected _useRGBColor: boolean;
  122583. /**
  122584. * Helps to directly use the maps channels instead of their level.
  122585. */
  122586. useRGBColor: boolean;
  122587. protected _enableNoise: boolean;
  122588. /**
  122589. * This helps reducing the banding effect that could occur on the background.
  122590. */
  122591. enableNoise: boolean;
  122592. /**
  122593. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  122594. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  122595. * Recommended to be keep at 1.0 except for special cases.
  122596. */
  122597. get fovMultiplier(): number;
  122598. set fovMultiplier(value: number);
  122599. private _fovMultiplier;
  122600. /**
  122601. * Enable the FOV adjustment feature controlled by fovMultiplier.
  122602. */
  122603. useEquirectangularFOV: boolean;
  122604. private _maxSimultaneousLights;
  122605. /**
  122606. * Number of Simultaneous lights allowed on the material.
  122607. */
  122608. maxSimultaneousLights: int;
  122609. /**
  122610. * Default configuration related to image processing available in the Background Material.
  122611. */
  122612. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  122613. /**
  122614. * Keep track of the image processing observer to allow dispose and replace.
  122615. */
  122616. private _imageProcessingObserver;
  122617. /**
  122618. * Attaches a new image processing configuration to the PBR Material.
  122619. * @param configuration (if null the scene configuration will be use)
  122620. */
  122621. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  122622. /**
  122623. * Gets the image processing configuration used either in this material.
  122624. */
  122625. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  122626. /**
  122627. * Sets the Default image processing configuration used either in the this material.
  122628. *
  122629. * If sets to null, the scene one is in use.
  122630. */
  122631. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  122632. /**
  122633. * Gets wether the color curves effect is enabled.
  122634. */
  122635. get cameraColorCurvesEnabled(): boolean;
  122636. /**
  122637. * Sets wether the color curves effect is enabled.
  122638. */
  122639. set cameraColorCurvesEnabled(value: boolean);
  122640. /**
  122641. * Gets wether the color grading effect is enabled.
  122642. */
  122643. get cameraColorGradingEnabled(): boolean;
  122644. /**
  122645. * Gets wether the color grading effect is enabled.
  122646. */
  122647. set cameraColorGradingEnabled(value: boolean);
  122648. /**
  122649. * Gets wether tonemapping is enabled or not.
  122650. */
  122651. get cameraToneMappingEnabled(): boolean;
  122652. /**
  122653. * Sets wether tonemapping is enabled or not
  122654. */
  122655. set cameraToneMappingEnabled(value: boolean);
  122656. /**
  122657. * The camera exposure used on this material.
  122658. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  122659. * This corresponds to a photographic exposure.
  122660. */
  122661. get cameraExposure(): float;
  122662. /**
  122663. * The camera exposure used on this material.
  122664. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  122665. * This corresponds to a photographic exposure.
  122666. */
  122667. set cameraExposure(value: float);
  122668. /**
  122669. * Gets The camera contrast used on this material.
  122670. */
  122671. get cameraContrast(): float;
  122672. /**
  122673. * Sets The camera contrast used on this material.
  122674. */
  122675. set cameraContrast(value: float);
  122676. /**
  122677. * Gets the Color Grading 2D Lookup Texture.
  122678. */
  122679. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  122680. /**
  122681. * Sets the Color Grading 2D Lookup Texture.
  122682. */
  122683. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  122684. /**
  122685. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  122686. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  122687. * 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;
  122688. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  122689. */
  122690. get cameraColorCurves(): Nullable<ColorCurves>;
  122691. /**
  122692. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  122693. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  122694. * 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;
  122695. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  122696. */
  122697. set cameraColorCurves(value: Nullable<ColorCurves>);
  122698. /**
  122699. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  122700. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  122701. */
  122702. switchToBGR: boolean;
  122703. private _renderTargets;
  122704. private _reflectionControls;
  122705. private _white;
  122706. private _primaryShadowColor;
  122707. private _primaryHighlightColor;
  122708. /**
  122709. * Instantiates a Background Material in the given scene
  122710. * @param name The friendly name of the material
  122711. * @param scene The scene to add the material to
  122712. */
  122713. constructor(name: string, scene: Scene);
  122714. /**
  122715. * Gets a boolean indicating that current material needs to register RTT
  122716. */
  122717. get hasRenderTargetTextures(): boolean;
  122718. /**
  122719. * The entire material has been created in order to prevent overdraw.
  122720. * @returns false
  122721. */
  122722. needAlphaTesting(): boolean;
  122723. /**
  122724. * The entire material has been created in order to prevent overdraw.
  122725. * @returns true if blending is enable
  122726. */
  122727. needAlphaBlending(): boolean;
  122728. /**
  122729. * Checks wether the material is ready to be rendered for a given mesh.
  122730. * @param mesh The mesh to render
  122731. * @param subMesh The submesh to check against
  122732. * @param useInstances Specify wether or not the material is used with instances
  122733. * @returns true if all the dependencies are ready (Textures, Effects...)
  122734. */
  122735. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  122736. /**
  122737. * Compute the primary color according to the chosen perceptual color.
  122738. */
  122739. private _computePrimaryColorFromPerceptualColor;
  122740. /**
  122741. * Compute the highlights and shadow colors according to their chosen levels.
  122742. */
  122743. private _computePrimaryColors;
  122744. /**
  122745. * Build the uniform buffer used in the material.
  122746. */
  122747. buildUniformLayout(): void;
  122748. /**
  122749. * Unbind the material.
  122750. */
  122751. unbind(): void;
  122752. /**
  122753. * Bind only the world matrix to the material.
  122754. * @param world The world matrix to bind.
  122755. */
  122756. bindOnlyWorldMatrix(world: Matrix): void;
  122757. /**
  122758. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  122759. * @param world The world matrix to bind.
  122760. * @param subMesh The submesh to bind for.
  122761. */
  122762. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  122763. /**
  122764. * Checks to see if a texture is used in the material.
  122765. * @param texture - Base texture to use.
  122766. * @returns - Boolean specifying if a texture is used in the material.
  122767. */
  122768. hasTexture(texture: BaseTexture): boolean;
  122769. /**
  122770. * Dispose the material.
  122771. * @param forceDisposeEffect Force disposal of the associated effect.
  122772. * @param forceDisposeTextures Force disposal of the associated textures.
  122773. */
  122774. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  122775. /**
  122776. * Clones the material.
  122777. * @param name The cloned name.
  122778. * @returns The cloned material.
  122779. */
  122780. clone(name: string): BackgroundMaterial;
  122781. /**
  122782. * Serializes the current material to its JSON representation.
  122783. * @returns The JSON representation.
  122784. */
  122785. serialize(): any;
  122786. /**
  122787. * Gets the class name of the material
  122788. * @returns "BackgroundMaterial"
  122789. */
  122790. getClassName(): string;
  122791. /**
  122792. * Parse a JSON input to create back a background material.
  122793. * @param source The JSON data to parse
  122794. * @param scene The scene to create the parsed material in
  122795. * @param rootUrl The root url of the assets the material depends upon
  122796. * @returns the instantiated BackgroundMaterial.
  122797. */
  122798. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  122799. }
  122800. }
  122801. declare module BABYLON {
  122802. /**
  122803. * Represents the different options available during the creation of
  122804. * a Environment helper.
  122805. *
  122806. * This can control the default ground, skybox and image processing setup of your scene.
  122807. */
  122808. export interface IEnvironmentHelperOptions {
  122809. /**
  122810. * Specifies whether or not to create a ground.
  122811. * True by default.
  122812. */
  122813. createGround: boolean;
  122814. /**
  122815. * Specifies the ground size.
  122816. * 15 by default.
  122817. */
  122818. groundSize: number;
  122819. /**
  122820. * The texture used on the ground for the main color.
  122821. * Comes from the BabylonJS CDN by default.
  122822. *
  122823. * Remarks: Can be either a texture or a url.
  122824. */
  122825. groundTexture: string | BaseTexture;
  122826. /**
  122827. * The color mixed in the ground texture by default.
  122828. * BabylonJS clearColor by default.
  122829. */
  122830. groundColor: Color3;
  122831. /**
  122832. * Specifies the ground opacity.
  122833. * 1 by default.
  122834. */
  122835. groundOpacity: number;
  122836. /**
  122837. * Enables the ground to receive shadows.
  122838. * True by default.
  122839. */
  122840. enableGroundShadow: boolean;
  122841. /**
  122842. * Helps preventing the shadow to be fully black on the ground.
  122843. * 0.5 by default.
  122844. */
  122845. groundShadowLevel: number;
  122846. /**
  122847. * Creates a mirror texture attach to the ground.
  122848. * false by default.
  122849. */
  122850. enableGroundMirror: boolean;
  122851. /**
  122852. * Specifies the ground mirror size ratio.
  122853. * 0.3 by default as the default kernel is 64.
  122854. */
  122855. groundMirrorSizeRatio: number;
  122856. /**
  122857. * Specifies the ground mirror blur kernel size.
  122858. * 64 by default.
  122859. */
  122860. groundMirrorBlurKernel: number;
  122861. /**
  122862. * Specifies the ground mirror visibility amount.
  122863. * 1 by default
  122864. */
  122865. groundMirrorAmount: number;
  122866. /**
  122867. * Specifies the ground mirror reflectance weight.
  122868. * This uses the standard weight of the background material to setup the fresnel effect
  122869. * of the mirror.
  122870. * 1 by default.
  122871. */
  122872. groundMirrorFresnelWeight: number;
  122873. /**
  122874. * Specifies the ground mirror Falloff distance.
  122875. * This can helps reducing the size of the reflection.
  122876. * 0 by Default.
  122877. */
  122878. groundMirrorFallOffDistance: number;
  122879. /**
  122880. * Specifies the ground mirror texture type.
  122881. * Unsigned Int by Default.
  122882. */
  122883. groundMirrorTextureType: number;
  122884. /**
  122885. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  122886. * the shown objects.
  122887. */
  122888. groundYBias: number;
  122889. /**
  122890. * Specifies whether or not to create a skybox.
  122891. * True by default.
  122892. */
  122893. createSkybox: boolean;
  122894. /**
  122895. * Specifies the skybox size.
  122896. * 20 by default.
  122897. */
  122898. skyboxSize: number;
  122899. /**
  122900. * The texture used on the skybox for the main color.
  122901. * Comes from the BabylonJS CDN by default.
  122902. *
  122903. * Remarks: Can be either a texture or a url.
  122904. */
  122905. skyboxTexture: string | BaseTexture;
  122906. /**
  122907. * The color mixed in the skybox texture by default.
  122908. * BabylonJS clearColor by default.
  122909. */
  122910. skyboxColor: Color3;
  122911. /**
  122912. * The background rotation around the Y axis of the scene.
  122913. * This helps aligning the key lights of your scene with the background.
  122914. * 0 by default.
  122915. */
  122916. backgroundYRotation: number;
  122917. /**
  122918. * Compute automatically the size of the elements to best fit with the scene.
  122919. */
  122920. sizeAuto: boolean;
  122921. /**
  122922. * Default position of the rootMesh if autoSize is not true.
  122923. */
  122924. rootPosition: Vector3;
  122925. /**
  122926. * Sets up the image processing in the scene.
  122927. * true by default.
  122928. */
  122929. setupImageProcessing: boolean;
  122930. /**
  122931. * The texture used as your environment texture in the scene.
  122932. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  122933. *
  122934. * Remarks: Can be either a texture or a url.
  122935. */
  122936. environmentTexture: string | BaseTexture;
  122937. /**
  122938. * The value of the exposure to apply to the scene.
  122939. * 0.6 by default if setupImageProcessing is true.
  122940. */
  122941. cameraExposure: number;
  122942. /**
  122943. * The value of the contrast to apply to the scene.
  122944. * 1.6 by default if setupImageProcessing is true.
  122945. */
  122946. cameraContrast: number;
  122947. /**
  122948. * Specifies whether or not tonemapping should be enabled in the scene.
  122949. * true by default if setupImageProcessing is true.
  122950. */
  122951. toneMappingEnabled: boolean;
  122952. }
  122953. /**
  122954. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  122955. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  122956. * It also helps with the default setup of your imageProcessing configuration.
  122957. */
  122958. export class EnvironmentHelper {
  122959. /**
  122960. * Default ground texture URL.
  122961. */
  122962. private static _groundTextureCDNUrl;
  122963. /**
  122964. * Default skybox texture URL.
  122965. */
  122966. private static _skyboxTextureCDNUrl;
  122967. /**
  122968. * Default environment texture URL.
  122969. */
  122970. private static _environmentTextureCDNUrl;
  122971. /**
  122972. * Creates the default options for the helper.
  122973. */
  122974. private static _getDefaultOptions;
  122975. private _rootMesh;
  122976. /**
  122977. * Gets the root mesh created by the helper.
  122978. */
  122979. get rootMesh(): Mesh;
  122980. private _skybox;
  122981. /**
  122982. * Gets the skybox created by the helper.
  122983. */
  122984. get skybox(): Nullable<Mesh>;
  122985. private _skyboxTexture;
  122986. /**
  122987. * Gets the skybox texture created by the helper.
  122988. */
  122989. get skyboxTexture(): Nullable<BaseTexture>;
  122990. private _skyboxMaterial;
  122991. /**
  122992. * Gets the skybox material created by the helper.
  122993. */
  122994. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  122995. private _ground;
  122996. /**
  122997. * Gets the ground mesh created by the helper.
  122998. */
  122999. get ground(): Nullable<Mesh>;
  123000. private _groundTexture;
  123001. /**
  123002. * Gets the ground texture created by the helper.
  123003. */
  123004. get groundTexture(): Nullable<BaseTexture>;
  123005. private _groundMirror;
  123006. /**
  123007. * Gets the ground mirror created by the helper.
  123008. */
  123009. get groundMirror(): Nullable<MirrorTexture>;
  123010. /**
  123011. * Gets the ground mirror render list to helps pushing the meshes
  123012. * you wish in the ground reflection.
  123013. */
  123014. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  123015. private _groundMaterial;
  123016. /**
  123017. * Gets the ground material created by the helper.
  123018. */
  123019. get groundMaterial(): Nullable<BackgroundMaterial>;
  123020. /**
  123021. * Stores the creation options.
  123022. */
  123023. private readonly _scene;
  123024. private _options;
  123025. /**
  123026. * This observable will be notified with any error during the creation of the environment,
  123027. * mainly texture creation errors.
  123028. */
  123029. onErrorObservable: Observable<{
  123030. message?: string;
  123031. exception?: any;
  123032. }>;
  123033. /**
  123034. * constructor
  123035. * @param options Defines the options we want to customize the helper
  123036. * @param scene The scene to add the material to
  123037. */
  123038. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  123039. /**
  123040. * Updates the background according to the new options
  123041. * @param options
  123042. */
  123043. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  123044. /**
  123045. * Sets the primary color of all the available elements.
  123046. * @param color the main color to affect to the ground and the background
  123047. */
  123048. setMainColor(color: Color3): void;
  123049. /**
  123050. * Setup the image processing according to the specified options.
  123051. */
  123052. private _setupImageProcessing;
  123053. /**
  123054. * Setup the environment texture according to the specified options.
  123055. */
  123056. private _setupEnvironmentTexture;
  123057. /**
  123058. * Setup the background according to the specified options.
  123059. */
  123060. private _setupBackground;
  123061. /**
  123062. * Get the scene sizes according to the setup.
  123063. */
  123064. private _getSceneSize;
  123065. /**
  123066. * Setup the ground according to the specified options.
  123067. */
  123068. private _setupGround;
  123069. /**
  123070. * Setup the ground material according to the specified options.
  123071. */
  123072. private _setupGroundMaterial;
  123073. /**
  123074. * Setup the ground diffuse texture according to the specified options.
  123075. */
  123076. private _setupGroundDiffuseTexture;
  123077. /**
  123078. * Setup the ground mirror texture according to the specified options.
  123079. */
  123080. private _setupGroundMirrorTexture;
  123081. /**
  123082. * Setup the ground to receive the mirror texture.
  123083. */
  123084. private _setupMirrorInGroundMaterial;
  123085. /**
  123086. * Setup the skybox according to the specified options.
  123087. */
  123088. private _setupSkybox;
  123089. /**
  123090. * Setup the skybox material according to the specified options.
  123091. */
  123092. private _setupSkyboxMaterial;
  123093. /**
  123094. * Setup the skybox reflection texture according to the specified options.
  123095. */
  123096. private _setupSkyboxReflectionTexture;
  123097. private _errorHandler;
  123098. /**
  123099. * Dispose all the elements created by the Helper.
  123100. */
  123101. dispose(): void;
  123102. }
  123103. }
  123104. declare module BABYLON {
  123105. /**
  123106. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  123107. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  123108. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  123109. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  123110. */
  123111. export class PhotoDome extends TransformNode {
  123112. /**
  123113. * Define the image as a Monoscopic panoramic 360 image.
  123114. */
  123115. static readonly MODE_MONOSCOPIC: number;
  123116. /**
  123117. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  123118. */
  123119. static readonly MODE_TOPBOTTOM: number;
  123120. /**
  123121. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  123122. */
  123123. static readonly MODE_SIDEBYSIDE: number;
  123124. private _useDirectMapping;
  123125. /**
  123126. * The texture being displayed on the sphere
  123127. */
  123128. protected _photoTexture: Texture;
  123129. /**
  123130. * Gets or sets the texture being displayed on the sphere
  123131. */
  123132. get photoTexture(): Texture;
  123133. set photoTexture(value: Texture);
  123134. /**
  123135. * Observable raised when an error occured while loading the 360 image
  123136. */
  123137. onLoadErrorObservable: Observable<string>;
  123138. /**
  123139. * The skybox material
  123140. */
  123141. protected _material: BackgroundMaterial;
  123142. /**
  123143. * The surface used for the skybox
  123144. */
  123145. protected _mesh: Mesh;
  123146. /**
  123147. * Gets the mesh used for the skybox.
  123148. */
  123149. get mesh(): Mesh;
  123150. /**
  123151. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  123152. * Also see the options.resolution property.
  123153. */
  123154. get fovMultiplier(): number;
  123155. set fovMultiplier(value: number);
  123156. private _imageMode;
  123157. /**
  123158. * Gets or set the current video mode for the video. It can be:
  123159. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  123160. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  123161. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  123162. */
  123163. get imageMode(): number;
  123164. set imageMode(value: number);
  123165. /**
  123166. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  123167. * @param name Element's name, child elements will append suffixes for their own names.
  123168. * @param urlsOfPhoto defines the url of the photo to display
  123169. * @param options defines an object containing optional or exposed sub element properties
  123170. * @param onError defines a callback called when an error occured while loading the texture
  123171. */
  123172. constructor(name: string, urlOfPhoto: string, options: {
  123173. resolution?: number;
  123174. size?: number;
  123175. useDirectMapping?: boolean;
  123176. faceForward?: boolean;
  123177. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  123178. private _onBeforeCameraRenderObserver;
  123179. private _changeImageMode;
  123180. /**
  123181. * Releases resources associated with this node.
  123182. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  123183. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  123184. */
  123185. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  123186. }
  123187. }
  123188. declare module BABYLON {
  123189. /**
  123190. * Class used to host RGBD texture specific utilities
  123191. */
  123192. export class RGBDTextureTools {
  123193. /**
  123194. * Expand the RGBD Texture from RGBD to Half Float if possible.
  123195. * @param texture the texture to expand.
  123196. */
  123197. static ExpandRGBDTexture(texture: Texture): void;
  123198. }
  123199. }
  123200. declare module BABYLON {
  123201. /**
  123202. * Class used to host texture specific utilities
  123203. */
  123204. export class BRDFTextureTools {
  123205. /**
  123206. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  123207. * @param scene defines the hosting scene
  123208. * @returns the environment BRDF texture
  123209. */
  123210. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  123211. private static _environmentBRDFBase64Texture;
  123212. }
  123213. }
  123214. declare module BABYLON {
  123215. /**
  123216. * @hidden
  123217. */
  123218. export interface IMaterialClearCoatDefines {
  123219. CLEARCOAT: boolean;
  123220. CLEARCOAT_DEFAULTIOR: boolean;
  123221. CLEARCOAT_TEXTURE: boolean;
  123222. CLEARCOAT_TEXTUREDIRECTUV: number;
  123223. CLEARCOAT_BUMP: boolean;
  123224. CLEARCOAT_BUMPDIRECTUV: number;
  123225. CLEARCOAT_TINT: boolean;
  123226. CLEARCOAT_TINT_TEXTURE: boolean;
  123227. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  123228. /** @hidden */
  123229. _areTexturesDirty: boolean;
  123230. }
  123231. /**
  123232. * Define the code related to the clear coat parameters of the pbr material.
  123233. */
  123234. export class PBRClearCoatConfiguration {
  123235. /**
  123236. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  123237. * The default fits with a polyurethane material.
  123238. */
  123239. private static readonly _DefaultIndexOfRefraction;
  123240. private _isEnabled;
  123241. /**
  123242. * Defines if the clear coat is enabled in the material.
  123243. */
  123244. isEnabled: boolean;
  123245. /**
  123246. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  123247. */
  123248. intensity: number;
  123249. /**
  123250. * Defines the clear coat layer roughness.
  123251. */
  123252. roughness: number;
  123253. private _indexOfRefraction;
  123254. /**
  123255. * Defines the index of refraction of the clear coat.
  123256. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  123257. * The default fits with a polyurethane material.
  123258. * Changing the default value is more performance intensive.
  123259. */
  123260. indexOfRefraction: number;
  123261. private _texture;
  123262. /**
  123263. * Stores the clear coat values in a texture.
  123264. */
  123265. texture: Nullable<BaseTexture>;
  123266. private _bumpTexture;
  123267. /**
  123268. * Define the clear coat specific bump texture.
  123269. */
  123270. bumpTexture: Nullable<BaseTexture>;
  123271. private _isTintEnabled;
  123272. /**
  123273. * Defines if the clear coat tint is enabled in the material.
  123274. */
  123275. isTintEnabled: boolean;
  123276. /**
  123277. * Defines the clear coat tint of the material.
  123278. * This is only use if tint is enabled
  123279. */
  123280. tintColor: Color3;
  123281. /**
  123282. * Defines the distance at which the tint color should be found in the
  123283. * clear coat media.
  123284. * This is only use if tint is enabled
  123285. */
  123286. tintColorAtDistance: number;
  123287. /**
  123288. * Defines the clear coat layer thickness.
  123289. * This is only use if tint is enabled
  123290. */
  123291. tintThickness: number;
  123292. private _tintTexture;
  123293. /**
  123294. * Stores the clear tint values in a texture.
  123295. * rgb is tint
  123296. * a is a thickness factor
  123297. */
  123298. tintTexture: Nullable<BaseTexture>;
  123299. /** @hidden */
  123300. private _internalMarkAllSubMeshesAsTexturesDirty;
  123301. /** @hidden */
  123302. _markAllSubMeshesAsTexturesDirty(): void;
  123303. /**
  123304. * Instantiate a new istance of clear coat configuration.
  123305. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123306. */
  123307. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123308. /**
  123309. * Gets wehter the submesh is ready to be used or not.
  123310. * @param defines the list of "defines" to update.
  123311. * @param scene defines the scene the material belongs to.
  123312. * @param engine defines the engine the material belongs to.
  123313. * @param disableBumpMap defines wether the material disables bump or not.
  123314. * @returns - boolean indicating that the submesh is ready or not.
  123315. */
  123316. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  123317. /**
  123318. * Checks to see if a texture is used in the material.
  123319. * @param defines the list of "defines" to update.
  123320. * @param scene defines the scene to the material belongs to.
  123321. */
  123322. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  123323. /**
  123324. * Binds the material data.
  123325. * @param uniformBuffer defines the Uniform buffer to fill in.
  123326. * @param scene defines the scene the material belongs to.
  123327. * @param engine defines the engine the material belongs to.
  123328. * @param disableBumpMap defines wether the material disables bump or not.
  123329. * @param isFrozen defines wether the material is frozen or not.
  123330. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  123331. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  123332. */
  123333. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  123334. /**
  123335. * Checks to see if a texture is used in the material.
  123336. * @param texture - Base texture to use.
  123337. * @returns - Boolean specifying if a texture is used in the material.
  123338. */
  123339. hasTexture(texture: BaseTexture): boolean;
  123340. /**
  123341. * Returns an array of the actively used textures.
  123342. * @param activeTextures Array of BaseTextures
  123343. */
  123344. getActiveTextures(activeTextures: BaseTexture[]): void;
  123345. /**
  123346. * Returns the animatable textures.
  123347. * @param animatables Array of animatable textures.
  123348. */
  123349. getAnimatables(animatables: IAnimatable[]): void;
  123350. /**
  123351. * Disposes the resources of the material.
  123352. * @param forceDisposeTextures - Forces the disposal of all textures.
  123353. */
  123354. dispose(forceDisposeTextures?: boolean): void;
  123355. /**
  123356. * Get the current class name of the texture useful for serialization or dynamic coding.
  123357. * @returns "PBRClearCoatConfiguration"
  123358. */
  123359. getClassName(): string;
  123360. /**
  123361. * Add fallbacks to the effect fallbacks list.
  123362. * @param defines defines the Base texture to use.
  123363. * @param fallbacks defines the current fallback list.
  123364. * @param currentRank defines the current fallback rank.
  123365. * @returns the new fallback rank.
  123366. */
  123367. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123368. /**
  123369. * Add the required uniforms to the current list.
  123370. * @param uniforms defines the current uniform list.
  123371. */
  123372. static AddUniforms(uniforms: string[]): void;
  123373. /**
  123374. * Add the required samplers to the current list.
  123375. * @param samplers defines the current sampler list.
  123376. */
  123377. static AddSamplers(samplers: string[]): void;
  123378. /**
  123379. * Add the required uniforms to the current buffer.
  123380. * @param uniformBuffer defines the current uniform buffer.
  123381. */
  123382. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123383. /**
  123384. * Makes a duplicate of the current configuration into another one.
  123385. * @param clearCoatConfiguration define the config where to copy the info
  123386. */
  123387. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  123388. /**
  123389. * Serializes this clear coat configuration.
  123390. * @returns - An object with the serialized config.
  123391. */
  123392. serialize(): any;
  123393. /**
  123394. * Parses a anisotropy Configuration from a serialized object.
  123395. * @param source - Serialized object.
  123396. * @param scene Defines the scene we are parsing for
  123397. * @param rootUrl Defines the rootUrl to load from
  123398. */
  123399. parse(source: any, scene: Scene, rootUrl: string): void;
  123400. }
  123401. }
  123402. declare module BABYLON {
  123403. /**
  123404. * @hidden
  123405. */
  123406. export interface IMaterialAnisotropicDefines {
  123407. ANISOTROPIC: boolean;
  123408. ANISOTROPIC_TEXTURE: boolean;
  123409. ANISOTROPIC_TEXTUREDIRECTUV: number;
  123410. MAINUV1: boolean;
  123411. _areTexturesDirty: boolean;
  123412. _needUVs: boolean;
  123413. }
  123414. /**
  123415. * Define the code related to the anisotropic parameters of the pbr material.
  123416. */
  123417. export class PBRAnisotropicConfiguration {
  123418. private _isEnabled;
  123419. /**
  123420. * Defines if the anisotropy is enabled in the material.
  123421. */
  123422. isEnabled: boolean;
  123423. /**
  123424. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  123425. */
  123426. intensity: number;
  123427. /**
  123428. * Defines if the effect is along the tangents, bitangents or in between.
  123429. * By default, the effect is "strectching" the highlights along the tangents.
  123430. */
  123431. direction: Vector2;
  123432. private _texture;
  123433. /**
  123434. * Stores the anisotropy values in a texture.
  123435. * rg is direction (like normal from -1 to 1)
  123436. * b is a intensity
  123437. */
  123438. texture: Nullable<BaseTexture>;
  123439. /** @hidden */
  123440. private _internalMarkAllSubMeshesAsTexturesDirty;
  123441. /** @hidden */
  123442. _markAllSubMeshesAsTexturesDirty(): void;
  123443. /**
  123444. * Instantiate a new istance of anisotropy configuration.
  123445. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123446. */
  123447. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123448. /**
  123449. * Specifies that the submesh is ready to be used.
  123450. * @param defines the list of "defines" to update.
  123451. * @param scene defines the scene the material belongs to.
  123452. * @returns - boolean indicating that the submesh is ready or not.
  123453. */
  123454. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  123455. /**
  123456. * Checks to see if a texture is used in the material.
  123457. * @param defines the list of "defines" to update.
  123458. * @param mesh the mesh we are preparing the defines for.
  123459. * @param scene defines the scene the material belongs to.
  123460. */
  123461. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  123462. /**
  123463. * Binds the material data.
  123464. * @param uniformBuffer defines the Uniform buffer to fill in.
  123465. * @param scene defines the scene the material belongs to.
  123466. * @param isFrozen defines wether the material is frozen or not.
  123467. */
  123468. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  123469. /**
  123470. * Checks to see if a texture is used in the material.
  123471. * @param texture - Base texture to use.
  123472. * @returns - Boolean specifying if a texture is used in the material.
  123473. */
  123474. hasTexture(texture: BaseTexture): boolean;
  123475. /**
  123476. * Returns an array of the actively used textures.
  123477. * @param activeTextures Array of BaseTextures
  123478. */
  123479. getActiveTextures(activeTextures: BaseTexture[]): void;
  123480. /**
  123481. * Returns the animatable textures.
  123482. * @param animatables Array of animatable textures.
  123483. */
  123484. getAnimatables(animatables: IAnimatable[]): void;
  123485. /**
  123486. * Disposes the resources of the material.
  123487. * @param forceDisposeTextures - Forces the disposal of all textures.
  123488. */
  123489. dispose(forceDisposeTextures?: boolean): void;
  123490. /**
  123491. * Get the current class name of the texture useful for serialization or dynamic coding.
  123492. * @returns "PBRAnisotropicConfiguration"
  123493. */
  123494. getClassName(): string;
  123495. /**
  123496. * Add fallbacks to the effect fallbacks list.
  123497. * @param defines defines the Base texture to use.
  123498. * @param fallbacks defines the current fallback list.
  123499. * @param currentRank defines the current fallback rank.
  123500. * @returns the new fallback rank.
  123501. */
  123502. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123503. /**
  123504. * Add the required uniforms to the current list.
  123505. * @param uniforms defines the current uniform list.
  123506. */
  123507. static AddUniforms(uniforms: string[]): void;
  123508. /**
  123509. * Add the required uniforms to the current buffer.
  123510. * @param uniformBuffer defines the current uniform buffer.
  123511. */
  123512. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123513. /**
  123514. * Add the required samplers to the current list.
  123515. * @param samplers defines the current sampler list.
  123516. */
  123517. static AddSamplers(samplers: string[]): void;
  123518. /**
  123519. * Makes a duplicate of the current configuration into another one.
  123520. * @param anisotropicConfiguration define the config where to copy the info
  123521. */
  123522. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  123523. /**
  123524. * Serializes this anisotropy configuration.
  123525. * @returns - An object with the serialized config.
  123526. */
  123527. serialize(): any;
  123528. /**
  123529. * Parses a anisotropy Configuration from a serialized object.
  123530. * @param source - Serialized object.
  123531. * @param scene Defines the scene we are parsing for
  123532. * @param rootUrl Defines the rootUrl to load from
  123533. */
  123534. parse(source: any, scene: Scene, rootUrl: string): void;
  123535. }
  123536. }
  123537. declare module BABYLON {
  123538. /**
  123539. * @hidden
  123540. */
  123541. export interface IMaterialBRDFDefines {
  123542. BRDF_V_HEIGHT_CORRELATED: boolean;
  123543. MS_BRDF_ENERGY_CONSERVATION: boolean;
  123544. SPHERICAL_HARMONICS: boolean;
  123545. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  123546. /** @hidden */
  123547. _areMiscDirty: boolean;
  123548. }
  123549. /**
  123550. * Define the code related to the BRDF parameters of the pbr material.
  123551. */
  123552. export class PBRBRDFConfiguration {
  123553. /**
  123554. * Default value used for the energy conservation.
  123555. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  123556. */
  123557. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  123558. /**
  123559. * Default value used for the Smith Visibility Height Correlated mode.
  123560. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  123561. */
  123562. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  123563. /**
  123564. * Default value used for the IBL diffuse part.
  123565. * This can help switching back to the polynomials mode globally which is a tiny bit
  123566. * less GPU intensive at the drawback of a lower quality.
  123567. */
  123568. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  123569. /**
  123570. * Default value used for activating energy conservation for the specular workflow.
  123571. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  123572. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  123573. */
  123574. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  123575. private _useEnergyConservation;
  123576. /**
  123577. * Defines if the material uses energy conservation.
  123578. */
  123579. useEnergyConservation: boolean;
  123580. private _useSmithVisibilityHeightCorrelated;
  123581. /**
  123582. * LEGACY Mode set to false
  123583. * Defines if the material uses height smith correlated visibility term.
  123584. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  123585. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  123586. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  123587. * Not relying on height correlated will also disable energy conservation.
  123588. */
  123589. useSmithVisibilityHeightCorrelated: boolean;
  123590. private _useSphericalHarmonics;
  123591. /**
  123592. * LEGACY Mode set to false
  123593. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  123594. * diffuse part of the IBL.
  123595. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  123596. * to the ground truth.
  123597. */
  123598. useSphericalHarmonics: boolean;
  123599. private _useSpecularGlossinessInputEnergyConservation;
  123600. /**
  123601. * Defines if the material uses energy conservation, when the specular workflow is active.
  123602. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  123603. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  123604. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  123605. */
  123606. useSpecularGlossinessInputEnergyConservation: boolean;
  123607. /** @hidden */
  123608. private _internalMarkAllSubMeshesAsMiscDirty;
  123609. /** @hidden */
  123610. _markAllSubMeshesAsMiscDirty(): void;
  123611. /**
  123612. * Instantiate a new istance of clear coat configuration.
  123613. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  123614. */
  123615. constructor(markAllSubMeshesAsMiscDirty: () => void);
  123616. /**
  123617. * Checks to see if a texture is used in the material.
  123618. * @param defines the list of "defines" to update.
  123619. */
  123620. prepareDefines(defines: IMaterialBRDFDefines): void;
  123621. /**
  123622. * Get the current class name of the texture useful for serialization or dynamic coding.
  123623. * @returns "PBRClearCoatConfiguration"
  123624. */
  123625. getClassName(): string;
  123626. /**
  123627. * Makes a duplicate of the current configuration into another one.
  123628. * @param brdfConfiguration define the config where to copy the info
  123629. */
  123630. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  123631. /**
  123632. * Serializes this BRDF configuration.
  123633. * @returns - An object with the serialized config.
  123634. */
  123635. serialize(): any;
  123636. /**
  123637. * Parses a anisotropy Configuration from a serialized object.
  123638. * @param source - Serialized object.
  123639. * @param scene Defines the scene we are parsing for
  123640. * @param rootUrl Defines the rootUrl to load from
  123641. */
  123642. parse(source: any, scene: Scene, rootUrl: string): void;
  123643. }
  123644. }
  123645. declare module BABYLON {
  123646. /**
  123647. * @hidden
  123648. */
  123649. export interface IMaterialSheenDefines {
  123650. SHEEN: boolean;
  123651. SHEEN_TEXTURE: boolean;
  123652. SHEEN_TEXTUREDIRECTUV: number;
  123653. SHEEN_LINKWITHALBEDO: boolean;
  123654. /** @hidden */
  123655. _areTexturesDirty: boolean;
  123656. }
  123657. /**
  123658. * Define the code related to the Sheen parameters of the pbr material.
  123659. */
  123660. export class PBRSheenConfiguration {
  123661. private _isEnabled;
  123662. /**
  123663. * Defines if the material uses sheen.
  123664. */
  123665. isEnabled: boolean;
  123666. private _linkSheenWithAlbedo;
  123667. /**
  123668. * Defines if the sheen is linked to the sheen color.
  123669. */
  123670. linkSheenWithAlbedo: boolean;
  123671. /**
  123672. * Defines the sheen intensity.
  123673. */
  123674. intensity: number;
  123675. /**
  123676. * Defines the sheen color.
  123677. */
  123678. color: Color3;
  123679. private _texture;
  123680. /**
  123681. * Stores the sheen tint values in a texture.
  123682. * rgb is tint
  123683. * a is a intensity
  123684. */
  123685. texture: Nullable<BaseTexture>;
  123686. /** @hidden */
  123687. private _internalMarkAllSubMeshesAsTexturesDirty;
  123688. /** @hidden */
  123689. _markAllSubMeshesAsTexturesDirty(): void;
  123690. /**
  123691. * Instantiate a new istance of clear coat configuration.
  123692. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123693. */
  123694. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123695. /**
  123696. * Specifies that the submesh is ready to be used.
  123697. * @param defines the list of "defines" to update.
  123698. * @param scene defines the scene the material belongs to.
  123699. * @returns - boolean indicating that the submesh is ready or not.
  123700. */
  123701. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  123702. /**
  123703. * Checks to see if a texture is used in the material.
  123704. * @param defines the list of "defines" to update.
  123705. * @param scene defines the scene the material belongs to.
  123706. */
  123707. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  123708. /**
  123709. * Binds the material data.
  123710. * @param uniformBuffer defines the Uniform buffer to fill in.
  123711. * @param scene defines the scene the material belongs to.
  123712. * @param isFrozen defines wether the material is frozen or not.
  123713. */
  123714. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  123715. /**
  123716. * Checks to see if a texture is used in the material.
  123717. * @param texture - Base texture to use.
  123718. * @returns - Boolean specifying if a texture is used in the material.
  123719. */
  123720. hasTexture(texture: BaseTexture): boolean;
  123721. /**
  123722. * Returns an array of the actively used textures.
  123723. * @param activeTextures Array of BaseTextures
  123724. */
  123725. getActiveTextures(activeTextures: BaseTexture[]): void;
  123726. /**
  123727. * Returns the animatable textures.
  123728. * @param animatables Array of animatable textures.
  123729. */
  123730. getAnimatables(animatables: IAnimatable[]): void;
  123731. /**
  123732. * Disposes the resources of the material.
  123733. * @param forceDisposeTextures - Forces the disposal of all textures.
  123734. */
  123735. dispose(forceDisposeTextures?: boolean): void;
  123736. /**
  123737. * Get the current class name of the texture useful for serialization or dynamic coding.
  123738. * @returns "PBRSheenConfiguration"
  123739. */
  123740. getClassName(): string;
  123741. /**
  123742. * Add fallbacks to the effect fallbacks list.
  123743. * @param defines defines the Base texture to use.
  123744. * @param fallbacks defines the current fallback list.
  123745. * @param currentRank defines the current fallback rank.
  123746. * @returns the new fallback rank.
  123747. */
  123748. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123749. /**
  123750. * Add the required uniforms to the current list.
  123751. * @param uniforms defines the current uniform list.
  123752. */
  123753. static AddUniforms(uniforms: string[]): void;
  123754. /**
  123755. * Add the required uniforms to the current buffer.
  123756. * @param uniformBuffer defines the current uniform buffer.
  123757. */
  123758. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123759. /**
  123760. * Add the required samplers to the current list.
  123761. * @param samplers defines the current sampler list.
  123762. */
  123763. static AddSamplers(samplers: string[]): void;
  123764. /**
  123765. * Makes a duplicate of the current configuration into another one.
  123766. * @param sheenConfiguration define the config where to copy the info
  123767. */
  123768. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  123769. /**
  123770. * Serializes this BRDF configuration.
  123771. * @returns - An object with the serialized config.
  123772. */
  123773. serialize(): any;
  123774. /**
  123775. * Parses a anisotropy Configuration from a serialized object.
  123776. * @param source - Serialized object.
  123777. * @param scene Defines the scene we are parsing for
  123778. * @param rootUrl Defines the rootUrl to load from
  123779. */
  123780. parse(source: any, scene: Scene, rootUrl: string): void;
  123781. }
  123782. }
  123783. declare module BABYLON {
  123784. /**
  123785. * @hidden
  123786. */
  123787. export interface IMaterialSubSurfaceDefines {
  123788. SUBSURFACE: boolean;
  123789. SS_REFRACTION: boolean;
  123790. SS_TRANSLUCENCY: boolean;
  123791. SS_SCATERRING: boolean;
  123792. SS_THICKNESSANDMASK_TEXTURE: boolean;
  123793. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  123794. SS_REFRACTIONMAP_3D: boolean;
  123795. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  123796. SS_LODINREFRACTIONALPHA: boolean;
  123797. SS_GAMMAREFRACTION: boolean;
  123798. SS_RGBDREFRACTION: boolean;
  123799. SS_LINEARSPECULARREFRACTION: boolean;
  123800. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  123801. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  123802. /** @hidden */
  123803. _areTexturesDirty: boolean;
  123804. }
  123805. /**
  123806. * Define the code related to the sub surface parameters of the pbr material.
  123807. */
  123808. export class PBRSubSurfaceConfiguration {
  123809. private _isRefractionEnabled;
  123810. /**
  123811. * Defines if the refraction is enabled in the material.
  123812. */
  123813. isRefractionEnabled: boolean;
  123814. private _isTranslucencyEnabled;
  123815. /**
  123816. * Defines if the translucency is enabled in the material.
  123817. */
  123818. isTranslucencyEnabled: boolean;
  123819. private _isScatteringEnabled;
  123820. /**
  123821. * Defines the refraction intensity of the material.
  123822. * The refraction when enabled replaces the Diffuse part of the material.
  123823. * The intensity helps transitionning between diffuse and refraction.
  123824. */
  123825. refractionIntensity: number;
  123826. /**
  123827. * Defines the translucency intensity of the material.
  123828. * When translucency has been enabled, this defines how much of the "translucency"
  123829. * is addded to the diffuse part of the material.
  123830. */
  123831. translucencyIntensity: number;
  123832. /**
  123833. * Defines the scattering intensity of the material.
  123834. * When scattering has been enabled, this defines how much of the "scattered light"
  123835. * is addded to the diffuse part of the material.
  123836. */
  123837. scatteringIntensity: number;
  123838. private _thicknessTexture;
  123839. /**
  123840. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  123841. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  123842. * 0 would mean minimumThickness
  123843. * 1 would mean maximumThickness
  123844. * The other channels might be use as a mask to vary the different effects intensity.
  123845. */
  123846. thicknessTexture: Nullable<BaseTexture>;
  123847. private _refractionTexture;
  123848. /**
  123849. * Defines the texture to use for refraction.
  123850. */
  123851. refractionTexture: Nullable<BaseTexture>;
  123852. private _indexOfRefraction;
  123853. /**
  123854. * Defines the index of refraction used in the material.
  123855. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  123856. */
  123857. indexOfRefraction: number;
  123858. private _invertRefractionY;
  123859. /**
  123860. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  123861. */
  123862. invertRefractionY: boolean;
  123863. private _linkRefractionWithTransparency;
  123864. /**
  123865. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  123866. * Materials half opaque for instance using refraction could benefit from this control.
  123867. */
  123868. linkRefractionWithTransparency: boolean;
  123869. /**
  123870. * Defines the minimum thickness stored in the thickness map.
  123871. * If no thickness map is defined, this value will be used to simulate thickness.
  123872. */
  123873. minimumThickness: number;
  123874. /**
  123875. * Defines the maximum thickness stored in the thickness map.
  123876. */
  123877. maximumThickness: number;
  123878. /**
  123879. * Defines the volume tint of the material.
  123880. * This is used for both translucency and scattering.
  123881. */
  123882. tintColor: Color3;
  123883. /**
  123884. * Defines the distance at which the tint color should be found in the media.
  123885. * This is used for refraction only.
  123886. */
  123887. tintColorAtDistance: number;
  123888. /**
  123889. * Defines how far each channel transmit through the media.
  123890. * It is defined as a color to simplify it selection.
  123891. */
  123892. diffusionDistance: Color3;
  123893. private _useMaskFromThicknessTexture;
  123894. /**
  123895. * Stores the intensity of the different subsurface effects in the thickness texture.
  123896. * * the green channel is the translucency intensity.
  123897. * * the blue channel is the scattering intensity.
  123898. * * the alpha channel is the refraction intensity.
  123899. */
  123900. useMaskFromThicknessTexture: boolean;
  123901. /** @hidden */
  123902. private _internalMarkAllSubMeshesAsTexturesDirty;
  123903. /** @hidden */
  123904. _markAllSubMeshesAsTexturesDirty(): void;
  123905. /**
  123906. * Instantiate a new istance of sub surface configuration.
  123907. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123908. */
  123909. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123910. /**
  123911. * Gets wehter the submesh is ready to be used or not.
  123912. * @param defines the list of "defines" to update.
  123913. * @param scene defines the scene the material belongs to.
  123914. * @returns - boolean indicating that the submesh is ready or not.
  123915. */
  123916. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  123917. /**
  123918. * Checks to see if a texture is used in the material.
  123919. * @param defines the list of "defines" to update.
  123920. * @param scene defines the scene to the material belongs to.
  123921. */
  123922. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  123923. /**
  123924. * Binds the material data.
  123925. * @param uniformBuffer defines the Uniform buffer to fill in.
  123926. * @param scene defines the scene the material belongs to.
  123927. * @param engine defines the engine the material belongs to.
  123928. * @param isFrozen defines wether the material is frozen or not.
  123929. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  123930. */
  123931. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  123932. /**
  123933. * Unbinds the material from the mesh.
  123934. * @param activeEffect defines the effect that should be unbound from.
  123935. * @returns true if unbound, otherwise false
  123936. */
  123937. unbind(activeEffect: Effect): boolean;
  123938. /**
  123939. * Returns the texture used for refraction or null if none is used.
  123940. * @param scene defines the scene the material belongs to.
  123941. * @returns - Refraction texture if present. If no refraction texture and refraction
  123942. * is linked with transparency, returns environment texture. Otherwise, returns null.
  123943. */
  123944. private _getRefractionTexture;
  123945. /**
  123946. * Returns true if alpha blending should be disabled.
  123947. */
  123948. get disableAlphaBlending(): boolean;
  123949. /**
  123950. * Fills the list of render target textures.
  123951. * @param renderTargets the list of render targets to update
  123952. */
  123953. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  123954. /**
  123955. * Checks to see if a texture is used in the material.
  123956. * @param texture - Base texture to use.
  123957. * @returns - Boolean specifying if a texture is used in the material.
  123958. */
  123959. hasTexture(texture: BaseTexture): boolean;
  123960. /**
  123961. * Gets a boolean indicating that current material needs to register RTT
  123962. * @returns true if this uses a render target otherwise false.
  123963. */
  123964. hasRenderTargetTextures(): boolean;
  123965. /**
  123966. * Returns an array of the actively used textures.
  123967. * @param activeTextures Array of BaseTextures
  123968. */
  123969. getActiveTextures(activeTextures: BaseTexture[]): void;
  123970. /**
  123971. * Returns the animatable textures.
  123972. * @param animatables Array of animatable textures.
  123973. */
  123974. getAnimatables(animatables: IAnimatable[]): void;
  123975. /**
  123976. * Disposes the resources of the material.
  123977. * @param forceDisposeTextures - Forces the disposal of all textures.
  123978. */
  123979. dispose(forceDisposeTextures?: boolean): void;
  123980. /**
  123981. * Get the current class name of the texture useful for serialization or dynamic coding.
  123982. * @returns "PBRSubSurfaceConfiguration"
  123983. */
  123984. getClassName(): string;
  123985. /**
  123986. * Add fallbacks to the effect fallbacks list.
  123987. * @param defines defines the Base texture to use.
  123988. * @param fallbacks defines the current fallback list.
  123989. * @param currentRank defines the current fallback rank.
  123990. * @returns the new fallback rank.
  123991. */
  123992. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123993. /**
  123994. * Add the required uniforms to the current list.
  123995. * @param uniforms defines the current uniform list.
  123996. */
  123997. static AddUniforms(uniforms: string[]): void;
  123998. /**
  123999. * Add the required samplers to the current list.
  124000. * @param samplers defines the current sampler list.
  124001. */
  124002. static AddSamplers(samplers: string[]): void;
  124003. /**
  124004. * Add the required uniforms to the current buffer.
  124005. * @param uniformBuffer defines the current uniform buffer.
  124006. */
  124007. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  124008. /**
  124009. * Makes a duplicate of the current configuration into another one.
  124010. * @param configuration define the config where to copy the info
  124011. */
  124012. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  124013. /**
  124014. * Serializes this Sub Surface configuration.
  124015. * @returns - An object with the serialized config.
  124016. */
  124017. serialize(): any;
  124018. /**
  124019. * Parses a anisotropy Configuration from a serialized object.
  124020. * @param source - Serialized object.
  124021. * @param scene Defines the scene we are parsing for
  124022. * @param rootUrl Defines the rootUrl to load from
  124023. */
  124024. parse(source: any, scene: Scene, rootUrl: string): void;
  124025. }
  124026. }
  124027. declare module BABYLON {
  124028. /** @hidden */
  124029. export var pbrFragmentDeclaration: {
  124030. name: string;
  124031. shader: string;
  124032. };
  124033. }
  124034. declare module BABYLON {
  124035. /** @hidden */
  124036. export var pbrUboDeclaration: {
  124037. name: string;
  124038. shader: string;
  124039. };
  124040. }
  124041. declare module BABYLON {
  124042. /** @hidden */
  124043. export var pbrFragmentExtraDeclaration: {
  124044. name: string;
  124045. shader: string;
  124046. };
  124047. }
  124048. declare module BABYLON {
  124049. /** @hidden */
  124050. export var pbrFragmentSamplersDeclaration: {
  124051. name: string;
  124052. shader: string;
  124053. };
  124054. }
  124055. declare module BABYLON {
  124056. /** @hidden */
  124057. export var pbrHelperFunctions: {
  124058. name: string;
  124059. shader: string;
  124060. };
  124061. }
  124062. declare module BABYLON {
  124063. /** @hidden */
  124064. export var harmonicsFunctions: {
  124065. name: string;
  124066. shader: string;
  124067. };
  124068. }
  124069. declare module BABYLON {
  124070. /** @hidden */
  124071. export var pbrDirectLightingSetupFunctions: {
  124072. name: string;
  124073. shader: string;
  124074. };
  124075. }
  124076. declare module BABYLON {
  124077. /** @hidden */
  124078. export var pbrDirectLightingFalloffFunctions: {
  124079. name: string;
  124080. shader: string;
  124081. };
  124082. }
  124083. declare module BABYLON {
  124084. /** @hidden */
  124085. export var pbrBRDFFunctions: {
  124086. name: string;
  124087. shader: string;
  124088. };
  124089. }
  124090. declare module BABYLON {
  124091. /** @hidden */
  124092. export var pbrDirectLightingFunctions: {
  124093. name: string;
  124094. shader: string;
  124095. };
  124096. }
  124097. declare module BABYLON {
  124098. /** @hidden */
  124099. export var pbrIBLFunctions: {
  124100. name: string;
  124101. shader: string;
  124102. };
  124103. }
  124104. declare module BABYLON {
  124105. /** @hidden */
  124106. export var pbrDebug: {
  124107. name: string;
  124108. shader: string;
  124109. };
  124110. }
  124111. declare module BABYLON {
  124112. /** @hidden */
  124113. export var pbrPixelShader: {
  124114. name: string;
  124115. shader: string;
  124116. };
  124117. }
  124118. declare module BABYLON {
  124119. /** @hidden */
  124120. export var pbrVertexDeclaration: {
  124121. name: string;
  124122. shader: string;
  124123. };
  124124. }
  124125. declare module BABYLON {
  124126. /** @hidden */
  124127. export var pbrVertexShader: {
  124128. name: string;
  124129. shader: string;
  124130. };
  124131. }
  124132. declare module BABYLON {
  124133. /**
  124134. * Manages the defines for the PBR Material.
  124135. * @hidden
  124136. */
  124137. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  124138. PBR: boolean;
  124139. MAINUV1: boolean;
  124140. MAINUV2: boolean;
  124141. UV1: boolean;
  124142. UV2: boolean;
  124143. ALBEDO: boolean;
  124144. ALBEDODIRECTUV: number;
  124145. VERTEXCOLOR: boolean;
  124146. AMBIENT: boolean;
  124147. AMBIENTDIRECTUV: number;
  124148. AMBIENTINGRAYSCALE: boolean;
  124149. OPACITY: boolean;
  124150. VERTEXALPHA: boolean;
  124151. OPACITYDIRECTUV: number;
  124152. OPACITYRGB: boolean;
  124153. ALPHATEST: boolean;
  124154. DEPTHPREPASS: boolean;
  124155. ALPHABLEND: boolean;
  124156. ALPHAFROMALBEDO: boolean;
  124157. ALPHATESTVALUE: string;
  124158. SPECULAROVERALPHA: boolean;
  124159. RADIANCEOVERALPHA: boolean;
  124160. ALPHAFRESNEL: boolean;
  124161. LINEARALPHAFRESNEL: boolean;
  124162. PREMULTIPLYALPHA: boolean;
  124163. EMISSIVE: boolean;
  124164. EMISSIVEDIRECTUV: number;
  124165. REFLECTIVITY: boolean;
  124166. REFLECTIVITYDIRECTUV: number;
  124167. SPECULARTERM: boolean;
  124168. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  124169. MICROSURFACEAUTOMATIC: boolean;
  124170. LODBASEDMICROSFURACE: boolean;
  124171. MICROSURFACEMAP: boolean;
  124172. MICROSURFACEMAPDIRECTUV: number;
  124173. METALLICWORKFLOW: boolean;
  124174. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  124175. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  124176. METALLNESSSTOREINMETALMAPBLUE: boolean;
  124177. AOSTOREINMETALMAPRED: boolean;
  124178. METALLICF0FACTORFROMMETALLICMAP: boolean;
  124179. ENVIRONMENTBRDF: boolean;
  124180. ENVIRONMENTBRDF_RGBD: boolean;
  124181. NORMAL: boolean;
  124182. TANGENT: boolean;
  124183. BUMP: boolean;
  124184. BUMPDIRECTUV: number;
  124185. OBJECTSPACE_NORMALMAP: boolean;
  124186. PARALLAX: boolean;
  124187. PARALLAXOCCLUSION: boolean;
  124188. NORMALXYSCALE: boolean;
  124189. LIGHTMAP: boolean;
  124190. LIGHTMAPDIRECTUV: number;
  124191. USELIGHTMAPASSHADOWMAP: boolean;
  124192. GAMMALIGHTMAP: boolean;
  124193. RGBDLIGHTMAP: boolean;
  124194. REFLECTION: boolean;
  124195. REFLECTIONMAP_3D: boolean;
  124196. REFLECTIONMAP_SPHERICAL: boolean;
  124197. REFLECTIONMAP_PLANAR: boolean;
  124198. REFLECTIONMAP_CUBIC: boolean;
  124199. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  124200. REFLECTIONMAP_PROJECTION: boolean;
  124201. REFLECTIONMAP_SKYBOX: boolean;
  124202. REFLECTIONMAP_EXPLICIT: boolean;
  124203. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  124204. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  124205. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  124206. INVERTCUBICMAP: boolean;
  124207. USESPHERICALFROMREFLECTIONMAP: boolean;
  124208. USEIRRADIANCEMAP: boolean;
  124209. SPHERICAL_HARMONICS: boolean;
  124210. USESPHERICALINVERTEX: boolean;
  124211. REFLECTIONMAP_OPPOSITEZ: boolean;
  124212. LODINREFLECTIONALPHA: boolean;
  124213. GAMMAREFLECTION: boolean;
  124214. RGBDREFLECTION: boolean;
  124215. LINEARSPECULARREFLECTION: boolean;
  124216. RADIANCEOCCLUSION: boolean;
  124217. HORIZONOCCLUSION: boolean;
  124218. INSTANCES: boolean;
  124219. NUM_BONE_INFLUENCERS: number;
  124220. BonesPerMesh: number;
  124221. BONETEXTURE: boolean;
  124222. NONUNIFORMSCALING: boolean;
  124223. MORPHTARGETS: boolean;
  124224. MORPHTARGETS_NORMAL: boolean;
  124225. MORPHTARGETS_TANGENT: boolean;
  124226. MORPHTARGETS_UV: boolean;
  124227. NUM_MORPH_INFLUENCERS: number;
  124228. IMAGEPROCESSING: boolean;
  124229. VIGNETTE: boolean;
  124230. VIGNETTEBLENDMODEMULTIPLY: boolean;
  124231. VIGNETTEBLENDMODEOPAQUE: boolean;
  124232. TONEMAPPING: boolean;
  124233. TONEMAPPING_ACES: boolean;
  124234. CONTRAST: boolean;
  124235. COLORCURVES: boolean;
  124236. COLORGRADING: boolean;
  124237. COLORGRADING3D: boolean;
  124238. SAMPLER3DGREENDEPTH: boolean;
  124239. SAMPLER3DBGRMAP: boolean;
  124240. IMAGEPROCESSINGPOSTPROCESS: boolean;
  124241. EXPOSURE: boolean;
  124242. MULTIVIEW: boolean;
  124243. USEPHYSICALLIGHTFALLOFF: boolean;
  124244. USEGLTFLIGHTFALLOFF: boolean;
  124245. TWOSIDEDLIGHTING: boolean;
  124246. SHADOWFLOAT: boolean;
  124247. CLIPPLANE: boolean;
  124248. CLIPPLANE2: boolean;
  124249. CLIPPLANE3: boolean;
  124250. CLIPPLANE4: boolean;
  124251. CLIPPLANE5: boolean;
  124252. CLIPPLANE6: boolean;
  124253. POINTSIZE: boolean;
  124254. FOG: boolean;
  124255. LOGARITHMICDEPTH: boolean;
  124256. FORCENORMALFORWARD: boolean;
  124257. SPECULARAA: boolean;
  124258. CLEARCOAT: boolean;
  124259. CLEARCOAT_DEFAULTIOR: boolean;
  124260. CLEARCOAT_TEXTURE: boolean;
  124261. CLEARCOAT_TEXTUREDIRECTUV: number;
  124262. CLEARCOAT_BUMP: boolean;
  124263. CLEARCOAT_BUMPDIRECTUV: number;
  124264. CLEARCOAT_TINT: boolean;
  124265. CLEARCOAT_TINT_TEXTURE: boolean;
  124266. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  124267. ANISOTROPIC: boolean;
  124268. ANISOTROPIC_TEXTURE: boolean;
  124269. ANISOTROPIC_TEXTUREDIRECTUV: number;
  124270. BRDF_V_HEIGHT_CORRELATED: boolean;
  124271. MS_BRDF_ENERGY_CONSERVATION: boolean;
  124272. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  124273. SHEEN: boolean;
  124274. SHEEN_TEXTURE: boolean;
  124275. SHEEN_TEXTUREDIRECTUV: number;
  124276. SHEEN_LINKWITHALBEDO: boolean;
  124277. SUBSURFACE: boolean;
  124278. SS_REFRACTION: boolean;
  124279. SS_TRANSLUCENCY: boolean;
  124280. SS_SCATERRING: boolean;
  124281. SS_THICKNESSANDMASK_TEXTURE: boolean;
  124282. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  124283. SS_REFRACTIONMAP_3D: boolean;
  124284. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  124285. SS_LODINREFRACTIONALPHA: boolean;
  124286. SS_GAMMAREFRACTION: boolean;
  124287. SS_RGBDREFRACTION: boolean;
  124288. SS_LINEARSPECULARREFRACTION: boolean;
  124289. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  124290. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  124291. UNLIT: boolean;
  124292. DEBUGMODE: number;
  124293. /**
  124294. * Initializes the PBR Material defines.
  124295. */
  124296. constructor();
  124297. /**
  124298. * Resets the PBR Material defines.
  124299. */
  124300. reset(): void;
  124301. }
  124302. /**
  124303. * The Physically based material base class of BJS.
  124304. *
  124305. * This offers the main features of a standard PBR material.
  124306. * For more information, please refer to the documentation :
  124307. * https://doc.babylonjs.com/how_to/physically_based_rendering
  124308. */
  124309. export abstract class PBRBaseMaterial extends PushMaterial {
  124310. /**
  124311. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  124312. */
  124313. static readonly PBRMATERIAL_OPAQUE: number;
  124314. /**
  124315. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  124316. */
  124317. static readonly PBRMATERIAL_ALPHATEST: number;
  124318. /**
  124319. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124320. */
  124321. static readonly PBRMATERIAL_ALPHABLEND: number;
  124322. /**
  124323. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124324. * They are also discarded below the alpha cutoff threshold to improve performances.
  124325. */
  124326. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  124327. /**
  124328. * Defines the default value of how much AO map is occluding the analytical lights
  124329. * (point spot...).
  124330. */
  124331. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  124332. /**
  124333. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  124334. */
  124335. static readonly LIGHTFALLOFF_PHYSICAL: number;
  124336. /**
  124337. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  124338. * to enhance interoperability with other engines.
  124339. */
  124340. static readonly LIGHTFALLOFF_GLTF: number;
  124341. /**
  124342. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  124343. * to enhance interoperability with other materials.
  124344. */
  124345. static readonly LIGHTFALLOFF_STANDARD: number;
  124346. /**
  124347. * Intensity of the direct lights e.g. the four lights available in your scene.
  124348. * This impacts both the direct diffuse and specular highlights.
  124349. */
  124350. protected _directIntensity: number;
  124351. /**
  124352. * Intensity of the emissive part of the material.
  124353. * This helps controlling the emissive effect without modifying the emissive color.
  124354. */
  124355. protected _emissiveIntensity: number;
  124356. /**
  124357. * Intensity of the environment e.g. how much the environment will light the object
  124358. * either through harmonics for rough material or through the refelction for shiny ones.
  124359. */
  124360. protected _environmentIntensity: number;
  124361. /**
  124362. * This is a special control allowing the reduction of the specular highlights coming from the
  124363. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  124364. */
  124365. protected _specularIntensity: number;
  124366. /**
  124367. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  124368. */
  124369. private _lightingInfos;
  124370. /**
  124371. * Debug Control allowing disabling the bump map on this material.
  124372. */
  124373. protected _disableBumpMap: boolean;
  124374. /**
  124375. * AKA Diffuse Texture in standard nomenclature.
  124376. */
  124377. protected _albedoTexture: Nullable<BaseTexture>;
  124378. /**
  124379. * AKA Occlusion Texture in other nomenclature.
  124380. */
  124381. protected _ambientTexture: Nullable<BaseTexture>;
  124382. /**
  124383. * AKA Occlusion Texture Intensity in other nomenclature.
  124384. */
  124385. protected _ambientTextureStrength: number;
  124386. /**
  124387. * Defines how much the AO map is occluding the analytical lights (point spot...).
  124388. * 1 means it completely occludes it
  124389. * 0 mean it has no impact
  124390. */
  124391. protected _ambientTextureImpactOnAnalyticalLights: number;
  124392. /**
  124393. * Stores the alpha values in a texture.
  124394. */
  124395. protected _opacityTexture: Nullable<BaseTexture>;
  124396. /**
  124397. * Stores the reflection values in a texture.
  124398. */
  124399. protected _reflectionTexture: Nullable<BaseTexture>;
  124400. /**
  124401. * Stores the emissive values in a texture.
  124402. */
  124403. protected _emissiveTexture: Nullable<BaseTexture>;
  124404. /**
  124405. * AKA Specular texture in other nomenclature.
  124406. */
  124407. protected _reflectivityTexture: Nullable<BaseTexture>;
  124408. /**
  124409. * Used to switch from specular/glossiness to metallic/roughness workflow.
  124410. */
  124411. protected _metallicTexture: Nullable<BaseTexture>;
  124412. /**
  124413. * Specifies the metallic scalar of the metallic/roughness workflow.
  124414. * Can also be used to scale the metalness values of the metallic texture.
  124415. */
  124416. protected _metallic: Nullable<number>;
  124417. /**
  124418. * Specifies the roughness scalar of the metallic/roughness workflow.
  124419. * Can also be used to scale the roughness values of the metallic texture.
  124420. */
  124421. protected _roughness: Nullable<number>;
  124422. /**
  124423. * Specifies the an F0 factor to help configuring the material F0.
  124424. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  124425. * to 0.5 the previously hard coded value stays the same.
  124426. * Can also be used to scale the F0 values of the metallic texture.
  124427. */
  124428. protected _metallicF0Factor: number;
  124429. /**
  124430. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  124431. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  124432. * your expectation as it multiplies with the texture data.
  124433. */
  124434. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  124435. /**
  124436. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  124437. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  124438. */
  124439. protected _microSurfaceTexture: Nullable<BaseTexture>;
  124440. /**
  124441. * Stores surface normal data used to displace a mesh in a texture.
  124442. */
  124443. protected _bumpTexture: Nullable<BaseTexture>;
  124444. /**
  124445. * Stores the pre-calculated light information of a mesh in a texture.
  124446. */
  124447. protected _lightmapTexture: Nullable<BaseTexture>;
  124448. /**
  124449. * The color of a material in ambient lighting.
  124450. */
  124451. protected _ambientColor: Color3;
  124452. /**
  124453. * AKA Diffuse Color in other nomenclature.
  124454. */
  124455. protected _albedoColor: Color3;
  124456. /**
  124457. * AKA Specular Color in other nomenclature.
  124458. */
  124459. protected _reflectivityColor: Color3;
  124460. /**
  124461. * The color applied when light is reflected from a material.
  124462. */
  124463. protected _reflectionColor: Color3;
  124464. /**
  124465. * The color applied when light is emitted from a material.
  124466. */
  124467. protected _emissiveColor: Color3;
  124468. /**
  124469. * AKA Glossiness in other nomenclature.
  124470. */
  124471. protected _microSurface: number;
  124472. /**
  124473. * Specifies that the material will use the light map as a show map.
  124474. */
  124475. protected _useLightmapAsShadowmap: boolean;
  124476. /**
  124477. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  124478. * makes the reflect vector face the model (under horizon).
  124479. */
  124480. protected _useHorizonOcclusion: boolean;
  124481. /**
  124482. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  124483. * too much the area relying on ambient texture to define their ambient occlusion.
  124484. */
  124485. protected _useRadianceOcclusion: boolean;
  124486. /**
  124487. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  124488. */
  124489. protected _useAlphaFromAlbedoTexture: boolean;
  124490. /**
  124491. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  124492. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  124493. */
  124494. protected _useSpecularOverAlpha: boolean;
  124495. /**
  124496. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  124497. */
  124498. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  124499. /**
  124500. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  124501. */
  124502. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  124503. /**
  124504. * Specifies if the metallic texture contains the roughness information in its green channel.
  124505. */
  124506. protected _useRoughnessFromMetallicTextureGreen: boolean;
  124507. /**
  124508. * Specifies if the metallic texture contains the metallness information in its blue channel.
  124509. */
  124510. protected _useMetallnessFromMetallicTextureBlue: boolean;
  124511. /**
  124512. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  124513. */
  124514. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  124515. /**
  124516. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  124517. */
  124518. protected _useAmbientInGrayScale: boolean;
  124519. /**
  124520. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  124521. * The material will try to infer what glossiness each pixel should be.
  124522. */
  124523. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  124524. /**
  124525. * Defines the falloff type used in this material.
  124526. * It by default is Physical.
  124527. */
  124528. protected _lightFalloff: number;
  124529. /**
  124530. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  124531. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  124532. */
  124533. protected _useRadianceOverAlpha: boolean;
  124534. /**
  124535. * Allows using an object space normal map (instead of tangent space).
  124536. */
  124537. protected _useObjectSpaceNormalMap: boolean;
  124538. /**
  124539. * Allows using the bump map in parallax mode.
  124540. */
  124541. protected _useParallax: boolean;
  124542. /**
  124543. * Allows using the bump map in parallax occlusion mode.
  124544. */
  124545. protected _useParallaxOcclusion: boolean;
  124546. /**
  124547. * Controls the scale bias of the parallax mode.
  124548. */
  124549. protected _parallaxScaleBias: number;
  124550. /**
  124551. * If sets to true, disables all the lights affecting the material.
  124552. */
  124553. protected _disableLighting: boolean;
  124554. /**
  124555. * Number of Simultaneous lights allowed on the material.
  124556. */
  124557. protected _maxSimultaneousLights: number;
  124558. /**
  124559. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  124560. */
  124561. protected _invertNormalMapX: boolean;
  124562. /**
  124563. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  124564. */
  124565. protected _invertNormalMapY: boolean;
  124566. /**
  124567. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  124568. */
  124569. protected _twoSidedLighting: boolean;
  124570. /**
  124571. * Defines the alpha limits in alpha test mode.
  124572. */
  124573. protected _alphaCutOff: number;
  124574. /**
  124575. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  124576. */
  124577. protected _forceAlphaTest: boolean;
  124578. /**
  124579. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124580. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  124581. */
  124582. protected _useAlphaFresnel: boolean;
  124583. /**
  124584. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124585. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  124586. */
  124587. protected _useLinearAlphaFresnel: boolean;
  124588. /**
  124589. * The transparency mode of the material.
  124590. */
  124591. protected _transparencyMode: Nullable<number>;
  124592. /**
  124593. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  124594. * from cos thetav and roughness:
  124595. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  124596. */
  124597. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  124598. /**
  124599. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  124600. */
  124601. protected _forceIrradianceInFragment: boolean;
  124602. /**
  124603. * Force normal to face away from face.
  124604. */
  124605. protected _forceNormalForward: boolean;
  124606. /**
  124607. * Enables specular anti aliasing in the PBR shader.
  124608. * It will both interacts on the Geometry for analytical and IBL lighting.
  124609. * It also prefilter the roughness map based on the bump values.
  124610. */
  124611. protected _enableSpecularAntiAliasing: boolean;
  124612. /**
  124613. * Default configuration related to image processing available in the PBR Material.
  124614. */
  124615. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  124616. /**
  124617. * Keep track of the image processing observer to allow dispose and replace.
  124618. */
  124619. private _imageProcessingObserver;
  124620. /**
  124621. * Attaches a new image processing configuration to the PBR Material.
  124622. * @param configuration
  124623. */
  124624. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  124625. /**
  124626. * Stores the available render targets.
  124627. */
  124628. private _renderTargets;
  124629. /**
  124630. * Sets the global ambient color for the material used in lighting calculations.
  124631. */
  124632. private _globalAmbientColor;
  124633. /**
  124634. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  124635. */
  124636. private _useLogarithmicDepth;
  124637. /**
  124638. * If set to true, no lighting calculations will be applied.
  124639. */
  124640. private _unlit;
  124641. private _debugMode;
  124642. /**
  124643. * @hidden
  124644. * This is reserved for the inspector.
  124645. * Defines the material debug mode.
  124646. * It helps seeing only some components of the material while troubleshooting.
  124647. */
  124648. debugMode: number;
  124649. /**
  124650. * @hidden
  124651. * This is reserved for the inspector.
  124652. * Specify from where on screen the debug mode should start.
  124653. * The value goes from -1 (full screen) to 1 (not visible)
  124654. * It helps with side by side comparison against the final render
  124655. * This defaults to -1
  124656. */
  124657. private debugLimit;
  124658. /**
  124659. * @hidden
  124660. * This is reserved for the inspector.
  124661. * As the default viewing range might not be enough (if the ambient is really small for instance)
  124662. * You can use the factor to better multiply the final value.
  124663. */
  124664. private debugFactor;
  124665. /**
  124666. * Defines the clear coat layer parameters for the material.
  124667. */
  124668. readonly clearCoat: PBRClearCoatConfiguration;
  124669. /**
  124670. * Defines the anisotropic parameters for the material.
  124671. */
  124672. readonly anisotropy: PBRAnisotropicConfiguration;
  124673. /**
  124674. * Defines the BRDF parameters for the material.
  124675. */
  124676. readonly brdf: PBRBRDFConfiguration;
  124677. /**
  124678. * Defines the Sheen parameters for the material.
  124679. */
  124680. readonly sheen: PBRSheenConfiguration;
  124681. /**
  124682. * Defines the SubSurface parameters for the material.
  124683. */
  124684. readonly subSurface: PBRSubSurfaceConfiguration;
  124685. /**
  124686. * Custom callback helping to override the default shader used in the material.
  124687. */
  124688. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  124689. protected _rebuildInParallel: boolean;
  124690. /**
  124691. * Instantiates a new PBRMaterial instance.
  124692. *
  124693. * @param name The material name
  124694. * @param scene The scene the material will be use in.
  124695. */
  124696. constructor(name: string, scene: Scene);
  124697. /**
  124698. * Gets a boolean indicating that current material needs to register RTT
  124699. */
  124700. get hasRenderTargetTextures(): boolean;
  124701. /**
  124702. * Gets the name of the material class.
  124703. */
  124704. getClassName(): string;
  124705. /**
  124706. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  124707. */
  124708. get useLogarithmicDepth(): boolean;
  124709. /**
  124710. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  124711. */
  124712. set useLogarithmicDepth(value: boolean);
  124713. /**
  124714. * Gets the current transparency mode.
  124715. */
  124716. get transparencyMode(): Nullable<number>;
  124717. /**
  124718. * Sets the transparency mode of the material.
  124719. *
  124720. * | Value | Type | Description |
  124721. * | ----- | ----------------------------------- | ----------- |
  124722. * | 0 | OPAQUE | |
  124723. * | 1 | ALPHATEST | |
  124724. * | 2 | ALPHABLEND | |
  124725. * | 3 | ALPHATESTANDBLEND | |
  124726. *
  124727. */
  124728. set transparencyMode(value: Nullable<number>);
  124729. /**
  124730. * Returns true if alpha blending should be disabled.
  124731. */
  124732. private get _disableAlphaBlending();
  124733. /**
  124734. * Specifies whether or not this material should be rendered in alpha blend mode.
  124735. */
  124736. needAlphaBlending(): boolean;
  124737. /**
  124738. * Specifies if the mesh will require alpha blending.
  124739. * @param mesh - BJS mesh.
  124740. */
  124741. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  124742. /**
  124743. * Specifies whether or not this material should be rendered in alpha test mode.
  124744. */
  124745. needAlphaTesting(): boolean;
  124746. /**
  124747. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  124748. */
  124749. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  124750. /**
  124751. * Gets the texture used for the alpha test.
  124752. */
  124753. getAlphaTestTexture(): Nullable<BaseTexture>;
  124754. /**
  124755. * Specifies that the submesh is ready to be used.
  124756. * @param mesh - BJS mesh.
  124757. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  124758. * @param useInstances - Specifies that instances should be used.
  124759. * @returns - boolean indicating that the submesh is ready or not.
  124760. */
  124761. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  124762. /**
  124763. * Specifies if the material uses metallic roughness workflow.
  124764. * @returns boolean specifiying if the material uses metallic roughness workflow.
  124765. */
  124766. isMetallicWorkflow(): boolean;
  124767. private _prepareEffect;
  124768. private _prepareDefines;
  124769. /**
  124770. * Force shader compilation
  124771. */
  124772. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  124773. /**
  124774. * Initializes the uniform buffer layout for the shader.
  124775. */
  124776. buildUniformLayout(): void;
  124777. /**
  124778. * Unbinds the material from the mesh
  124779. */
  124780. unbind(): void;
  124781. /**
  124782. * Binds the submesh data.
  124783. * @param world - The world matrix.
  124784. * @param mesh - The BJS mesh.
  124785. * @param subMesh - A submesh of the BJS mesh.
  124786. */
  124787. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  124788. /**
  124789. * Returns the animatable textures.
  124790. * @returns - Array of animatable textures.
  124791. */
  124792. getAnimatables(): IAnimatable[];
  124793. /**
  124794. * Returns the texture used for reflections.
  124795. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  124796. */
  124797. private _getReflectionTexture;
  124798. /**
  124799. * Returns an array of the actively used textures.
  124800. * @returns - Array of BaseTextures
  124801. */
  124802. getActiveTextures(): BaseTexture[];
  124803. /**
  124804. * Checks to see if a texture is used in the material.
  124805. * @param texture - Base texture to use.
  124806. * @returns - Boolean specifying if a texture is used in the material.
  124807. */
  124808. hasTexture(texture: BaseTexture): boolean;
  124809. /**
  124810. * Disposes the resources of the material.
  124811. * @param forceDisposeEffect - Forces the disposal of effects.
  124812. * @param forceDisposeTextures - Forces the disposal of all textures.
  124813. */
  124814. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  124815. }
  124816. }
  124817. declare module BABYLON {
  124818. /**
  124819. * The Physically based material of BJS.
  124820. *
  124821. * This offers the main features of a standard PBR material.
  124822. * For more information, please refer to the documentation :
  124823. * https://doc.babylonjs.com/how_to/physically_based_rendering
  124824. */
  124825. export class PBRMaterial extends PBRBaseMaterial {
  124826. /**
  124827. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  124828. */
  124829. static readonly PBRMATERIAL_OPAQUE: number;
  124830. /**
  124831. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  124832. */
  124833. static readonly PBRMATERIAL_ALPHATEST: number;
  124834. /**
  124835. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124836. */
  124837. static readonly PBRMATERIAL_ALPHABLEND: number;
  124838. /**
  124839. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124840. * They are also discarded below the alpha cutoff threshold to improve performances.
  124841. */
  124842. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  124843. /**
  124844. * Defines the default value of how much AO map is occluding the analytical lights
  124845. * (point spot...).
  124846. */
  124847. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  124848. /**
  124849. * Intensity of the direct lights e.g. the four lights available in your scene.
  124850. * This impacts both the direct diffuse and specular highlights.
  124851. */
  124852. directIntensity: number;
  124853. /**
  124854. * Intensity of the emissive part of the material.
  124855. * This helps controlling the emissive effect without modifying the emissive color.
  124856. */
  124857. emissiveIntensity: number;
  124858. /**
  124859. * Intensity of the environment e.g. how much the environment will light the object
  124860. * either through harmonics for rough material or through the refelction for shiny ones.
  124861. */
  124862. environmentIntensity: number;
  124863. /**
  124864. * This is a special control allowing the reduction of the specular highlights coming from the
  124865. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  124866. */
  124867. specularIntensity: number;
  124868. /**
  124869. * Debug Control allowing disabling the bump map on this material.
  124870. */
  124871. disableBumpMap: boolean;
  124872. /**
  124873. * AKA Diffuse Texture in standard nomenclature.
  124874. */
  124875. albedoTexture: BaseTexture;
  124876. /**
  124877. * AKA Occlusion Texture in other nomenclature.
  124878. */
  124879. ambientTexture: BaseTexture;
  124880. /**
  124881. * AKA Occlusion Texture Intensity in other nomenclature.
  124882. */
  124883. ambientTextureStrength: number;
  124884. /**
  124885. * Defines how much the AO map is occluding the analytical lights (point spot...).
  124886. * 1 means it completely occludes it
  124887. * 0 mean it has no impact
  124888. */
  124889. ambientTextureImpactOnAnalyticalLights: number;
  124890. /**
  124891. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  124892. */
  124893. opacityTexture: BaseTexture;
  124894. /**
  124895. * Stores the reflection values in a texture.
  124896. */
  124897. reflectionTexture: Nullable<BaseTexture>;
  124898. /**
  124899. * Stores the emissive values in a texture.
  124900. */
  124901. emissiveTexture: BaseTexture;
  124902. /**
  124903. * AKA Specular texture in other nomenclature.
  124904. */
  124905. reflectivityTexture: BaseTexture;
  124906. /**
  124907. * Used to switch from specular/glossiness to metallic/roughness workflow.
  124908. */
  124909. metallicTexture: BaseTexture;
  124910. /**
  124911. * Specifies the metallic scalar of the metallic/roughness workflow.
  124912. * Can also be used to scale the metalness values of the metallic texture.
  124913. */
  124914. metallic: Nullable<number>;
  124915. /**
  124916. * Specifies the roughness scalar of the metallic/roughness workflow.
  124917. * Can also be used to scale the roughness values of the metallic texture.
  124918. */
  124919. roughness: Nullable<number>;
  124920. /**
  124921. * Specifies the an F0 factor to help configuring the material F0.
  124922. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  124923. * to 0.5 the previously hard coded value stays the same.
  124924. * Can also be used to scale the F0 values of the metallic texture.
  124925. */
  124926. metallicF0Factor: number;
  124927. /**
  124928. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  124929. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  124930. * your expectation as it multiplies with the texture data.
  124931. */
  124932. useMetallicF0FactorFromMetallicTexture: boolean;
  124933. /**
  124934. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  124935. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  124936. */
  124937. microSurfaceTexture: BaseTexture;
  124938. /**
  124939. * Stores surface normal data used to displace a mesh in a texture.
  124940. */
  124941. bumpTexture: BaseTexture;
  124942. /**
  124943. * Stores the pre-calculated light information of a mesh in a texture.
  124944. */
  124945. lightmapTexture: BaseTexture;
  124946. /**
  124947. * Stores the refracted light information in a texture.
  124948. */
  124949. get refractionTexture(): Nullable<BaseTexture>;
  124950. set refractionTexture(value: Nullable<BaseTexture>);
  124951. /**
  124952. * The color of a material in ambient lighting.
  124953. */
  124954. ambientColor: Color3;
  124955. /**
  124956. * AKA Diffuse Color in other nomenclature.
  124957. */
  124958. albedoColor: Color3;
  124959. /**
  124960. * AKA Specular Color in other nomenclature.
  124961. */
  124962. reflectivityColor: Color3;
  124963. /**
  124964. * The color reflected from the material.
  124965. */
  124966. reflectionColor: Color3;
  124967. /**
  124968. * The color emitted from the material.
  124969. */
  124970. emissiveColor: Color3;
  124971. /**
  124972. * AKA Glossiness in other nomenclature.
  124973. */
  124974. microSurface: number;
  124975. /**
  124976. * source material index of refraction (IOR)' / 'destination material IOR.
  124977. */
  124978. get indexOfRefraction(): number;
  124979. set indexOfRefraction(value: number);
  124980. /**
  124981. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  124982. */
  124983. get invertRefractionY(): boolean;
  124984. set invertRefractionY(value: boolean);
  124985. /**
  124986. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  124987. * Materials half opaque for instance using refraction could benefit from this control.
  124988. */
  124989. get linkRefractionWithTransparency(): boolean;
  124990. set linkRefractionWithTransparency(value: boolean);
  124991. /**
  124992. * If true, the light map contains occlusion information instead of lighting info.
  124993. */
  124994. useLightmapAsShadowmap: boolean;
  124995. /**
  124996. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  124997. */
  124998. useAlphaFromAlbedoTexture: boolean;
  124999. /**
  125000. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  125001. */
  125002. forceAlphaTest: boolean;
  125003. /**
  125004. * Defines the alpha limits in alpha test mode.
  125005. */
  125006. alphaCutOff: number;
  125007. /**
  125008. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  125009. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  125010. */
  125011. useSpecularOverAlpha: boolean;
  125012. /**
  125013. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  125014. */
  125015. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  125016. /**
  125017. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  125018. */
  125019. useRoughnessFromMetallicTextureAlpha: boolean;
  125020. /**
  125021. * Specifies if the metallic texture contains the roughness information in its green channel.
  125022. */
  125023. useRoughnessFromMetallicTextureGreen: boolean;
  125024. /**
  125025. * Specifies if the metallic texture contains the metallness information in its blue channel.
  125026. */
  125027. useMetallnessFromMetallicTextureBlue: boolean;
  125028. /**
  125029. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  125030. */
  125031. useAmbientOcclusionFromMetallicTextureRed: boolean;
  125032. /**
  125033. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  125034. */
  125035. useAmbientInGrayScale: boolean;
  125036. /**
  125037. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  125038. * The material will try to infer what glossiness each pixel should be.
  125039. */
  125040. useAutoMicroSurfaceFromReflectivityMap: boolean;
  125041. /**
  125042. * BJS is using an harcoded light falloff based on a manually sets up range.
  125043. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  125044. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  125045. */
  125046. get usePhysicalLightFalloff(): boolean;
  125047. /**
  125048. * BJS is using an harcoded light falloff based on a manually sets up range.
  125049. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  125050. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  125051. */
  125052. set usePhysicalLightFalloff(value: boolean);
  125053. /**
  125054. * In order to support the falloff compatibility with gltf, a special mode has been added
  125055. * to reproduce the gltf light falloff.
  125056. */
  125057. get useGLTFLightFalloff(): boolean;
  125058. /**
  125059. * In order to support the falloff compatibility with gltf, a special mode has been added
  125060. * to reproduce the gltf light falloff.
  125061. */
  125062. set useGLTFLightFalloff(value: boolean);
  125063. /**
  125064. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  125065. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  125066. */
  125067. useRadianceOverAlpha: boolean;
  125068. /**
  125069. * Allows using an object space normal map (instead of tangent space).
  125070. */
  125071. useObjectSpaceNormalMap: boolean;
  125072. /**
  125073. * Allows using the bump map in parallax mode.
  125074. */
  125075. useParallax: boolean;
  125076. /**
  125077. * Allows using the bump map in parallax occlusion mode.
  125078. */
  125079. useParallaxOcclusion: boolean;
  125080. /**
  125081. * Controls the scale bias of the parallax mode.
  125082. */
  125083. parallaxScaleBias: number;
  125084. /**
  125085. * If sets to true, disables all the lights affecting the material.
  125086. */
  125087. disableLighting: boolean;
  125088. /**
  125089. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  125090. */
  125091. forceIrradianceInFragment: boolean;
  125092. /**
  125093. * Number of Simultaneous lights allowed on the material.
  125094. */
  125095. maxSimultaneousLights: number;
  125096. /**
  125097. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  125098. */
  125099. invertNormalMapX: boolean;
  125100. /**
  125101. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  125102. */
  125103. invertNormalMapY: boolean;
  125104. /**
  125105. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  125106. */
  125107. twoSidedLighting: boolean;
  125108. /**
  125109. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  125110. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  125111. */
  125112. useAlphaFresnel: boolean;
  125113. /**
  125114. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  125115. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  125116. */
  125117. useLinearAlphaFresnel: boolean;
  125118. /**
  125119. * Let user defines the brdf lookup texture used for IBL.
  125120. * A default 8bit version is embedded but you could point at :
  125121. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  125122. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  125123. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  125124. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  125125. */
  125126. environmentBRDFTexture: Nullable<BaseTexture>;
  125127. /**
  125128. * Force normal to face away from face.
  125129. */
  125130. forceNormalForward: boolean;
  125131. /**
  125132. * Enables specular anti aliasing in the PBR shader.
  125133. * It will both interacts on the Geometry for analytical and IBL lighting.
  125134. * It also prefilter the roughness map based on the bump values.
  125135. */
  125136. enableSpecularAntiAliasing: boolean;
  125137. /**
  125138. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  125139. * makes the reflect vector face the model (under horizon).
  125140. */
  125141. useHorizonOcclusion: boolean;
  125142. /**
  125143. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  125144. * too much the area relying on ambient texture to define their ambient occlusion.
  125145. */
  125146. useRadianceOcclusion: boolean;
  125147. /**
  125148. * If set to true, no lighting calculations will be applied.
  125149. */
  125150. unlit: boolean;
  125151. /**
  125152. * Gets the image processing configuration used either in this material.
  125153. */
  125154. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  125155. /**
  125156. * Sets the Default image processing configuration used either in the this material.
  125157. *
  125158. * If sets to null, the scene one is in use.
  125159. */
  125160. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  125161. /**
  125162. * Gets wether the color curves effect is enabled.
  125163. */
  125164. get cameraColorCurvesEnabled(): boolean;
  125165. /**
  125166. * Sets wether the color curves effect is enabled.
  125167. */
  125168. set cameraColorCurvesEnabled(value: boolean);
  125169. /**
  125170. * Gets wether the color grading effect is enabled.
  125171. */
  125172. get cameraColorGradingEnabled(): boolean;
  125173. /**
  125174. * Gets wether the color grading effect is enabled.
  125175. */
  125176. set cameraColorGradingEnabled(value: boolean);
  125177. /**
  125178. * Gets wether tonemapping is enabled or not.
  125179. */
  125180. get cameraToneMappingEnabled(): boolean;
  125181. /**
  125182. * Sets wether tonemapping is enabled or not
  125183. */
  125184. set cameraToneMappingEnabled(value: boolean);
  125185. /**
  125186. * The camera exposure used on this material.
  125187. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  125188. * This corresponds to a photographic exposure.
  125189. */
  125190. get cameraExposure(): number;
  125191. /**
  125192. * The camera exposure used on this material.
  125193. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  125194. * This corresponds to a photographic exposure.
  125195. */
  125196. set cameraExposure(value: number);
  125197. /**
  125198. * Gets The camera contrast used on this material.
  125199. */
  125200. get cameraContrast(): number;
  125201. /**
  125202. * Sets The camera contrast used on this material.
  125203. */
  125204. set cameraContrast(value: number);
  125205. /**
  125206. * Gets the Color Grading 2D Lookup Texture.
  125207. */
  125208. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  125209. /**
  125210. * Sets the Color Grading 2D Lookup Texture.
  125211. */
  125212. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  125213. /**
  125214. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  125215. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  125216. * 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;
  125217. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  125218. */
  125219. get cameraColorCurves(): Nullable<ColorCurves>;
  125220. /**
  125221. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  125222. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  125223. * 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;
  125224. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  125225. */
  125226. set cameraColorCurves(value: Nullable<ColorCurves>);
  125227. /**
  125228. * Instantiates a new PBRMaterial instance.
  125229. *
  125230. * @param name The material name
  125231. * @param scene The scene the material will be use in.
  125232. */
  125233. constructor(name: string, scene: Scene);
  125234. /**
  125235. * Returns the name of this material class.
  125236. */
  125237. getClassName(): string;
  125238. /**
  125239. * Makes a duplicate of the current material.
  125240. * @param name - name to use for the new material.
  125241. */
  125242. clone(name: string): PBRMaterial;
  125243. /**
  125244. * Serializes this PBR Material.
  125245. * @returns - An object with the serialized material.
  125246. */
  125247. serialize(): any;
  125248. /**
  125249. * Parses a PBR Material from a serialized object.
  125250. * @param source - Serialized object.
  125251. * @param scene - BJS scene instance.
  125252. * @param rootUrl - url for the scene object
  125253. * @returns - PBRMaterial
  125254. */
  125255. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  125256. }
  125257. }
  125258. declare module BABYLON {
  125259. /**
  125260. * Direct draw surface info
  125261. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  125262. */
  125263. export interface DDSInfo {
  125264. /**
  125265. * Width of the texture
  125266. */
  125267. width: number;
  125268. /**
  125269. * Width of the texture
  125270. */
  125271. height: number;
  125272. /**
  125273. * Number of Mipmaps for the texture
  125274. * @see https://en.wikipedia.org/wiki/Mipmap
  125275. */
  125276. mipmapCount: number;
  125277. /**
  125278. * If the textures format is a known fourCC format
  125279. * @see https://www.fourcc.org/
  125280. */
  125281. isFourCC: boolean;
  125282. /**
  125283. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  125284. */
  125285. isRGB: boolean;
  125286. /**
  125287. * If the texture is a lumincance format
  125288. */
  125289. isLuminance: boolean;
  125290. /**
  125291. * If this is a cube texture
  125292. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  125293. */
  125294. isCube: boolean;
  125295. /**
  125296. * If the texture is a compressed format eg. FOURCC_DXT1
  125297. */
  125298. isCompressed: boolean;
  125299. /**
  125300. * The dxgiFormat of the texture
  125301. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  125302. */
  125303. dxgiFormat: number;
  125304. /**
  125305. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  125306. */
  125307. textureType: number;
  125308. /**
  125309. * Sphericle polynomial created for the dds texture
  125310. */
  125311. sphericalPolynomial?: SphericalPolynomial;
  125312. }
  125313. /**
  125314. * Class used to provide DDS decompression tools
  125315. */
  125316. export class DDSTools {
  125317. /**
  125318. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  125319. */
  125320. static StoreLODInAlphaChannel: boolean;
  125321. /**
  125322. * Gets DDS information from an array buffer
  125323. * @param data defines the array buffer view to read data from
  125324. * @returns the DDS information
  125325. */
  125326. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  125327. private static _FloatView;
  125328. private static _Int32View;
  125329. private static _ToHalfFloat;
  125330. private static _FromHalfFloat;
  125331. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  125332. private static _GetHalfFloatRGBAArrayBuffer;
  125333. private static _GetFloatRGBAArrayBuffer;
  125334. private static _GetFloatAsUIntRGBAArrayBuffer;
  125335. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  125336. private static _GetRGBAArrayBuffer;
  125337. private static _ExtractLongWordOrder;
  125338. private static _GetRGBArrayBuffer;
  125339. private static _GetLuminanceArrayBuffer;
  125340. /**
  125341. * Uploads DDS Levels to a Babylon Texture
  125342. * @hidden
  125343. */
  125344. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  125345. }
  125346. interface ThinEngine {
  125347. /**
  125348. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  125349. * @param rootUrl defines the url where the file to load is located
  125350. * @param scene defines the current scene
  125351. * @param lodScale defines scale to apply to the mip map selection
  125352. * @param lodOffset defines offset to apply to the mip map selection
  125353. * @param onLoad defines an optional callback raised when the texture is loaded
  125354. * @param onError defines an optional callback raised if there is an issue to load the texture
  125355. * @param format defines the format of the data
  125356. * @param forcedExtension defines the extension to use to pick the right loader
  125357. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  125358. * @returns the cube texture as an InternalTexture
  125359. */
  125360. 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;
  125361. }
  125362. }
  125363. declare module BABYLON {
  125364. /**
  125365. * Implementation of the DDS Texture Loader.
  125366. * @hidden
  125367. */
  125368. export class _DDSTextureLoader implements IInternalTextureLoader {
  125369. /**
  125370. * Defines wether the loader supports cascade loading the different faces.
  125371. */
  125372. readonly supportCascades: boolean;
  125373. /**
  125374. * This returns if the loader support the current file information.
  125375. * @param extension defines the file extension of the file being loaded
  125376. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125377. * @param fallback defines the fallback internal texture if any
  125378. * @param isBase64 defines whether the texture is encoded as a base64
  125379. * @param isBuffer defines whether the texture data are stored as a buffer
  125380. * @returns true if the loader can load the specified file
  125381. */
  125382. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  125383. /**
  125384. * Transform the url before loading if required.
  125385. * @param rootUrl the url of the texture
  125386. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125387. * @returns the transformed texture
  125388. */
  125389. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  125390. /**
  125391. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  125392. * @param rootUrl the url of the texture
  125393. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125394. * @returns the fallback texture
  125395. */
  125396. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  125397. /**
  125398. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  125399. * @param data contains the texture data
  125400. * @param texture defines the BabylonJS internal texture
  125401. * @param createPolynomials will be true if polynomials have been requested
  125402. * @param onLoad defines the callback to trigger once the texture is ready
  125403. * @param onError defines the callback to trigger in case of error
  125404. */
  125405. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125406. /**
  125407. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  125408. * @param data contains the texture data
  125409. * @param texture defines the BabylonJS internal texture
  125410. * @param callback defines the method to call once ready to upload
  125411. */
  125412. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125413. }
  125414. }
  125415. declare module BABYLON {
  125416. /**
  125417. * Implementation of the ENV Texture Loader.
  125418. * @hidden
  125419. */
  125420. export class _ENVTextureLoader implements IInternalTextureLoader {
  125421. /**
  125422. * Defines wether the loader supports cascade loading the different faces.
  125423. */
  125424. readonly supportCascades: boolean;
  125425. /**
  125426. * This returns if the loader support the current file information.
  125427. * @param extension defines the file extension of the file being loaded
  125428. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125429. * @param fallback defines the fallback internal texture if any
  125430. * @param isBase64 defines whether the texture is encoded as a base64
  125431. * @param isBuffer defines whether the texture data are stored as a buffer
  125432. * @returns true if the loader can load the specified file
  125433. */
  125434. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  125435. /**
  125436. * Transform the url before loading if required.
  125437. * @param rootUrl the url of the texture
  125438. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125439. * @returns the transformed texture
  125440. */
  125441. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  125442. /**
  125443. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  125444. * @param rootUrl the url of the texture
  125445. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125446. * @returns the fallback texture
  125447. */
  125448. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  125449. /**
  125450. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  125451. * @param data contains the texture data
  125452. * @param texture defines the BabylonJS internal texture
  125453. * @param createPolynomials will be true if polynomials have been requested
  125454. * @param onLoad defines the callback to trigger once the texture is ready
  125455. * @param onError defines the callback to trigger in case of error
  125456. */
  125457. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125458. /**
  125459. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  125460. * @param data contains the texture data
  125461. * @param texture defines the BabylonJS internal texture
  125462. * @param callback defines the method to call once ready to upload
  125463. */
  125464. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125465. }
  125466. }
  125467. declare module BABYLON {
  125468. /**
  125469. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  125470. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  125471. */
  125472. export class KhronosTextureContainer {
  125473. /** contents of the KTX container file */
  125474. data: ArrayBufferView;
  125475. private static HEADER_LEN;
  125476. private static COMPRESSED_2D;
  125477. private static COMPRESSED_3D;
  125478. private static TEX_2D;
  125479. private static TEX_3D;
  125480. /**
  125481. * Gets the openGL type
  125482. */
  125483. glType: number;
  125484. /**
  125485. * Gets the openGL type size
  125486. */
  125487. glTypeSize: number;
  125488. /**
  125489. * Gets the openGL format
  125490. */
  125491. glFormat: number;
  125492. /**
  125493. * Gets the openGL internal format
  125494. */
  125495. glInternalFormat: number;
  125496. /**
  125497. * Gets the base internal format
  125498. */
  125499. glBaseInternalFormat: number;
  125500. /**
  125501. * Gets image width in pixel
  125502. */
  125503. pixelWidth: number;
  125504. /**
  125505. * Gets image height in pixel
  125506. */
  125507. pixelHeight: number;
  125508. /**
  125509. * Gets image depth in pixels
  125510. */
  125511. pixelDepth: number;
  125512. /**
  125513. * Gets the number of array elements
  125514. */
  125515. numberOfArrayElements: number;
  125516. /**
  125517. * Gets the number of faces
  125518. */
  125519. numberOfFaces: number;
  125520. /**
  125521. * Gets the number of mipmap levels
  125522. */
  125523. numberOfMipmapLevels: number;
  125524. /**
  125525. * Gets the bytes of key value data
  125526. */
  125527. bytesOfKeyValueData: number;
  125528. /**
  125529. * Gets the load type
  125530. */
  125531. loadType: number;
  125532. /**
  125533. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  125534. */
  125535. isInvalid: boolean;
  125536. /**
  125537. * Creates a new KhronosTextureContainer
  125538. * @param data contents of the KTX container file
  125539. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  125540. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  125541. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  125542. */
  125543. constructor(
  125544. /** contents of the KTX container file */
  125545. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  125546. /**
  125547. * Uploads KTX content to a Babylon Texture.
  125548. * It is assumed that the texture has already been created & is currently bound
  125549. * @hidden
  125550. */
  125551. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  125552. private _upload2DCompressedLevels;
  125553. }
  125554. }
  125555. declare module BABYLON {
  125556. /**
  125557. * Implementation of the KTX Texture Loader.
  125558. * @hidden
  125559. */
  125560. export class _KTXTextureLoader implements IInternalTextureLoader {
  125561. /**
  125562. * Defines wether the loader supports cascade loading the different faces.
  125563. */
  125564. readonly supportCascades: boolean;
  125565. /**
  125566. * This returns if the loader support the current file information.
  125567. * @param extension defines the file extension of the file being loaded
  125568. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125569. * @param fallback defines the fallback internal texture if any
  125570. * @param isBase64 defines whether the texture is encoded as a base64
  125571. * @param isBuffer defines whether the texture data are stored as a buffer
  125572. * @returns true if the loader can load the specified file
  125573. */
  125574. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  125575. /**
  125576. * Transform the url before loading if required.
  125577. * @param rootUrl the url of the texture
  125578. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125579. * @returns the transformed texture
  125580. */
  125581. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  125582. /**
  125583. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  125584. * @param rootUrl the url of the texture
  125585. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125586. * @returns the fallback texture
  125587. */
  125588. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  125589. /**
  125590. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  125591. * @param data contains the texture data
  125592. * @param texture defines the BabylonJS internal texture
  125593. * @param createPolynomials will be true if polynomials have been requested
  125594. * @param onLoad defines the callback to trigger once the texture is ready
  125595. * @param onError defines the callback to trigger in case of error
  125596. */
  125597. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125598. /**
  125599. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  125600. * @param data contains the texture data
  125601. * @param texture defines the BabylonJS internal texture
  125602. * @param callback defines the method to call once ready to upload
  125603. */
  125604. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  125605. }
  125606. }
  125607. declare module BABYLON {
  125608. /** @hidden */
  125609. export var _forceSceneHelpersToBundle: boolean;
  125610. interface Scene {
  125611. /**
  125612. * Creates a default light for the scene.
  125613. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  125614. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  125615. */
  125616. createDefaultLight(replace?: boolean): void;
  125617. /**
  125618. * Creates a default camera for the scene.
  125619. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  125620. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  125621. * @param replace has default false, when true replaces the active camera in the scene
  125622. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  125623. */
  125624. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  125625. /**
  125626. * Creates a default camera and a default light.
  125627. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  125628. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  125629. * @param replace has the default false, when true replaces the active camera/light in the scene
  125630. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  125631. */
  125632. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  125633. /**
  125634. * Creates a new sky box
  125635. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  125636. * @param environmentTexture defines the texture to use as environment texture
  125637. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  125638. * @param scale defines the overall scale of the skybox
  125639. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  125640. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  125641. * @returns a new mesh holding the sky box
  125642. */
  125643. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  125644. /**
  125645. * Creates a new environment
  125646. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  125647. * @param options defines the options you can use to configure the environment
  125648. * @returns the new EnvironmentHelper
  125649. */
  125650. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  125651. /**
  125652. * Creates a new VREXperienceHelper
  125653. * @see http://doc.babylonjs.com/how_to/webvr_helper
  125654. * @param webVROptions defines the options used to create the new VREXperienceHelper
  125655. * @returns a new VREXperienceHelper
  125656. */
  125657. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  125658. /**
  125659. * Creates a new WebXRDefaultExperience
  125660. * @see http://doc.babylonjs.com/how_to/webxr
  125661. * @param options experience options
  125662. * @returns a promise for a new WebXRDefaultExperience
  125663. */
  125664. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  125665. }
  125666. }
  125667. declare module BABYLON {
  125668. /**
  125669. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  125670. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  125671. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  125672. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  125673. */
  125674. export class VideoDome extends TransformNode {
  125675. /**
  125676. * Define the video source as a Monoscopic panoramic 360 video.
  125677. */
  125678. static readonly MODE_MONOSCOPIC: number;
  125679. /**
  125680. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  125681. */
  125682. static readonly MODE_TOPBOTTOM: number;
  125683. /**
  125684. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  125685. */
  125686. static readonly MODE_SIDEBYSIDE: number;
  125687. private _halfDome;
  125688. private _useDirectMapping;
  125689. /**
  125690. * The video texture being displayed on the sphere
  125691. */
  125692. protected _videoTexture: VideoTexture;
  125693. /**
  125694. * Gets the video texture being displayed on the sphere
  125695. */
  125696. get videoTexture(): VideoTexture;
  125697. /**
  125698. * The skybox material
  125699. */
  125700. protected _material: BackgroundMaterial;
  125701. /**
  125702. * The surface used for the skybox
  125703. */
  125704. protected _mesh: Mesh;
  125705. /**
  125706. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  125707. */
  125708. private _halfDomeMask;
  125709. /**
  125710. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  125711. * Also see the options.resolution property.
  125712. */
  125713. get fovMultiplier(): number;
  125714. set fovMultiplier(value: number);
  125715. private _videoMode;
  125716. /**
  125717. * Gets or set the current video mode for the video. It can be:
  125718. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  125719. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  125720. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  125721. */
  125722. get videoMode(): number;
  125723. set videoMode(value: number);
  125724. /**
  125725. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  125726. *
  125727. */
  125728. get halfDome(): boolean;
  125729. /**
  125730. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  125731. */
  125732. set halfDome(enabled: boolean);
  125733. /**
  125734. * Oberserver used in Stereoscopic VR Mode.
  125735. */
  125736. private _onBeforeCameraRenderObserver;
  125737. /**
  125738. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  125739. * @param name Element's name, child elements will append suffixes for their own names.
  125740. * @param urlsOrVideo defines the url(s) or the video element to use
  125741. * @param options An object containing optional or exposed sub element properties
  125742. */
  125743. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  125744. resolution?: number;
  125745. clickToPlay?: boolean;
  125746. autoPlay?: boolean;
  125747. loop?: boolean;
  125748. size?: number;
  125749. poster?: string;
  125750. faceForward?: boolean;
  125751. useDirectMapping?: boolean;
  125752. halfDomeMode?: boolean;
  125753. }, scene: Scene);
  125754. private _changeVideoMode;
  125755. /**
  125756. * Releases resources associated with this node.
  125757. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  125758. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  125759. */
  125760. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  125761. }
  125762. }
  125763. declare module BABYLON {
  125764. /**
  125765. * This class can be used to get instrumentation data from a Babylon engine
  125766. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  125767. */
  125768. export class EngineInstrumentation implements IDisposable {
  125769. /**
  125770. * Define the instrumented engine.
  125771. */
  125772. engine: Engine;
  125773. private _captureGPUFrameTime;
  125774. private _gpuFrameTimeToken;
  125775. private _gpuFrameTime;
  125776. private _captureShaderCompilationTime;
  125777. private _shaderCompilationTime;
  125778. private _onBeginFrameObserver;
  125779. private _onEndFrameObserver;
  125780. private _onBeforeShaderCompilationObserver;
  125781. private _onAfterShaderCompilationObserver;
  125782. /**
  125783. * Gets the perf counter used for GPU frame time
  125784. */
  125785. get gpuFrameTimeCounter(): PerfCounter;
  125786. /**
  125787. * Gets the GPU frame time capture status
  125788. */
  125789. get captureGPUFrameTime(): boolean;
  125790. /**
  125791. * Enable or disable the GPU frame time capture
  125792. */
  125793. set captureGPUFrameTime(value: boolean);
  125794. /**
  125795. * Gets the perf counter used for shader compilation time
  125796. */
  125797. get shaderCompilationTimeCounter(): PerfCounter;
  125798. /**
  125799. * Gets the shader compilation time capture status
  125800. */
  125801. get captureShaderCompilationTime(): boolean;
  125802. /**
  125803. * Enable or disable the shader compilation time capture
  125804. */
  125805. set captureShaderCompilationTime(value: boolean);
  125806. /**
  125807. * Instantiates a new engine instrumentation.
  125808. * This class can be used to get instrumentation data from a Babylon engine
  125809. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  125810. * @param engine Defines the engine to instrument
  125811. */
  125812. constructor(
  125813. /**
  125814. * Define the instrumented engine.
  125815. */
  125816. engine: Engine);
  125817. /**
  125818. * Dispose and release associated resources.
  125819. */
  125820. dispose(): void;
  125821. }
  125822. }
  125823. declare module BABYLON {
  125824. /**
  125825. * This class can be used to get instrumentation data from a Babylon engine
  125826. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  125827. */
  125828. export class SceneInstrumentation implements IDisposable {
  125829. /**
  125830. * Defines the scene to instrument
  125831. */
  125832. scene: Scene;
  125833. private _captureActiveMeshesEvaluationTime;
  125834. private _activeMeshesEvaluationTime;
  125835. private _captureRenderTargetsRenderTime;
  125836. private _renderTargetsRenderTime;
  125837. private _captureFrameTime;
  125838. private _frameTime;
  125839. private _captureRenderTime;
  125840. private _renderTime;
  125841. private _captureInterFrameTime;
  125842. private _interFrameTime;
  125843. private _captureParticlesRenderTime;
  125844. private _particlesRenderTime;
  125845. private _captureSpritesRenderTime;
  125846. private _spritesRenderTime;
  125847. private _capturePhysicsTime;
  125848. private _physicsTime;
  125849. private _captureAnimationsTime;
  125850. private _animationsTime;
  125851. private _captureCameraRenderTime;
  125852. private _cameraRenderTime;
  125853. private _onBeforeActiveMeshesEvaluationObserver;
  125854. private _onAfterActiveMeshesEvaluationObserver;
  125855. private _onBeforeRenderTargetsRenderObserver;
  125856. private _onAfterRenderTargetsRenderObserver;
  125857. private _onAfterRenderObserver;
  125858. private _onBeforeDrawPhaseObserver;
  125859. private _onAfterDrawPhaseObserver;
  125860. private _onBeforeAnimationsObserver;
  125861. private _onBeforeParticlesRenderingObserver;
  125862. private _onAfterParticlesRenderingObserver;
  125863. private _onBeforeSpritesRenderingObserver;
  125864. private _onAfterSpritesRenderingObserver;
  125865. private _onBeforePhysicsObserver;
  125866. private _onAfterPhysicsObserver;
  125867. private _onAfterAnimationsObserver;
  125868. private _onBeforeCameraRenderObserver;
  125869. private _onAfterCameraRenderObserver;
  125870. /**
  125871. * Gets the perf counter used for active meshes evaluation time
  125872. */
  125873. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  125874. /**
  125875. * Gets the active meshes evaluation time capture status
  125876. */
  125877. get captureActiveMeshesEvaluationTime(): boolean;
  125878. /**
  125879. * Enable or disable the active meshes evaluation time capture
  125880. */
  125881. set captureActiveMeshesEvaluationTime(value: boolean);
  125882. /**
  125883. * Gets the perf counter used for render targets render time
  125884. */
  125885. get renderTargetsRenderTimeCounter(): PerfCounter;
  125886. /**
  125887. * Gets the render targets render time capture status
  125888. */
  125889. get captureRenderTargetsRenderTime(): boolean;
  125890. /**
  125891. * Enable or disable the render targets render time capture
  125892. */
  125893. set captureRenderTargetsRenderTime(value: boolean);
  125894. /**
  125895. * Gets the perf counter used for particles render time
  125896. */
  125897. get particlesRenderTimeCounter(): PerfCounter;
  125898. /**
  125899. * Gets the particles render time capture status
  125900. */
  125901. get captureParticlesRenderTime(): boolean;
  125902. /**
  125903. * Enable or disable the particles render time capture
  125904. */
  125905. set captureParticlesRenderTime(value: boolean);
  125906. /**
  125907. * Gets the perf counter used for sprites render time
  125908. */
  125909. get spritesRenderTimeCounter(): PerfCounter;
  125910. /**
  125911. * Gets the sprites render time capture status
  125912. */
  125913. get captureSpritesRenderTime(): boolean;
  125914. /**
  125915. * Enable or disable the sprites render time capture
  125916. */
  125917. set captureSpritesRenderTime(value: boolean);
  125918. /**
  125919. * Gets the perf counter used for physics time
  125920. */
  125921. get physicsTimeCounter(): PerfCounter;
  125922. /**
  125923. * Gets the physics time capture status
  125924. */
  125925. get capturePhysicsTime(): boolean;
  125926. /**
  125927. * Enable or disable the physics time capture
  125928. */
  125929. set capturePhysicsTime(value: boolean);
  125930. /**
  125931. * Gets the perf counter used for animations time
  125932. */
  125933. get animationsTimeCounter(): PerfCounter;
  125934. /**
  125935. * Gets the animations time capture status
  125936. */
  125937. get captureAnimationsTime(): boolean;
  125938. /**
  125939. * Enable or disable the animations time capture
  125940. */
  125941. set captureAnimationsTime(value: boolean);
  125942. /**
  125943. * Gets the perf counter used for frame time capture
  125944. */
  125945. get frameTimeCounter(): PerfCounter;
  125946. /**
  125947. * Gets the frame time capture status
  125948. */
  125949. get captureFrameTime(): boolean;
  125950. /**
  125951. * Enable or disable the frame time capture
  125952. */
  125953. set captureFrameTime(value: boolean);
  125954. /**
  125955. * Gets the perf counter used for inter-frames time capture
  125956. */
  125957. get interFrameTimeCounter(): PerfCounter;
  125958. /**
  125959. * Gets the inter-frames time capture status
  125960. */
  125961. get captureInterFrameTime(): boolean;
  125962. /**
  125963. * Enable or disable the inter-frames time capture
  125964. */
  125965. set captureInterFrameTime(value: boolean);
  125966. /**
  125967. * Gets the perf counter used for render time capture
  125968. */
  125969. get renderTimeCounter(): PerfCounter;
  125970. /**
  125971. * Gets the render time capture status
  125972. */
  125973. get captureRenderTime(): boolean;
  125974. /**
  125975. * Enable or disable the render time capture
  125976. */
  125977. set captureRenderTime(value: boolean);
  125978. /**
  125979. * Gets the perf counter used for camera render time capture
  125980. */
  125981. get cameraRenderTimeCounter(): PerfCounter;
  125982. /**
  125983. * Gets the camera render time capture status
  125984. */
  125985. get captureCameraRenderTime(): boolean;
  125986. /**
  125987. * Enable or disable the camera render time capture
  125988. */
  125989. set captureCameraRenderTime(value: boolean);
  125990. /**
  125991. * Gets the perf counter used for draw calls
  125992. */
  125993. get drawCallsCounter(): PerfCounter;
  125994. /**
  125995. * Instantiates a new scene instrumentation.
  125996. * This class can be used to get instrumentation data from a Babylon engine
  125997. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  125998. * @param scene Defines the scene to instrument
  125999. */
  126000. constructor(
  126001. /**
  126002. * Defines the scene to instrument
  126003. */
  126004. scene: Scene);
  126005. /**
  126006. * Dispose and release associated resources.
  126007. */
  126008. dispose(): void;
  126009. }
  126010. }
  126011. declare module BABYLON {
  126012. /** @hidden */
  126013. export var glowMapGenerationPixelShader: {
  126014. name: string;
  126015. shader: string;
  126016. };
  126017. }
  126018. declare module BABYLON {
  126019. /** @hidden */
  126020. export var glowMapGenerationVertexShader: {
  126021. name: string;
  126022. shader: string;
  126023. };
  126024. }
  126025. declare module BABYLON {
  126026. /**
  126027. * Effect layer options. This helps customizing the behaviour
  126028. * of the effect layer.
  126029. */
  126030. export interface IEffectLayerOptions {
  126031. /**
  126032. * Multiplication factor apply to the canvas size to compute the render target size
  126033. * used to generated the objects (the smaller the faster).
  126034. */
  126035. mainTextureRatio: number;
  126036. /**
  126037. * Enforces a fixed size texture to ensure effect stability across devices.
  126038. */
  126039. mainTextureFixedSize?: number;
  126040. /**
  126041. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  126042. */
  126043. alphaBlendingMode: number;
  126044. /**
  126045. * The camera attached to the layer.
  126046. */
  126047. camera: Nullable<Camera>;
  126048. /**
  126049. * The rendering group to draw the layer in.
  126050. */
  126051. renderingGroupId: number;
  126052. }
  126053. /**
  126054. * The effect layer Helps adding post process effect blended with the main pass.
  126055. *
  126056. * This can be for instance use to generate glow or higlight effects on the scene.
  126057. *
  126058. * The effect layer class can not be used directly and is intented to inherited from to be
  126059. * customized per effects.
  126060. */
  126061. export abstract class EffectLayer {
  126062. private _vertexBuffers;
  126063. private _indexBuffer;
  126064. private _cachedDefines;
  126065. private _effectLayerMapGenerationEffect;
  126066. private _effectLayerOptions;
  126067. private _mergeEffect;
  126068. protected _scene: Scene;
  126069. protected _engine: Engine;
  126070. protected _maxSize: number;
  126071. protected _mainTextureDesiredSize: ISize;
  126072. protected _mainTexture: RenderTargetTexture;
  126073. protected _shouldRender: boolean;
  126074. protected _postProcesses: PostProcess[];
  126075. protected _textures: BaseTexture[];
  126076. protected _emissiveTextureAndColor: {
  126077. texture: Nullable<BaseTexture>;
  126078. color: Color4;
  126079. };
  126080. /**
  126081. * The name of the layer
  126082. */
  126083. name: string;
  126084. /**
  126085. * The clear color of the texture used to generate the glow map.
  126086. */
  126087. neutralColor: Color4;
  126088. /**
  126089. * Specifies whether the highlight layer is enabled or not.
  126090. */
  126091. isEnabled: boolean;
  126092. /**
  126093. * Gets the camera attached to the layer.
  126094. */
  126095. get camera(): Nullable<Camera>;
  126096. /**
  126097. * Gets the rendering group id the layer should render in.
  126098. */
  126099. get renderingGroupId(): number;
  126100. set renderingGroupId(renderingGroupId: number);
  126101. /**
  126102. * An event triggered when the effect layer has been disposed.
  126103. */
  126104. onDisposeObservable: Observable<EffectLayer>;
  126105. /**
  126106. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  126107. */
  126108. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  126109. /**
  126110. * An event triggered when the generated texture is being merged in the scene.
  126111. */
  126112. onBeforeComposeObservable: Observable<EffectLayer>;
  126113. /**
  126114. * An event triggered when the mesh is rendered into the effect render target.
  126115. */
  126116. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  126117. /**
  126118. * An event triggered after the mesh has been rendered into the effect render target.
  126119. */
  126120. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  126121. /**
  126122. * An event triggered when the generated texture has been merged in the scene.
  126123. */
  126124. onAfterComposeObservable: Observable<EffectLayer>;
  126125. /**
  126126. * An event triggered when the efffect layer changes its size.
  126127. */
  126128. onSizeChangedObservable: Observable<EffectLayer>;
  126129. /** @hidden */
  126130. static _SceneComponentInitialization: (scene: Scene) => void;
  126131. /**
  126132. * Instantiates a new effect Layer and references it in the scene.
  126133. * @param name The name of the layer
  126134. * @param scene The scene to use the layer in
  126135. */
  126136. constructor(
  126137. /** The Friendly of the effect in the scene */
  126138. name: string, scene: Scene);
  126139. /**
  126140. * Get the effect name of the layer.
  126141. * @return The effect name
  126142. */
  126143. abstract getEffectName(): string;
  126144. /**
  126145. * Checks for the readiness of the element composing the layer.
  126146. * @param subMesh the mesh to check for
  126147. * @param useInstances specify whether or not to use instances to render the mesh
  126148. * @return true if ready otherwise, false
  126149. */
  126150. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126151. /**
  126152. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  126153. * @returns true if the effect requires stencil during the main canvas render pass.
  126154. */
  126155. abstract needStencil(): boolean;
  126156. /**
  126157. * Create the merge effect. This is the shader use to blit the information back
  126158. * to the main canvas at the end of the scene rendering.
  126159. * @returns The effect containing the shader used to merge the effect on the main canvas
  126160. */
  126161. protected abstract _createMergeEffect(): Effect;
  126162. /**
  126163. * Creates the render target textures and post processes used in the effect layer.
  126164. */
  126165. protected abstract _createTextureAndPostProcesses(): void;
  126166. /**
  126167. * Implementation specific of rendering the generating effect on the main canvas.
  126168. * @param effect The effect used to render through
  126169. */
  126170. protected abstract _internalRender(effect: Effect): void;
  126171. /**
  126172. * Sets the required values for both the emissive texture and and the main color.
  126173. */
  126174. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126175. /**
  126176. * Free any resources and references associated to a mesh.
  126177. * Internal use
  126178. * @param mesh The mesh to free.
  126179. */
  126180. abstract _disposeMesh(mesh: Mesh): void;
  126181. /**
  126182. * Serializes this layer (Glow or Highlight for example)
  126183. * @returns a serialized layer object
  126184. */
  126185. abstract serialize?(): any;
  126186. /**
  126187. * Initializes the effect layer with the required options.
  126188. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  126189. */
  126190. protected _init(options: Partial<IEffectLayerOptions>): void;
  126191. /**
  126192. * Generates the index buffer of the full screen quad blending to the main canvas.
  126193. */
  126194. private _generateIndexBuffer;
  126195. /**
  126196. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  126197. */
  126198. private _generateVertexBuffer;
  126199. /**
  126200. * Sets the main texture desired size which is the closest power of two
  126201. * of the engine canvas size.
  126202. */
  126203. private _setMainTextureSize;
  126204. /**
  126205. * Creates the main texture for the effect layer.
  126206. */
  126207. protected _createMainTexture(): void;
  126208. /**
  126209. * Adds specific effects defines.
  126210. * @param defines The defines to add specifics to.
  126211. */
  126212. protected _addCustomEffectDefines(defines: string[]): void;
  126213. /**
  126214. * Checks for the readiness of the element composing the layer.
  126215. * @param subMesh the mesh to check for
  126216. * @param useInstances specify whether or not to use instances to render the mesh
  126217. * @param emissiveTexture the associated emissive texture used to generate the glow
  126218. * @return true if ready otherwise, false
  126219. */
  126220. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  126221. /**
  126222. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  126223. */
  126224. render(): void;
  126225. /**
  126226. * Determine if a given mesh will be used in the current effect.
  126227. * @param mesh mesh to test
  126228. * @returns true if the mesh will be used
  126229. */
  126230. hasMesh(mesh: AbstractMesh): boolean;
  126231. /**
  126232. * Returns true if the layer contains information to display, otherwise false.
  126233. * @returns true if the glow layer should be rendered
  126234. */
  126235. shouldRender(): boolean;
  126236. /**
  126237. * Returns true if the mesh should render, otherwise false.
  126238. * @param mesh The mesh to render
  126239. * @returns true if it should render otherwise false
  126240. */
  126241. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  126242. /**
  126243. * Returns true if the mesh can be rendered, otherwise false.
  126244. * @param mesh The mesh to render
  126245. * @param material The material used on the mesh
  126246. * @returns true if it can be rendered otherwise false
  126247. */
  126248. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  126249. /**
  126250. * Returns true if the mesh should render, otherwise false.
  126251. * @param mesh The mesh to render
  126252. * @returns true if it should render otherwise false
  126253. */
  126254. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  126255. /**
  126256. * Renders the submesh passed in parameter to the generation map.
  126257. */
  126258. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  126259. /**
  126260. * Defines whether the current material of the mesh should be use to render the effect.
  126261. * @param mesh defines the current mesh to render
  126262. */
  126263. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  126264. /**
  126265. * Rebuild the required buffers.
  126266. * @hidden Internal use only.
  126267. */
  126268. _rebuild(): void;
  126269. /**
  126270. * Dispose only the render target textures and post process.
  126271. */
  126272. private _disposeTextureAndPostProcesses;
  126273. /**
  126274. * Dispose the highlight layer and free resources.
  126275. */
  126276. dispose(): void;
  126277. /**
  126278. * Gets the class name of the effect layer
  126279. * @returns the string with the class name of the effect layer
  126280. */
  126281. getClassName(): string;
  126282. /**
  126283. * Creates an effect layer from parsed effect layer data
  126284. * @param parsedEffectLayer defines effect layer data
  126285. * @param scene defines the current scene
  126286. * @param rootUrl defines the root URL containing the effect layer information
  126287. * @returns a parsed effect Layer
  126288. */
  126289. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  126290. }
  126291. }
  126292. declare module BABYLON {
  126293. interface AbstractScene {
  126294. /**
  126295. * The list of effect layers (highlights/glow) added to the scene
  126296. * @see http://doc.babylonjs.com/how_to/highlight_layer
  126297. * @see http://doc.babylonjs.com/how_to/glow_layer
  126298. */
  126299. effectLayers: Array<EffectLayer>;
  126300. /**
  126301. * Removes the given effect layer from this scene.
  126302. * @param toRemove defines the effect layer to remove
  126303. * @returns the index of the removed effect layer
  126304. */
  126305. removeEffectLayer(toRemove: EffectLayer): number;
  126306. /**
  126307. * Adds the given effect layer to this scene
  126308. * @param newEffectLayer defines the effect layer to add
  126309. */
  126310. addEffectLayer(newEffectLayer: EffectLayer): void;
  126311. }
  126312. /**
  126313. * Defines the layer scene component responsible to manage any effect layers
  126314. * in a given scene.
  126315. */
  126316. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  126317. /**
  126318. * The component name helpfull to identify the component in the list of scene components.
  126319. */
  126320. readonly name: string;
  126321. /**
  126322. * The scene the component belongs to.
  126323. */
  126324. scene: Scene;
  126325. private _engine;
  126326. private _renderEffects;
  126327. private _needStencil;
  126328. private _previousStencilState;
  126329. /**
  126330. * Creates a new instance of the component for the given scene
  126331. * @param scene Defines the scene to register the component in
  126332. */
  126333. constructor(scene: Scene);
  126334. /**
  126335. * Registers the component in a given scene
  126336. */
  126337. register(): void;
  126338. /**
  126339. * Rebuilds the elements related to this component in case of
  126340. * context lost for instance.
  126341. */
  126342. rebuild(): void;
  126343. /**
  126344. * Serializes the component data to the specified json object
  126345. * @param serializationObject The object to serialize to
  126346. */
  126347. serialize(serializationObject: any): void;
  126348. /**
  126349. * Adds all the elements from the container to the scene
  126350. * @param container the container holding the elements
  126351. */
  126352. addFromContainer(container: AbstractScene): void;
  126353. /**
  126354. * Removes all the elements in the container from the scene
  126355. * @param container contains the elements to remove
  126356. * @param dispose if the removed element should be disposed (default: false)
  126357. */
  126358. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  126359. /**
  126360. * Disposes the component and the associated ressources.
  126361. */
  126362. dispose(): void;
  126363. private _isReadyForMesh;
  126364. private _renderMainTexture;
  126365. private _setStencil;
  126366. private _setStencilBack;
  126367. private _draw;
  126368. private _drawCamera;
  126369. private _drawRenderingGroup;
  126370. }
  126371. }
  126372. declare module BABYLON {
  126373. /** @hidden */
  126374. export var glowMapMergePixelShader: {
  126375. name: string;
  126376. shader: string;
  126377. };
  126378. }
  126379. declare module BABYLON {
  126380. /** @hidden */
  126381. export var glowMapMergeVertexShader: {
  126382. name: string;
  126383. shader: string;
  126384. };
  126385. }
  126386. declare module BABYLON {
  126387. interface AbstractScene {
  126388. /**
  126389. * Return a the first highlight layer of the scene with a given name.
  126390. * @param name The name of the highlight layer to look for.
  126391. * @return The highlight layer if found otherwise null.
  126392. */
  126393. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  126394. }
  126395. /**
  126396. * Glow layer options. This helps customizing the behaviour
  126397. * of the glow layer.
  126398. */
  126399. export interface IGlowLayerOptions {
  126400. /**
  126401. * Multiplication factor apply to the canvas size to compute the render target size
  126402. * used to generated the glowing objects (the smaller the faster).
  126403. */
  126404. mainTextureRatio: number;
  126405. /**
  126406. * Enforces a fixed size texture to ensure resize independant blur.
  126407. */
  126408. mainTextureFixedSize?: number;
  126409. /**
  126410. * How big is the kernel of the blur texture.
  126411. */
  126412. blurKernelSize: number;
  126413. /**
  126414. * The camera attached to the layer.
  126415. */
  126416. camera: Nullable<Camera>;
  126417. /**
  126418. * Enable MSAA by chosing the number of samples.
  126419. */
  126420. mainTextureSamples?: number;
  126421. /**
  126422. * The rendering group to draw the layer in.
  126423. */
  126424. renderingGroupId: number;
  126425. }
  126426. /**
  126427. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  126428. *
  126429. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  126430. *
  126431. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  126432. */
  126433. export class GlowLayer extends EffectLayer {
  126434. /**
  126435. * Effect Name of the layer.
  126436. */
  126437. static readonly EffectName: string;
  126438. /**
  126439. * The default blur kernel size used for the glow.
  126440. */
  126441. static DefaultBlurKernelSize: number;
  126442. /**
  126443. * The default texture size ratio used for the glow.
  126444. */
  126445. static DefaultTextureRatio: number;
  126446. /**
  126447. * Sets the kernel size of the blur.
  126448. */
  126449. set blurKernelSize(value: number);
  126450. /**
  126451. * Gets the kernel size of the blur.
  126452. */
  126453. get blurKernelSize(): number;
  126454. /**
  126455. * Sets the glow intensity.
  126456. */
  126457. set intensity(value: number);
  126458. /**
  126459. * Gets the glow intensity.
  126460. */
  126461. get intensity(): number;
  126462. private _options;
  126463. private _intensity;
  126464. private _horizontalBlurPostprocess1;
  126465. private _verticalBlurPostprocess1;
  126466. private _horizontalBlurPostprocess2;
  126467. private _verticalBlurPostprocess2;
  126468. private _blurTexture1;
  126469. private _blurTexture2;
  126470. private _postProcesses1;
  126471. private _postProcesses2;
  126472. private _includedOnlyMeshes;
  126473. private _excludedMeshes;
  126474. private _meshesUsingTheirOwnMaterials;
  126475. /**
  126476. * Callback used to let the user override the color selection on a per mesh basis
  126477. */
  126478. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  126479. /**
  126480. * Callback used to let the user override the texture selection on a per mesh basis
  126481. */
  126482. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  126483. /**
  126484. * Instantiates a new glow Layer and references it to the scene.
  126485. * @param name The name of the layer
  126486. * @param scene The scene to use the layer in
  126487. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  126488. */
  126489. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  126490. /**
  126491. * Get the effect name of the layer.
  126492. * @return The effect name
  126493. */
  126494. getEffectName(): string;
  126495. /**
  126496. * Create the merge effect. This is the shader use to blit the information back
  126497. * to the main canvas at the end of the scene rendering.
  126498. */
  126499. protected _createMergeEffect(): Effect;
  126500. /**
  126501. * Creates the render target textures and post processes used in the glow layer.
  126502. */
  126503. protected _createTextureAndPostProcesses(): void;
  126504. /**
  126505. * Checks for the readiness of the element composing the layer.
  126506. * @param subMesh the mesh to check for
  126507. * @param useInstances specify wether or not to use instances to render the mesh
  126508. * @param emissiveTexture the associated emissive texture used to generate the glow
  126509. * @return true if ready otherwise, false
  126510. */
  126511. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126512. /**
  126513. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  126514. */
  126515. needStencil(): boolean;
  126516. /**
  126517. * Returns true if the mesh can be rendered, otherwise false.
  126518. * @param mesh The mesh to render
  126519. * @param material The material used on the mesh
  126520. * @returns true if it can be rendered otherwise false
  126521. */
  126522. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  126523. /**
  126524. * Implementation specific of rendering the generating effect on the main canvas.
  126525. * @param effect The effect used to render through
  126526. */
  126527. protected _internalRender(effect: Effect): void;
  126528. /**
  126529. * Sets the required values for both the emissive texture and and the main color.
  126530. */
  126531. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126532. /**
  126533. * Returns true if the mesh should render, otherwise false.
  126534. * @param mesh The mesh to render
  126535. * @returns true if it should render otherwise false
  126536. */
  126537. protected _shouldRenderMesh(mesh: Mesh): boolean;
  126538. /**
  126539. * Adds specific effects defines.
  126540. * @param defines The defines to add specifics to.
  126541. */
  126542. protected _addCustomEffectDefines(defines: string[]): void;
  126543. /**
  126544. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  126545. * @param mesh The mesh to exclude from the glow layer
  126546. */
  126547. addExcludedMesh(mesh: Mesh): void;
  126548. /**
  126549. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  126550. * @param mesh The mesh to remove
  126551. */
  126552. removeExcludedMesh(mesh: Mesh): void;
  126553. /**
  126554. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  126555. * @param mesh The mesh to include in the glow layer
  126556. */
  126557. addIncludedOnlyMesh(mesh: Mesh): void;
  126558. /**
  126559. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  126560. * @param mesh The mesh to remove
  126561. */
  126562. removeIncludedOnlyMesh(mesh: Mesh): void;
  126563. /**
  126564. * Determine if a given mesh will be used in the glow layer
  126565. * @param mesh The mesh to test
  126566. * @returns true if the mesh will be highlighted by the current glow layer
  126567. */
  126568. hasMesh(mesh: AbstractMesh): boolean;
  126569. /**
  126570. * Defines whether the current material of the mesh should be use to render the effect.
  126571. * @param mesh defines the current mesh to render
  126572. */
  126573. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  126574. /**
  126575. * Add a mesh to be rendered through its own material and not with emissive only.
  126576. * @param mesh The mesh for which we need to use its material
  126577. */
  126578. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  126579. /**
  126580. * Remove a mesh from being rendered through its own material and not with emissive only.
  126581. * @param mesh The mesh for which we need to not use its material
  126582. */
  126583. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  126584. /**
  126585. * Free any resources and references associated to a mesh.
  126586. * Internal use
  126587. * @param mesh The mesh to free.
  126588. * @hidden
  126589. */
  126590. _disposeMesh(mesh: Mesh): void;
  126591. /**
  126592. * Gets the class name of the effect layer
  126593. * @returns the string with the class name of the effect layer
  126594. */
  126595. getClassName(): string;
  126596. /**
  126597. * Serializes this glow layer
  126598. * @returns a serialized glow layer object
  126599. */
  126600. serialize(): any;
  126601. /**
  126602. * Creates a Glow Layer from parsed glow layer data
  126603. * @param parsedGlowLayer defines glow layer data
  126604. * @param scene defines the current scene
  126605. * @param rootUrl defines the root URL containing the glow layer information
  126606. * @returns a parsed Glow Layer
  126607. */
  126608. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  126609. }
  126610. }
  126611. declare module BABYLON {
  126612. /** @hidden */
  126613. export var glowBlurPostProcessPixelShader: {
  126614. name: string;
  126615. shader: string;
  126616. };
  126617. }
  126618. declare module BABYLON {
  126619. interface AbstractScene {
  126620. /**
  126621. * Return a the first highlight layer of the scene with a given name.
  126622. * @param name The name of the highlight layer to look for.
  126623. * @return The highlight layer if found otherwise null.
  126624. */
  126625. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  126626. }
  126627. /**
  126628. * Highlight layer options. This helps customizing the behaviour
  126629. * of the highlight layer.
  126630. */
  126631. export interface IHighlightLayerOptions {
  126632. /**
  126633. * Multiplication factor apply to the canvas size to compute the render target size
  126634. * used to generated the glowing objects (the smaller the faster).
  126635. */
  126636. mainTextureRatio: number;
  126637. /**
  126638. * Enforces a fixed size texture to ensure resize independant blur.
  126639. */
  126640. mainTextureFixedSize?: number;
  126641. /**
  126642. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  126643. * of the picture to blur (the smaller the faster).
  126644. */
  126645. blurTextureSizeRatio: number;
  126646. /**
  126647. * How big in texel of the blur texture is the vertical blur.
  126648. */
  126649. blurVerticalSize: number;
  126650. /**
  126651. * How big in texel of the blur texture is the horizontal blur.
  126652. */
  126653. blurHorizontalSize: number;
  126654. /**
  126655. * Alpha blending mode used to apply the blur. Default is combine.
  126656. */
  126657. alphaBlendingMode: number;
  126658. /**
  126659. * The camera attached to the layer.
  126660. */
  126661. camera: Nullable<Camera>;
  126662. /**
  126663. * Should we display highlight as a solid stroke?
  126664. */
  126665. isStroke?: boolean;
  126666. /**
  126667. * The rendering group to draw the layer in.
  126668. */
  126669. renderingGroupId: number;
  126670. }
  126671. /**
  126672. * The highlight layer Helps adding a glow effect around a mesh.
  126673. *
  126674. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  126675. * glowy meshes to your scene.
  126676. *
  126677. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  126678. */
  126679. export class HighlightLayer extends EffectLayer {
  126680. name: string;
  126681. /**
  126682. * Effect Name of the highlight layer.
  126683. */
  126684. static readonly EffectName: string;
  126685. /**
  126686. * The neutral color used during the preparation of the glow effect.
  126687. * This is black by default as the blend operation is a blend operation.
  126688. */
  126689. static NeutralColor: Color4;
  126690. /**
  126691. * Stencil value used for glowing meshes.
  126692. */
  126693. static GlowingMeshStencilReference: number;
  126694. /**
  126695. * Stencil value used for the other meshes in the scene.
  126696. */
  126697. static NormalMeshStencilReference: number;
  126698. /**
  126699. * Specifies whether or not the inner glow is ACTIVE in the layer.
  126700. */
  126701. innerGlow: boolean;
  126702. /**
  126703. * Specifies whether or not the outer glow is ACTIVE in the layer.
  126704. */
  126705. outerGlow: boolean;
  126706. /**
  126707. * Specifies the horizontal size of the blur.
  126708. */
  126709. set blurHorizontalSize(value: number);
  126710. /**
  126711. * Specifies the vertical size of the blur.
  126712. */
  126713. set blurVerticalSize(value: number);
  126714. /**
  126715. * Gets the horizontal size of the blur.
  126716. */
  126717. get blurHorizontalSize(): number;
  126718. /**
  126719. * Gets the vertical size of the blur.
  126720. */
  126721. get blurVerticalSize(): number;
  126722. /**
  126723. * An event triggered when the highlight layer is being blurred.
  126724. */
  126725. onBeforeBlurObservable: Observable<HighlightLayer>;
  126726. /**
  126727. * An event triggered when the highlight layer has been blurred.
  126728. */
  126729. onAfterBlurObservable: Observable<HighlightLayer>;
  126730. private _instanceGlowingMeshStencilReference;
  126731. private _options;
  126732. private _downSamplePostprocess;
  126733. private _horizontalBlurPostprocess;
  126734. private _verticalBlurPostprocess;
  126735. private _blurTexture;
  126736. private _meshes;
  126737. private _excludedMeshes;
  126738. /**
  126739. * Instantiates a new highlight Layer and references it to the scene..
  126740. * @param name The name of the layer
  126741. * @param scene The scene to use the layer in
  126742. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  126743. */
  126744. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  126745. /**
  126746. * Get the effect name of the layer.
  126747. * @return The effect name
  126748. */
  126749. getEffectName(): string;
  126750. /**
  126751. * Create the merge effect. This is the shader use to blit the information back
  126752. * to the main canvas at the end of the scene rendering.
  126753. */
  126754. protected _createMergeEffect(): Effect;
  126755. /**
  126756. * Creates the render target textures and post processes used in the highlight layer.
  126757. */
  126758. protected _createTextureAndPostProcesses(): void;
  126759. /**
  126760. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  126761. */
  126762. needStencil(): boolean;
  126763. /**
  126764. * Checks for the readiness of the element composing the layer.
  126765. * @param subMesh the mesh to check for
  126766. * @param useInstances specify wether or not to use instances to render the mesh
  126767. * @param emissiveTexture the associated emissive texture used to generate the glow
  126768. * @return true if ready otherwise, false
  126769. */
  126770. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126771. /**
  126772. * Implementation specific of rendering the generating effect on the main canvas.
  126773. * @param effect The effect used to render through
  126774. */
  126775. protected _internalRender(effect: Effect): void;
  126776. /**
  126777. * Returns true if the layer contains information to display, otherwise false.
  126778. */
  126779. shouldRender(): boolean;
  126780. /**
  126781. * Returns true if the mesh should render, otherwise false.
  126782. * @param mesh The mesh to render
  126783. * @returns true if it should render otherwise false
  126784. */
  126785. protected _shouldRenderMesh(mesh: Mesh): boolean;
  126786. /**
  126787. * Sets the required values for both the emissive texture and and the main color.
  126788. */
  126789. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126790. /**
  126791. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  126792. * @param mesh The mesh to exclude from the highlight layer
  126793. */
  126794. addExcludedMesh(mesh: Mesh): void;
  126795. /**
  126796. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  126797. * @param mesh The mesh to highlight
  126798. */
  126799. removeExcludedMesh(mesh: Mesh): void;
  126800. /**
  126801. * Determine if a given mesh will be highlighted by the current HighlightLayer
  126802. * @param mesh mesh to test
  126803. * @returns true if the mesh will be highlighted by the current HighlightLayer
  126804. */
  126805. hasMesh(mesh: AbstractMesh): boolean;
  126806. /**
  126807. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  126808. * @param mesh The mesh to highlight
  126809. * @param color The color of the highlight
  126810. * @param glowEmissiveOnly Extract the glow from the emissive texture
  126811. */
  126812. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  126813. /**
  126814. * Remove a mesh from the highlight layer in order to make it stop glowing.
  126815. * @param mesh The mesh to highlight
  126816. */
  126817. removeMesh(mesh: Mesh): void;
  126818. /**
  126819. * Force the stencil to the normal expected value for none glowing parts
  126820. */
  126821. private _defaultStencilReference;
  126822. /**
  126823. * Free any resources and references associated to a mesh.
  126824. * Internal use
  126825. * @param mesh The mesh to free.
  126826. * @hidden
  126827. */
  126828. _disposeMesh(mesh: Mesh): void;
  126829. /**
  126830. * Dispose the highlight layer and free resources.
  126831. */
  126832. dispose(): void;
  126833. /**
  126834. * Gets the class name of the effect layer
  126835. * @returns the string with the class name of the effect layer
  126836. */
  126837. getClassName(): string;
  126838. /**
  126839. * Serializes this Highlight layer
  126840. * @returns a serialized Highlight layer object
  126841. */
  126842. serialize(): any;
  126843. /**
  126844. * Creates a Highlight layer from parsed Highlight layer data
  126845. * @param parsedHightlightLayer defines the Highlight layer data
  126846. * @param scene defines the current scene
  126847. * @param rootUrl defines the root URL containing the Highlight layer information
  126848. * @returns a parsed Highlight layer
  126849. */
  126850. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  126851. }
  126852. }
  126853. declare module BABYLON {
  126854. interface AbstractScene {
  126855. /**
  126856. * The list of layers (background and foreground) of the scene
  126857. */
  126858. layers: Array<Layer>;
  126859. }
  126860. /**
  126861. * Defines the layer scene component responsible to manage any layers
  126862. * in a given scene.
  126863. */
  126864. export class LayerSceneComponent implements ISceneComponent {
  126865. /**
  126866. * The component name helpfull to identify the component in the list of scene components.
  126867. */
  126868. readonly name: string;
  126869. /**
  126870. * The scene the component belongs to.
  126871. */
  126872. scene: Scene;
  126873. private _engine;
  126874. /**
  126875. * Creates a new instance of the component for the given scene
  126876. * @param scene Defines the scene to register the component in
  126877. */
  126878. constructor(scene: Scene);
  126879. /**
  126880. * Registers the component in a given scene
  126881. */
  126882. register(): void;
  126883. /**
  126884. * Rebuilds the elements related to this component in case of
  126885. * context lost for instance.
  126886. */
  126887. rebuild(): void;
  126888. /**
  126889. * Disposes the component and the associated ressources.
  126890. */
  126891. dispose(): void;
  126892. private _draw;
  126893. private _drawCameraPredicate;
  126894. private _drawCameraBackground;
  126895. private _drawCameraForeground;
  126896. private _drawRenderTargetPredicate;
  126897. private _drawRenderTargetBackground;
  126898. private _drawRenderTargetForeground;
  126899. /**
  126900. * Adds all the elements from the container to the scene
  126901. * @param container the container holding the elements
  126902. */
  126903. addFromContainer(container: AbstractScene): void;
  126904. /**
  126905. * Removes all the elements in the container from the scene
  126906. * @param container contains the elements to remove
  126907. * @param dispose if the removed element should be disposed (default: false)
  126908. */
  126909. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  126910. }
  126911. }
  126912. declare module BABYLON {
  126913. /** @hidden */
  126914. export var layerPixelShader: {
  126915. name: string;
  126916. shader: string;
  126917. };
  126918. }
  126919. declare module BABYLON {
  126920. /** @hidden */
  126921. export var layerVertexShader: {
  126922. name: string;
  126923. shader: string;
  126924. };
  126925. }
  126926. declare module BABYLON {
  126927. /**
  126928. * This represents a full screen 2d layer.
  126929. * This can be useful to display a picture in the background of your scene for instance.
  126930. * @see https://www.babylonjs-playground.com/#08A2BS#1
  126931. */
  126932. export class Layer {
  126933. /**
  126934. * Define the name of the layer.
  126935. */
  126936. name: string;
  126937. /**
  126938. * Define the texture the layer should display.
  126939. */
  126940. texture: Nullable<Texture>;
  126941. /**
  126942. * Is the layer in background or foreground.
  126943. */
  126944. isBackground: boolean;
  126945. /**
  126946. * Define the color of the layer (instead of texture).
  126947. */
  126948. color: Color4;
  126949. /**
  126950. * Define the scale of the layer in order to zoom in out of the texture.
  126951. */
  126952. scale: Vector2;
  126953. /**
  126954. * Define an offset for the layer in order to shift the texture.
  126955. */
  126956. offset: Vector2;
  126957. /**
  126958. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  126959. */
  126960. alphaBlendingMode: number;
  126961. /**
  126962. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  126963. * Alpha test will not mix with the background color in case of transparency.
  126964. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  126965. */
  126966. alphaTest: boolean;
  126967. /**
  126968. * Define a mask to restrict the layer to only some of the scene cameras.
  126969. */
  126970. layerMask: number;
  126971. /**
  126972. * Define the list of render target the layer is visible into.
  126973. */
  126974. renderTargetTextures: RenderTargetTexture[];
  126975. /**
  126976. * Define if the layer is only used in renderTarget or if it also
  126977. * renders in the main frame buffer of the canvas.
  126978. */
  126979. renderOnlyInRenderTargetTextures: boolean;
  126980. private _scene;
  126981. private _vertexBuffers;
  126982. private _indexBuffer;
  126983. private _effect;
  126984. private _previousDefines;
  126985. /**
  126986. * An event triggered when the layer is disposed.
  126987. */
  126988. onDisposeObservable: Observable<Layer>;
  126989. private _onDisposeObserver;
  126990. /**
  126991. * Back compatibility with callback before the onDisposeObservable existed.
  126992. * The set callback will be triggered when the layer has been disposed.
  126993. */
  126994. set onDispose(callback: () => void);
  126995. /**
  126996. * An event triggered before rendering the scene
  126997. */
  126998. onBeforeRenderObservable: Observable<Layer>;
  126999. private _onBeforeRenderObserver;
  127000. /**
  127001. * Back compatibility with callback before the onBeforeRenderObservable existed.
  127002. * The set callback will be triggered just before rendering the layer.
  127003. */
  127004. set onBeforeRender(callback: () => void);
  127005. /**
  127006. * An event triggered after rendering the scene
  127007. */
  127008. onAfterRenderObservable: Observable<Layer>;
  127009. private _onAfterRenderObserver;
  127010. /**
  127011. * Back compatibility with callback before the onAfterRenderObservable existed.
  127012. * The set callback will be triggered just after rendering the layer.
  127013. */
  127014. set onAfterRender(callback: () => void);
  127015. /**
  127016. * Instantiates a new layer.
  127017. * This represents a full screen 2d layer.
  127018. * This can be useful to display a picture in the background of your scene for instance.
  127019. * @see https://www.babylonjs-playground.com/#08A2BS#1
  127020. * @param name Define the name of the layer in the scene
  127021. * @param imgUrl Define the url of the texture to display in the layer
  127022. * @param scene Define the scene the layer belongs to
  127023. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  127024. * @param color Defines a color for the layer
  127025. */
  127026. constructor(
  127027. /**
  127028. * Define the name of the layer.
  127029. */
  127030. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  127031. private _createIndexBuffer;
  127032. /** @hidden */
  127033. _rebuild(): void;
  127034. /**
  127035. * Renders the layer in the scene.
  127036. */
  127037. render(): void;
  127038. /**
  127039. * Disposes and releases the associated ressources.
  127040. */
  127041. dispose(): void;
  127042. }
  127043. }
  127044. declare module BABYLON {
  127045. /** @hidden */
  127046. export var lensFlarePixelShader: {
  127047. name: string;
  127048. shader: string;
  127049. };
  127050. }
  127051. declare module BABYLON {
  127052. /** @hidden */
  127053. export var lensFlareVertexShader: {
  127054. name: string;
  127055. shader: string;
  127056. };
  127057. }
  127058. declare module BABYLON {
  127059. /**
  127060. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  127061. * It is usually composed of several `lensFlare`.
  127062. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127063. */
  127064. export class LensFlareSystem {
  127065. /**
  127066. * Define the name of the lens flare system
  127067. */
  127068. name: string;
  127069. /**
  127070. * List of lens flares used in this system.
  127071. */
  127072. lensFlares: LensFlare[];
  127073. /**
  127074. * Define a limit from the border the lens flare can be visible.
  127075. */
  127076. borderLimit: number;
  127077. /**
  127078. * Define a viewport border we do not want to see the lens flare in.
  127079. */
  127080. viewportBorder: number;
  127081. /**
  127082. * Define a predicate which could limit the list of meshes able to occlude the effect.
  127083. */
  127084. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  127085. /**
  127086. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  127087. */
  127088. layerMask: number;
  127089. /**
  127090. * Define the id of the lens flare system in the scene.
  127091. * (equal to name by default)
  127092. */
  127093. id: string;
  127094. private _scene;
  127095. private _emitter;
  127096. private _vertexBuffers;
  127097. private _indexBuffer;
  127098. private _effect;
  127099. private _positionX;
  127100. private _positionY;
  127101. private _isEnabled;
  127102. /** @hidden */
  127103. static _SceneComponentInitialization: (scene: Scene) => void;
  127104. /**
  127105. * Instantiates a lens flare system.
  127106. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  127107. * It is usually composed of several `lensFlare`.
  127108. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127109. * @param name Define the name of the lens flare system in the scene
  127110. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  127111. * @param scene Define the scene the lens flare system belongs to
  127112. */
  127113. constructor(
  127114. /**
  127115. * Define the name of the lens flare system
  127116. */
  127117. name: string, emitter: any, scene: Scene);
  127118. /**
  127119. * Define if the lens flare system is enabled.
  127120. */
  127121. get isEnabled(): boolean;
  127122. set isEnabled(value: boolean);
  127123. /**
  127124. * Get the scene the effects belongs to.
  127125. * @returns the scene holding the lens flare system
  127126. */
  127127. getScene(): Scene;
  127128. /**
  127129. * Get the emitter of the lens flare system.
  127130. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  127131. * @returns the emitter of the lens flare system
  127132. */
  127133. getEmitter(): any;
  127134. /**
  127135. * Set the emitter of the lens flare system.
  127136. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  127137. * @param newEmitter Define the new emitter of the system
  127138. */
  127139. setEmitter(newEmitter: any): void;
  127140. /**
  127141. * Get the lens flare system emitter position.
  127142. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  127143. * @returns the position
  127144. */
  127145. getEmitterPosition(): Vector3;
  127146. /**
  127147. * @hidden
  127148. */
  127149. computeEffectivePosition(globalViewport: Viewport): boolean;
  127150. /** @hidden */
  127151. _isVisible(): boolean;
  127152. /**
  127153. * @hidden
  127154. */
  127155. render(): boolean;
  127156. /**
  127157. * Dispose and release the lens flare with its associated resources.
  127158. */
  127159. dispose(): void;
  127160. /**
  127161. * Parse a lens flare system from a JSON repressentation
  127162. * @param parsedLensFlareSystem Define the JSON to parse
  127163. * @param scene Define the scene the parsed system should be instantiated in
  127164. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  127165. * @returns the parsed system
  127166. */
  127167. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  127168. /**
  127169. * Serialize the current Lens Flare System into a JSON representation.
  127170. * @returns the serialized JSON
  127171. */
  127172. serialize(): any;
  127173. }
  127174. }
  127175. declare module BABYLON {
  127176. /**
  127177. * This represents one of the lens effect in a `lensFlareSystem`.
  127178. * It controls one of the indiviual texture used in the effect.
  127179. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127180. */
  127181. export class LensFlare {
  127182. /**
  127183. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  127184. */
  127185. size: number;
  127186. /**
  127187. * 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. */
  127189. position: number;
  127190. /**
  127191. * Define the lens color.
  127192. */
  127193. color: Color3;
  127194. /**
  127195. * Define the lens texture.
  127196. */
  127197. texture: Nullable<Texture>;
  127198. /**
  127199. * Define the alpha mode to render this particular lens.
  127200. */
  127201. alphaMode: number;
  127202. private _system;
  127203. /**
  127204. * Creates a new Lens Flare.
  127205. * This represents one of the lens effect in a `lensFlareSystem`.
  127206. * It controls one of the indiviual texture used in the effect.
  127207. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127208. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  127209. * @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.
  127210. * @param color Define the lens color
  127211. * @param imgUrl Define the lens texture url
  127212. * @param system Define the `lensFlareSystem` this flare is part of
  127213. * @returns The newly created Lens Flare
  127214. */
  127215. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  127216. /**
  127217. * Instantiates a new Lens Flare.
  127218. * This represents one of the lens effect in a `lensFlareSystem`.
  127219. * It controls one of the indiviual texture used in the effect.
  127220. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127221. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  127222. * @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.
  127223. * @param color Define the lens color
  127224. * @param imgUrl Define the lens texture url
  127225. * @param system Define the `lensFlareSystem` this flare is part of
  127226. */
  127227. constructor(
  127228. /**
  127229. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  127230. */
  127231. size: number,
  127232. /**
  127233. * 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.
  127234. */
  127235. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  127236. /**
  127237. * Dispose and release the lens flare with its associated resources.
  127238. */
  127239. dispose(): void;
  127240. }
  127241. }
  127242. declare module BABYLON {
  127243. interface AbstractScene {
  127244. /**
  127245. * The list of lens flare system added to the scene
  127246. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127247. */
  127248. lensFlareSystems: Array<LensFlareSystem>;
  127249. /**
  127250. * Removes the given lens flare system from this scene.
  127251. * @param toRemove The lens flare system to remove
  127252. * @returns The index of the removed lens flare system
  127253. */
  127254. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  127255. /**
  127256. * Adds the given lens flare system to this scene
  127257. * @param newLensFlareSystem The lens flare system to add
  127258. */
  127259. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  127260. /**
  127261. * Gets a lens flare system using its name
  127262. * @param name defines the name to look for
  127263. * @returns the lens flare system or null if not found
  127264. */
  127265. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  127266. /**
  127267. * Gets a lens flare system using its id
  127268. * @param id defines the id to look for
  127269. * @returns the lens flare system or null if not found
  127270. */
  127271. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  127272. }
  127273. /**
  127274. * Defines the lens flare scene component responsible to manage any lens flares
  127275. * in a given scene.
  127276. */
  127277. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  127278. /**
  127279. * The component name helpfull to identify the component in the list of scene components.
  127280. */
  127281. readonly name: string;
  127282. /**
  127283. * The scene the component belongs to.
  127284. */
  127285. scene: Scene;
  127286. /**
  127287. * Creates a new instance of the component for the given scene
  127288. * @param scene Defines the scene to register the component in
  127289. */
  127290. constructor(scene: Scene);
  127291. /**
  127292. * Registers the component in a given scene
  127293. */
  127294. register(): void;
  127295. /**
  127296. * Rebuilds the elements related to this component in case of
  127297. * context lost for instance.
  127298. */
  127299. rebuild(): void;
  127300. /**
  127301. * Adds all the elements from the container to the scene
  127302. * @param container the container holding the elements
  127303. */
  127304. addFromContainer(container: AbstractScene): void;
  127305. /**
  127306. * Removes all the elements in the container from the scene
  127307. * @param container contains the elements to remove
  127308. * @param dispose if the removed element should be disposed (default: false)
  127309. */
  127310. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127311. /**
  127312. * Serializes the component data to the specified json object
  127313. * @param serializationObject The object to serialize to
  127314. */
  127315. serialize(serializationObject: any): void;
  127316. /**
  127317. * Disposes the component and the associated ressources.
  127318. */
  127319. dispose(): void;
  127320. private _draw;
  127321. }
  127322. }
  127323. declare module BABYLON {
  127324. /** @hidden */
  127325. export var depthPixelShader: {
  127326. name: string;
  127327. shader: string;
  127328. };
  127329. }
  127330. declare module BABYLON {
  127331. /** @hidden */
  127332. export var depthVertexShader: {
  127333. name: string;
  127334. shader: string;
  127335. };
  127336. }
  127337. declare module BABYLON {
  127338. /**
  127339. * This represents a depth renderer in Babylon.
  127340. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  127341. */
  127342. export class DepthRenderer {
  127343. private _scene;
  127344. private _depthMap;
  127345. private _effect;
  127346. private readonly _storeNonLinearDepth;
  127347. private readonly _clearColor;
  127348. /** Get if the depth renderer is using packed depth or not */
  127349. readonly isPacked: boolean;
  127350. private _cachedDefines;
  127351. private _camera;
  127352. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  127353. enabled: boolean;
  127354. /**
  127355. * Specifiess that the depth renderer will only be used within
  127356. * the camera it is created for.
  127357. * This can help forcing its rendering during the camera processing.
  127358. */
  127359. useOnlyInActiveCamera: boolean;
  127360. /** @hidden */
  127361. static _SceneComponentInitialization: (scene: Scene) => void;
  127362. /**
  127363. * Instantiates a depth renderer
  127364. * @param scene The scene the renderer belongs to
  127365. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  127366. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  127367. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  127368. */
  127369. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  127370. /**
  127371. * Creates the depth rendering effect and checks if the effect is ready.
  127372. * @param subMesh The submesh to be used to render the depth map of
  127373. * @param useInstances If multiple world instances should be used
  127374. * @returns if the depth renderer is ready to render the depth map
  127375. */
  127376. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  127377. /**
  127378. * Gets the texture which the depth map will be written to.
  127379. * @returns The depth map texture
  127380. */
  127381. getDepthMap(): RenderTargetTexture;
  127382. /**
  127383. * Disposes of the depth renderer.
  127384. */
  127385. dispose(): void;
  127386. }
  127387. }
  127388. declare module BABYLON {
  127389. /** @hidden */
  127390. export var minmaxReduxPixelShader: {
  127391. name: string;
  127392. shader: string;
  127393. };
  127394. }
  127395. declare module BABYLON {
  127396. /**
  127397. * This class computes a min/max reduction from a texture: it means it computes the minimum
  127398. * and maximum values from all values of the texture.
  127399. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  127400. * The source values are read from the red channel of the texture.
  127401. */
  127402. export class MinMaxReducer {
  127403. /**
  127404. * Observable triggered when the computation has been performed
  127405. */
  127406. onAfterReductionPerformed: Observable<{
  127407. min: number;
  127408. max: number;
  127409. }>;
  127410. protected _camera: Camera;
  127411. protected _sourceTexture: Nullable<RenderTargetTexture>;
  127412. protected _reductionSteps: Nullable<Array<PostProcess>>;
  127413. protected _postProcessManager: PostProcessManager;
  127414. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  127415. protected _forceFullscreenViewport: boolean;
  127416. /**
  127417. * Creates a min/max reducer
  127418. * @param camera The camera to use for the post processes
  127419. */
  127420. constructor(camera: Camera);
  127421. /**
  127422. * Gets the texture used to read the values from.
  127423. */
  127424. get sourceTexture(): Nullable<RenderTargetTexture>;
  127425. /**
  127426. * Sets the source texture to read the values from.
  127427. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  127428. * because in such textures '1' value must not be taken into account to compute the maximum
  127429. * as this value is used to clear the texture.
  127430. * Note that the computation is not activated by calling this function, you must call activate() for that!
  127431. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  127432. * @param depthRedux Indicates if the texture is a depth texture or not
  127433. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  127434. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  127435. */
  127436. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  127437. /**
  127438. * Defines the refresh rate of the computation.
  127439. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  127440. */
  127441. get refreshRate(): number;
  127442. set refreshRate(value: number);
  127443. protected _activated: boolean;
  127444. /**
  127445. * Gets the activation status of the reducer
  127446. */
  127447. get activated(): boolean;
  127448. /**
  127449. * Activates the reduction computation.
  127450. * When activated, the observers registered in onAfterReductionPerformed are
  127451. * called after the compuation is performed
  127452. */
  127453. activate(): void;
  127454. /**
  127455. * Deactivates the reduction computation.
  127456. */
  127457. deactivate(): void;
  127458. /**
  127459. * Disposes the min/max reducer
  127460. * @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.
  127461. */
  127462. dispose(disposeAll?: boolean): void;
  127463. }
  127464. }
  127465. declare module BABYLON {
  127466. /**
  127467. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  127468. */
  127469. export class DepthReducer extends MinMaxReducer {
  127470. private _depthRenderer;
  127471. private _depthRendererId;
  127472. /**
  127473. * Gets the depth renderer used for the computation.
  127474. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  127475. */
  127476. get depthRenderer(): Nullable<DepthRenderer>;
  127477. /**
  127478. * Creates a depth reducer
  127479. * @param camera The camera used to render the depth texture
  127480. */
  127481. constructor(camera: Camera);
  127482. /**
  127483. * Sets the depth renderer to use to generate the depth map
  127484. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  127485. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  127486. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  127487. */
  127488. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  127489. /** @hidden */
  127490. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  127491. /**
  127492. * Activates the reduction computation.
  127493. * When activated, the observers registered in onAfterReductionPerformed are
  127494. * called after the compuation is performed
  127495. */
  127496. activate(): void;
  127497. /**
  127498. * Deactivates the reduction computation.
  127499. */
  127500. deactivate(): void;
  127501. /**
  127502. * Disposes the depth reducer
  127503. * @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.
  127504. */
  127505. dispose(disposeAll?: boolean): void;
  127506. }
  127507. }
  127508. declare module BABYLON {
  127509. /**
  127510. * A CSM implementation allowing casting shadows on large scenes.
  127511. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  127512. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  127513. */
  127514. export class CascadedShadowGenerator extends ShadowGenerator {
  127515. private static readonly frustumCornersNDCSpace;
  127516. /**
  127517. * Name of the CSM class
  127518. */
  127519. static CLASSNAME: string;
  127520. /**
  127521. * Defines the default number of cascades used by the CSM.
  127522. */
  127523. static readonly DEFAULT_CASCADES_COUNT: number;
  127524. /**
  127525. * Defines the minimum number of cascades used by the CSM.
  127526. */
  127527. static readonly MIN_CASCADES_COUNT: number;
  127528. /**
  127529. * Defines the maximum number of cascades used by the CSM.
  127530. */
  127531. static readonly MAX_CASCADES_COUNT: number;
  127532. protected _validateFilter(filter: number): number;
  127533. /**
  127534. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  127535. */
  127536. penumbraDarkness: number;
  127537. private _numCascades;
  127538. /**
  127539. * Gets or set the number of cascades used by the CSM.
  127540. */
  127541. get numCascades(): number;
  127542. set numCascades(value: number);
  127543. /**
  127544. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  127545. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  127546. */
  127547. stabilizeCascades: boolean;
  127548. private _freezeShadowCastersBoundingInfo;
  127549. private _freezeShadowCastersBoundingInfoObservable;
  127550. /**
  127551. * Enables or disables the shadow casters bounding info computation.
  127552. * If your shadow casters don't move, you can disable this feature.
  127553. * If it is enabled, the bounding box computation is done every frame.
  127554. */
  127555. get freezeShadowCastersBoundingInfo(): boolean;
  127556. set freezeShadowCastersBoundingInfo(freeze: boolean);
  127557. private _scbiMin;
  127558. private _scbiMax;
  127559. protected _computeShadowCastersBoundingInfo(): void;
  127560. protected _shadowCastersBoundingInfo: BoundingInfo;
  127561. /**
  127562. * Gets or sets the shadow casters bounding info.
  127563. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  127564. * so that the system won't overwrite the bounds you provide
  127565. */
  127566. get shadowCastersBoundingInfo(): BoundingInfo;
  127567. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  127568. protected _breaksAreDirty: boolean;
  127569. protected _minDistance: number;
  127570. protected _maxDistance: number;
  127571. /**
  127572. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  127573. *
  127574. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  127575. * If you don't know these values, simply leave them to their defaults and don't call this function.
  127576. * @param min minimal distance for the breaks (default to 0.)
  127577. * @param max maximal distance for the breaks (default to 1.)
  127578. */
  127579. setMinMaxDistance(min: number, max: number): void;
  127580. /** Gets the minimal distance used in the cascade break computation */
  127581. get minDistance(): number;
  127582. /** Gets the maximal distance used in the cascade break computation */
  127583. get maxDistance(): number;
  127584. /**
  127585. * Gets the class name of that object
  127586. * @returns "CascadedShadowGenerator"
  127587. */
  127588. getClassName(): string;
  127589. private _cascadeMinExtents;
  127590. private _cascadeMaxExtents;
  127591. /**
  127592. * Gets a cascade minimum extents
  127593. * @param cascadeIndex index of the cascade
  127594. * @returns the minimum cascade extents
  127595. */
  127596. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  127597. /**
  127598. * Gets a cascade maximum extents
  127599. * @param cascadeIndex index of the cascade
  127600. * @returns the maximum cascade extents
  127601. */
  127602. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  127603. private _cascades;
  127604. private _currentLayer;
  127605. private _viewSpaceFrustumsZ;
  127606. private _viewMatrices;
  127607. private _projectionMatrices;
  127608. private _transformMatrices;
  127609. private _transformMatricesAsArray;
  127610. private _frustumLengths;
  127611. private _lightSizeUVCorrection;
  127612. private _depthCorrection;
  127613. private _frustumCornersWorldSpace;
  127614. private _frustumCenter;
  127615. private _shadowCameraPos;
  127616. private _shadowMaxZ;
  127617. /**
  127618. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  127619. * It defaults to camera.maxZ
  127620. */
  127621. get shadowMaxZ(): number;
  127622. /**
  127623. * Sets the shadow max z distance.
  127624. */
  127625. set shadowMaxZ(value: number);
  127626. protected _debug: boolean;
  127627. /**
  127628. * Gets or sets the debug flag.
  127629. * When enabled, the cascades are materialized by different colors on the screen.
  127630. */
  127631. get debug(): boolean;
  127632. set debug(dbg: boolean);
  127633. private _depthClamp;
  127634. /**
  127635. * Gets or sets the depth clamping value.
  127636. *
  127637. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  127638. * to account for the shadow casters far away.
  127639. *
  127640. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  127641. */
  127642. get depthClamp(): boolean;
  127643. set depthClamp(value: boolean);
  127644. private _cascadeBlendPercentage;
  127645. /**
  127646. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  127647. * It defaults to 0.1 (10% blending).
  127648. */
  127649. get cascadeBlendPercentage(): number;
  127650. set cascadeBlendPercentage(value: number);
  127651. private _lambda;
  127652. /**
  127653. * Gets or set the lambda parameter.
  127654. * This parameter is used to split the camera frustum and create the cascades.
  127655. * 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.
  127656. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  127657. */
  127658. get lambda(): number;
  127659. set lambda(value: number);
  127660. /**
  127661. * Gets the view matrix corresponding to a given cascade
  127662. * @param cascadeNum cascade to retrieve the view matrix from
  127663. * @returns the cascade view matrix
  127664. */
  127665. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  127666. /**
  127667. * Gets the projection matrix corresponding to a given cascade
  127668. * @param cascadeNum cascade to retrieve the projection matrix from
  127669. * @returns the cascade projection matrix
  127670. */
  127671. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  127672. /**
  127673. * Gets the transformation matrix corresponding to a given cascade
  127674. * @param cascadeNum cascade to retrieve the transformation matrix from
  127675. * @returns the cascade transformation matrix
  127676. */
  127677. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  127678. private _depthRenderer;
  127679. /**
  127680. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  127681. *
  127682. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  127683. *
  127684. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  127685. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  127686. * @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
  127687. */
  127688. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  127689. private _depthReducer;
  127690. private _autoCalcDepthBounds;
  127691. /**
  127692. * Gets or sets the autoCalcDepthBounds property.
  127693. *
  127694. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  127695. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  127696. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  127697. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  127698. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  127699. */
  127700. get autoCalcDepthBounds(): boolean;
  127701. set autoCalcDepthBounds(value: boolean);
  127702. /**
  127703. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  127704. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  127705. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  127706. * for setting the refresh rate on the renderer yourself!
  127707. */
  127708. get autoCalcDepthBoundsRefreshRate(): number;
  127709. set autoCalcDepthBoundsRefreshRate(value: number);
  127710. /**
  127711. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  127712. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  127713. * you change the camera near/far planes!
  127714. */
  127715. splitFrustum(): void;
  127716. private _splitFrustum;
  127717. private _computeMatrices;
  127718. private _computeFrustumInWorldSpace;
  127719. private _computeCascadeFrustum;
  127720. /** @hidden */
  127721. static _SceneComponentInitialization: (scene: Scene) => void;
  127722. /**
  127723. * Creates a Cascaded Shadow Generator object.
  127724. * A ShadowGenerator is the required tool to use the shadows.
  127725. * Each directional light casting shadows needs to use its own ShadowGenerator.
  127726. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  127727. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  127728. * @param light The directional light object generating the shadows.
  127729. * @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.
  127730. */
  127731. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  127732. protected _initializeGenerator(): void;
  127733. protected _createTargetRenderTexture(): void;
  127734. protected _initializeShadowMap(): void;
  127735. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  127736. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  127737. /**
  127738. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  127739. * @param defines Defines of the material we want to update
  127740. * @param lightIndex Index of the light in the enabled light list of the material
  127741. */
  127742. prepareDefines(defines: any, lightIndex: number): void;
  127743. /**
  127744. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  127745. * defined in the generator but impacting the effect).
  127746. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  127747. * @param effect The effect we are binfing the information for
  127748. */
  127749. bindShadowLight(lightIndex: string, effect: Effect): void;
  127750. /**
  127751. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  127752. * (eq to view projection * shadow projection matrices)
  127753. * @returns The transform matrix used to create the shadow map
  127754. */
  127755. getTransformMatrix(): Matrix;
  127756. /**
  127757. * Disposes the ShadowGenerator.
  127758. * Returns nothing.
  127759. */
  127760. dispose(): void;
  127761. /**
  127762. * Serializes the shadow generator setup to a json object.
  127763. * @returns The serialized JSON object
  127764. */
  127765. serialize(): any;
  127766. /**
  127767. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  127768. * @param parsedShadowGenerator The JSON object to parse
  127769. * @param scene The scene to create the shadow map for
  127770. * @returns The parsed shadow generator
  127771. */
  127772. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  127773. }
  127774. }
  127775. declare module BABYLON {
  127776. /**
  127777. * Defines the shadow generator component responsible to manage any shadow generators
  127778. * in a given scene.
  127779. */
  127780. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  127781. /**
  127782. * The component name helpfull to identify the component in the list of scene components.
  127783. */
  127784. readonly name: string;
  127785. /**
  127786. * The scene the component belongs to.
  127787. */
  127788. scene: Scene;
  127789. /**
  127790. * Creates a new instance of the component for the given scene
  127791. * @param scene Defines the scene to register the component in
  127792. */
  127793. constructor(scene: Scene);
  127794. /**
  127795. * Registers the component in a given scene
  127796. */
  127797. register(): void;
  127798. /**
  127799. * Rebuilds the elements related to this component in case of
  127800. * context lost for instance.
  127801. */
  127802. rebuild(): void;
  127803. /**
  127804. * Serializes the component data to the specified json object
  127805. * @param serializationObject The object to serialize to
  127806. */
  127807. serialize(serializationObject: any): void;
  127808. /**
  127809. * Adds all the elements from the container to the scene
  127810. * @param container the container holding the elements
  127811. */
  127812. addFromContainer(container: AbstractScene): void;
  127813. /**
  127814. * Removes all the elements in the container from the scene
  127815. * @param container contains the elements to remove
  127816. * @param dispose if the removed element should be disposed (default: false)
  127817. */
  127818. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127819. /**
  127820. * Rebuilds the elements related to this component in case of
  127821. * context lost for instance.
  127822. */
  127823. dispose(): void;
  127824. private _gatherRenderTargets;
  127825. }
  127826. }
  127827. declare module BABYLON {
  127828. /**
  127829. * A point light is a light defined by an unique point in world space.
  127830. * The light is emitted in every direction from this point.
  127831. * A good example of a point light is a standard light bulb.
  127832. * Documentation: https://doc.babylonjs.com/babylon101/lights
  127833. */
  127834. export class PointLight extends ShadowLight {
  127835. private _shadowAngle;
  127836. /**
  127837. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127838. * This specifies what angle the shadow will use to be created.
  127839. *
  127840. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  127841. */
  127842. get shadowAngle(): number;
  127843. /**
  127844. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127845. * This specifies what angle the shadow will use to be created.
  127846. *
  127847. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  127848. */
  127849. set shadowAngle(value: number);
  127850. /**
  127851. * Gets the direction if it has been set.
  127852. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127853. */
  127854. get direction(): Vector3;
  127855. /**
  127856. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127857. */
  127858. set direction(value: Vector3);
  127859. /**
  127860. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  127861. * A PointLight emits the light in every direction.
  127862. * It can cast shadows.
  127863. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  127864. * ```javascript
  127865. * var pointLight = new PointLight("pl", camera.position, scene);
  127866. * ```
  127867. * Documentation : https://doc.babylonjs.com/babylon101/lights
  127868. * @param name The light friendly name
  127869. * @param position The position of the point light in the scene
  127870. * @param scene The scene the lights belongs to
  127871. */
  127872. constructor(name: string, position: Vector3, scene: Scene);
  127873. /**
  127874. * Returns the string "PointLight"
  127875. * @returns the class name
  127876. */
  127877. getClassName(): string;
  127878. /**
  127879. * Returns the integer 0.
  127880. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  127881. */
  127882. getTypeID(): number;
  127883. /**
  127884. * Specifies wether or not the shadowmap should be a cube texture.
  127885. * @returns true if the shadowmap needs to be a cube texture.
  127886. */
  127887. needCube(): boolean;
  127888. /**
  127889. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  127890. * @param faceIndex The index of the face we are computed the direction to generate shadow
  127891. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  127892. */
  127893. getShadowDirection(faceIndex?: number): Vector3;
  127894. /**
  127895. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  127896. * - fov = PI / 2
  127897. * - aspect ratio : 1.0
  127898. * - z-near and far equal to the active camera minZ and maxZ.
  127899. * Returns the PointLight.
  127900. */
  127901. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  127902. protected _buildUniformLayout(): void;
  127903. /**
  127904. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  127905. * @param effect The effect to update
  127906. * @param lightIndex The index of the light in the effect to update
  127907. * @returns The point light
  127908. */
  127909. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  127910. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  127911. /**
  127912. * Prepares the list of defines specific to the light type.
  127913. * @param defines the list of defines
  127914. * @param lightIndex defines the index of the light for the effect
  127915. */
  127916. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  127917. }
  127918. }
  127919. declare module BABYLON {
  127920. /**
  127921. * Header information of HDR texture files.
  127922. */
  127923. export interface HDRInfo {
  127924. /**
  127925. * The height of the texture in pixels.
  127926. */
  127927. height: number;
  127928. /**
  127929. * The width of the texture in pixels.
  127930. */
  127931. width: number;
  127932. /**
  127933. * The index of the beginning of the data in the binary file.
  127934. */
  127935. dataPosition: number;
  127936. }
  127937. /**
  127938. * This groups tools to convert HDR texture to native colors array.
  127939. */
  127940. export class HDRTools {
  127941. private static Ldexp;
  127942. private static Rgbe2float;
  127943. private static readStringLine;
  127944. /**
  127945. * Reads header information from an RGBE texture stored in a native array.
  127946. * More information on this format are available here:
  127947. * https://en.wikipedia.org/wiki/RGBE_image_format
  127948. *
  127949. * @param uint8array The binary file stored in native array.
  127950. * @return The header information.
  127951. */
  127952. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  127953. /**
  127954. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  127955. * This RGBE texture needs to store the information as a panorama.
  127956. *
  127957. * More information on this format are available here:
  127958. * https://en.wikipedia.org/wiki/RGBE_image_format
  127959. *
  127960. * @param buffer The binary file stored in an array buffer.
  127961. * @param size The expected size of the extracted cubemap.
  127962. * @return The Cube Map information.
  127963. */
  127964. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  127965. /**
  127966. * Returns the pixels data extracted from an RGBE texture.
  127967. * This pixels will be stored left to right up to down in the R G B order in one array.
  127968. *
  127969. * More information on this format are available here:
  127970. * https://en.wikipedia.org/wiki/RGBE_image_format
  127971. *
  127972. * @param uint8array The binary file stored in an array buffer.
  127973. * @param hdrInfo The header information of the file.
  127974. * @return The pixels data in RGB right to left up to down order.
  127975. */
  127976. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  127977. private static RGBE_ReadPixels_RLE;
  127978. }
  127979. }
  127980. declare module BABYLON {
  127981. /**
  127982. * This represents a texture coming from an HDR input.
  127983. *
  127984. * The only supported format is currently panorama picture stored in RGBE format.
  127985. * Example of such files can be found on HDRLib: http://hdrlib.com/
  127986. */
  127987. export class HDRCubeTexture extends BaseTexture {
  127988. private static _facesMapping;
  127989. private _generateHarmonics;
  127990. private _noMipmap;
  127991. private _textureMatrix;
  127992. private _size;
  127993. private _onLoad;
  127994. private _onError;
  127995. /**
  127996. * The texture URL.
  127997. */
  127998. url: string;
  127999. /**
  128000. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  128001. */
  128002. coordinatesMode: number;
  128003. protected _isBlocking: boolean;
  128004. /**
  128005. * Sets wether or not the texture is blocking during loading.
  128006. */
  128007. set isBlocking(value: boolean);
  128008. /**
  128009. * Gets wether or not the texture is blocking during loading.
  128010. */
  128011. get isBlocking(): boolean;
  128012. protected _rotationY: number;
  128013. /**
  128014. * Sets texture matrix rotation angle around Y axis in radians.
  128015. */
  128016. set rotationY(value: number);
  128017. /**
  128018. * Gets texture matrix rotation angle around Y axis radians.
  128019. */
  128020. get rotationY(): number;
  128021. /**
  128022. * Gets or sets the center of the bounding box associated with the cube texture
  128023. * It must define where the camera used to render the texture was set
  128024. */
  128025. boundingBoxPosition: Vector3;
  128026. private _boundingBoxSize;
  128027. /**
  128028. * Gets or sets the size of the bounding box associated with the cube texture
  128029. * When defined, the cubemap will switch to local mode
  128030. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  128031. * @example https://www.babylonjs-playground.com/#RNASML
  128032. */
  128033. set boundingBoxSize(value: Vector3);
  128034. get boundingBoxSize(): Vector3;
  128035. /**
  128036. * Instantiates an HDRTexture from the following parameters.
  128037. *
  128038. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  128039. * @param scene The scene the texture will be used in
  128040. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  128041. * @param noMipmap Forces to not generate the mipmap if true
  128042. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  128043. * @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)
  128044. * @param reserved Reserved flag for internal use.
  128045. */
  128046. 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>);
  128047. /**
  128048. * Get the current class name of the texture useful for serialization or dynamic coding.
  128049. * @returns "HDRCubeTexture"
  128050. */
  128051. getClassName(): string;
  128052. /**
  128053. * Occurs when the file is raw .hdr file.
  128054. */
  128055. private loadTexture;
  128056. clone(): HDRCubeTexture;
  128057. delayLoad(): void;
  128058. /**
  128059. * Get the texture reflection matrix used to rotate/transform the reflection.
  128060. * @returns the reflection matrix
  128061. */
  128062. getReflectionTextureMatrix(): Matrix;
  128063. /**
  128064. * Set the texture reflection matrix used to rotate/transform the reflection.
  128065. * @param value Define the reflection matrix to set
  128066. */
  128067. setReflectionTextureMatrix(value: Matrix): void;
  128068. /**
  128069. * Parses a JSON representation of an HDR Texture in order to create the texture
  128070. * @param parsedTexture Define the JSON representation
  128071. * @param scene Define the scene the texture should be created in
  128072. * @param rootUrl Define the root url in case we need to load relative dependencies
  128073. * @returns the newly created texture after parsing
  128074. */
  128075. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  128076. serialize(): any;
  128077. }
  128078. }
  128079. declare module BABYLON {
  128080. /**
  128081. * Class used to control physics engine
  128082. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  128083. */
  128084. export class PhysicsEngine implements IPhysicsEngine {
  128085. private _physicsPlugin;
  128086. /**
  128087. * Global value used to control the smallest number supported by the simulation
  128088. */
  128089. static Epsilon: number;
  128090. private _impostors;
  128091. private _joints;
  128092. private _subTimeStep;
  128093. /**
  128094. * Gets the gravity vector used by the simulation
  128095. */
  128096. gravity: Vector3;
  128097. /**
  128098. * Factory used to create the default physics plugin.
  128099. * @returns The default physics plugin
  128100. */
  128101. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  128102. /**
  128103. * Creates a new Physics Engine
  128104. * @param gravity defines the gravity vector used by the simulation
  128105. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  128106. */
  128107. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  128108. /**
  128109. * Sets the gravity vector used by the simulation
  128110. * @param gravity defines the gravity vector to use
  128111. */
  128112. setGravity(gravity: Vector3): void;
  128113. /**
  128114. * Set the time step of the physics engine.
  128115. * Default is 1/60.
  128116. * To slow it down, enter 1/600 for example.
  128117. * To speed it up, 1/30
  128118. * @param newTimeStep defines the new timestep to apply to this world.
  128119. */
  128120. setTimeStep(newTimeStep?: number): void;
  128121. /**
  128122. * Get the time step of the physics engine.
  128123. * @returns the current time step
  128124. */
  128125. getTimeStep(): number;
  128126. /**
  128127. * Set the sub time step of the physics engine.
  128128. * Default is 0 meaning there is no sub steps
  128129. * To increase physics resolution precision, set a small value (like 1 ms)
  128130. * @param subTimeStep defines the new sub timestep used for physics resolution.
  128131. */
  128132. setSubTimeStep(subTimeStep?: number): void;
  128133. /**
  128134. * Get the sub time step of the physics engine.
  128135. * @returns the current sub time step
  128136. */
  128137. getSubTimeStep(): number;
  128138. /**
  128139. * Release all resources
  128140. */
  128141. dispose(): void;
  128142. /**
  128143. * Gets the name of the current physics plugin
  128144. * @returns the name of the plugin
  128145. */
  128146. getPhysicsPluginName(): string;
  128147. /**
  128148. * Adding a new impostor for the impostor tracking.
  128149. * This will be done by the impostor itself.
  128150. * @param impostor the impostor to add
  128151. */
  128152. addImpostor(impostor: PhysicsImpostor): void;
  128153. /**
  128154. * Remove an impostor from the engine.
  128155. * This impostor and its mesh will not longer be updated by the physics engine.
  128156. * @param impostor the impostor to remove
  128157. */
  128158. removeImpostor(impostor: PhysicsImpostor): void;
  128159. /**
  128160. * Add a joint to the physics engine
  128161. * @param mainImpostor defines the main impostor to which the joint is added.
  128162. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  128163. * @param joint defines the joint that will connect both impostors.
  128164. */
  128165. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  128166. /**
  128167. * Removes a joint from the simulation
  128168. * @param mainImpostor defines the impostor used with the joint
  128169. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  128170. * @param joint defines the joint to remove
  128171. */
  128172. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  128173. /**
  128174. * Called by the scene. No need to call it.
  128175. * @param delta defines the timespam between frames
  128176. */
  128177. _step(delta: number): void;
  128178. /**
  128179. * Gets the current plugin used to run the simulation
  128180. * @returns current plugin
  128181. */
  128182. getPhysicsPlugin(): IPhysicsEnginePlugin;
  128183. /**
  128184. * Gets the list of physic impostors
  128185. * @returns an array of PhysicsImpostor
  128186. */
  128187. getImpostors(): Array<PhysicsImpostor>;
  128188. /**
  128189. * Gets the impostor for a physics enabled object
  128190. * @param object defines the object impersonated by the impostor
  128191. * @returns the PhysicsImpostor or null if not found
  128192. */
  128193. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  128194. /**
  128195. * Gets the impostor for a physics body object
  128196. * @param body defines physics body used by the impostor
  128197. * @returns the PhysicsImpostor or null if not found
  128198. */
  128199. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  128200. /**
  128201. * Does a raycast in the physics world
  128202. * @param from when should the ray start?
  128203. * @param to when should the ray end?
  128204. * @returns PhysicsRaycastResult
  128205. */
  128206. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128207. }
  128208. }
  128209. declare module BABYLON {
  128210. /** @hidden */
  128211. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  128212. private _useDeltaForWorldStep;
  128213. world: any;
  128214. name: string;
  128215. private _physicsMaterials;
  128216. private _fixedTimeStep;
  128217. private _cannonRaycastResult;
  128218. private _raycastResult;
  128219. private _physicsBodysToRemoveAfterStep;
  128220. BJSCANNON: any;
  128221. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  128222. setGravity(gravity: Vector3): void;
  128223. setTimeStep(timeStep: number): void;
  128224. getTimeStep(): number;
  128225. executeStep(delta: number): void;
  128226. private _removeMarkedPhysicsBodiesFromWorld;
  128227. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128228. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128229. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128230. private _processChildMeshes;
  128231. removePhysicsBody(impostor: PhysicsImpostor): void;
  128232. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128233. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128234. private _addMaterial;
  128235. private _checkWithEpsilon;
  128236. private _createShape;
  128237. private _createHeightmap;
  128238. private _minus90X;
  128239. private _plus90X;
  128240. private _tmpPosition;
  128241. private _tmpDeltaPosition;
  128242. private _tmpUnityRotation;
  128243. private _updatePhysicsBodyTransformation;
  128244. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128245. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128246. isSupported(): boolean;
  128247. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128248. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128249. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128250. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128251. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128252. getBodyMass(impostor: PhysicsImpostor): number;
  128253. getBodyFriction(impostor: PhysicsImpostor): number;
  128254. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128255. getBodyRestitution(impostor: PhysicsImpostor): number;
  128256. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128257. sleepBody(impostor: PhysicsImpostor): void;
  128258. wakeUpBody(impostor: PhysicsImpostor): void;
  128259. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  128260. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  128261. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  128262. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128263. getRadius(impostor: PhysicsImpostor): number;
  128264. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128265. dispose(): void;
  128266. private _extendNamespace;
  128267. /**
  128268. * Does a raycast in the physics world
  128269. * @param from when should the ray start?
  128270. * @param to when should the ray end?
  128271. * @returns PhysicsRaycastResult
  128272. */
  128273. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128274. }
  128275. }
  128276. declare module BABYLON {
  128277. /** @hidden */
  128278. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  128279. world: any;
  128280. name: string;
  128281. BJSOIMO: any;
  128282. private _raycastResult;
  128283. constructor(iterations?: number, oimoInjection?: any);
  128284. setGravity(gravity: Vector3): void;
  128285. setTimeStep(timeStep: number): void;
  128286. getTimeStep(): number;
  128287. private _tmpImpostorsArray;
  128288. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  128289. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128290. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128291. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128292. private _tmpPositionVector;
  128293. removePhysicsBody(impostor: PhysicsImpostor): void;
  128294. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128295. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128296. isSupported(): boolean;
  128297. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128298. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128299. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128300. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128301. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128302. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128303. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128304. getBodyMass(impostor: PhysicsImpostor): number;
  128305. getBodyFriction(impostor: PhysicsImpostor): number;
  128306. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128307. getBodyRestitution(impostor: PhysicsImpostor): number;
  128308. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128309. sleepBody(impostor: PhysicsImpostor): void;
  128310. wakeUpBody(impostor: PhysicsImpostor): void;
  128311. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  128312. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  128313. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  128314. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128315. getRadius(impostor: PhysicsImpostor): number;
  128316. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128317. dispose(): void;
  128318. /**
  128319. * Does a raycast in the physics world
  128320. * @param from when should the ray start?
  128321. * @param to when should the ray end?
  128322. * @returns PhysicsRaycastResult
  128323. */
  128324. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128325. }
  128326. }
  128327. declare module BABYLON {
  128328. /**
  128329. * Class containing static functions to help procedurally build meshes
  128330. */
  128331. export class RibbonBuilder {
  128332. /**
  128333. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  128334. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  128335. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  128336. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  128337. * * 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
  128338. * * 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
  128339. * * 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
  128340. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128341. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128342. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  128343. * * 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
  128344. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  128345. * * 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
  128346. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  128347. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128348. * @param name defines the name of the mesh
  128349. * @param options defines the options used to create the mesh
  128350. * @param scene defines the hosting scene
  128351. * @returns the ribbon mesh
  128352. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  128353. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128354. */
  128355. static CreateRibbon(name: string, options: {
  128356. pathArray: Vector3[][];
  128357. closeArray?: boolean;
  128358. closePath?: boolean;
  128359. offset?: number;
  128360. updatable?: boolean;
  128361. sideOrientation?: number;
  128362. frontUVs?: Vector4;
  128363. backUVs?: Vector4;
  128364. instance?: Mesh;
  128365. invertUV?: boolean;
  128366. uvs?: Vector2[];
  128367. colors?: Color4[];
  128368. }, scene?: Nullable<Scene>): Mesh;
  128369. }
  128370. }
  128371. declare module BABYLON {
  128372. /**
  128373. * Class containing static functions to help procedurally build meshes
  128374. */
  128375. export class ShapeBuilder {
  128376. /**
  128377. * 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.
  128378. * * 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.
  128379. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  128380. * * 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.
  128381. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  128382. * * 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
  128383. * * 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
  128384. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  128385. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128386. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128387. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  128388. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  128389. * @param name defines the name of the mesh
  128390. * @param options defines the options used to create the mesh
  128391. * @param scene defines the hosting scene
  128392. * @returns the extruded shape mesh
  128393. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128394. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  128395. */
  128396. static ExtrudeShape(name: string, options: {
  128397. shape: Vector3[];
  128398. path: Vector3[];
  128399. scale?: number;
  128400. rotation?: number;
  128401. cap?: number;
  128402. updatable?: boolean;
  128403. sideOrientation?: number;
  128404. frontUVs?: Vector4;
  128405. backUVs?: Vector4;
  128406. instance?: Mesh;
  128407. invertUV?: boolean;
  128408. }, scene?: Nullable<Scene>): Mesh;
  128409. /**
  128410. * Creates an custom extruded shape mesh.
  128411. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  128412. * * 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.
  128413. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  128414. * * 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
  128415. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  128416. * * 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
  128417. * * It must returns a float value that will be the scale value applied to the shape on each path point
  128418. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  128419. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  128420. * * 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
  128421. * * 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
  128422. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  128423. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128424. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128425. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  128426. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128427. * @param name defines the name of the mesh
  128428. * @param options defines the options used to create the mesh
  128429. * @param scene defines the hosting scene
  128430. * @returns the custom extruded shape mesh
  128431. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  128432. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128433. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  128434. */
  128435. static ExtrudeShapeCustom(name: string, options: {
  128436. shape: Vector3[];
  128437. path: Vector3[];
  128438. scaleFunction?: any;
  128439. rotationFunction?: any;
  128440. ribbonCloseArray?: boolean;
  128441. ribbonClosePath?: boolean;
  128442. cap?: number;
  128443. updatable?: boolean;
  128444. sideOrientation?: number;
  128445. frontUVs?: Vector4;
  128446. backUVs?: Vector4;
  128447. instance?: Mesh;
  128448. invertUV?: boolean;
  128449. }, scene?: Nullable<Scene>): Mesh;
  128450. private static _ExtrudeShapeGeneric;
  128451. }
  128452. }
  128453. declare module BABYLON {
  128454. /**
  128455. * AmmoJS Physics plugin
  128456. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  128457. * @see https://github.com/kripken/ammo.js/
  128458. */
  128459. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  128460. private _useDeltaForWorldStep;
  128461. /**
  128462. * Reference to the Ammo library
  128463. */
  128464. bjsAMMO: any;
  128465. /**
  128466. * Created ammoJS world which physics bodies are added to
  128467. */
  128468. world: any;
  128469. /**
  128470. * Name of the plugin
  128471. */
  128472. name: string;
  128473. private _timeStep;
  128474. private _fixedTimeStep;
  128475. private _maxSteps;
  128476. private _tmpQuaternion;
  128477. private _tmpAmmoTransform;
  128478. private _tmpAmmoQuaternion;
  128479. private _tmpAmmoConcreteContactResultCallback;
  128480. private _collisionConfiguration;
  128481. private _dispatcher;
  128482. private _overlappingPairCache;
  128483. private _solver;
  128484. private _softBodySolver;
  128485. private _tmpAmmoVectorA;
  128486. private _tmpAmmoVectorB;
  128487. private _tmpAmmoVectorC;
  128488. private _tmpAmmoVectorD;
  128489. private _tmpContactCallbackResult;
  128490. private _tmpAmmoVectorRCA;
  128491. private _tmpAmmoVectorRCB;
  128492. private _raycastResult;
  128493. private static readonly DISABLE_COLLISION_FLAG;
  128494. private static readonly KINEMATIC_FLAG;
  128495. private static readonly DISABLE_DEACTIVATION_FLAG;
  128496. /**
  128497. * Initializes the ammoJS plugin
  128498. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  128499. * @param ammoInjection can be used to inject your own ammo reference
  128500. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  128501. */
  128502. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  128503. /**
  128504. * Sets the gravity of the physics world (m/(s^2))
  128505. * @param gravity Gravity to set
  128506. */
  128507. setGravity(gravity: Vector3): void;
  128508. /**
  128509. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  128510. * @param timeStep timestep to use in seconds
  128511. */
  128512. setTimeStep(timeStep: number): void;
  128513. /**
  128514. * 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)
  128515. * @param fixedTimeStep fixedTimeStep to use in seconds
  128516. */
  128517. setFixedTimeStep(fixedTimeStep: number): void;
  128518. /**
  128519. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  128520. * @param maxSteps the maximum number of steps by the physics engine per frame
  128521. */
  128522. setMaxSteps(maxSteps: number): void;
  128523. /**
  128524. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  128525. * @returns the current timestep in seconds
  128526. */
  128527. getTimeStep(): number;
  128528. /**
  128529. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  128530. */
  128531. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  128532. private _isImpostorInContact;
  128533. private _isImpostorPairInContact;
  128534. private _stepSimulation;
  128535. /**
  128536. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  128537. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  128538. * After the step the babylon meshes are set to the position of the physics imposters
  128539. * @param delta amount of time to step forward
  128540. * @param impostors array of imposters to update before/after the step
  128541. */
  128542. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  128543. /**
  128544. * Update babylon mesh to match physics world object
  128545. * @param impostor imposter to match
  128546. */
  128547. private _afterSoftStep;
  128548. /**
  128549. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  128550. * @param impostor imposter to match
  128551. */
  128552. private _ropeStep;
  128553. /**
  128554. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  128555. * @param impostor imposter to match
  128556. */
  128557. private _softbodyOrClothStep;
  128558. private _tmpVector;
  128559. private _tmpMatrix;
  128560. /**
  128561. * Applies an impulse on the imposter
  128562. * @param impostor imposter to apply impulse to
  128563. * @param force amount of force to be applied to the imposter
  128564. * @param contactPoint the location to apply the impulse on the imposter
  128565. */
  128566. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128567. /**
  128568. * Applies a force on the imposter
  128569. * @param impostor imposter to apply force
  128570. * @param force amount of force to be applied to the imposter
  128571. * @param contactPoint the location to apply the force on the imposter
  128572. */
  128573. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128574. /**
  128575. * Creates a physics body using the plugin
  128576. * @param impostor the imposter to create the physics body on
  128577. */
  128578. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128579. /**
  128580. * Removes the physics body from the imposter and disposes of the body's memory
  128581. * @param impostor imposter to remove the physics body from
  128582. */
  128583. removePhysicsBody(impostor: PhysicsImpostor): void;
  128584. /**
  128585. * Generates a joint
  128586. * @param impostorJoint the imposter joint to create the joint with
  128587. */
  128588. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128589. /**
  128590. * Removes a joint
  128591. * @param impostorJoint the imposter joint to remove the joint from
  128592. */
  128593. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128594. private _addMeshVerts;
  128595. /**
  128596. * Initialise the soft body vertices to match its object's (mesh) vertices
  128597. * Softbody vertices (nodes) are in world space and to match this
  128598. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  128599. * @param impostor to create the softbody for
  128600. */
  128601. private _softVertexData;
  128602. /**
  128603. * Create an impostor's soft body
  128604. * @param impostor to create the softbody for
  128605. */
  128606. private _createSoftbody;
  128607. /**
  128608. * Create cloth for an impostor
  128609. * @param impostor to create the softbody for
  128610. */
  128611. private _createCloth;
  128612. /**
  128613. * Create rope for an impostor
  128614. * @param impostor to create the softbody for
  128615. */
  128616. private _createRope;
  128617. /**
  128618. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  128619. * @param impostor to create the custom physics shape for
  128620. */
  128621. private _createCustom;
  128622. private _addHullVerts;
  128623. private _createShape;
  128624. /**
  128625. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  128626. * @param impostor imposter containing the physics body and babylon object
  128627. */
  128628. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128629. /**
  128630. * Sets the babylon object's position/rotation from the physics body's position/rotation
  128631. * @param impostor imposter containing the physics body and babylon object
  128632. * @param newPosition new position
  128633. * @param newRotation new rotation
  128634. */
  128635. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128636. /**
  128637. * If this plugin is supported
  128638. * @returns true if its supported
  128639. */
  128640. isSupported(): boolean;
  128641. /**
  128642. * Sets the linear velocity of the physics body
  128643. * @param impostor imposter to set the velocity on
  128644. * @param velocity velocity to set
  128645. */
  128646. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128647. /**
  128648. * Sets the angular velocity of the physics body
  128649. * @param impostor imposter to set the velocity on
  128650. * @param velocity velocity to set
  128651. */
  128652. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128653. /**
  128654. * gets the linear velocity
  128655. * @param impostor imposter to get linear velocity from
  128656. * @returns linear velocity
  128657. */
  128658. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128659. /**
  128660. * gets the angular velocity
  128661. * @param impostor imposter to get angular velocity from
  128662. * @returns angular velocity
  128663. */
  128664. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128665. /**
  128666. * Sets the mass of physics body
  128667. * @param impostor imposter to set the mass on
  128668. * @param mass mass to set
  128669. */
  128670. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128671. /**
  128672. * Gets the mass of the physics body
  128673. * @param impostor imposter to get the mass from
  128674. * @returns mass
  128675. */
  128676. getBodyMass(impostor: PhysicsImpostor): number;
  128677. /**
  128678. * Gets friction of the impostor
  128679. * @param impostor impostor to get friction from
  128680. * @returns friction value
  128681. */
  128682. getBodyFriction(impostor: PhysicsImpostor): number;
  128683. /**
  128684. * Sets friction of the impostor
  128685. * @param impostor impostor to set friction on
  128686. * @param friction friction value
  128687. */
  128688. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128689. /**
  128690. * Gets restitution of the impostor
  128691. * @param impostor impostor to get restitution from
  128692. * @returns restitution value
  128693. */
  128694. getBodyRestitution(impostor: PhysicsImpostor): number;
  128695. /**
  128696. * Sets resitution of the impostor
  128697. * @param impostor impostor to set resitution on
  128698. * @param restitution resitution value
  128699. */
  128700. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128701. /**
  128702. * Gets pressure inside the impostor
  128703. * @param impostor impostor to get pressure from
  128704. * @returns pressure value
  128705. */
  128706. getBodyPressure(impostor: PhysicsImpostor): number;
  128707. /**
  128708. * Sets pressure inside a soft body impostor
  128709. * Cloth and rope must remain 0 pressure
  128710. * @param impostor impostor to set pressure on
  128711. * @param pressure pressure value
  128712. */
  128713. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  128714. /**
  128715. * Gets stiffness of the impostor
  128716. * @param impostor impostor to get stiffness from
  128717. * @returns pressure value
  128718. */
  128719. getBodyStiffness(impostor: PhysicsImpostor): number;
  128720. /**
  128721. * Sets stiffness of the impostor
  128722. * @param impostor impostor to set stiffness on
  128723. * @param stiffness stiffness value from 0 to 1
  128724. */
  128725. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  128726. /**
  128727. * Gets velocityIterations of the impostor
  128728. * @param impostor impostor to get velocity iterations from
  128729. * @returns velocityIterations value
  128730. */
  128731. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  128732. /**
  128733. * Sets velocityIterations of the impostor
  128734. * @param impostor impostor to set velocity iterations on
  128735. * @param velocityIterations velocityIterations value
  128736. */
  128737. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  128738. /**
  128739. * Gets positionIterations of the impostor
  128740. * @param impostor impostor to get position iterations from
  128741. * @returns positionIterations value
  128742. */
  128743. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  128744. /**
  128745. * Sets positionIterations of the impostor
  128746. * @param impostor impostor to set position on
  128747. * @param positionIterations positionIterations value
  128748. */
  128749. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  128750. /**
  128751. * Append an anchor to a cloth object
  128752. * @param impostor is the cloth impostor to add anchor to
  128753. * @param otherImpostor is the rigid impostor to anchor to
  128754. * @param width ratio across width from 0 to 1
  128755. * @param height ratio up height from 0 to 1
  128756. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  128757. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  128758. */
  128759. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  128760. /**
  128761. * Append an hook to a rope object
  128762. * @param impostor is the rope impostor to add hook to
  128763. * @param otherImpostor is the rigid impostor to hook to
  128764. * @param length ratio along the rope from 0 to 1
  128765. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  128766. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  128767. */
  128768. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  128769. /**
  128770. * Sleeps the physics body and stops it from being active
  128771. * @param impostor impostor to sleep
  128772. */
  128773. sleepBody(impostor: PhysicsImpostor): void;
  128774. /**
  128775. * Activates the physics body
  128776. * @param impostor impostor to activate
  128777. */
  128778. wakeUpBody(impostor: PhysicsImpostor): void;
  128779. /**
  128780. * Updates the distance parameters of the joint
  128781. * @param joint joint to update
  128782. * @param maxDistance maximum distance of the joint
  128783. * @param minDistance minimum distance of the joint
  128784. */
  128785. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  128786. /**
  128787. * Sets a motor on the joint
  128788. * @param joint joint to set motor on
  128789. * @param speed speed of the motor
  128790. * @param maxForce maximum force of the motor
  128791. * @param motorIndex index of the motor
  128792. */
  128793. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  128794. /**
  128795. * Sets the motors limit
  128796. * @param joint joint to set limit on
  128797. * @param upperLimit upper limit
  128798. * @param lowerLimit lower limit
  128799. */
  128800. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  128801. /**
  128802. * Syncs the position and rotation of a mesh with the impostor
  128803. * @param mesh mesh to sync
  128804. * @param impostor impostor to update the mesh with
  128805. */
  128806. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128807. /**
  128808. * Gets the radius of the impostor
  128809. * @param impostor impostor to get radius from
  128810. * @returns the radius
  128811. */
  128812. getRadius(impostor: PhysicsImpostor): number;
  128813. /**
  128814. * Gets the box size of the impostor
  128815. * @param impostor impostor to get box size from
  128816. * @param result the resulting box size
  128817. */
  128818. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128819. /**
  128820. * Disposes of the impostor
  128821. */
  128822. dispose(): void;
  128823. /**
  128824. * Does a raycast in the physics world
  128825. * @param from when should the ray start?
  128826. * @param to when should the ray end?
  128827. * @returns PhysicsRaycastResult
  128828. */
  128829. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128830. }
  128831. }
  128832. declare module BABYLON {
  128833. interface AbstractScene {
  128834. /**
  128835. * The list of reflection probes added to the scene
  128836. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  128837. */
  128838. reflectionProbes: Array<ReflectionProbe>;
  128839. /**
  128840. * Removes the given reflection probe from this scene.
  128841. * @param toRemove The reflection probe to remove
  128842. * @returns The index of the removed reflection probe
  128843. */
  128844. removeReflectionProbe(toRemove: ReflectionProbe): number;
  128845. /**
  128846. * Adds the given reflection probe to this scene.
  128847. * @param newReflectionProbe The reflection probe to add
  128848. */
  128849. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  128850. }
  128851. /**
  128852. * Class used to generate realtime reflection / refraction cube textures
  128853. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  128854. */
  128855. export class ReflectionProbe {
  128856. /** defines the name of the probe */
  128857. name: string;
  128858. private _scene;
  128859. private _renderTargetTexture;
  128860. private _projectionMatrix;
  128861. private _viewMatrix;
  128862. private _target;
  128863. private _add;
  128864. private _attachedMesh;
  128865. private _invertYAxis;
  128866. /** Gets or sets probe position (center of the cube map) */
  128867. position: Vector3;
  128868. /**
  128869. * Creates a new reflection probe
  128870. * @param name defines the name of the probe
  128871. * @param size defines the texture resolution (for each face)
  128872. * @param scene defines the hosting scene
  128873. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  128874. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  128875. */
  128876. constructor(
  128877. /** defines the name of the probe */
  128878. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  128879. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  128880. get samples(): number;
  128881. set samples(value: number);
  128882. /** Gets or sets the refresh rate to use (on every frame by default) */
  128883. get refreshRate(): number;
  128884. set refreshRate(value: number);
  128885. /**
  128886. * Gets the hosting scene
  128887. * @returns a Scene
  128888. */
  128889. getScene(): Scene;
  128890. /** Gets the internal CubeTexture used to render to */
  128891. get cubeTexture(): RenderTargetTexture;
  128892. /** Gets the list of meshes to render */
  128893. get renderList(): Nullable<AbstractMesh[]>;
  128894. /**
  128895. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  128896. * @param mesh defines the mesh to attach to
  128897. */
  128898. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  128899. /**
  128900. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  128901. * @param renderingGroupId The rendering group id corresponding to its index
  128902. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  128903. */
  128904. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  128905. /**
  128906. * Clean all associated resources
  128907. */
  128908. dispose(): void;
  128909. /**
  128910. * Converts the reflection probe information to a readable string for debug purpose.
  128911. * @param fullDetails Supports for multiple levels of logging within scene loading
  128912. * @returns the human readable reflection probe info
  128913. */
  128914. toString(fullDetails?: boolean): string;
  128915. /**
  128916. * Get the class name of the relfection probe.
  128917. * @returns "ReflectionProbe"
  128918. */
  128919. getClassName(): string;
  128920. /**
  128921. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  128922. * @returns The JSON representation of the texture
  128923. */
  128924. serialize(): any;
  128925. /**
  128926. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  128927. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  128928. * @param scene Define the scene the parsed reflection probe should be instantiated in
  128929. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  128930. * @returns The parsed reflection probe if successful
  128931. */
  128932. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  128933. }
  128934. }
  128935. declare module BABYLON {
  128936. /** @hidden */
  128937. export var _BabylonLoaderRegistered: boolean;
  128938. /**
  128939. * Helps setting up some configuration for the babylon file loader.
  128940. */
  128941. export class BabylonFileLoaderConfiguration {
  128942. /**
  128943. * The loader does not allow injecting custom physix engine into the plugins.
  128944. * Unfortunately in ES6, we need to manually inject them into the plugin.
  128945. * So you could set this variable to your engine import to make it work.
  128946. */
  128947. static LoaderInjectedPhysicsEngine: any;
  128948. }
  128949. }
  128950. declare module BABYLON {
  128951. /**
  128952. * The Physically based simple base material of BJS.
  128953. *
  128954. * This enables better naming and convention enforcements on top of the pbrMaterial.
  128955. * It is used as the base class for both the specGloss and metalRough conventions.
  128956. */
  128957. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  128958. /**
  128959. * Number of Simultaneous lights allowed on the material.
  128960. */
  128961. maxSimultaneousLights: number;
  128962. /**
  128963. * If sets to true, disables all the lights affecting the material.
  128964. */
  128965. disableLighting: boolean;
  128966. /**
  128967. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  128968. */
  128969. environmentTexture: BaseTexture;
  128970. /**
  128971. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  128972. */
  128973. invertNormalMapX: boolean;
  128974. /**
  128975. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  128976. */
  128977. invertNormalMapY: boolean;
  128978. /**
  128979. * Normal map used in the model.
  128980. */
  128981. normalTexture: BaseTexture;
  128982. /**
  128983. * Emissivie color used to self-illuminate the model.
  128984. */
  128985. emissiveColor: Color3;
  128986. /**
  128987. * Emissivie texture used to self-illuminate the model.
  128988. */
  128989. emissiveTexture: BaseTexture;
  128990. /**
  128991. * Occlusion Channel Strenght.
  128992. */
  128993. occlusionStrength: number;
  128994. /**
  128995. * Occlusion Texture of the material (adding extra occlusion effects).
  128996. */
  128997. occlusionTexture: BaseTexture;
  128998. /**
  128999. * Defines the alpha limits in alpha test mode.
  129000. */
  129001. alphaCutOff: number;
  129002. /**
  129003. * Gets the current double sided mode.
  129004. */
  129005. get doubleSided(): boolean;
  129006. /**
  129007. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  129008. */
  129009. set doubleSided(value: boolean);
  129010. /**
  129011. * Stores the pre-calculated light information of a mesh in a texture.
  129012. */
  129013. lightmapTexture: BaseTexture;
  129014. /**
  129015. * If true, the light map contains occlusion information instead of lighting info.
  129016. */
  129017. useLightmapAsShadowmap: boolean;
  129018. /**
  129019. * Instantiates a new PBRMaterial instance.
  129020. *
  129021. * @param name The material name
  129022. * @param scene The scene the material will be use in.
  129023. */
  129024. constructor(name: string, scene: Scene);
  129025. getClassName(): string;
  129026. }
  129027. }
  129028. declare module BABYLON {
  129029. /**
  129030. * The PBR material of BJS following the metal roughness convention.
  129031. *
  129032. * This fits to the PBR convention in the GLTF definition:
  129033. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  129034. */
  129035. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  129036. /**
  129037. * The base color has two different interpretations depending on the value of metalness.
  129038. * When the material is a metal, the base color is the specific measured reflectance value
  129039. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  129040. * of the material.
  129041. */
  129042. baseColor: Color3;
  129043. /**
  129044. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  129045. * well as opacity information in the alpha channel.
  129046. */
  129047. baseTexture: BaseTexture;
  129048. /**
  129049. * Specifies the metallic scalar value of the material.
  129050. * Can also be used to scale the metalness values of the metallic texture.
  129051. */
  129052. metallic: number;
  129053. /**
  129054. * Specifies the roughness scalar value of the material.
  129055. * Can also be used to scale the roughness values of the metallic texture.
  129056. */
  129057. roughness: number;
  129058. /**
  129059. * Texture containing both the metallic value in the B channel and the
  129060. * roughness value in the G channel to keep better precision.
  129061. */
  129062. metallicRoughnessTexture: BaseTexture;
  129063. /**
  129064. * Instantiates a new PBRMetalRoughnessMaterial instance.
  129065. *
  129066. * @param name The material name
  129067. * @param scene The scene the material will be use in.
  129068. */
  129069. constructor(name: string, scene: Scene);
  129070. /**
  129071. * Return the currrent class name of the material.
  129072. */
  129073. getClassName(): string;
  129074. /**
  129075. * Makes a duplicate of the current material.
  129076. * @param name - name to use for the new material.
  129077. */
  129078. clone(name: string): PBRMetallicRoughnessMaterial;
  129079. /**
  129080. * Serialize the material to a parsable JSON object.
  129081. */
  129082. serialize(): any;
  129083. /**
  129084. * Parses a JSON object correponding to the serialize function.
  129085. */
  129086. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  129087. }
  129088. }
  129089. declare module BABYLON {
  129090. /**
  129091. * The PBR material of BJS following the specular glossiness convention.
  129092. *
  129093. * This fits to the PBR convention in the GLTF definition:
  129094. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  129095. */
  129096. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  129097. /**
  129098. * Specifies the diffuse color of the material.
  129099. */
  129100. diffuseColor: Color3;
  129101. /**
  129102. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  129103. * channel.
  129104. */
  129105. diffuseTexture: BaseTexture;
  129106. /**
  129107. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  129108. */
  129109. specularColor: Color3;
  129110. /**
  129111. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  129112. */
  129113. glossiness: number;
  129114. /**
  129115. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  129116. */
  129117. specularGlossinessTexture: BaseTexture;
  129118. /**
  129119. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  129120. *
  129121. * @param name The material name
  129122. * @param scene The scene the material will be use in.
  129123. */
  129124. constructor(name: string, scene: Scene);
  129125. /**
  129126. * Return the currrent class name of the material.
  129127. */
  129128. getClassName(): string;
  129129. /**
  129130. * Makes a duplicate of the current material.
  129131. * @param name - name to use for the new material.
  129132. */
  129133. clone(name: string): PBRSpecularGlossinessMaterial;
  129134. /**
  129135. * Serialize the material to a parsable JSON object.
  129136. */
  129137. serialize(): any;
  129138. /**
  129139. * Parses a JSON object correponding to the serialize function.
  129140. */
  129141. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  129142. }
  129143. }
  129144. declare module BABYLON {
  129145. /**
  129146. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  129147. * It can help converting any input color in a desired output one. This can then be used to create effects
  129148. * from sepia, black and white to sixties or futuristic rendering...
  129149. *
  129150. * The only supported format is currently 3dl.
  129151. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  129152. */
  129153. export class ColorGradingTexture extends BaseTexture {
  129154. /**
  129155. * The current texture matrix. (will always be identity in color grading texture)
  129156. */
  129157. private _textureMatrix;
  129158. /**
  129159. * The texture URL.
  129160. */
  129161. url: string;
  129162. /**
  129163. * Empty line regex stored for GC.
  129164. */
  129165. private static _noneEmptyLineRegex;
  129166. private _engine;
  129167. /**
  129168. * Instantiates a ColorGradingTexture from the following parameters.
  129169. *
  129170. * @param url The location of the color gradind data (currently only supporting 3dl)
  129171. * @param scene The scene the texture will be used in
  129172. */
  129173. constructor(url: string, scene: Scene);
  129174. /**
  129175. * Returns the texture matrix used in most of the material.
  129176. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  129177. */
  129178. getTextureMatrix(): Matrix;
  129179. /**
  129180. * Occurs when the file being loaded is a .3dl LUT file.
  129181. */
  129182. private load3dlTexture;
  129183. /**
  129184. * Starts the loading process of the texture.
  129185. */
  129186. private loadTexture;
  129187. /**
  129188. * Clones the color gradind texture.
  129189. */
  129190. clone(): ColorGradingTexture;
  129191. /**
  129192. * Called during delayed load for textures.
  129193. */
  129194. delayLoad(): void;
  129195. /**
  129196. * Parses a color grading texture serialized by Babylon.
  129197. * @param parsedTexture The texture information being parsedTexture
  129198. * @param scene The scene to load the texture in
  129199. * @param rootUrl The root url of the data assets to load
  129200. * @return A color gradind texture
  129201. */
  129202. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  129203. /**
  129204. * Serializes the LUT texture to json format.
  129205. */
  129206. serialize(): any;
  129207. }
  129208. }
  129209. declare module BABYLON {
  129210. /**
  129211. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  129212. */
  129213. export class EquiRectangularCubeTexture extends BaseTexture {
  129214. /** The six faces of the cube. */
  129215. private static _FacesMapping;
  129216. private _noMipmap;
  129217. private _onLoad;
  129218. private _onError;
  129219. /** The size of the cubemap. */
  129220. private _size;
  129221. /** The buffer of the image. */
  129222. private _buffer;
  129223. /** The width of the input image. */
  129224. private _width;
  129225. /** The height of the input image. */
  129226. private _height;
  129227. /** The URL to the image. */
  129228. url: string;
  129229. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  129230. coordinatesMode: number;
  129231. /**
  129232. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  129233. * @param url The location of the image
  129234. * @param scene The scene the texture will be used in
  129235. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  129236. * @param noMipmap Forces to not generate the mipmap if true
  129237. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  129238. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  129239. * @param onLoad — defines a callback called when texture is loaded
  129240. * @param onError — defines a callback called if there is an error
  129241. */
  129242. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  129243. /**
  129244. * Load the image data, by putting the image on a canvas and extracting its buffer.
  129245. */
  129246. private loadImage;
  129247. /**
  129248. * Convert the image buffer into a cubemap and create a CubeTexture.
  129249. */
  129250. private loadTexture;
  129251. /**
  129252. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  129253. * @param buffer The ArrayBuffer that should be converted.
  129254. * @returns The buffer as Float32Array.
  129255. */
  129256. private getFloat32ArrayFromArrayBuffer;
  129257. /**
  129258. * Get the current class name of the texture useful for serialization or dynamic coding.
  129259. * @returns "EquiRectangularCubeTexture"
  129260. */
  129261. getClassName(): string;
  129262. /**
  129263. * Create a clone of the current EquiRectangularCubeTexture and return it.
  129264. * @returns A clone of the current EquiRectangularCubeTexture.
  129265. */
  129266. clone(): EquiRectangularCubeTexture;
  129267. }
  129268. }
  129269. declare module BABYLON {
  129270. /**
  129271. * Based on jsTGALoader - Javascript loader for TGA file
  129272. * By Vincent Thibault
  129273. * @see http://blog.robrowser.com/javascript-tga-loader.html
  129274. */
  129275. export class TGATools {
  129276. private static _TYPE_INDEXED;
  129277. private static _TYPE_RGB;
  129278. private static _TYPE_GREY;
  129279. private static _TYPE_RLE_INDEXED;
  129280. private static _TYPE_RLE_RGB;
  129281. private static _TYPE_RLE_GREY;
  129282. private static _ORIGIN_MASK;
  129283. private static _ORIGIN_SHIFT;
  129284. private static _ORIGIN_BL;
  129285. private static _ORIGIN_BR;
  129286. private static _ORIGIN_UL;
  129287. private static _ORIGIN_UR;
  129288. /**
  129289. * Gets the header of a TGA file
  129290. * @param data defines the TGA data
  129291. * @returns the header
  129292. */
  129293. static GetTGAHeader(data: Uint8Array): any;
  129294. /**
  129295. * Uploads TGA content to a Babylon Texture
  129296. * @hidden
  129297. */
  129298. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  129299. /** @hidden */
  129300. 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;
  129301. /** @hidden */
  129302. 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;
  129303. /** @hidden */
  129304. 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;
  129305. /** @hidden */
  129306. 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;
  129307. /** @hidden */
  129308. 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;
  129309. /** @hidden */
  129310. 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;
  129311. }
  129312. }
  129313. declare module BABYLON {
  129314. /**
  129315. * Implementation of the TGA Texture Loader.
  129316. * @hidden
  129317. */
  129318. export class _TGATextureLoader implements IInternalTextureLoader {
  129319. /**
  129320. * Defines wether the loader supports cascade loading the different faces.
  129321. */
  129322. readonly supportCascades: boolean;
  129323. /**
  129324. * This returns if the loader support the current file information.
  129325. * @param extension defines the file extension of the file being loaded
  129326. * @param textureFormatInUse defines the current compressed format in use iun the engine
  129327. * @param fallback defines the fallback internal texture if any
  129328. * @param isBase64 defines whether the texture is encoded as a base64
  129329. * @param isBuffer defines whether the texture data are stored as a buffer
  129330. * @returns true if the loader can load the specified file
  129331. */
  129332. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  129333. /**
  129334. * Transform the url before loading if required.
  129335. * @param rootUrl the url of the texture
  129336. * @param textureFormatInUse defines the current compressed format in use iun the engine
  129337. * @returns the transformed texture
  129338. */
  129339. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  129340. /**
  129341. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  129342. * @param rootUrl the url of the texture
  129343. * @param textureFormatInUse defines the current compressed format in use iun the engine
  129344. * @returns the fallback texture
  129345. */
  129346. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  129347. /**
  129348. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  129349. * @param data contains the texture data
  129350. * @param texture defines the BabylonJS internal texture
  129351. * @param createPolynomials will be true if polynomials have been requested
  129352. * @param onLoad defines the callback to trigger once the texture is ready
  129353. * @param onError defines the callback to trigger in case of error
  129354. */
  129355. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  129356. /**
  129357. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  129358. * @param data contains the texture data
  129359. * @param texture defines the BabylonJS internal texture
  129360. * @param callback defines the method to call once ready to upload
  129361. */
  129362. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  129363. }
  129364. }
  129365. declare module BABYLON {
  129366. /**
  129367. * Info about the .basis files
  129368. */
  129369. class BasisFileInfo {
  129370. /**
  129371. * If the file has alpha
  129372. */
  129373. hasAlpha: boolean;
  129374. /**
  129375. * Info about each image of the basis file
  129376. */
  129377. images: Array<{
  129378. levels: Array<{
  129379. width: number;
  129380. height: number;
  129381. transcodedPixels: ArrayBufferView;
  129382. }>;
  129383. }>;
  129384. }
  129385. /**
  129386. * Result of transcoding a basis file
  129387. */
  129388. class TranscodeResult {
  129389. /**
  129390. * Info about the .basis file
  129391. */
  129392. fileInfo: BasisFileInfo;
  129393. /**
  129394. * Format to use when loading the file
  129395. */
  129396. format: number;
  129397. }
  129398. /**
  129399. * Configuration options for the Basis transcoder
  129400. */
  129401. export class BasisTranscodeConfiguration {
  129402. /**
  129403. * Supported compression formats used to determine the supported output format of the transcoder
  129404. */
  129405. supportedCompressionFormats?: {
  129406. /**
  129407. * etc1 compression format
  129408. */
  129409. etc1?: boolean;
  129410. /**
  129411. * s3tc compression format
  129412. */
  129413. s3tc?: boolean;
  129414. /**
  129415. * pvrtc compression format
  129416. */
  129417. pvrtc?: boolean;
  129418. /**
  129419. * etc2 compression format
  129420. */
  129421. etc2?: boolean;
  129422. };
  129423. /**
  129424. * If mipmap levels should be loaded for transcoded images (Default: true)
  129425. */
  129426. loadMipmapLevels?: boolean;
  129427. /**
  129428. * Index of a single image to load (Default: all images)
  129429. */
  129430. loadSingleImage?: number;
  129431. }
  129432. /**
  129433. * Used to load .Basis files
  129434. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  129435. */
  129436. export class BasisTools {
  129437. private static _IgnoreSupportedFormats;
  129438. /**
  129439. * URL to use when loading the basis transcoder
  129440. */
  129441. static JSModuleURL: string;
  129442. /**
  129443. * URL to use when loading the wasm module for the transcoder
  129444. */
  129445. static WasmModuleURL: string;
  129446. /**
  129447. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  129448. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  129449. * @returns internal format corresponding to the Basis format
  129450. */
  129451. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  129452. private static _WorkerPromise;
  129453. private static _Worker;
  129454. private static _actionId;
  129455. private static _CreateWorkerAsync;
  129456. /**
  129457. * Transcodes a loaded image file to compressed pixel data
  129458. * @param data image data to transcode
  129459. * @param config configuration options for the transcoding
  129460. * @returns a promise resulting in the transcoded image
  129461. */
  129462. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  129463. /**
  129464. * Loads a texture from the transcode result
  129465. * @param texture texture load to
  129466. * @param transcodeResult the result of transcoding the basis file to load from
  129467. */
  129468. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  129469. }
  129470. }
  129471. declare module BABYLON {
  129472. /**
  129473. * Loader for .basis file format
  129474. */
  129475. export class _BasisTextureLoader implements IInternalTextureLoader {
  129476. /**
  129477. * Defines whether the loader supports cascade loading the different faces.
  129478. */
  129479. readonly supportCascades: boolean;
  129480. /**
  129481. * This returns if the loader support the current file information.
  129482. * @param extension defines the file extension of the file being loaded
  129483. * @param textureFormatInUse defines the current compressed format in use iun the engine
  129484. * @param fallback defines the fallback internal texture if any
  129485. * @param isBase64 defines whether the texture is encoded as a base64
  129486. * @param isBuffer defines whether the texture data are stored as a buffer
  129487. * @returns true if the loader can load the specified file
  129488. */
  129489. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  129490. /**
  129491. * Transform the url before loading if required.
  129492. * @param rootUrl the url of the texture
  129493. * @param textureFormatInUse defines the current compressed format in use iun the engine
  129494. * @returns the transformed texture
  129495. */
  129496. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  129497. /**
  129498. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  129499. * @param rootUrl the url of the texture
  129500. * @param textureFormatInUse defines the current compressed format in use iun the engine
  129501. * @returns the fallback texture
  129502. */
  129503. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  129504. /**
  129505. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  129506. * @param data contains the texture data
  129507. * @param texture defines the BabylonJS internal texture
  129508. * @param createPolynomials will be true if polynomials have been requested
  129509. * @param onLoad defines the callback to trigger once the texture is ready
  129510. * @param onError defines the callback to trigger in case of error
  129511. */
  129512. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  129513. /**
  129514. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  129515. * @param data contains the texture data
  129516. * @param texture defines the BabylonJS internal texture
  129517. * @param callback defines the method to call once ready to upload
  129518. */
  129519. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  129520. }
  129521. }
  129522. declare module BABYLON {
  129523. /**
  129524. * 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.
  129525. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  129526. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  129527. */
  129528. export class CustomProceduralTexture extends ProceduralTexture {
  129529. private _animate;
  129530. private _time;
  129531. private _config;
  129532. private _texturePath;
  129533. /**
  129534. * Instantiates a new Custom Procedural Texture.
  129535. * 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.
  129536. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  129537. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  129538. * @param name Define the name of the texture
  129539. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  129540. * @param size Define the size of the texture to create
  129541. * @param scene Define the scene the texture belongs to
  129542. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  129543. * @param generateMipMaps Define if the texture should creates mip maps or not
  129544. */
  129545. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  129546. private _loadJson;
  129547. /**
  129548. * Is the texture ready to be used ? (rendered at least once)
  129549. * @returns true if ready, otherwise, false.
  129550. */
  129551. isReady(): boolean;
  129552. /**
  129553. * Render the texture to its associated render target.
  129554. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  129555. */
  129556. render(useCameraPostProcess?: boolean): void;
  129557. /**
  129558. * Update the list of dependant textures samplers in the shader.
  129559. */
  129560. updateTextures(): void;
  129561. /**
  129562. * Update the uniform values of the procedural texture in the shader.
  129563. */
  129564. updateShaderUniforms(): void;
  129565. /**
  129566. * Define if the texture animates or not.
  129567. */
  129568. get animate(): boolean;
  129569. set animate(value: boolean);
  129570. }
  129571. }
  129572. declare module BABYLON {
  129573. /** @hidden */
  129574. export var noisePixelShader: {
  129575. name: string;
  129576. shader: string;
  129577. };
  129578. }
  129579. declare module BABYLON {
  129580. /**
  129581. * Class used to generate noise procedural textures
  129582. */
  129583. export class NoiseProceduralTexture extends ProceduralTexture {
  129584. private _time;
  129585. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  129586. brightness: number;
  129587. /** Defines the number of octaves to process */
  129588. octaves: number;
  129589. /** Defines the level of persistence (0.8 by default) */
  129590. persistence: number;
  129591. /** Gets or sets animation speed factor (default is 1) */
  129592. animationSpeedFactor: number;
  129593. /**
  129594. * Creates a new NoiseProceduralTexture
  129595. * @param name defines the name fo the texture
  129596. * @param size defines the size of the texture (default is 256)
  129597. * @param scene defines the hosting scene
  129598. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  129599. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  129600. */
  129601. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  129602. private _updateShaderUniforms;
  129603. protected _getDefines(): string;
  129604. /** Generate the current state of the procedural texture */
  129605. render(useCameraPostProcess?: boolean): void;
  129606. /**
  129607. * Serializes this noise procedural texture
  129608. * @returns a serialized noise procedural texture object
  129609. */
  129610. serialize(): any;
  129611. /**
  129612. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  129613. * @param parsedTexture defines parsed texture data
  129614. * @param scene defines the current scene
  129615. * @param rootUrl defines the root URL containing noise procedural texture information
  129616. * @returns a parsed NoiseProceduralTexture
  129617. */
  129618. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  129619. }
  129620. }
  129621. declare module BABYLON {
  129622. /**
  129623. * Raw cube texture where the raw buffers are passed in
  129624. */
  129625. export class RawCubeTexture extends CubeTexture {
  129626. /**
  129627. * Creates a cube texture where the raw buffers are passed in.
  129628. * @param scene defines the scene the texture is attached to
  129629. * @param data defines the array of data to use to create each face
  129630. * @param size defines the size of the textures
  129631. * @param format defines the format of the data
  129632. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  129633. * @param generateMipMaps defines if the engine should generate the mip levels
  129634. * @param invertY defines if data must be stored with Y axis inverted
  129635. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  129636. * @param compression defines the compression used (null by default)
  129637. */
  129638. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  129639. /**
  129640. * Updates the raw cube texture.
  129641. * @param data defines the data to store
  129642. * @param format defines the data format
  129643. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  129644. * @param invertY defines if data must be stored with Y axis inverted
  129645. * @param compression defines the compression used (null by default)
  129646. * @param level defines which level of the texture to update
  129647. */
  129648. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  129649. /**
  129650. * Updates a raw cube texture with RGBD encoded data.
  129651. * @param data defines the array of data [mipmap][face] to use to create each face
  129652. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  129653. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  129654. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  129655. * @returns a promsie that resolves when the operation is complete
  129656. */
  129657. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  129658. /**
  129659. * Clones the raw cube texture.
  129660. * @return a new cube texture
  129661. */
  129662. clone(): CubeTexture;
  129663. /** @hidden */
  129664. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  129665. }
  129666. }
  129667. declare module BABYLON {
  129668. /**
  129669. * Class used to store 3D textures containing user data
  129670. */
  129671. export class RawTexture3D extends Texture {
  129672. /** Gets or sets the texture format to use */
  129673. format: number;
  129674. private _engine;
  129675. /**
  129676. * Create a new RawTexture3D
  129677. * @param data defines the data of the texture
  129678. * @param width defines the width of the texture
  129679. * @param height defines the height of the texture
  129680. * @param depth defines the depth of the texture
  129681. * @param format defines the texture format to use
  129682. * @param scene defines the hosting scene
  129683. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  129684. * @param invertY defines if texture must be stored with Y axis inverted
  129685. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129686. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  129687. */
  129688. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  129689. /** Gets or sets the texture format to use */
  129690. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  129691. /**
  129692. * Update the texture with new data
  129693. * @param data defines the data to store in the texture
  129694. */
  129695. update(data: ArrayBufferView): void;
  129696. }
  129697. }
  129698. declare module BABYLON {
  129699. /**
  129700. * Class used to store 2D array textures containing user data
  129701. */
  129702. export class RawTexture2DArray extends Texture {
  129703. /** Gets or sets the texture format to use */
  129704. format: number;
  129705. private _engine;
  129706. /**
  129707. * Create a new RawTexture2DArray
  129708. * @param data defines the data of the texture
  129709. * @param width defines the width of the texture
  129710. * @param height defines the height of the texture
  129711. * @param depth defines the number of layers of the texture
  129712. * @param format defines the texture format to use
  129713. * @param scene defines the hosting scene
  129714. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  129715. * @param invertY defines if texture must be stored with Y axis inverted
  129716. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129717. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  129718. */
  129719. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  129720. /** Gets or sets the texture format to use */
  129721. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  129722. /**
  129723. * Update the texture with new data
  129724. * @param data defines the data to store in the texture
  129725. */
  129726. update(data: ArrayBufferView): void;
  129727. }
  129728. }
  129729. declare module BABYLON {
  129730. /**
  129731. * Creates a refraction texture used by refraction channel of the standard material.
  129732. * It is like a mirror but to see through a material.
  129733. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129734. */
  129735. export class RefractionTexture extends RenderTargetTexture {
  129736. /**
  129737. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  129738. * 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.
  129739. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129740. */
  129741. refractionPlane: Plane;
  129742. /**
  129743. * Define how deep under the surface we should see.
  129744. */
  129745. depth: number;
  129746. /**
  129747. * Creates a refraction texture used by refraction channel of the standard material.
  129748. * It is like a mirror but to see through a material.
  129749. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129750. * @param name Define the texture name
  129751. * @param size Define the size of the underlying texture
  129752. * @param scene Define the scene the refraction belongs to
  129753. * @param generateMipMaps Define if we need to generate mips level for the refraction
  129754. */
  129755. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  129756. /**
  129757. * Clone the refraction texture.
  129758. * @returns the cloned texture
  129759. */
  129760. clone(): RefractionTexture;
  129761. /**
  129762. * Serialize the texture to a JSON representation you could use in Parse later on
  129763. * @returns the serialized JSON representation
  129764. */
  129765. serialize(): any;
  129766. }
  129767. }
  129768. declare module BABYLON {
  129769. /**
  129770. * Defines the options related to the creation of an HtmlElementTexture
  129771. */
  129772. export interface IHtmlElementTextureOptions {
  129773. /**
  129774. * Defines wether mip maps should be created or not.
  129775. */
  129776. generateMipMaps?: boolean;
  129777. /**
  129778. * Defines the sampling mode of the texture.
  129779. */
  129780. samplingMode?: number;
  129781. /**
  129782. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  129783. */
  129784. engine: Nullable<ThinEngine>;
  129785. /**
  129786. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  129787. */
  129788. scene: Nullable<Scene>;
  129789. }
  129790. /**
  129791. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  129792. * To be as efficient as possible depending on your constraints nothing aside the first upload
  129793. * is automatically managed.
  129794. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  129795. * in your application.
  129796. *
  129797. * As the update is not automatic, you need to call them manually.
  129798. */
  129799. export class HtmlElementTexture extends BaseTexture {
  129800. /**
  129801. * The texture URL.
  129802. */
  129803. element: HTMLVideoElement | HTMLCanvasElement;
  129804. private static readonly DefaultOptions;
  129805. private _textureMatrix;
  129806. private _engine;
  129807. private _isVideo;
  129808. private _generateMipMaps;
  129809. private _samplingMode;
  129810. /**
  129811. * Instantiates a HtmlElementTexture from the following parameters.
  129812. *
  129813. * @param name Defines the name of the texture
  129814. * @param element Defines the video or canvas the texture is filled with
  129815. * @param options Defines the other none mandatory texture creation options
  129816. */
  129817. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  129818. private _createInternalTexture;
  129819. /**
  129820. * Returns the texture matrix used in most of the material.
  129821. */
  129822. getTextureMatrix(): Matrix;
  129823. /**
  129824. * Updates the content of the texture.
  129825. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  129826. */
  129827. update(invertY?: Nullable<boolean>): void;
  129828. }
  129829. }
  129830. declare module BABYLON {
  129831. /**
  129832. * Defines the basic options interface of a TexturePacker Frame
  129833. */
  129834. export interface ITexturePackerFrame {
  129835. /**
  129836. * The frame ID
  129837. */
  129838. id: number;
  129839. /**
  129840. * The frames Scale
  129841. */
  129842. scale: Vector2;
  129843. /**
  129844. * The Frames offset
  129845. */
  129846. offset: Vector2;
  129847. }
  129848. /**
  129849. * This is a support class for frame Data on texture packer sets.
  129850. */
  129851. export class TexturePackerFrame implements ITexturePackerFrame {
  129852. /**
  129853. * The frame ID
  129854. */
  129855. id: number;
  129856. /**
  129857. * The frames Scale
  129858. */
  129859. scale: Vector2;
  129860. /**
  129861. * The Frames offset
  129862. */
  129863. offset: Vector2;
  129864. /**
  129865. * Initializes a texture package frame.
  129866. * @param id The numerical frame identifier
  129867. * @param scale Scalar Vector2 for UV frame
  129868. * @param offset Vector2 for the frame position in UV units.
  129869. * @returns TexturePackerFrame
  129870. */
  129871. constructor(id: number, scale: Vector2, offset: Vector2);
  129872. }
  129873. }
  129874. declare module BABYLON {
  129875. /**
  129876. * Defines the basic options interface of a TexturePacker
  129877. */
  129878. export interface ITexturePackerOptions {
  129879. /**
  129880. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  129881. */
  129882. map?: string[];
  129883. /**
  129884. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  129885. */
  129886. uvsIn?: string;
  129887. /**
  129888. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  129889. */
  129890. uvsOut?: string;
  129891. /**
  129892. * number representing the layout style. Defaults to LAYOUT_STRIP
  129893. */
  129894. layout?: number;
  129895. /**
  129896. * number of columns if using custom column count layout(2). This defaults to 4.
  129897. */
  129898. colnum?: number;
  129899. /**
  129900. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  129901. */
  129902. updateInputMeshes?: boolean;
  129903. /**
  129904. * boolean flag to dispose all the source textures. Defaults to true.
  129905. */
  129906. disposeSources?: boolean;
  129907. /**
  129908. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  129909. */
  129910. fillBlanks?: boolean;
  129911. /**
  129912. * string value representing the context fill style color. Defaults to 'black'.
  129913. */
  129914. customFillColor?: string;
  129915. /**
  129916. * Width and Height Value of each Frame in the TexturePacker Sets
  129917. */
  129918. frameSize?: number;
  129919. /**
  129920. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  129921. */
  129922. paddingRatio?: number;
  129923. /**
  129924. * Number that declares the fill method for the padding gutter.
  129925. */
  129926. paddingMode?: number;
  129927. /**
  129928. * If in SUBUV_COLOR padding mode what color to use.
  129929. */
  129930. paddingColor?: Color3 | Color4;
  129931. }
  129932. /**
  129933. * Defines the basic interface of a TexturePacker JSON File
  129934. */
  129935. export interface ITexturePackerJSON {
  129936. /**
  129937. * The frame ID
  129938. */
  129939. name: string;
  129940. /**
  129941. * The base64 channel data
  129942. */
  129943. sets: any;
  129944. /**
  129945. * The options of the Packer
  129946. */
  129947. options: ITexturePackerOptions;
  129948. /**
  129949. * The frame data of the Packer
  129950. */
  129951. frames: Array<number>;
  129952. }
  129953. /**
  129954. * This is a support class that generates a series of packed texture sets.
  129955. * @see https://doc.babylonjs.com/babylon101/materials
  129956. */
  129957. export class TexturePacker {
  129958. /** Packer Layout Constant 0 */
  129959. static readonly LAYOUT_STRIP: number;
  129960. /** Packer Layout Constant 1 */
  129961. static readonly LAYOUT_POWER2: number;
  129962. /** Packer Layout Constant 2 */
  129963. static readonly LAYOUT_COLNUM: number;
  129964. /** Packer Layout Constant 0 */
  129965. static readonly SUBUV_WRAP: number;
  129966. /** Packer Layout Constant 1 */
  129967. static readonly SUBUV_EXTEND: number;
  129968. /** Packer Layout Constant 2 */
  129969. static readonly SUBUV_COLOR: number;
  129970. /** The Name of the Texture Package */
  129971. name: string;
  129972. /** The scene scope of the TexturePacker */
  129973. scene: Scene;
  129974. /** The Meshes to target */
  129975. meshes: AbstractMesh[];
  129976. /** Arguments passed with the Constructor */
  129977. options: ITexturePackerOptions;
  129978. /** The promise that is started upon initialization */
  129979. promise: Nullable<Promise<TexturePacker | string>>;
  129980. /** The Container object for the channel sets that are generated */
  129981. sets: object;
  129982. /** The Container array for the frames that are generated */
  129983. frames: TexturePackerFrame[];
  129984. /** The expected number of textures the system is parsing. */
  129985. private _expecting;
  129986. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  129987. private _paddingValue;
  129988. /**
  129989. * Initializes a texture package series from an array of meshes or a single mesh.
  129990. * @param name The name of the package
  129991. * @param meshes The target meshes to compose the package from
  129992. * @param options The arguments that texture packer should follow while building.
  129993. * @param scene The scene which the textures are scoped to.
  129994. * @returns TexturePacker
  129995. */
  129996. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  129997. /**
  129998. * Starts the package process
  129999. * @param resolve The promises resolution function
  130000. * @returns TexturePacker
  130001. */
  130002. private _createFrames;
  130003. /**
  130004. * Calculates the Size of the Channel Sets
  130005. * @returns Vector2
  130006. */
  130007. private _calculateSize;
  130008. /**
  130009. * Calculates the UV data for the frames.
  130010. * @param baseSize the base frameSize
  130011. * @param padding the base frame padding
  130012. * @param dtSize size of the Dynamic Texture for that channel
  130013. * @param dtUnits is 1/dtSize
  130014. * @param update flag to update the input meshes
  130015. */
  130016. private _calculateMeshUVFrames;
  130017. /**
  130018. * Calculates the frames Offset.
  130019. * @param index of the frame
  130020. * @returns Vector2
  130021. */
  130022. private _getFrameOffset;
  130023. /**
  130024. * Updates a Mesh to the frame data
  130025. * @param mesh that is the target
  130026. * @param frameID or the frame index
  130027. */
  130028. private _updateMeshUV;
  130029. /**
  130030. * Updates a Meshes materials to use the texture packer channels
  130031. * @param m is the mesh to target
  130032. * @param force all channels on the packer to be set.
  130033. */
  130034. private _updateTextureReferences;
  130035. /**
  130036. * Public method to set a Mesh to a frame
  130037. * @param m that is the target
  130038. * @param frameID or the frame index
  130039. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  130040. */
  130041. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  130042. /**
  130043. * Starts the async promise to compile the texture packer.
  130044. * @returns Promise<void>
  130045. */
  130046. processAsync(): Promise<void>;
  130047. /**
  130048. * Disposes all textures associated with this packer
  130049. */
  130050. dispose(): void;
  130051. /**
  130052. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  130053. * @param imageType is the image type to use.
  130054. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  130055. */
  130056. download(imageType?: string, quality?: number): void;
  130057. /**
  130058. * Public method to load a texturePacker JSON file.
  130059. * @param data of the JSON file in string format.
  130060. */
  130061. updateFromJSON(data: string): void;
  130062. }
  130063. }
  130064. declare module BABYLON {
  130065. /**
  130066. * Enum used to define the target of a block
  130067. */
  130068. export enum NodeMaterialBlockTargets {
  130069. /** Vertex shader */
  130070. Vertex = 1,
  130071. /** Fragment shader */
  130072. Fragment = 2,
  130073. /** Neutral */
  130074. Neutral = 4,
  130075. /** Vertex and Fragment */
  130076. VertexAndFragment = 3
  130077. }
  130078. }
  130079. declare module BABYLON {
  130080. /**
  130081. * Defines the kind of connection point for node based material
  130082. */
  130083. export enum NodeMaterialBlockConnectionPointTypes {
  130084. /** Float */
  130085. Float = 1,
  130086. /** Int */
  130087. Int = 2,
  130088. /** Vector2 */
  130089. Vector2 = 4,
  130090. /** Vector3 */
  130091. Vector3 = 8,
  130092. /** Vector4 */
  130093. Vector4 = 16,
  130094. /** Color3 */
  130095. Color3 = 32,
  130096. /** Color4 */
  130097. Color4 = 64,
  130098. /** Matrix */
  130099. Matrix = 128,
  130100. /** Detect type based on connection */
  130101. AutoDetect = 1024,
  130102. /** Output type that will be defined by input type */
  130103. BasedOnInput = 2048
  130104. }
  130105. }
  130106. declare module BABYLON {
  130107. /**
  130108. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  130109. */
  130110. export enum NodeMaterialBlockConnectionPointMode {
  130111. /** Value is an uniform */
  130112. Uniform = 0,
  130113. /** Value is a mesh attribute */
  130114. Attribute = 1,
  130115. /** Value is a varying between vertex and fragment shaders */
  130116. Varying = 2,
  130117. /** Mode is undefined */
  130118. Undefined = 3
  130119. }
  130120. }
  130121. declare module BABYLON {
  130122. /**
  130123. * Enum used to define system values e.g. values automatically provided by the system
  130124. */
  130125. export enum NodeMaterialSystemValues {
  130126. /** World */
  130127. World = 1,
  130128. /** View */
  130129. View = 2,
  130130. /** Projection */
  130131. Projection = 3,
  130132. /** ViewProjection */
  130133. ViewProjection = 4,
  130134. /** WorldView */
  130135. WorldView = 5,
  130136. /** WorldViewProjection */
  130137. WorldViewProjection = 6,
  130138. /** CameraPosition */
  130139. CameraPosition = 7,
  130140. /** Fog Color */
  130141. FogColor = 8,
  130142. /** Delta time */
  130143. DeltaTime = 9
  130144. }
  130145. }
  130146. declare module BABYLON {
  130147. /**
  130148. * Root class for all node material optimizers
  130149. */
  130150. export class NodeMaterialOptimizer {
  130151. /**
  130152. * Function used to optimize a NodeMaterial graph
  130153. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  130154. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  130155. */
  130156. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  130157. }
  130158. }
  130159. declare module BABYLON {
  130160. /**
  130161. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  130162. */
  130163. export class TransformBlock extends NodeMaterialBlock {
  130164. /**
  130165. * Defines the value to use to complement W value to transform it to a Vector4
  130166. */
  130167. complementW: number;
  130168. /**
  130169. * Defines the value to use to complement z value to transform it to a Vector4
  130170. */
  130171. complementZ: number;
  130172. /**
  130173. * Creates a new TransformBlock
  130174. * @param name defines the block name
  130175. */
  130176. constructor(name: string);
  130177. /**
  130178. * Gets the current class name
  130179. * @returns the class name
  130180. */
  130181. getClassName(): string;
  130182. /**
  130183. * Gets the vector input
  130184. */
  130185. get vector(): NodeMaterialConnectionPoint;
  130186. /**
  130187. * Gets the output component
  130188. */
  130189. get output(): NodeMaterialConnectionPoint;
  130190. /**
  130191. * Gets the matrix transform input
  130192. */
  130193. get transform(): NodeMaterialConnectionPoint;
  130194. protected _buildBlock(state: NodeMaterialBuildState): this;
  130195. serialize(): any;
  130196. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130197. protected _dumpPropertiesCode(): string;
  130198. }
  130199. }
  130200. declare module BABYLON {
  130201. /**
  130202. * Block used to output the vertex position
  130203. */
  130204. export class VertexOutputBlock extends NodeMaterialBlock {
  130205. /**
  130206. * Creates a new VertexOutputBlock
  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 vector input component
  130217. */
  130218. get vector(): NodeMaterialConnectionPoint;
  130219. protected _buildBlock(state: NodeMaterialBuildState): this;
  130220. }
  130221. }
  130222. declare module BABYLON {
  130223. /**
  130224. * Block used to output the final color
  130225. */
  130226. export class FragmentOutputBlock extends NodeMaterialBlock {
  130227. /**
  130228. * Create a new FragmentOutputBlock
  130229. * @param name defines the block name
  130230. */
  130231. constructor(name: string);
  130232. /**
  130233. * Gets the current class name
  130234. * @returns the class name
  130235. */
  130236. getClassName(): string;
  130237. /**
  130238. * Gets the rgba input component
  130239. */
  130240. get rgba(): NodeMaterialConnectionPoint;
  130241. /**
  130242. * Gets the rgb input component
  130243. */
  130244. get rgb(): NodeMaterialConnectionPoint;
  130245. /**
  130246. * Gets the a input component
  130247. */
  130248. get a(): NodeMaterialConnectionPoint;
  130249. protected _buildBlock(state: NodeMaterialBuildState): this;
  130250. }
  130251. }
  130252. declare module BABYLON {
  130253. /**
  130254. * Block used to read a reflection texture from a sampler
  130255. */
  130256. export class ReflectionTextureBlock extends NodeMaterialBlock {
  130257. private _define3DName;
  130258. private _defineCubicName;
  130259. private _defineExplicitName;
  130260. private _defineProjectionName;
  130261. private _defineLocalCubicName;
  130262. private _defineSphericalName;
  130263. private _definePlanarName;
  130264. private _defineEquirectangularName;
  130265. private _defineMirroredEquirectangularFixedName;
  130266. private _defineEquirectangularFixedName;
  130267. private _defineSkyboxName;
  130268. private _cubeSamplerName;
  130269. private _2DSamplerName;
  130270. private _positionUVWName;
  130271. private _directionWName;
  130272. private _reflectionCoordsName;
  130273. private _reflection2DCoordsName;
  130274. private _reflectionColorName;
  130275. private _reflectionMatrixName;
  130276. /**
  130277. * Gets or sets the texture associated with the node
  130278. */
  130279. texture: Nullable<BaseTexture>;
  130280. /**
  130281. * Create a new TextureBlock
  130282. * @param name defines the block name
  130283. */
  130284. constructor(name: string);
  130285. /**
  130286. * Gets the current class name
  130287. * @returns the class name
  130288. */
  130289. getClassName(): string;
  130290. /**
  130291. * Gets the world position input component
  130292. */
  130293. get position(): NodeMaterialConnectionPoint;
  130294. /**
  130295. * Gets the world position input component
  130296. */
  130297. get worldPosition(): NodeMaterialConnectionPoint;
  130298. /**
  130299. * Gets the world normal input component
  130300. */
  130301. get worldNormal(): NodeMaterialConnectionPoint;
  130302. /**
  130303. * Gets the world input component
  130304. */
  130305. get world(): NodeMaterialConnectionPoint;
  130306. /**
  130307. * Gets the camera (or eye) position component
  130308. */
  130309. get cameraPosition(): NodeMaterialConnectionPoint;
  130310. /**
  130311. * Gets the view input component
  130312. */
  130313. get view(): NodeMaterialConnectionPoint;
  130314. /**
  130315. * Gets the rgb output component
  130316. */
  130317. get rgb(): NodeMaterialConnectionPoint;
  130318. /**
  130319. * Gets the r output component
  130320. */
  130321. get r(): NodeMaterialConnectionPoint;
  130322. /**
  130323. * Gets the g output component
  130324. */
  130325. get g(): NodeMaterialConnectionPoint;
  130326. /**
  130327. * Gets the b output component
  130328. */
  130329. get b(): NodeMaterialConnectionPoint;
  130330. autoConfigure(material: NodeMaterial): void;
  130331. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130332. isReady(): boolean;
  130333. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130334. private _injectVertexCode;
  130335. private _writeOutput;
  130336. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  130337. protected _dumpPropertiesCode(): string;
  130338. serialize(): any;
  130339. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130340. }
  130341. }
  130342. declare module BABYLON {
  130343. /**
  130344. * Interface used to configure the node material editor
  130345. */
  130346. export interface INodeMaterialEditorOptions {
  130347. /** Define the URl to load node editor script */
  130348. editorURL?: string;
  130349. }
  130350. /** @hidden */
  130351. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  130352. NORMAL: boolean;
  130353. TANGENT: boolean;
  130354. UV1: boolean;
  130355. /** BONES */
  130356. NUM_BONE_INFLUENCERS: number;
  130357. BonesPerMesh: number;
  130358. BONETEXTURE: boolean;
  130359. /** MORPH TARGETS */
  130360. MORPHTARGETS: boolean;
  130361. MORPHTARGETS_NORMAL: boolean;
  130362. MORPHTARGETS_TANGENT: boolean;
  130363. MORPHTARGETS_UV: boolean;
  130364. NUM_MORPH_INFLUENCERS: number;
  130365. /** IMAGE PROCESSING */
  130366. IMAGEPROCESSING: boolean;
  130367. VIGNETTE: boolean;
  130368. VIGNETTEBLENDMODEMULTIPLY: boolean;
  130369. VIGNETTEBLENDMODEOPAQUE: boolean;
  130370. TONEMAPPING: boolean;
  130371. TONEMAPPING_ACES: boolean;
  130372. CONTRAST: boolean;
  130373. EXPOSURE: boolean;
  130374. COLORCURVES: boolean;
  130375. COLORGRADING: boolean;
  130376. COLORGRADING3D: boolean;
  130377. SAMPLER3DGREENDEPTH: boolean;
  130378. SAMPLER3DBGRMAP: boolean;
  130379. IMAGEPROCESSINGPOSTPROCESS: boolean;
  130380. /** MISC. */
  130381. BUMPDIRECTUV: number;
  130382. constructor();
  130383. setValue(name: string, value: boolean): void;
  130384. }
  130385. /**
  130386. * Class used to configure NodeMaterial
  130387. */
  130388. export interface INodeMaterialOptions {
  130389. /**
  130390. * Defines if blocks should emit comments
  130391. */
  130392. emitComments: boolean;
  130393. }
  130394. /**
  130395. * Class used to create a node based material built by assembling shader blocks
  130396. */
  130397. export class NodeMaterial extends PushMaterial {
  130398. private static _BuildIdGenerator;
  130399. private _options;
  130400. private _vertexCompilationState;
  130401. private _fragmentCompilationState;
  130402. private _sharedData;
  130403. private _buildId;
  130404. private _buildWasSuccessful;
  130405. private _cachedWorldViewMatrix;
  130406. private _cachedWorldViewProjectionMatrix;
  130407. private _optimizers;
  130408. private _animationFrame;
  130409. /** Define the Url to load node editor script */
  130410. static EditorURL: string;
  130411. /** Define the Url to load snippets */
  130412. static SnippetUrl: string;
  130413. private BJSNODEMATERIALEDITOR;
  130414. /** Get the inspector from bundle or global */
  130415. private _getGlobalNodeMaterialEditor;
  130416. /**
  130417. * Gets or sets data used by visual editor
  130418. * @see https://nme.babylonjs.com
  130419. */
  130420. editorData: any;
  130421. /**
  130422. * 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)
  130423. */
  130424. ignoreAlpha: boolean;
  130425. /**
  130426. * Defines the maximum number of lights that can be used in the material
  130427. */
  130428. maxSimultaneousLights: number;
  130429. /**
  130430. * Observable raised when the material is built
  130431. */
  130432. onBuildObservable: Observable<NodeMaterial>;
  130433. /**
  130434. * Gets or sets the root nodes of the material vertex shader
  130435. */
  130436. _vertexOutputNodes: NodeMaterialBlock[];
  130437. /**
  130438. * Gets or sets the root nodes of the material fragment (pixel) shader
  130439. */
  130440. _fragmentOutputNodes: NodeMaterialBlock[];
  130441. /** Gets or sets options to control the node material overall behavior */
  130442. get options(): INodeMaterialOptions;
  130443. set options(options: INodeMaterialOptions);
  130444. /**
  130445. * Default configuration related to image processing available in the standard Material.
  130446. */
  130447. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  130448. /**
  130449. * Gets the image processing configuration used either in this material.
  130450. */
  130451. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  130452. /**
  130453. * Sets the Default image processing configuration used either in the this material.
  130454. *
  130455. * If sets to null, the scene one is in use.
  130456. */
  130457. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  130458. /**
  130459. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  130460. */
  130461. attachedBlocks: NodeMaterialBlock[];
  130462. /**
  130463. * Create a new node based material
  130464. * @param name defines the material name
  130465. * @param scene defines the hosting scene
  130466. * @param options defines creation option
  130467. */
  130468. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  130469. /**
  130470. * Gets the current class name of the material e.g. "NodeMaterial"
  130471. * @returns the class name
  130472. */
  130473. getClassName(): string;
  130474. /**
  130475. * Keep track of the image processing observer to allow dispose and replace.
  130476. */
  130477. private _imageProcessingObserver;
  130478. /**
  130479. * Attaches a new image processing configuration to the Standard Material.
  130480. * @param configuration
  130481. */
  130482. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  130483. /**
  130484. * Get a block by its name
  130485. * @param name defines the name of the block to retrieve
  130486. * @returns the required block or null if not found
  130487. */
  130488. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  130489. /**
  130490. * Get a block by its name
  130491. * @param predicate defines the predicate used to find the good candidate
  130492. * @returns the required block or null if not found
  130493. */
  130494. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  130495. /**
  130496. * Get an input block by its name
  130497. * @param predicate defines the predicate used to find the good candidate
  130498. * @returns the required input block or null if not found
  130499. */
  130500. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  130501. /**
  130502. * Gets the list of input blocks attached to this material
  130503. * @returns an array of InputBlocks
  130504. */
  130505. getInputBlocks(): InputBlock[];
  130506. /**
  130507. * Adds a new optimizer to the list of optimizers
  130508. * @param optimizer defines the optimizers to add
  130509. * @returns the current material
  130510. */
  130511. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  130512. /**
  130513. * Remove an optimizer from the list of optimizers
  130514. * @param optimizer defines the optimizers to remove
  130515. * @returns the current material
  130516. */
  130517. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  130518. /**
  130519. * Add a new block to the list of output nodes
  130520. * @param node defines the node to add
  130521. * @returns the current material
  130522. */
  130523. addOutputNode(node: NodeMaterialBlock): this;
  130524. /**
  130525. * Remove a block from the list of root nodes
  130526. * @param node defines the node to remove
  130527. * @returns the current material
  130528. */
  130529. removeOutputNode(node: NodeMaterialBlock): this;
  130530. private _addVertexOutputNode;
  130531. private _removeVertexOutputNode;
  130532. private _addFragmentOutputNode;
  130533. private _removeFragmentOutputNode;
  130534. /**
  130535. * Specifies if the material will require alpha blending
  130536. * @returns a boolean specifying if alpha blending is needed
  130537. */
  130538. needAlphaBlending(): boolean;
  130539. /**
  130540. * Specifies if this material should be rendered in alpha test mode
  130541. * @returns a boolean specifying if an alpha test is needed.
  130542. */
  130543. needAlphaTesting(): boolean;
  130544. private _initializeBlock;
  130545. private _resetDualBlocks;
  130546. /**
  130547. * Remove a block from the current node material
  130548. * @param block defines the block to remove
  130549. */
  130550. removeBlock(block: NodeMaterialBlock): void;
  130551. /**
  130552. * Build the material and generates the inner effect
  130553. * @param verbose defines if the build should log activity
  130554. */
  130555. build(verbose?: boolean): void;
  130556. /**
  130557. * Runs an otpimization phase to try to improve the shader code
  130558. */
  130559. optimize(): void;
  130560. private _prepareDefinesForAttributes;
  130561. /**
  130562. * Get if the submesh is ready to be used and all its information available.
  130563. * Child classes can use it to update shaders
  130564. * @param mesh defines the mesh to check
  130565. * @param subMesh defines which submesh to check
  130566. * @param useInstances specifies that instances should be used
  130567. * @returns a boolean indicating that the submesh is ready or not
  130568. */
  130569. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  130570. /**
  130571. * Get a string representing the shaders built by the current node graph
  130572. */
  130573. get compiledShaders(): string;
  130574. /**
  130575. * Binds the world matrix to the material
  130576. * @param world defines the world transformation matrix
  130577. */
  130578. bindOnlyWorldMatrix(world: Matrix): void;
  130579. /**
  130580. * Binds the submesh to this material by preparing the effect and shader to draw
  130581. * @param world defines the world transformation matrix
  130582. * @param mesh defines the mesh containing the submesh
  130583. * @param subMesh defines the submesh to bind the material to
  130584. */
  130585. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  130586. /**
  130587. * Gets the active textures from the material
  130588. * @returns an array of textures
  130589. */
  130590. getActiveTextures(): BaseTexture[];
  130591. /**
  130592. * Gets the list of texture blocks
  130593. * @returns an array of texture blocks
  130594. */
  130595. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  130596. /**
  130597. * Specifies if the material uses a texture
  130598. * @param texture defines the texture to check against the material
  130599. * @returns a boolean specifying if the material uses the texture
  130600. */
  130601. hasTexture(texture: BaseTexture): boolean;
  130602. /**
  130603. * Disposes the material
  130604. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  130605. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  130606. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  130607. */
  130608. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  130609. /** Creates the node editor window. */
  130610. private _createNodeEditor;
  130611. /**
  130612. * Launch the node material editor
  130613. * @param config Define the configuration of the editor
  130614. * @return a promise fulfilled when the node editor is visible
  130615. */
  130616. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  130617. /**
  130618. * Clear the current material
  130619. */
  130620. clear(): void;
  130621. /**
  130622. * Clear the current material and set it to a default state
  130623. */
  130624. setToDefault(): void;
  130625. /**
  130626. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  130627. * @param url defines the url to load from
  130628. * @returns a promise that will fullfil when the material is fully loaded
  130629. */
  130630. loadAsync(url: string): Promise<void>;
  130631. private _gatherBlocks;
  130632. /**
  130633. * Generate a string containing the code declaration required to create an equivalent of this material
  130634. * @returns a string
  130635. */
  130636. generateCode(): string;
  130637. /**
  130638. * Serializes this material in a JSON representation
  130639. * @returns the serialized material object
  130640. */
  130641. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  130642. private _restoreConnections;
  130643. /**
  130644. * Clear the current graph and load a new one from a serialization object
  130645. * @param source defines the JSON representation of the material
  130646. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130647. */
  130648. loadFromSerialization(source: any, rootUrl?: string): void;
  130649. /**
  130650. * Creates a node material from parsed material data
  130651. * @param source defines the JSON representation of the material
  130652. * @param scene defines the hosting scene
  130653. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130654. * @returns a new node material
  130655. */
  130656. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  130657. /**
  130658. * Creates a node material from a snippet saved in a remote file
  130659. * @param name defines the name of the material to create
  130660. * @param url defines the url to load from
  130661. * @param scene defines the hosting scene
  130662. * @returns a promise that will resolve to the new node material
  130663. */
  130664. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  130665. /**
  130666. * Creates a node material from a snippet saved by the node material editor
  130667. * @param snippetId defines the snippet to load
  130668. * @param scene defines the hosting scene
  130669. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130670. * @returns a promise that will resolve to the new node material
  130671. */
  130672. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  130673. /**
  130674. * Creates a new node material set to default basic configuration
  130675. * @param name defines the name of the material
  130676. * @param scene defines the hosting scene
  130677. * @returns a new NodeMaterial
  130678. */
  130679. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  130680. }
  130681. }
  130682. declare module BABYLON {
  130683. /**
  130684. * Block used to read a texture from a sampler
  130685. */
  130686. export class TextureBlock extends NodeMaterialBlock {
  130687. private _defineName;
  130688. private _linearDefineName;
  130689. private _tempTextureRead;
  130690. private _samplerName;
  130691. private _transformedUVName;
  130692. private _textureTransformName;
  130693. private _textureInfoName;
  130694. private _mainUVName;
  130695. private _mainUVDefineName;
  130696. /**
  130697. * Gets or sets the texture associated with the node
  130698. */
  130699. texture: Nullable<Texture>;
  130700. /**
  130701. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  130702. */
  130703. convertToGammaSpace: boolean;
  130704. /**
  130705. * Create a new TextureBlock
  130706. * @param name defines the block name
  130707. */
  130708. constructor(name: string);
  130709. /**
  130710. * Gets the current class name
  130711. * @returns the class name
  130712. */
  130713. getClassName(): string;
  130714. /**
  130715. * Gets the uv input component
  130716. */
  130717. get uv(): NodeMaterialConnectionPoint;
  130718. /**
  130719. * Gets the rgba output component
  130720. */
  130721. get rgba(): NodeMaterialConnectionPoint;
  130722. /**
  130723. * Gets the rgb output component
  130724. */
  130725. get rgb(): NodeMaterialConnectionPoint;
  130726. /**
  130727. * Gets the r output component
  130728. */
  130729. get r(): NodeMaterialConnectionPoint;
  130730. /**
  130731. * Gets the g output component
  130732. */
  130733. get g(): NodeMaterialConnectionPoint;
  130734. /**
  130735. * Gets the b output component
  130736. */
  130737. get b(): NodeMaterialConnectionPoint;
  130738. /**
  130739. * Gets the a output component
  130740. */
  130741. get a(): NodeMaterialConnectionPoint;
  130742. get target(): NodeMaterialBlockTargets;
  130743. autoConfigure(material: NodeMaterial): void;
  130744. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  130745. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130746. isReady(): boolean;
  130747. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130748. private get _isMixed();
  130749. private _injectVertexCode;
  130750. private _writeTextureRead;
  130751. private _writeOutput;
  130752. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  130753. protected _dumpPropertiesCode(): string;
  130754. serialize(): any;
  130755. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130756. }
  130757. }
  130758. declare module BABYLON {
  130759. /**
  130760. * Class used to store shared data between 2 NodeMaterialBuildState
  130761. */
  130762. export class NodeMaterialBuildStateSharedData {
  130763. /**
  130764. * Gets the list of emitted varyings
  130765. */
  130766. temps: string[];
  130767. /**
  130768. * Gets the list of emitted varyings
  130769. */
  130770. varyings: string[];
  130771. /**
  130772. * Gets the varying declaration string
  130773. */
  130774. varyingDeclaration: string;
  130775. /**
  130776. * Input blocks
  130777. */
  130778. inputBlocks: InputBlock[];
  130779. /**
  130780. * Input blocks
  130781. */
  130782. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  130783. /**
  130784. * Bindable blocks (Blocks that need to set data to the effect)
  130785. */
  130786. bindableBlocks: NodeMaterialBlock[];
  130787. /**
  130788. * List of blocks that can provide a compilation fallback
  130789. */
  130790. blocksWithFallbacks: NodeMaterialBlock[];
  130791. /**
  130792. * List of blocks that can provide a define update
  130793. */
  130794. blocksWithDefines: NodeMaterialBlock[];
  130795. /**
  130796. * List of blocks that can provide a repeatable content
  130797. */
  130798. repeatableContentBlocks: NodeMaterialBlock[];
  130799. /**
  130800. * List of blocks that can provide a dynamic list of uniforms
  130801. */
  130802. dynamicUniformBlocks: NodeMaterialBlock[];
  130803. /**
  130804. * List of blocks that can block the isReady function for the material
  130805. */
  130806. blockingBlocks: NodeMaterialBlock[];
  130807. /**
  130808. * Gets the list of animated inputs
  130809. */
  130810. animatedInputs: InputBlock[];
  130811. /**
  130812. * Build Id used to avoid multiple recompilations
  130813. */
  130814. buildId: number;
  130815. /** List of emitted variables */
  130816. variableNames: {
  130817. [key: string]: number;
  130818. };
  130819. /** List of emitted defines */
  130820. defineNames: {
  130821. [key: string]: number;
  130822. };
  130823. /** Should emit comments? */
  130824. emitComments: boolean;
  130825. /** Emit build activity */
  130826. verbose: boolean;
  130827. /** Gets or sets the hosting scene */
  130828. scene: Scene;
  130829. /**
  130830. * Gets the compilation hints emitted at compilation time
  130831. */
  130832. hints: {
  130833. needWorldViewMatrix: boolean;
  130834. needWorldViewProjectionMatrix: boolean;
  130835. needAlphaBlending: boolean;
  130836. needAlphaTesting: boolean;
  130837. };
  130838. /**
  130839. * List of compilation checks
  130840. */
  130841. checks: {
  130842. emitVertex: boolean;
  130843. emitFragment: boolean;
  130844. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  130845. };
  130846. /** Creates a new shared data */
  130847. constructor();
  130848. /**
  130849. * Emits console errors and exceptions if there is a failing check
  130850. */
  130851. emitErrors(): void;
  130852. }
  130853. }
  130854. declare module BABYLON {
  130855. /**
  130856. * Class used to store node based material build state
  130857. */
  130858. export class NodeMaterialBuildState {
  130859. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  130860. supportUniformBuffers: boolean;
  130861. /**
  130862. * Gets the list of emitted attributes
  130863. */
  130864. attributes: string[];
  130865. /**
  130866. * Gets the list of emitted uniforms
  130867. */
  130868. uniforms: string[];
  130869. /**
  130870. * Gets the list of emitted constants
  130871. */
  130872. constants: string[];
  130873. /**
  130874. * Gets the list of emitted samplers
  130875. */
  130876. samplers: string[];
  130877. /**
  130878. * Gets the list of emitted functions
  130879. */
  130880. functions: {
  130881. [key: string]: string;
  130882. };
  130883. /**
  130884. * Gets the list of emitted extensions
  130885. */
  130886. extensions: {
  130887. [key: string]: string;
  130888. };
  130889. /**
  130890. * Gets the target of the compilation state
  130891. */
  130892. target: NodeMaterialBlockTargets;
  130893. /**
  130894. * Gets the list of emitted counters
  130895. */
  130896. counters: {
  130897. [key: string]: number;
  130898. };
  130899. /**
  130900. * Shared data between multiple NodeMaterialBuildState instances
  130901. */
  130902. sharedData: NodeMaterialBuildStateSharedData;
  130903. /** @hidden */
  130904. _vertexState: NodeMaterialBuildState;
  130905. /** @hidden */
  130906. _attributeDeclaration: string;
  130907. /** @hidden */
  130908. _uniformDeclaration: string;
  130909. /** @hidden */
  130910. _constantDeclaration: string;
  130911. /** @hidden */
  130912. _samplerDeclaration: string;
  130913. /** @hidden */
  130914. _varyingTransfer: string;
  130915. private _repeatableContentAnchorIndex;
  130916. /** @hidden */
  130917. _builtCompilationString: string;
  130918. /**
  130919. * Gets the emitted compilation strings
  130920. */
  130921. compilationString: string;
  130922. /**
  130923. * Finalize the compilation strings
  130924. * @param state defines the current compilation state
  130925. */
  130926. finalize(state: NodeMaterialBuildState): void;
  130927. /** @hidden */
  130928. get _repeatableContentAnchor(): string;
  130929. /** @hidden */
  130930. _getFreeVariableName(prefix: string): string;
  130931. /** @hidden */
  130932. _getFreeDefineName(prefix: string): string;
  130933. /** @hidden */
  130934. _excludeVariableName(name: string): void;
  130935. /** @hidden */
  130936. _emit2DSampler(name: string): void;
  130937. /** @hidden */
  130938. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  130939. /** @hidden */
  130940. _emitExtension(name: string, extension: string): void;
  130941. /** @hidden */
  130942. _emitFunction(name: string, code: string, comments: string): void;
  130943. /** @hidden */
  130944. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  130945. replaceStrings?: {
  130946. search: RegExp;
  130947. replace: string;
  130948. }[];
  130949. repeatKey?: string;
  130950. }): string;
  130951. /** @hidden */
  130952. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  130953. repeatKey?: string;
  130954. removeAttributes?: boolean;
  130955. removeUniforms?: boolean;
  130956. removeVaryings?: boolean;
  130957. removeIfDef?: boolean;
  130958. replaceStrings?: {
  130959. search: RegExp;
  130960. replace: string;
  130961. }[];
  130962. }, storeKey?: string): void;
  130963. /** @hidden */
  130964. _registerTempVariable(name: string): boolean;
  130965. /** @hidden */
  130966. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  130967. /** @hidden */
  130968. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  130969. /** @hidden */
  130970. _emitFloat(value: number): string;
  130971. }
  130972. }
  130973. declare module BABYLON {
  130974. /**
  130975. * Defines a block that can be used inside a node based material
  130976. */
  130977. export class NodeMaterialBlock {
  130978. private _buildId;
  130979. private _buildTarget;
  130980. private _target;
  130981. private _isFinalMerger;
  130982. private _isInput;
  130983. protected _isUnique: boolean;
  130984. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  130985. inputsAreExclusive: boolean;
  130986. /** @hidden */
  130987. _codeVariableName: string;
  130988. /** @hidden */
  130989. _inputs: NodeMaterialConnectionPoint[];
  130990. /** @hidden */
  130991. _outputs: NodeMaterialConnectionPoint[];
  130992. /** @hidden */
  130993. _preparationId: number;
  130994. /**
  130995. * Gets or sets the name of the block
  130996. */
  130997. name: string;
  130998. /**
  130999. * Gets or sets the unique id of the node
  131000. */
  131001. uniqueId: number;
  131002. /**
  131003. * Gets or sets the comments associated with this block
  131004. */
  131005. comments: string;
  131006. /**
  131007. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  131008. */
  131009. get isUnique(): boolean;
  131010. /**
  131011. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  131012. */
  131013. get isFinalMerger(): boolean;
  131014. /**
  131015. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  131016. */
  131017. get isInput(): boolean;
  131018. /**
  131019. * Gets or sets the build Id
  131020. */
  131021. get buildId(): number;
  131022. set buildId(value: number);
  131023. /**
  131024. * Gets or sets the target of the block
  131025. */
  131026. get target(): NodeMaterialBlockTargets;
  131027. set target(value: NodeMaterialBlockTargets);
  131028. /**
  131029. * Gets the list of input points
  131030. */
  131031. get inputs(): NodeMaterialConnectionPoint[];
  131032. /** Gets the list of output points */
  131033. get outputs(): NodeMaterialConnectionPoint[];
  131034. /**
  131035. * Find an input by its name
  131036. * @param name defines the name of the input to look for
  131037. * @returns the input or null if not found
  131038. */
  131039. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  131040. /**
  131041. * Find an output by its name
  131042. * @param name defines the name of the outputto look for
  131043. * @returns the output or null if not found
  131044. */
  131045. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  131046. /**
  131047. * Creates a new NodeMaterialBlock
  131048. * @param name defines the block name
  131049. * @param target defines the target of that block (Vertex by default)
  131050. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  131051. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  131052. */
  131053. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  131054. /**
  131055. * Initialize the block and prepare the context for build
  131056. * @param state defines the state that will be used for the build
  131057. */
  131058. initialize(state: NodeMaterialBuildState): void;
  131059. /**
  131060. * Bind data to effect. Will only be called for blocks with isBindable === true
  131061. * @param effect defines the effect to bind data to
  131062. * @param nodeMaterial defines the hosting NodeMaterial
  131063. * @param mesh defines the mesh that will be rendered
  131064. */
  131065. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131066. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  131067. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  131068. protected _writeFloat(value: number): string;
  131069. /**
  131070. * Gets the current class name e.g. "NodeMaterialBlock"
  131071. * @returns the class name
  131072. */
  131073. getClassName(): string;
  131074. /**
  131075. * Register a new input. Must be called inside a block constructor
  131076. * @param name defines the connection point name
  131077. * @param type defines the connection point type
  131078. * @param isOptional defines a boolean indicating that this input can be omitted
  131079. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  131080. * @returns the current block
  131081. */
  131082. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  131083. /**
  131084. * Register a new output. Must be called inside a block constructor
  131085. * @param name defines the connection point name
  131086. * @param type defines the connection point type
  131087. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  131088. * @returns the current block
  131089. */
  131090. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  131091. /**
  131092. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  131093. * @param forOutput defines an optional connection point to check compatibility with
  131094. * @returns the first available input or null
  131095. */
  131096. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  131097. /**
  131098. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  131099. * @param forBlock defines an optional block to check compatibility with
  131100. * @returns the first available input or null
  131101. */
  131102. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  131103. /**
  131104. * Gets the sibling of the given output
  131105. * @param current defines the current output
  131106. * @returns the next output in the list or null
  131107. */
  131108. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  131109. /**
  131110. * Connect current block with another block
  131111. * @param other defines the block to connect with
  131112. * @param options define the various options to help pick the right connections
  131113. * @returns the current block
  131114. */
  131115. connectTo(other: NodeMaterialBlock, options?: {
  131116. input?: string;
  131117. output?: string;
  131118. outputSwizzle?: string;
  131119. }): this | undefined;
  131120. protected _buildBlock(state: NodeMaterialBuildState): void;
  131121. /**
  131122. * Add uniforms, samplers and uniform buffers at compilation time
  131123. * @param state defines the state to update
  131124. * @param nodeMaterial defines the node material requesting the update
  131125. * @param defines defines the material defines to update
  131126. * @param uniformBuffers defines the list of uniform buffer names
  131127. */
  131128. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  131129. /**
  131130. * Add potential fallbacks if shader compilation fails
  131131. * @param mesh defines the mesh to be rendered
  131132. * @param fallbacks defines the current prioritized list of fallbacks
  131133. */
  131134. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  131135. /**
  131136. * Initialize defines for shader compilation
  131137. * @param mesh defines the mesh to be rendered
  131138. * @param nodeMaterial defines the node material requesting the update
  131139. * @param defines defines the material defines to update
  131140. * @param useInstances specifies that instances should be used
  131141. */
  131142. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  131143. /**
  131144. * Update defines for shader compilation
  131145. * @param mesh defines the mesh to be rendered
  131146. * @param nodeMaterial defines the node material requesting the update
  131147. * @param defines defines the material defines to update
  131148. * @param useInstances specifies that instances should be used
  131149. */
  131150. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  131151. /**
  131152. * Lets the block try to connect some inputs automatically
  131153. * @param material defines the hosting NodeMaterial
  131154. */
  131155. autoConfigure(material: NodeMaterial): void;
  131156. /**
  131157. * Function called when a block is declared as repeatable content generator
  131158. * @param vertexShaderState defines the current compilation state for the vertex shader
  131159. * @param fragmentShaderState defines the current compilation state for the fragment shader
  131160. * @param mesh defines the mesh to be rendered
  131161. * @param defines defines the material defines to update
  131162. */
  131163. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  131164. /**
  131165. * Checks if the block is ready
  131166. * @param mesh defines the mesh to be rendered
  131167. * @param nodeMaterial defines the node material requesting the update
  131168. * @param defines defines the material defines to update
  131169. * @param useInstances specifies that instances should be used
  131170. * @returns true if the block is ready
  131171. */
  131172. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  131173. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  131174. private _processBuild;
  131175. /**
  131176. * Compile the current node and generate the shader code
  131177. * @param state defines the current compilation state (uniforms, samplers, current string)
  131178. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  131179. * @returns true if already built
  131180. */
  131181. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  131182. protected _inputRename(name: string): string;
  131183. protected _outputRename(name: string): string;
  131184. protected _dumpPropertiesCode(): string;
  131185. /** @hidden */
  131186. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  131187. /** @hidden */
  131188. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  131189. /**
  131190. * Clone the current block to a new identical block
  131191. * @param scene defines the hosting scene
  131192. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  131193. * @returns a copy of the current block
  131194. */
  131195. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  131196. /**
  131197. * Serializes this block in a JSON representation
  131198. * @returns the serialized block object
  131199. */
  131200. serialize(): any;
  131201. /** @hidden */
  131202. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131203. /**
  131204. * Release resources
  131205. */
  131206. dispose(): void;
  131207. }
  131208. }
  131209. declare module BABYLON {
  131210. /**
  131211. * Enum defining the type of animations supported by InputBlock
  131212. */
  131213. export enum AnimatedInputBlockTypes {
  131214. /** No animation */
  131215. None = 0,
  131216. /** Time based animation. Will only work for floats */
  131217. Time = 1
  131218. }
  131219. }
  131220. declare module BABYLON {
  131221. /**
  131222. * Block used to expose an input value
  131223. */
  131224. export class InputBlock extends NodeMaterialBlock {
  131225. private _mode;
  131226. private _associatedVariableName;
  131227. private _storedValue;
  131228. private _valueCallback;
  131229. private _type;
  131230. private _animationType;
  131231. /** Gets or set a value used to limit the range of float values */
  131232. min: number;
  131233. /** Gets or set a value used to limit the range of float values */
  131234. max: number;
  131235. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  131236. isBoolean: boolean;
  131237. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  131238. matrixMode: number;
  131239. /** @hidden */
  131240. _systemValue: Nullable<NodeMaterialSystemValues>;
  131241. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  131242. visibleInInspector: boolean;
  131243. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  131244. isConstant: boolean;
  131245. /** Gets or sets the group to use to display this block in the Inspector */
  131246. groupInInspector: string;
  131247. /**
  131248. * Gets or sets the connection point type (default is float)
  131249. */
  131250. get type(): NodeMaterialBlockConnectionPointTypes;
  131251. /**
  131252. * Creates a new InputBlock
  131253. * @param name defines the block name
  131254. * @param target defines the target of that block (Vertex by default)
  131255. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  131256. */
  131257. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  131258. /**
  131259. * Gets the output component
  131260. */
  131261. get output(): NodeMaterialConnectionPoint;
  131262. /**
  131263. * Set the source of this connection point to a vertex attribute
  131264. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  131265. * @returns the current connection point
  131266. */
  131267. setAsAttribute(attributeName?: string): InputBlock;
  131268. /**
  131269. * Set the source of this connection point to a system value
  131270. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  131271. * @returns the current connection point
  131272. */
  131273. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  131274. /**
  131275. * Gets or sets the value of that point.
  131276. * Please note that this value will be ignored if valueCallback is defined
  131277. */
  131278. get value(): any;
  131279. set value(value: any);
  131280. /**
  131281. * Gets or sets a callback used to get the value of that point.
  131282. * Please note that setting this value will force the connection point to ignore the value property
  131283. */
  131284. get valueCallback(): () => any;
  131285. set valueCallback(value: () => any);
  131286. /**
  131287. * Gets or sets the associated variable name in the shader
  131288. */
  131289. get associatedVariableName(): string;
  131290. set associatedVariableName(value: string);
  131291. /** Gets or sets the type of animation applied to the input */
  131292. get animationType(): AnimatedInputBlockTypes;
  131293. set animationType(value: AnimatedInputBlockTypes);
  131294. /**
  131295. * Gets a boolean indicating that this connection point not defined yet
  131296. */
  131297. get isUndefined(): boolean;
  131298. /**
  131299. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  131300. * In this case the connection point name must be the name of the uniform to use.
  131301. * Can only be set on inputs
  131302. */
  131303. get isUniform(): boolean;
  131304. set isUniform(value: boolean);
  131305. /**
  131306. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  131307. * In this case the connection point name must be the name of the attribute to use
  131308. * Can only be set on inputs
  131309. */
  131310. get isAttribute(): boolean;
  131311. set isAttribute(value: boolean);
  131312. /**
  131313. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  131314. * Can only be set on exit points
  131315. */
  131316. get isVarying(): boolean;
  131317. set isVarying(value: boolean);
  131318. /**
  131319. * Gets a boolean indicating that the current connection point is a system value
  131320. */
  131321. get isSystemValue(): boolean;
  131322. /**
  131323. * Gets or sets the current well known value or null if not defined as a system value
  131324. */
  131325. get systemValue(): Nullable<NodeMaterialSystemValues>;
  131326. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  131327. /**
  131328. * Gets the current class name
  131329. * @returns the class name
  131330. */
  131331. getClassName(): string;
  131332. /**
  131333. * Animate the input if animationType !== None
  131334. * @param scene defines the rendering scene
  131335. */
  131336. animate(scene: Scene): void;
  131337. private _emitDefine;
  131338. initialize(state: NodeMaterialBuildState): void;
  131339. /**
  131340. * Set the input block to its default value (based on its type)
  131341. */
  131342. setDefaultValue(): void;
  131343. private _emitConstant;
  131344. private _emit;
  131345. /** @hidden */
  131346. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  131347. /** @hidden */
  131348. _transmit(effect: Effect, scene: Scene): void;
  131349. protected _buildBlock(state: NodeMaterialBuildState): void;
  131350. protected _dumpPropertiesCode(): string;
  131351. serialize(): any;
  131352. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131353. }
  131354. }
  131355. declare module BABYLON {
  131356. /**
  131357. * Enum used to define the compatibility state between two connection points
  131358. */
  131359. export enum NodeMaterialConnectionPointCompatibilityStates {
  131360. /** Points are compatibles */
  131361. Compatible = 0,
  131362. /** Points are incompatible because of their types */
  131363. TypeIncompatible = 1,
  131364. /** Points are incompatible because of their targets (vertex vs fragment) */
  131365. TargetIncompatible = 2
  131366. }
  131367. /**
  131368. * Defines the direction of a connection point
  131369. */
  131370. export enum NodeMaterialConnectionPointDirection {
  131371. /** Input */
  131372. Input = 0,
  131373. /** Output */
  131374. Output = 1
  131375. }
  131376. /**
  131377. * Defines a connection point for a block
  131378. */
  131379. export class NodeMaterialConnectionPoint {
  131380. /** @hidden */
  131381. _ownerBlock: NodeMaterialBlock;
  131382. /** @hidden */
  131383. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  131384. private _endpoints;
  131385. private _associatedVariableName;
  131386. private _direction;
  131387. /** @hidden */
  131388. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  131389. /** @hidden */
  131390. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  131391. private _type;
  131392. /** @hidden */
  131393. _enforceAssociatedVariableName: boolean;
  131394. /** Gets the direction of the point */
  131395. get direction(): NodeMaterialConnectionPointDirection;
  131396. /**
  131397. * Gets or sets the additional types supported by this connection point
  131398. */
  131399. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  131400. /**
  131401. * Gets or sets the additional types excluded by this connection point
  131402. */
  131403. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  131404. /**
  131405. * Observable triggered when this point is connected
  131406. */
  131407. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  131408. /**
  131409. * Gets or sets the associated variable name in the shader
  131410. */
  131411. get associatedVariableName(): string;
  131412. set associatedVariableName(value: string);
  131413. /** Get the inner type (ie AutoDetect for isntance instead of the inferred one) */
  131414. get innerType(): NodeMaterialBlockConnectionPointTypes;
  131415. /**
  131416. * Gets or sets the connection point type (default is float)
  131417. */
  131418. get type(): NodeMaterialBlockConnectionPointTypes;
  131419. set type(value: NodeMaterialBlockConnectionPointTypes);
  131420. /**
  131421. * Gets or sets the connection point name
  131422. */
  131423. name: string;
  131424. /**
  131425. * Gets or sets a boolean indicating that this connection point can be omitted
  131426. */
  131427. isOptional: boolean;
  131428. /**
  131429. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  131430. */
  131431. define: string;
  131432. /** @hidden */
  131433. _prioritizeVertex: boolean;
  131434. private _target;
  131435. /** Gets or sets the target of that connection point */
  131436. get target(): NodeMaterialBlockTargets;
  131437. set target(value: NodeMaterialBlockTargets);
  131438. /**
  131439. * Gets a boolean indicating that the current point is connected
  131440. */
  131441. get isConnected(): boolean;
  131442. /**
  131443. * Gets a boolean indicating that the current point is connected to an input block
  131444. */
  131445. get isConnectedToInputBlock(): boolean;
  131446. /**
  131447. * Gets a the connected input block (if any)
  131448. */
  131449. get connectInputBlock(): Nullable<InputBlock>;
  131450. /** Get the other side of the connection (if any) */
  131451. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  131452. /** Get the block that owns this connection point */
  131453. get ownerBlock(): NodeMaterialBlock;
  131454. /** Get the block connected on the other side of this connection (if any) */
  131455. get sourceBlock(): Nullable<NodeMaterialBlock>;
  131456. /** Get the block connected on the endpoints of this connection (if any) */
  131457. get connectedBlocks(): Array<NodeMaterialBlock>;
  131458. /** Gets the list of connected endpoints */
  131459. get endpoints(): NodeMaterialConnectionPoint[];
  131460. /** Gets a boolean indicating if that output point is connected to at least one input */
  131461. get hasEndpoints(): boolean;
  131462. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  131463. get isConnectedInVertexShader(): boolean;
  131464. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  131465. get isConnectedInFragmentShader(): boolean;
  131466. /**
  131467. * Creates a new connection point
  131468. * @param name defines the connection point name
  131469. * @param ownerBlock defines the block hosting this connection point
  131470. * @param direction defines the direction of the connection point
  131471. */
  131472. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  131473. /**
  131474. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  131475. * @returns the class name
  131476. */
  131477. getClassName(): string;
  131478. /**
  131479. * Gets a boolean indicating if the current point can be connected to another point
  131480. * @param connectionPoint defines the other connection point
  131481. * @returns a boolean
  131482. */
  131483. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  131484. /**
  131485. * Gets a number indicating if the current point can be connected to another point
  131486. * @param connectionPoint defines the other connection point
  131487. * @returns a number defining the compatibility state
  131488. */
  131489. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  131490. /**
  131491. * Connect this point to another connection point
  131492. * @param connectionPoint defines the other connection point
  131493. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  131494. * @returns the current connection point
  131495. */
  131496. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  131497. /**
  131498. * Disconnect this point from one of his endpoint
  131499. * @param endpoint defines the other connection point
  131500. * @returns the current connection point
  131501. */
  131502. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  131503. /**
  131504. * Serializes this point in a JSON representation
  131505. * @returns the serialized point object
  131506. */
  131507. serialize(): any;
  131508. /**
  131509. * Release resources
  131510. */
  131511. dispose(): void;
  131512. }
  131513. }
  131514. declare module BABYLON {
  131515. /**
  131516. * Block used to add support for vertex skinning (bones)
  131517. */
  131518. export class BonesBlock extends NodeMaterialBlock {
  131519. /**
  131520. * Creates a new BonesBlock
  131521. * @param name defines the block name
  131522. */
  131523. constructor(name: string);
  131524. /**
  131525. * Initialize the block and prepare the context for build
  131526. * @param state defines the state that will be used for the build
  131527. */
  131528. initialize(state: NodeMaterialBuildState): void;
  131529. /**
  131530. * Gets the current class name
  131531. * @returns the class name
  131532. */
  131533. getClassName(): string;
  131534. /**
  131535. * Gets the matrix indices input component
  131536. */
  131537. get matricesIndices(): NodeMaterialConnectionPoint;
  131538. /**
  131539. * Gets the matrix weights input component
  131540. */
  131541. get matricesWeights(): NodeMaterialConnectionPoint;
  131542. /**
  131543. * Gets the extra matrix indices input component
  131544. */
  131545. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  131546. /**
  131547. * Gets the extra matrix weights input component
  131548. */
  131549. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  131550. /**
  131551. * Gets the world input component
  131552. */
  131553. get world(): NodeMaterialConnectionPoint;
  131554. /**
  131555. * Gets the output component
  131556. */
  131557. get output(): NodeMaterialConnectionPoint;
  131558. autoConfigure(material: NodeMaterial): void;
  131559. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  131560. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131561. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131562. protected _buildBlock(state: NodeMaterialBuildState): this;
  131563. }
  131564. }
  131565. declare module BABYLON {
  131566. /**
  131567. * Block used to add support for instances
  131568. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  131569. */
  131570. export class InstancesBlock extends NodeMaterialBlock {
  131571. /**
  131572. * Creates a new InstancesBlock
  131573. * @param name defines the block name
  131574. */
  131575. constructor(name: string);
  131576. /**
  131577. * Gets the current class name
  131578. * @returns the class name
  131579. */
  131580. getClassName(): string;
  131581. /**
  131582. * Gets the first world row input component
  131583. */
  131584. get world0(): NodeMaterialConnectionPoint;
  131585. /**
  131586. * Gets the second world row input component
  131587. */
  131588. get world1(): NodeMaterialConnectionPoint;
  131589. /**
  131590. * Gets the third world row input component
  131591. */
  131592. get world2(): NodeMaterialConnectionPoint;
  131593. /**
  131594. * Gets the forth world row input component
  131595. */
  131596. get world3(): NodeMaterialConnectionPoint;
  131597. /**
  131598. * Gets the world input component
  131599. */
  131600. get world(): NodeMaterialConnectionPoint;
  131601. /**
  131602. * Gets the output component
  131603. */
  131604. get output(): NodeMaterialConnectionPoint;
  131605. /**
  131606. * Gets the isntanceID component
  131607. */
  131608. get instanceID(): NodeMaterialConnectionPoint;
  131609. autoConfigure(material: NodeMaterial): void;
  131610. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  131611. protected _buildBlock(state: NodeMaterialBuildState): this;
  131612. }
  131613. }
  131614. declare module BABYLON {
  131615. /**
  131616. * Block used to add morph targets support to vertex shader
  131617. */
  131618. export class MorphTargetsBlock extends NodeMaterialBlock {
  131619. private _repeatableContentAnchor;
  131620. /**
  131621. * Create a new MorphTargetsBlock
  131622. * @param name defines the block name
  131623. */
  131624. constructor(name: string);
  131625. /**
  131626. * Gets the current class name
  131627. * @returns the class name
  131628. */
  131629. getClassName(): string;
  131630. /**
  131631. * Gets the position input component
  131632. */
  131633. get position(): NodeMaterialConnectionPoint;
  131634. /**
  131635. * Gets the normal input component
  131636. */
  131637. get normal(): NodeMaterialConnectionPoint;
  131638. /**
  131639. * Gets the tangent input component
  131640. */
  131641. get tangent(): NodeMaterialConnectionPoint;
  131642. /**
  131643. * Gets the tangent input component
  131644. */
  131645. get uv(): NodeMaterialConnectionPoint;
  131646. /**
  131647. * Gets the position output component
  131648. */
  131649. get positionOutput(): NodeMaterialConnectionPoint;
  131650. /**
  131651. * Gets the normal output component
  131652. */
  131653. get normalOutput(): NodeMaterialConnectionPoint;
  131654. /**
  131655. * Gets the tangent output component
  131656. */
  131657. get tangentOutput(): NodeMaterialConnectionPoint;
  131658. /**
  131659. * Gets the tangent output component
  131660. */
  131661. get uvOutput(): NodeMaterialConnectionPoint;
  131662. initialize(state: NodeMaterialBuildState): void;
  131663. autoConfigure(material: NodeMaterial): void;
  131664. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131665. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131666. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  131667. protected _buildBlock(state: NodeMaterialBuildState): this;
  131668. }
  131669. }
  131670. declare module BABYLON {
  131671. /**
  131672. * Block used to get data information from a light
  131673. */
  131674. export class LightInformationBlock extends NodeMaterialBlock {
  131675. private _lightDataUniformName;
  131676. private _lightColorUniformName;
  131677. private _lightTypeDefineName;
  131678. /**
  131679. * Gets or sets the light associated with this block
  131680. */
  131681. light: Nullable<Light>;
  131682. /**
  131683. * Creates a new LightInformationBlock
  131684. * @param name defines the block name
  131685. */
  131686. constructor(name: string);
  131687. /**
  131688. * Gets the current class name
  131689. * @returns the class name
  131690. */
  131691. getClassName(): string;
  131692. /**
  131693. * Gets the world position input component
  131694. */
  131695. get worldPosition(): NodeMaterialConnectionPoint;
  131696. /**
  131697. * Gets the direction output component
  131698. */
  131699. get direction(): NodeMaterialConnectionPoint;
  131700. /**
  131701. * Gets the direction output component
  131702. */
  131703. get color(): NodeMaterialConnectionPoint;
  131704. /**
  131705. * Gets the direction output component
  131706. */
  131707. get intensity(): NodeMaterialConnectionPoint;
  131708. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131709. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131710. protected _buildBlock(state: NodeMaterialBuildState): this;
  131711. serialize(): any;
  131712. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131713. }
  131714. }
  131715. declare module BABYLON {
  131716. /**
  131717. * Block used to add image processing support to fragment shader
  131718. */
  131719. export class ImageProcessingBlock extends NodeMaterialBlock {
  131720. /**
  131721. * Create a new ImageProcessingBlock
  131722. * @param name defines the block name
  131723. */
  131724. constructor(name: string);
  131725. /**
  131726. * Gets the current class name
  131727. * @returns the class name
  131728. */
  131729. getClassName(): string;
  131730. /**
  131731. * Gets the color input component
  131732. */
  131733. get color(): NodeMaterialConnectionPoint;
  131734. /**
  131735. * Gets the output component
  131736. */
  131737. get output(): NodeMaterialConnectionPoint;
  131738. /**
  131739. * Initialize the block and prepare the context for build
  131740. * @param state defines the state that will be used for the build
  131741. */
  131742. initialize(state: NodeMaterialBuildState): void;
  131743. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  131744. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131745. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131746. protected _buildBlock(state: NodeMaterialBuildState): this;
  131747. }
  131748. }
  131749. declare module BABYLON {
  131750. /**
  131751. * Block used to pertub normals based on a normal map
  131752. */
  131753. export class PerturbNormalBlock extends NodeMaterialBlock {
  131754. private _tangentSpaceParameterName;
  131755. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  131756. invertX: boolean;
  131757. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  131758. invertY: boolean;
  131759. /**
  131760. * Create a new PerturbNormalBlock
  131761. * @param name defines the block name
  131762. */
  131763. constructor(name: string);
  131764. /**
  131765. * Gets the current class name
  131766. * @returns the class name
  131767. */
  131768. getClassName(): string;
  131769. /**
  131770. * Gets the world position input component
  131771. */
  131772. get worldPosition(): NodeMaterialConnectionPoint;
  131773. /**
  131774. * Gets the world normal input component
  131775. */
  131776. get worldNormal(): NodeMaterialConnectionPoint;
  131777. /**
  131778. * Gets the world tangent input component
  131779. */
  131780. get worldTangent(): NodeMaterialConnectionPoint;
  131781. /**
  131782. * Gets the uv input component
  131783. */
  131784. get uv(): NodeMaterialConnectionPoint;
  131785. /**
  131786. * Gets the normal map color input component
  131787. */
  131788. get normalMapColor(): NodeMaterialConnectionPoint;
  131789. /**
  131790. * Gets the strength input component
  131791. */
  131792. get strength(): NodeMaterialConnectionPoint;
  131793. /**
  131794. * Gets the output component
  131795. */
  131796. get output(): NodeMaterialConnectionPoint;
  131797. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131798. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131799. autoConfigure(material: NodeMaterial): void;
  131800. protected _buildBlock(state: NodeMaterialBuildState): this;
  131801. protected _dumpPropertiesCode(): string;
  131802. serialize(): any;
  131803. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131804. }
  131805. }
  131806. declare module BABYLON {
  131807. /**
  131808. * Block used to discard a pixel if a value is smaller than a cutoff
  131809. */
  131810. export class DiscardBlock extends NodeMaterialBlock {
  131811. /**
  131812. * Create a new DiscardBlock
  131813. * @param name defines the block name
  131814. */
  131815. constructor(name: string);
  131816. /**
  131817. * Gets the current class name
  131818. * @returns the class name
  131819. */
  131820. getClassName(): string;
  131821. /**
  131822. * Gets the color input component
  131823. */
  131824. get value(): NodeMaterialConnectionPoint;
  131825. /**
  131826. * Gets the cutoff input component
  131827. */
  131828. get cutoff(): NodeMaterialConnectionPoint;
  131829. protected _buildBlock(state: NodeMaterialBuildState): this;
  131830. }
  131831. }
  131832. declare module BABYLON {
  131833. /**
  131834. * Block used to test if the fragment shader is front facing
  131835. */
  131836. export class FrontFacingBlock extends NodeMaterialBlock {
  131837. /**
  131838. * Creates a new FrontFacingBlock
  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 output component
  131849. */
  131850. get output(): NodeMaterialConnectionPoint;
  131851. protected _buildBlock(state: NodeMaterialBuildState): this;
  131852. }
  131853. }
  131854. declare module BABYLON {
  131855. /**
  131856. * Block used to get the derivative value on x and y of a given input
  131857. */
  131858. export class DerivativeBlock extends NodeMaterialBlock {
  131859. /**
  131860. * Create a new DerivativeBlock
  131861. * @param name defines the block name
  131862. */
  131863. constructor(name: string);
  131864. /**
  131865. * Gets the current class name
  131866. * @returns the class name
  131867. */
  131868. getClassName(): string;
  131869. /**
  131870. * Gets the input component
  131871. */
  131872. get input(): NodeMaterialConnectionPoint;
  131873. /**
  131874. * Gets the derivative output on x
  131875. */
  131876. get dx(): NodeMaterialConnectionPoint;
  131877. /**
  131878. * Gets the derivative output on y
  131879. */
  131880. get dy(): NodeMaterialConnectionPoint;
  131881. protected _buildBlock(state: NodeMaterialBuildState): this;
  131882. }
  131883. }
  131884. declare module BABYLON {
  131885. /**
  131886. * Block used to add support for scene fog
  131887. */
  131888. export class FogBlock extends NodeMaterialBlock {
  131889. private _fogDistanceName;
  131890. private _fogParameters;
  131891. /**
  131892. * Create a new FogBlock
  131893. * @param name defines the block name
  131894. */
  131895. constructor(name: string);
  131896. /**
  131897. * Gets the current class name
  131898. * @returns the class name
  131899. */
  131900. getClassName(): string;
  131901. /**
  131902. * Gets the world position input component
  131903. */
  131904. get worldPosition(): NodeMaterialConnectionPoint;
  131905. /**
  131906. * Gets the view input component
  131907. */
  131908. get view(): NodeMaterialConnectionPoint;
  131909. /**
  131910. * Gets the color input component
  131911. */
  131912. get input(): NodeMaterialConnectionPoint;
  131913. /**
  131914. * Gets the fog color input component
  131915. */
  131916. get fogColor(): NodeMaterialConnectionPoint;
  131917. /**
  131918. * Gets the output component
  131919. */
  131920. get output(): NodeMaterialConnectionPoint;
  131921. autoConfigure(material: NodeMaterial): void;
  131922. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131923. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131924. protected _buildBlock(state: NodeMaterialBuildState): this;
  131925. }
  131926. }
  131927. declare module BABYLON {
  131928. /**
  131929. * Block used to add light in the fragment shader
  131930. */
  131931. export class LightBlock extends NodeMaterialBlock {
  131932. private _lightId;
  131933. /**
  131934. * Gets or sets the light associated with this block
  131935. */
  131936. light: Nullable<Light>;
  131937. /**
  131938. * Create a new LightBlock
  131939. * @param name defines the block name
  131940. */
  131941. constructor(name: string);
  131942. /**
  131943. * Gets the current class name
  131944. * @returns the class name
  131945. */
  131946. getClassName(): string;
  131947. /**
  131948. * Gets the world position input component
  131949. */
  131950. get worldPosition(): NodeMaterialConnectionPoint;
  131951. /**
  131952. * Gets the world normal input component
  131953. */
  131954. get worldNormal(): NodeMaterialConnectionPoint;
  131955. /**
  131956. * Gets the camera (or eye) position component
  131957. */
  131958. get cameraPosition(): NodeMaterialConnectionPoint;
  131959. /**
  131960. * Gets the glossiness component
  131961. */
  131962. get glossiness(): NodeMaterialConnectionPoint;
  131963. /**
  131964. * Gets the glossinness power component
  131965. */
  131966. get glossPower(): NodeMaterialConnectionPoint;
  131967. /**
  131968. * Gets the diffuse color component
  131969. */
  131970. get diffuseColor(): NodeMaterialConnectionPoint;
  131971. /**
  131972. * Gets the specular color component
  131973. */
  131974. get specularColor(): NodeMaterialConnectionPoint;
  131975. /**
  131976. * Gets the diffuse output component
  131977. */
  131978. get diffuseOutput(): NodeMaterialConnectionPoint;
  131979. /**
  131980. * Gets the specular output component
  131981. */
  131982. get specularOutput(): NodeMaterialConnectionPoint;
  131983. /**
  131984. * Gets the shadow output component
  131985. */
  131986. get shadow(): NodeMaterialConnectionPoint;
  131987. autoConfigure(material: NodeMaterial): void;
  131988. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131989. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  131990. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131991. private _injectVertexCode;
  131992. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  131993. serialize(): any;
  131994. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131995. }
  131996. }
  131997. declare module BABYLON {
  131998. /**
  131999. * Block used to multiply 2 values
  132000. */
  132001. export class MultiplyBlock extends NodeMaterialBlock {
  132002. /**
  132003. * Creates a new MultiplyBlock
  132004. * @param name defines the block name
  132005. */
  132006. constructor(name: string);
  132007. /**
  132008. * Gets the current class name
  132009. * @returns the class name
  132010. */
  132011. getClassName(): string;
  132012. /**
  132013. * Gets the left operand input component
  132014. */
  132015. get left(): NodeMaterialConnectionPoint;
  132016. /**
  132017. * Gets the right operand input component
  132018. */
  132019. get right(): NodeMaterialConnectionPoint;
  132020. /**
  132021. * Gets the output component
  132022. */
  132023. get output(): NodeMaterialConnectionPoint;
  132024. protected _buildBlock(state: NodeMaterialBuildState): this;
  132025. }
  132026. }
  132027. declare module BABYLON {
  132028. /**
  132029. * Block used to add 2 vectors
  132030. */
  132031. export class AddBlock extends NodeMaterialBlock {
  132032. /**
  132033. * Creates a new AddBlock
  132034. * @param name defines the block name
  132035. */
  132036. constructor(name: string);
  132037. /**
  132038. * Gets the current class name
  132039. * @returns the class name
  132040. */
  132041. getClassName(): string;
  132042. /**
  132043. * Gets the left operand input component
  132044. */
  132045. get left(): NodeMaterialConnectionPoint;
  132046. /**
  132047. * Gets the right operand input component
  132048. */
  132049. get right(): NodeMaterialConnectionPoint;
  132050. /**
  132051. * Gets the output component
  132052. */
  132053. get output(): NodeMaterialConnectionPoint;
  132054. protected _buildBlock(state: NodeMaterialBuildState): this;
  132055. }
  132056. }
  132057. declare module BABYLON {
  132058. /**
  132059. * Block used to scale a vector by a float
  132060. */
  132061. export class ScaleBlock extends NodeMaterialBlock {
  132062. /**
  132063. * Creates a new ScaleBlock
  132064. * @param name defines the block name
  132065. */
  132066. constructor(name: string);
  132067. /**
  132068. * Gets the current class name
  132069. * @returns the class name
  132070. */
  132071. getClassName(): string;
  132072. /**
  132073. * Gets the input component
  132074. */
  132075. get input(): NodeMaterialConnectionPoint;
  132076. /**
  132077. * Gets the factor input component
  132078. */
  132079. get factor(): NodeMaterialConnectionPoint;
  132080. /**
  132081. * Gets the output component
  132082. */
  132083. get output(): NodeMaterialConnectionPoint;
  132084. protected _buildBlock(state: NodeMaterialBuildState): this;
  132085. }
  132086. }
  132087. declare module BABYLON {
  132088. /**
  132089. * Block used to clamp a float
  132090. */
  132091. export class ClampBlock extends NodeMaterialBlock {
  132092. /** Gets or sets the minimum range */
  132093. minimum: number;
  132094. /** Gets or sets the maximum range */
  132095. maximum: number;
  132096. /**
  132097. * Creates a new ClampBlock
  132098. * @param name defines the block name
  132099. */
  132100. constructor(name: string);
  132101. /**
  132102. * Gets the current class name
  132103. * @returns the class name
  132104. */
  132105. getClassName(): string;
  132106. /**
  132107. * Gets the value input component
  132108. */
  132109. get value(): NodeMaterialConnectionPoint;
  132110. /**
  132111. * Gets the output component
  132112. */
  132113. get output(): NodeMaterialConnectionPoint;
  132114. protected _buildBlock(state: NodeMaterialBuildState): this;
  132115. protected _dumpPropertiesCode(): string;
  132116. serialize(): any;
  132117. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132118. }
  132119. }
  132120. declare module BABYLON {
  132121. /**
  132122. * Block used to apply a cross product between 2 vectors
  132123. */
  132124. export class CrossBlock extends NodeMaterialBlock {
  132125. /**
  132126. * Creates a new CrossBlock
  132127. * @param name defines the block name
  132128. */
  132129. constructor(name: string);
  132130. /**
  132131. * Gets the current class name
  132132. * @returns the class name
  132133. */
  132134. getClassName(): string;
  132135. /**
  132136. * Gets the left operand input component
  132137. */
  132138. get left(): NodeMaterialConnectionPoint;
  132139. /**
  132140. * Gets the right operand input component
  132141. */
  132142. get right(): NodeMaterialConnectionPoint;
  132143. /**
  132144. * Gets the output component
  132145. */
  132146. get output(): NodeMaterialConnectionPoint;
  132147. protected _buildBlock(state: NodeMaterialBuildState): this;
  132148. }
  132149. }
  132150. declare module BABYLON {
  132151. /**
  132152. * Block used to apply a dot product between 2 vectors
  132153. */
  132154. export class DotBlock extends NodeMaterialBlock {
  132155. /**
  132156. * Creates a new DotBlock
  132157. * @param name defines the block name
  132158. */
  132159. constructor(name: string);
  132160. /**
  132161. * Gets the current class name
  132162. * @returns the class name
  132163. */
  132164. getClassName(): string;
  132165. /**
  132166. * Gets the left operand input component
  132167. */
  132168. get left(): NodeMaterialConnectionPoint;
  132169. /**
  132170. * Gets the right operand input component
  132171. */
  132172. get right(): NodeMaterialConnectionPoint;
  132173. /**
  132174. * Gets the output component
  132175. */
  132176. get output(): NodeMaterialConnectionPoint;
  132177. protected _buildBlock(state: NodeMaterialBuildState): this;
  132178. }
  132179. }
  132180. declare module BABYLON {
  132181. /**
  132182. * Block used to remap a float from a range to a new one
  132183. */
  132184. export class RemapBlock extends NodeMaterialBlock {
  132185. /**
  132186. * Gets or sets the source range
  132187. */
  132188. sourceRange: Vector2;
  132189. /**
  132190. * Gets or sets the target range
  132191. */
  132192. targetRange: Vector2;
  132193. /**
  132194. * Creates a new RemapBlock
  132195. * @param name defines the block name
  132196. */
  132197. constructor(name: string);
  132198. /**
  132199. * Gets the current class name
  132200. * @returns the class name
  132201. */
  132202. getClassName(): string;
  132203. /**
  132204. * Gets the input component
  132205. */
  132206. get input(): NodeMaterialConnectionPoint;
  132207. /**
  132208. * Gets the source min input component
  132209. */
  132210. get sourceMin(): NodeMaterialConnectionPoint;
  132211. /**
  132212. * Gets the source max input component
  132213. */
  132214. get sourceMax(): NodeMaterialConnectionPoint;
  132215. /**
  132216. * Gets the target min input component
  132217. */
  132218. get targetMin(): NodeMaterialConnectionPoint;
  132219. /**
  132220. * Gets the target max input component
  132221. */
  132222. get targetMax(): NodeMaterialConnectionPoint;
  132223. /**
  132224. * Gets the output component
  132225. */
  132226. get output(): NodeMaterialConnectionPoint;
  132227. protected _buildBlock(state: NodeMaterialBuildState): this;
  132228. protected _dumpPropertiesCode(): string;
  132229. serialize(): any;
  132230. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132231. }
  132232. }
  132233. declare module BABYLON {
  132234. /**
  132235. * Block used to normalize a vector
  132236. */
  132237. export class NormalizeBlock extends NodeMaterialBlock {
  132238. /**
  132239. * Creates a new NormalizeBlock
  132240. * @param name defines the block name
  132241. */
  132242. constructor(name: string);
  132243. /**
  132244. * Gets the current class name
  132245. * @returns the class name
  132246. */
  132247. getClassName(): string;
  132248. /**
  132249. * Gets the input component
  132250. */
  132251. get input(): NodeMaterialConnectionPoint;
  132252. /**
  132253. * Gets the output component
  132254. */
  132255. get output(): NodeMaterialConnectionPoint;
  132256. protected _buildBlock(state: NodeMaterialBuildState): this;
  132257. }
  132258. }
  132259. declare module BABYLON {
  132260. /**
  132261. * Operations supported by the Trigonometry block
  132262. */
  132263. export enum TrigonometryBlockOperations {
  132264. /** Cos */
  132265. Cos = 0,
  132266. /** Sin */
  132267. Sin = 1,
  132268. /** Abs */
  132269. Abs = 2,
  132270. /** Exp */
  132271. Exp = 3,
  132272. /** Exp2 */
  132273. Exp2 = 4,
  132274. /** Round */
  132275. Round = 5,
  132276. /** Floor */
  132277. Floor = 6,
  132278. /** Ceiling */
  132279. Ceiling = 7,
  132280. /** Square root */
  132281. Sqrt = 8,
  132282. /** Log */
  132283. Log = 9,
  132284. /** Tangent */
  132285. Tan = 10,
  132286. /** Arc tangent */
  132287. ArcTan = 11,
  132288. /** Arc cosinus */
  132289. ArcCos = 12,
  132290. /** Arc sinus */
  132291. ArcSin = 13,
  132292. /** Fraction */
  132293. Fract = 14,
  132294. /** Sign */
  132295. Sign = 15,
  132296. /** To radians (from degrees) */
  132297. Radians = 16,
  132298. /** To degrees (from radians) */
  132299. Degrees = 17
  132300. }
  132301. /**
  132302. * Block used to apply trigonometry operation to floats
  132303. */
  132304. export class TrigonometryBlock extends NodeMaterialBlock {
  132305. /**
  132306. * Gets or sets the operation applied by the block
  132307. */
  132308. operation: TrigonometryBlockOperations;
  132309. /**
  132310. * Creates a new TrigonometryBlock
  132311. * @param name defines the block name
  132312. */
  132313. constructor(name: string);
  132314. /**
  132315. * Gets the current class name
  132316. * @returns the class name
  132317. */
  132318. getClassName(): string;
  132319. /**
  132320. * Gets the input component
  132321. */
  132322. get input(): NodeMaterialConnectionPoint;
  132323. /**
  132324. * Gets the output component
  132325. */
  132326. get output(): NodeMaterialConnectionPoint;
  132327. protected _buildBlock(state: NodeMaterialBuildState): this;
  132328. serialize(): any;
  132329. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132330. protected _dumpPropertiesCode(): string;
  132331. }
  132332. }
  132333. declare module BABYLON {
  132334. /**
  132335. * Block used to create a Color3/4 out of individual inputs (one for each component)
  132336. */
  132337. export class ColorMergerBlock extends NodeMaterialBlock {
  132338. /**
  132339. * Create a new ColorMergerBlock
  132340. * @param name defines the block name
  132341. */
  132342. constructor(name: string);
  132343. /**
  132344. * Gets the current class name
  132345. * @returns the class name
  132346. */
  132347. getClassName(): string;
  132348. /**
  132349. * Gets the rgb component (input)
  132350. */
  132351. get rgbIn(): NodeMaterialConnectionPoint;
  132352. /**
  132353. * Gets the r component (input)
  132354. */
  132355. get r(): NodeMaterialConnectionPoint;
  132356. /**
  132357. * Gets the g component (input)
  132358. */
  132359. get g(): NodeMaterialConnectionPoint;
  132360. /**
  132361. * Gets the b component (input)
  132362. */
  132363. get b(): NodeMaterialConnectionPoint;
  132364. /**
  132365. * Gets the a component (input)
  132366. */
  132367. get a(): NodeMaterialConnectionPoint;
  132368. /**
  132369. * Gets the rgba component (output)
  132370. */
  132371. get rgba(): NodeMaterialConnectionPoint;
  132372. /**
  132373. * Gets the rgb component (output)
  132374. */
  132375. get rgbOut(): NodeMaterialConnectionPoint;
  132376. /**
  132377. * Gets the rgb component (output)
  132378. * @deprecated Please use rgbOut instead.
  132379. */
  132380. get rgb(): NodeMaterialConnectionPoint;
  132381. protected _buildBlock(state: NodeMaterialBuildState): this;
  132382. }
  132383. }
  132384. declare module BABYLON {
  132385. /**
  132386. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  132387. */
  132388. export class VectorMergerBlock extends NodeMaterialBlock {
  132389. /**
  132390. * Create a new VectorMergerBlock
  132391. * @param name defines the block name
  132392. */
  132393. constructor(name: string);
  132394. /**
  132395. * Gets the current class name
  132396. * @returns the class name
  132397. */
  132398. getClassName(): string;
  132399. /**
  132400. * Gets the xyz component (input)
  132401. */
  132402. get xyzIn(): NodeMaterialConnectionPoint;
  132403. /**
  132404. * Gets the xy component (input)
  132405. */
  132406. get xyIn(): NodeMaterialConnectionPoint;
  132407. /**
  132408. * Gets the x component (input)
  132409. */
  132410. get x(): NodeMaterialConnectionPoint;
  132411. /**
  132412. * Gets the y component (input)
  132413. */
  132414. get y(): NodeMaterialConnectionPoint;
  132415. /**
  132416. * Gets the z component (input)
  132417. */
  132418. get z(): NodeMaterialConnectionPoint;
  132419. /**
  132420. * Gets the w component (input)
  132421. */
  132422. get w(): NodeMaterialConnectionPoint;
  132423. /**
  132424. * Gets the xyzw component (output)
  132425. */
  132426. get xyzw(): NodeMaterialConnectionPoint;
  132427. /**
  132428. * Gets the xyz component (output)
  132429. */
  132430. get xyzOut(): NodeMaterialConnectionPoint;
  132431. /**
  132432. * Gets the xy component (output)
  132433. */
  132434. get xyOut(): NodeMaterialConnectionPoint;
  132435. /**
  132436. * Gets the xy component (output)
  132437. * @deprecated Please use xyOut instead.
  132438. */
  132439. get xy(): NodeMaterialConnectionPoint;
  132440. /**
  132441. * Gets the xyz component (output)
  132442. * @deprecated Please use xyzOut instead.
  132443. */
  132444. get xyz(): NodeMaterialConnectionPoint;
  132445. protected _buildBlock(state: NodeMaterialBuildState): this;
  132446. }
  132447. }
  132448. declare module BABYLON {
  132449. /**
  132450. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  132451. */
  132452. export class ColorSplitterBlock extends NodeMaterialBlock {
  132453. /**
  132454. * Create a new ColorSplitterBlock
  132455. * @param name defines the block name
  132456. */
  132457. constructor(name: string);
  132458. /**
  132459. * Gets the current class name
  132460. * @returns the class name
  132461. */
  132462. getClassName(): string;
  132463. /**
  132464. * Gets the rgba component (input)
  132465. */
  132466. get rgba(): NodeMaterialConnectionPoint;
  132467. /**
  132468. * Gets the rgb component (input)
  132469. */
  132470. get rgbIn(): NodeMaterialConnectionPoint;
  132471. /**
  132472. * Gets the rgb component (output)
  132473. */
  132474. get rgbOut(): NodeMaterialConnectionPoint;
  132475. /**
  132476. * Gets the r component (output)
  132477. */
  132478. get r(): NodeMaterialConnectionPoint;
  132479. /**
  132480. * Gets the g component (output)
  132481. */
  132482. get g(): NodeMaterialConnectionPoint;
  132483. /**
  132484. * Gets the b component (output)
  132485. */
  132486. get b(): NodeMaterialConnectionPoint;
  132487. /**
  132488. * Gets the a component (output)
  132489. */
  132490. get a(): NodeMaterialConnectionPoint;
  132491. protected _inputRename(name: string): string;
  132492. protected _outputRename(name: string): string;
  132493. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  132494. }
  132495. }
  132496. declare module BABYLON {
  132497. /**
  132498. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  132499. */
  132500. export class VectorSplitterBlock extends NodeMaterialBlock {
  132501. /**
  132502. * Create a new VectorSplitterBlock
  132503. * @param name defines the block name
  132504. */
  132505. constructor(name: string);
  132506. /**
  132507. * Gets the current class name
  132508. * @returns the class name
  132509. */
  132510. getClassName(): string;
  132511. /**
  132512. * Gets the xyzw component (input)
  132513. */
  132514. get xyzw(): NodeMaterialConnectionPoint;
  132515. /**
  132516. * Gets the xyz component (input)
  132517. */
  132518. get xyzIn(): NodeMaterialConnectionPoint;
  132519. /**
  132520. * Gets the xy component (input)
  132521. */
  132522. get xyIn(): NodeMaterialConnectionPoint;
  132523. /**
  132524. * Gets the xyz component (output)
  132525. */
  132526. get xyzOut(): NodeMaterialConnectionPoint;
  132527. /**
  132528. * Gets the xy component (output)
  132529. */
  132530. get xyOut(): NodeMaterialConnectionPoint;
  132531. /**
  132532. * Gets the x component (output)
  132533. */
  132534. get x(): NodeMaterialConnectionPoint;
  132535. /**
  132536. * Gets the y component (output)
  132537. */
  132538. get y(): NodeMaterialConnectionPoint;
  132539. /**
  132540. * Gets the z component (output)
  132541. */
  132542. get z(): NodeMaterialConnectionPoint;
  132543. /**
  132544. * Gets the w component (output)
  132545. */
  132546. get w(): NodeMaterialConnectionPoint;
  132547. protected _inputRename(name: string): string;
  132548. protected _outputRename(name: string): string;
  132549. protected _buildBlock(state: NodeMaterialBuildState): this;
  132550. }
  132551. }
  132552. declare module BABYLON {
  132553. /**
  132554. * Block used to lerp between 2 values
  132555. */
  132556. export class LerpBlock extends NodeMaterialBlock {
  132557. /**
  132558. * Creates a new LerpBlock
  132559. * @param name defines the block name
  132560. */
  132561. constructor(name: string);
  132562. /**
  132563. * Gets the current class name
  132564. * @returns the class name
  132565. */
  132566. getClassName(): string;
  132567. /**
  132568. * Gets the left operand input component
  132569. */
  132570. get left(): NodeMaterialConnectionPoint;
  132571. /**
  132572. * Gets the right operand input component
  132573. */
  132574. get right(): NodeMaterialConnectionPoint;
  132575. /**
  132576. * Gets the gradient operand input component
  132577. */
  132578. get gradient(): NodeMaterialConnectionPoint;
  132579. /**
  132580. * Gets the output component
  132581. */
  132582. get output(): NodeMaterialConnectionPoint;
  132583. protected _buildBlock(state: NodeMaterialBuildState): this;
  132584. }
  132585. }
  132586. declare module BABYLON {
  132587. /**
  132588. * Block used to divide 2 vectors
  132589. */
  132590. export class DivideBlock extends NodeMaterialBlock {
  132591. /**
  132592. * Creates a new DivideBlock
  132593. * @param name defines the block name
  132594. */
  132595. constructor(name: string);
  132596. /**
  132597. * Gets the current class name
  132598. * @returns the class name
  132599. */
  132600. getClassName(): string;
  132601. /**
  132602. * Gets the left operand input component
  132603. */
  132604. get left(): NodeMaterialConnectionPoint;
  132605. /**
  132606. * Gets the right operand input component
  132607. */
  132608. get right(): NodeMaterialConnectionPoint;
  132609. /**
  132610. * Gets the output component
  132611. */
  132612. get output(): NodeMaterialConnectionPoint;
  132613. protected _buildBlock(state: NodeMaterialBuildState): this;
  132614. }
  132615. }
  132616. declare module BABYLON {
  132617. /**
  132618. * Block used to subtract 2 vectors
  132619. */
  132620. export class SubtractBlock extends NodeMaterialBlock {
  132621. /**
  132622. * Creates a new SubtractBlock
  132623. * @param name defines the block name
  132624. */
  132625. constructor(name: string);
  132626. /**
  132627. * Gets the current class name
  132628. * @returns the class name
  132629. */
  132630. getClassName(): string;
  132631. /**
  132632. * Gets the left operand input component
  132633. */
  132634. get left(): NodeMaterialConnectionPoint;
  132635. /**
  132636. * Gets the right operand input component
  132637. */
  132638. get right(): NodeMaterialConnectionPoint;
  132639. /**
  132640. * Gets the output component
  132641. */
  132642. get output(): NodeMaterialConnectionPoint;
  132643. protected _buildBlock(state: NodeMaterialBuildState): this;
  132644. }
  132645. }
  132646. declare module BABYLON {
  132647. /**
  132648. * Block used to step a value
  132649. */
  132650. export class StepBlock extends NodeMaterialBlock {
  132651. /**
  132652. * Creates a new StepBlock
  132653. * @param name defines the block name
  132654. */
  132655. constructor(name: string);
  132656. /**
  132657. * Gets the current class name
  132658. * @returns the class name
  132659. */
  132660. getClassName(): string;
  132661. /**
  132662. * Gets the value operand input component
  132663. */
  132664. get value(): NodeMaterialConnectionPoint;
  132665. /**
  132666. * Gets the edge operand input component
  132667. */
  132668. get edge(): NodeMaterialConnectionPoint;
  132669. /**
  132670. * Gets the output component
  132671. */
  132672. get output(): NodeMaterialConnectionPoint;
  132673. protected _buildBlock(state: NodeMaterialBuildState): this;
  132674. }
  132675. }
  132676. declare module BABYLON {
  132677. /**
  132678. * Block used to get the opposite (1 - x) of a value
  132679. */
  132680. export class OneMinusBlock extends NodeMaterialBlock {
  132681. /**
  132682. * Creates a new OneMinusBlock
  132683. * @param name defines the block name
  132684. */
  132685. constructor(name: string);
  132686. /**
  132687. * Gets the current class name
  132688. * @returns the class name
  132689. */
  132690. getClassName(): string;
  132691. /**
  132692. * Gets the input component
  132693. */
  132694. get input(): NodeMaterialConnectionPoint;
  132695. /**
  132696. * Gets the output component
  132697. */
  132698. get output(): NodeMaterialConnectionPoint;
  132699. protected _buildBlock(state: NodeMaterialBuildState): this;
  132700. }
  132701. }
  132702. declare module BABYLON {
  132703. /**
  132704. * Block used to get the view direction
  132705. */
  132706. export class ViewDirectionBlock extends NodeMaterialBlock {
  132707. /**
  132708. * Creates a new ViewDirectionBlock
  132709. * @param name defines the block name
  132710. */
  132711. constructor(name: string);
  132712. /**
  132713. * Gets the current class name
  132714. * @returns the class name
  132715. */
  132716. getClassName(): string;
  132717. /**
  132718. * Gets the world position component
  132719. */
  132720. get worldPosition(): NodeMaterialConnectionPoint;
  132721. /**
  132722. * Gets the camera position component
  132723. */
  132724. get cameraPosition(): NodeMaterialConnectionPoint;
  132725. /**
  132726. * Gets the output component
  132727. */
  132728. get output(): NodeMaterialConnectionPoint;
  132729. autoConfigure(material: NodeMaterial): void;
  132730. protected _buildBlock(state: NodeMaterialBuildState): this;
  132731. }
  132732. }
  132733. declare module BABYLON {
  132734. /**
  132735. * Block used to compute fresnel value
  132736. */
  132737. export class FresnelBlock extends NodeMaterialBlock {
  132738. /**
  132739. * Create a new FresnelBlock
  132740. * @param name defines the block name
  132741. */
  132742. constructor(name: string);
  132743. /**
  132744. * Gets the current class name
  132745. * @returns the class name
  132746. */
  132747. getClassName(): string;
  132748. /**
  132749. * Gets the world normal input component
  132750. */
  132751. get worldNormal(): NodeMaterialConnectionPoint;
  132752. /**
  132753. * Gets the view direction input component
  132754. */
  132755. get viewDirection(): NodeMaterialConnectionPoint;
  132756. /**
  132757. * Gets the bias input component
  132758. */
  132759. get bias(): NodeMaterialConnectionPoint;
  132760. /**
  132761. * Gets the camera (or eye) position component
  132762. */
  132763. get power(): NodeMaterialConnectionPoint;
  132764. /**
  132765. * Gets the fresnel output component
  132766. */
  132767. get fresnel(): NodeMaterialConnectionPoint;
  132768. autoConfigure(material: NodeMaterial): void;
  132769. protected _buildBlock(state: NodeMaterialBuildState): this;
  132770. }
  132771. }
  132772. declare module BABYLON {
  132773. /**
  132774. * Block used to get the max of 2 values
  132775. */
  132776. export class MaxBlock extends NodeMaterialBlock {
  132777. /**
  132778. * Creates a new MaxBlock
  132779. * @param name defines the block name
  132780. */
  132781. constructor(name: string);
  132782. /**
  132783. * Gets the current class name
  132784. * @returns the class name
  132785. */
  132786. getClassName(): string;
  132787. /**
  132788. * Gets the left operand input component
  132789. */
  132790. get left(): NodeMaterialConnectionPoint;
  132791. /**
  132792. * Gets the right operand input component
  132793. */
  132794. get right(): NodeMaterialConnectionPoint;
  132795. /**
  132796. * Gets the output component
  132797. */
  132798. get output(): NodeMaterialConnectionPoint;
  132799. protected _buildBlock(state: NodeMaterialBuildState): this;
  132800. }
  132801. }
  132802. declare module BABYLON {
  132803. /**
  132804. * Block used to get the min of 2 values
  132805. */
  132806. export class MinBlock extends NodeMaterialBlock {
  132807. /**
  132808. * Creates a new MinBlock
  132809. * @param name defines the block name
  132810. */
  132811. constructor(name: string);
  132812. /**
  132813. * Gets the current class name
  132814. * @returns the class name
  132815. */
  132816. getClassName(): string;
  132817. /**
  132818. * Gets the left operand input component
  132819. */
  132820. get left(): NodeMaterialConnectionPoint;
  132821. /**
  132822. * Gets the right operand input component
  132823. */
  132824. get right(): NodeMaterialConnectionPoint;
  132825. /**
  132826. * Gets the output component
  132827. */
  132828. get output(): NodeMaterialConnectionPoint;
  132829. protected _buildBlock(state: NodeMaterialBuildState): this;
  132830. }
  132831. }
  132832. declare module BABYLON {
  132833. /**
  132834. * Block used to get the distance between 2 values
  132835. */
  132836. export class DistanceBlock extends NodeMaterialBlock {
  132837. /**
  132838. * Creates a new DistanceBlock
  132839. * @param name defines the block name
  132840. */
  132841. constructor(name: string);
  132842. /**
  132843. * Gets the current class name
  132844. * @returns the class name
  132845. */
  132846. getClassName(): string;
  132847. /**
  132848. * Gets the left operand input component
  132849. */
  132850. get left(): NodeMaterialConnectionPoint;
  132851. /**
  132852. * Gets the right operand input component
  132853. */
  132854. get right(): NodeMaterialConnectionPoint;
  132855. /**
  132856. * Gets the output component
  132857. */
  132858. get output(): NodeMaterialConnectionPoint;
  132859. protected _buildBlock(state: NodeMaterialBuildState): this;
  132860. }
  132861. }
  132862. declare module BABYLON {
  132863. /**
  132864. * Block used to get the length of a vector
  132865. */
  132866. export class LengthBlock extends NodeMaterialBlock {
  132867. /**
  132868. * Creates a new LengthBlock
  132869. * @param name defines the block name
  132870. */
  132871. constructor(name: string);
  132872. /**
  132873. * Gets the current class name
  132874. * @returns the class name
  132875. */
  132876. getClassName(): string;
  132877. /**
  132878. * Gets the value input component
  132879. */
  132880. get value(): NodeMaterialConnectionPoint;
  132881. /**
  132882. * Gets the output component
  132883. */
  132884. get output(): NodeMaterialConnectionPoint;
  132885. protected _buildBlock(state: NodeMaterialBuildState): this;
  132886. }
  132887. }
  132888. declare module BABYLON {
  132889. /**
  132890. * Block used to get negative version of a value (i.e. x * -1)
  132891. */
  132892. export class NegateBlock extends NodeMaterialBlock {
  132893. /**
  132894. * Creates a new NegateBlock
  132895. * @param name defines the block name
  132896. */
  132897. constructor(name: string);
  132898. /**
  132899. * Gets the current class name
  132900. * @returns the class name
  132901. */
  132902. getClassName(): string;
  132903. /**
  132904. * Gets the value input component
  132905. */
  132906. get value(): NodeMaterialConnectionPoint;
  132907. /**
  132908. * Gets the output component
  132909. */
  132910. get output(): NodeMaterialConnectionPoint;
  132911. protected _buildBlock(state: NodeMaterialBuildState): this;
  132912. }
  132913. }
  132914. declare module BABYLON {
  132915. /**
  132916. * Block used to get the value of the first parameter raised to the power of the second
  132917. */
  132918. export class PowBlock extends NodeMaterialBlock {
  132919. /**
  132920. * Creates a new PowBlock
  132921. * @param name defines the block name
  132922. */
  132923. constructor(name: string);
  132924. /**
  132925. * Gets the current class name
  132926. * @returns the class name
  132927. */
  132928. getClassName(): string;
  132929. /**
  132930. * Gets the value operand input component
  132931. */
  132932. get value(): NodeMaterialConnectionPoint;
  132933. /**
  132934. * Gets the power operand input component
  132935. */
  132936. get power(): NodeMaterialConnectionPoint;
  132937. /**
  132938. * Gets the output component
  132939. */
  132940. get output(): NodeMaterialConnectionPoint;
  132941. protected _buildBlock(state: NodeMaterialBuildState): this;
  132942. }
  132943. }
  132944. declare module BABYLON {
  132945. /**
  132946. * Block used to get a random number
  132947. */
  132948. export class RandomNumberBlock extends NodeMaterialBlock {
  132949. /**
  132950. * Creates a new RandomNumberBlock
  132951. * @param name defines the block name
  132952. */
  132953. constructor(name: string);
  132954. /**
  132955. * Gets the current class name
  132956. * @returns the class name
  132957. */
  132958. getClassName(): string;
  132959. /**
  132960. * Gets the seed input component
  132961. */
  132962. get seed(): NodeMaterialConnectionPoint;
  132963. /**
  132964. * Gets the output component
  132965. */
  132966. get output(): NodeMaterialConnectionPoint;
  132967. protected _buildBlock(state: NodeMaterialBuildState): this;
  132968. }
  132969. }
  132970. declare module BABYLON {
  132971. /**
  132972. * Block used to compute arc tangent of 2 values
  132973. */
  132974. export class ArcTan2Block extends NodeMaterialBlock {
  132975. /**
  132976. * Creates a new ArcTan2Block
  132977. * @param name defines the block name
  132978. */
  132979. constructor(name: string);
  132980. /**
  132981. * Gets the current class name
  132982. * @returns the class name
  132983. */
  132984. getClassName(): string;
  132985. /**
  132986. * Gets the x operand input component
  132987. */
  132988. get x(): NodeMaterialConnectionPoint;
  132989. /**
  132990. * Gets the y operand input component
  132991. */
  132992. get y(): NodeMaterialConnectionPoint;
  132993. /**
  132994. * Gets the output component
  132995. */
  132996. get output(): NodeMaterialConnectionPoint;
  132997. protected _buildBlock(state: NodeMaterialBuildState): this;
  132998. }
  132999. }
  133000. declare module BABYLON {
  133001. /**
  133002. * Block used to smooth step a value
  133003. */
  133004. export class SmoothStepBlock extends NodeMaterialBlock {
  133005. /**
  133006. * Creates a new SmoothStepBlock
  133007. * @param name defines the block name
  133008. */
  133009. constructor(name: string);
  133010. /**
  133011. * Gets the current class name
  133012. * @returns the class name
  133013. */
  133014. getClassName(): string;
  133015. /**
  133016. * Gets the value operand input component
  133017. */
  133018. get value(): NodeMaterialConnectionPoint;
  133019. /**
  133020. * Gets the first edge operand input component
  133021. */
  133022. get edge0(): NodeMaterialConnectionPoint;
  133023. /**
  133024. * Gets the second edge operand input component
  133025. */
  133026. get edge1(): NodeMaterialConnectionPoint;
  133027. /**
  133028. * Gets the output component
  133029. */
  133030. get output(): NodeMaterialConnectionPoint;
  133031. protected _buildBlock(state: NodeMaterialBuildState): this;
  133032. }
  133033. }
  133034. declare module BABYLON {
  133035. /**
  133036. * Block used to get the reciprocal (1 / x) of a value
  133037. */
  133038. export class ReciprocalBlock extends NodeMaterialBlock {
  133039. /**
  133040. * Creates a new ReciprocalBlock
  133041. * @param name defines the block name
  133042. */
  133043. constructor(name: string);
  133044. /**
  133045. * Gets the current class name
  133046. * @returns the class name
  133047. */
  133048. getClassName(): string;
  133049. /**
  133050. * Gets the input component
  133051. */
  133052. get input(): NodeMaterialConnectionPoint;
  133053. /**
  133054. * Gets the output component
  133055. */
  133056. get output(): NodeMaterialConnectionPoint;
  133057. protected _buildBlock(state: NodeMaterialBuildState): this;
  133058. }
  133059. }
  133060. declare module BABYLON {
  133061. /**
  133062. * Block used to replace a color by another one
  133063. */
  133064. export class ReplaceColorBlock extends NodeMaterialBlock {
  133065. /**
  133066. * Creates a new ReplaceColorBlock
  133067. * @param name defines the block name
  133068. */
  133069. constructor(name: string);
  133070. /**
  133071. * Gets the current class name
  133072. * @returns the class name
  133073. */
  133074. getClassName(): string;
  133075. /**
  133076. * Gets the value input component
  133077. */
  133078. get value(): NodeMaterialConnectionPoint;
  133079. /**
  133080. * Gets the reference input component
  133081. */
  133082. get reference(): NodeMaterialConnectionPoint;
  133083. /**
  133084. * Gets the distance input component
  133085. */
  133086. get distance(): NodeMaterialConnectionPoint;
  133087. /**
  133088. * Gets the replacement input component
  133089. */
  133090. get replacement(): NodeMaterialConnectionPoint;
  133091. /**
  133092. * Gets the output component
  133093. */
  133094. get output(): NodeMaterialConnectionPoint;
  133095. protected _buildBlock(state: NodeMaterialBuildState): this;
  133096. }
  133097. }
  133098. declare module BABYLON {
  133099. /**
  133100. * Block used to posterize a value
  133101. * @see https://en.wikipedia.org/wiki/Posterization
  133102. */
  133103. export class PosterizeBlock extends NodeMaterialBlock {
  133104. /**
  133105. * Creates a new PosterizeBlock
  133106. * @param name defines the block name
  133107. */
  133108. constructor(name: string);
  133109. /**
  133110. * Gets the current class name
  133111. * @returns the class name
  133112. */
  133113. getClassName(): string;
  133114. /**
  133115. * Gets the value input component
  133116. */
  133117. get value(): NodeMaterialConnectionPoint;
  133118. /**
  133119. * Gets the steps input component
  133120. */
  133121. get steps(): NodeMaterialConnectionPoint;
  133122. /**
  133123. * Gets the output component
  133124. */
  133125. get output(): NodeMaterialConnectionPoint;
  133126. protected _buildBlock(state: NodeMaterialBuildState): this;
  133127. }
  133128. }
  133129. declare module BABYLON {
  133130. /**
  133131. * Operations supported by the Wave block
  133132. */
  133133. export enum WaveBlockKind {
  133134. /** SawTooth */
  133135. SawTooth = 0,
  133136. /** Square */
  133137. Square = 1,
  133138. /** Triangle */
  133139. Triangle = 2
  133140. }
  133141. /**
  133142. * Block used to apply wave operation to floats
  133143. */
  133144. export class WaveBlock extends NodeMaterialBlock {
  133145. /**
  133146. * Gets or sets the kibnd of wave to be applied by the block
  133147. */
  133148. kind: WaveBlockKind;
  133149. /**
  133150. * Creates a new WaveBlock
  133151. * @param name defines the block name
  133152. */
  133153. constructor(name: string);
  133154. /**
  133155. * Gets the current class name
  133156. * @returns the class name
  133157. */
  133158. getClassName(): string;
  133159. /**
  133160. * Gets the input component
  133161. */
  133162. get input(): NodeMaterialConnectionPoint;
  133163. /**
  133164. * Gets the output component
  133165. */
  133166. get output(): NodeMaterialConnectionPoint;
  133167. protected _buildBlock(state: NodeMaterialBuildState): this;
  133168. serialize(): any;
  133169. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133170. }
  133171. }
  133172. declare module BABYLON {
  133173. /**
  133174. * Class used to store a color step for the GradientBlock
  133175. */
  133176. export class GradientBlockColorStep {
  133177. /**
  133178. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  133179. */
  133180. step: number;
  133181. /**
  133182. * Gets or sets the color associated with this step
  133183. */
  133184. color: Color3;
  133185. /**
  133186. * Creates a new GradientBlockColorStep
  133187. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  133188. * @param color defines the color associated with this step
  133189. */
  133190. constructor(
  133191. /**
  133192. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  133193. */
  133194. step: number,
  133195. /**
  133196. * Gets or sets the color associated with this step
  133197. */
  133198. color: Color3);
  133199. }
  133200. /**
  133201. * Block used to return a color from a gradient based on an input value between 0 and 1
  133202. */
  133203. export class GradientBlock extends NodeMaterialBlock {
  133204. /**
  133205. * Gets or sets the list of color steps
  133206. */
  133207. colorSteps: GradientBlockColorStep[];
  133208. /**
  133209. * Creates a new GradientBlock
  133210. * @param name defines the block name
  133211. */
  133212. constructor(name: string);
  133213. /**
  133214. * Gets the current class name
  133215. * @returns the class name
  133216. */
  133217. getClassName(): string;
  133218. /**
  133219. * Gets the gradient input component
  133220. */
  133221. get gradient(): NodeMaterialConnectionPoint;
  133222. /**
  133223. * Gets the output component
  133224. */
  133225. get output(): NodeMaterialConnectionPoint;
  133226. private _writeColorConstant;
  133227. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133228. serialize(): any;
  133229. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133230. protected _dumpPropertiesCode(): string;
  133231. }
  133232. }
  133233. declare module BABYLON {
  133234. /**
  133235. * Block used to normalize lerp between 2 values
  133236. */
  133237. export class NLerpBlock extends NodeMaterialBlock {
  133238. /**
  133239. * Creates a new NLerpBlock
  133240. * @param name defines the block name
  133241. */
  133242. constructor(name: string);
  133243. /**
  133244. * Gets the current class name
  133245. * @returns the class name
  133246. */
  133247. getClassName(): string;
  133248. /**
  133249. * Gets the left operand input component
  133250. */
  133251. get left(): NodeMaterialConnectionPoint;
  133252. /**
  133253. * Gets the right operand input component
  133254. */
  133255. get right(): NodeMaterialConnectionPoint;
  133256. /**
  133257. * Gets the gradient operand input component
  133258. */
  133259. get gradient(): NodeMaterialConnectionPoint;
  133260. /**
  133261. * Gets the output component
  133262. */
  133263. get output(): NodeMaterialConnectionPoint;
  133264. protected _buildBlock(state: NodeMaterialBuildState): this;
  133265. }
  133266. }
  133267. declare module BABYLON {
  133268. /**
  133269. * block used to Generate a Worley Noise 3D Noise Pattern
  133270. */
  133271. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  133272. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  133273. manhattanDistance: boolean;
  133274. /**
  133275. * Creates a new WorleyNoise3DBlock
  133276. * @param name defines the block name
  133277. */
  133278. constructor(name: string);
  133279. /**
  133280. * Gets the current class name
  133281. * @returns the class name
  133282. */
  133283. getClassName(): string;
  133284. /**
  133285. * Gets the seed input component
  133286. */
  133287. get seed(): NodeMaterialConnectionPoint;
  133288. /**
  133289. * Gets the jitter input component
  133290. */
  133291. get jitter(): NodeMaterialConnectionPoint;
  133292. /**
  133293. * Gets the output component
  133294. */
  133295. get output(): NodeMaterialConnectionPoint;
  133296. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133297. /**
  133298. * Exposes the properties to the UI?
  133299. */
  133300. protected _dumpPropertiesCode(): string;
  133301. /**
  133302. * Exposes the properties to the Seralize?
  133303. */
  133304. serialize(): any;
  133305. /**
  133306. * Exposes the properties to the deseralize?
  133307. */
  133308. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133309. }
  133310. }
  133311. declare module BABYLON {
  133312. /**
  133313. * block used to Generate a Simplex Perlin 3d Noise Pattern
  133314. */
  133315. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  133316. /**
  133317. * Creates a new SimplexPerlin3DBlock
  133318. * @param name defines the block name
  133319. */
  133320. constructor(name: string);
  133321. /**
  133322. * Gets the current class name
  133323. * @returns the class name
  133324. */
  133325. getClassName(): string;
  133326. /**
  133327. * Gets the seed operand input component
  133328. */
  133329. get seed(): NodeMaterialConnectionPoint;
  133330. /**
  133331. * Gets the output component
  133332. */
  133333. get output(): NodeMaterialConnectionPoint;
  133334. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133335. }
  133336. }
  133337. declare module BABYLON {
  133338. /**
  133339. * Block used to blend normals
  133340. */
  133341. export class NormalBlendBlock extends NodeMaterialBlock {
  133342. /**
  133343. * Creates a new NormalBlendBlock
  133344. * @param name defines the block name
  133345. */
  133346. constructor(name: string);
  133347. /**
  133348. * Gets the current class name
  133349. * @returns the class name
  133350. */
  133351. getClassName(): string;
  133352. /**
  133353. * Gets the first input component
  133354. */
  133355. get normalMap0(): NodeMaterialConnectionPoint;
  133356. /**
  133357. * Gets the second input component
  133358. */
  133359. get normalMap1(): NodeMaterialConnectionPoint;
  133360. /**
  133361. * Gets the output component
  133362. */
  133363. get output(): NodeMaterialConnectionPoint;
  133364. protected _buildBlock(state: NodeMaterialBuildState): this;
  133365. }
  133366. }
  133367. declare module BABYLON {
  133368. /**
  133369. * Block used to rotate a 2d vector by a given angle
  133370. */
  133371. export class Rotate2dBlock extends NodeMaterialBlock {
  133372. /**
  133373. * Creates a new Rotate2dBlock
  133374. * @param name defines the block name
  133375. */
  133376. constructor(name: string);
  133377. /**
  133378. * Gets the current class name
  133379. * @returns the class name
  133380. */
  133381. getClassName(): string;
  133382. /**
  133383. * Gets the input vector
  133384. */
  133385. get input(): NodeMaterialConnectionPoint;
  133386. /**
  133387. * Gets the input angle
  133388. */
  133389. get angle(): NodeMaterialConnectionPoint;
  133390. /**
  133391. * Gets the output component
  133392. */
  133393. get output(): NodeMaterialConnectionPoint;
  133394. autoConfigure(material: NodeMaterial): void;
  133395. protected _buildBlock(state: NodeMaterialBuildState): this;
  133396. }
  133397. }
  133398. declare module BABYLON {
  133399. /**
  133400. * Block used to get the reflected vector from a direction and a normal
  133401. */
  133402. export class ReflectBlock extends NodeMaterialBlock {
  133403. /**
  133404. * Creates a new ReflectBlock
  133405. * @param name defines the block name
  133406. */
  133407. constructor(name: string);
  133408. /**
  133409. * Gets the current class name
  133410. * @returns the class name
  133411. */
  133412. getClassName(): string;
  133413. /**
  133414. * Gets the incident component
  133415. */
  133416. get incident(): NodeMaterialConnectionPoint;
  133417. /**
  133418. * Gets the normal component
  133419. */
  133420. get normal(): NodeMaterialConnectionPoint;
  133421. /**
  133422. * Gets the output component
  133423. */
  133424. get output(): NodeMaterialConnectionPoint;
  133425. protected _buildBlock(state: NodeMaterialBuildState): this;
  133426. }
  133427. }
  133428. declare module BABYLON {
  133429. /**
  133430. * Block used to get the refracted vector from a direction and a normal
  133431. */
  133432. export class RefractBlock extends NodeMaterialBlock {
  133433. /**
  133434. * Creates a new RefractBlock
  133435. * @param name defines the block name
  133436. */
  133437. constructor(name: string);
  133438. /**
  133439. * Gets the current class name
  133440. * @returns the class name
  133441. */
  133442. getClassName(): string;
  133443. /**
  133444. * Gets the incident component
  133445. */
  133446. get incident(): NodeMaterialConnectionPoint;
  133447. /**
  133448. * Gets the normal component
  133449. */
  133450. get normal(): NodeMaterialConnectionPoint;
  133451. /**
  133452. * Gets the index of refraction component
  133453. */
  133454. get ior(): NodeMaterialConnectionPoint;
  133455. /**
  133456. * Gets the output component
  133457. */
  133458. get output(): NodeMaterialConnectionPoint;
  133459. protected _buildBlock(state: NodeMaterialBuildState): this;
  133460. }
  133461. }
  133462. declare module BABYLON {
  133463. /**
  133464. * Block used to desaturate a color
  133465. */
  133466. export class DesaturateBlock extends NodeMaterialBlock {
  133467. /**
  133468. * Creates a new DesaturateBlock
  133469. * @param name defines the block name
  133470. */
  133471. constructor(name: string);
  133472. /**
  133473. * Gets the current class name
  133474. * @returns the class name
  133475. */
  133476. getClassName(): string;
  133477. /**
  133478. * Gets the color operand input component
  133479. */
  133480. get color(): NodeMaterialConnectionPoint;
  133481. /**
  133482. * Gets the level operand input component
  133483. */
  133484. get level(): NodeMaterialConnectionPoint;
  133485. /**
  133486. * Gets the output component
  133487. */
  133488. get output(): NodeMaterialConnectionPoint;
  133489. protected _buildBlock(state: NodeMaterialBuildState): this;
  133490. }
  133491. }
  133492. declare module BABYLON {
  133493. /**
  133494. * Effect Render Options
  133495. */
  133496. export interface IEffectRendererOptions {
  133497. /**
  133498. * Defines the vertices positions.
  133499. */
  133500. positions?: number[];
  133501. /**
  133502. * Defines the indices.
  133503. */
  133504. indices?: number[];
  133505. }
  133506. /**
  133507. * Helper class to render one or more effects
  133508. */
  133509. export class EffectRenderer {
  133510. private engine;
  133511. private static _DefaultOptions;
  133512. private _vertexBuffers;
  133513. private _indexBuffer;
  133514. private _ringBufferIndex;
  133515. private _ringScreenBuffer;
  133516. private _fullscreenViewport;
  133517. private _getNextFrameBuffer;
  133518. /**
  133519. * Creates an effect renderer
  133520. * @param engine the engine to use for rendering
  133521. * @param options defines the options of the effect renderer
  133522. */
  133523. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  133524. /**
  133525. * Sets the current viewport in normalized coordinates 0-1
  133526. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  133527. */
  133528. setViewport(viewport?: Viewport): void;
  133529. /**
  133530. * Binds the embedded attributes buffer to the effect.
  133531. * @param effect Defines the effect to bind the attributes for
  133532. */
  133533. bindBuffers(effect: Effect): void;
  133534. /**
  133535. * Sets the current effect wrapper to use during draw.
  133536. * The effect needs to be ready before calling this api.
  133537. * This also sets the default full screen position attribute.
  133538. * @param effectWrapper Defines the effect to draw with
  133539. */
  133540. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  133541. /**
  133542. * Draws a full screen quad.
  133543. */
  133544. draw(): void;
  133545. /**
  133546. * renders one or more effects to a specified texture
  133547. * @param effectWrappers list of effects to renderer
  133548. * @param outputTexture texture to draw to, if null it will render to the screen
  133549. */
  133550. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  133551. /**
  133552. * Disposes of the effect renderer
  133553. */
  133554. dispose(): void;
  133555. }
  133556. /**
  133557. * Options to create an EffectWrapper
  133558. */
  133559. interface EffectWrapperCreationOptions {
  133560. /**
  133561. * Engine to use to create the effect
  133562. */
  133563. engine: ThinEngine;
  133564. /**
  133565. * Fragment shader for the effect
  133566. */
  133567. fragmentShader: string;
  133568. /**
  133569. * Vertex shader for the effect
  133570. */
  133571. vertexShader?: string;
  133572. /**
  133573. * Attributes to use in the shader
  133574. */
  133575. attributeNames?: Array<string>;
  133576. /**
  133577. * Uniforms to use in the shader
  133578. */
  133579. uniformNames?: Array<string>;
  133580. /**
  133581. * Texture sampler names to use in the shader
  133582. */
  133583. samplerNames?: Array<string>;
  133584. /**
  133585. * The friendly name of the effect displayed in Spector.
  133586. */
  133587. name?: string;
  133588. }
  133589. /**
  133590. * Wraps an effect to be used for rendering
  133591. */
  133592. export class EffectWrapper {
  133593. /**
  133594. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  133595. */
  133596. onApplyObservable: Observable<{}>;
  133597. /**
  133598. * The underlying effect
  133599. */
  133600. effect: Effect;
  133601. /**
  133602. * Creates an effect to be renderer
  133603. * @param creationOptions options to create the effect
  133604. */
  133605. constructor(creationOptions: EffectWrapperCreationOptions);
  133606. /**
  133607. * Disposes of the effect wrapper
  133608. */
  133609. dispose(): void;
  133610. }
  133611. }
  133612. declare module BABYLON {
  133613. /**
  133614. * Helper class to push actions to a pool of workers.
  133615. */
  133616. export class WorkerPool implements IDisposable {
  133617. private _workerInfos;
  133618. private _pendingActions;
  133619. /**
  133620. * Constructor
  133621. * @param workers Array of workers to use for actions
  133622. */
  133623. constructor(workers: Array<Worker>);
  133624. /**
  133625. * Terminates all workers and clears any pending actions.
  133626. */
  133627. dispose(): void;
  133628. /**
  133629. * Pushes an action to the worker pool. If all the workers are active, the action will be
  133630. * pended until a worker has completed its action.
  133631. * @param action The action to perform. Call onComplete when the action is complete.
  133632. */
  133633. push(action: (worker: Worker, onComplete: () => void) => void): void;
  133634. private _execute;
  133635. }
  133636. }
  133637. declare module BABYLON {
  133638. /**
  133639. * Configuration for Draco compression
  133640. */
  133641. export interface IDracoCompressionConfiguration {
  133642. /**
  133643. * Configuration for the decoder.
  133644. */
  133645. decoder: {
  133646. /**
  133647. * The url to the WebAssembly module.
  133648. */
  133649. wasmUrl?: string;
  133650. /**
  133651. * The url to the WebAssembly binary.
  133652. */
  133653. wasmBinaryUrl?: string;
  133654. /**
  133655. * The url to the fallback JavaScript module.
  133656. */
  133657. fallbackUrl?: string;
  133658. };
  133659. }
  133660. /**
  133661. * Draco compression (https://google.github.io/draco/)
  133662. *
  133663. * This class wraps the Draco module.
  133664. *
  133665. * **Encoder**
  133666. *
  133667. * The encoder is not currently implemented.
  133668. *
  133669. * **Decoder**
  133670. *
  133671. * 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.
  133672. *
  133673. * To update the configuration, use the following code:
  133674. * ```javascript
  133675. * DracoCompression.Configuration = {
  133676. * decoder: {
  133677. * wasmUrl: "<url to the WebAssembly library>",
  133678. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  133679. * fallbackUrl: "<url to the fallback JavaScript library>",
  133680. * }
  133681. * };
  133682. * ```
  133683. *
  133684. * 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.
  133685. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  133686. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  133687. *
  133688. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  133689. * ```javascript
  133690. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  133691. * ```
  133692. *
  133693. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  133694. */
  133695. export class DracoCompression implements IDisposable {
  133696. private _workerPoolPromise?;
  133697. private _decoderModulePromise?;
  133698. /**
  133699. * The configuration. Defaults to the following urls:
  133700. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  133701. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  133702. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  133703. */
  133704. static Configuration: IDracoCompressionConfiguration;
  133705. /**
  133706. * Returns true if the decoder configuration is available.
  133707. */
  133708. static get DecoderAvailable(): boolean;
  133709. /**
  133710. * Default number of workers to create when creating the draco compression object.
  133711. */
  133712. static DefaultNumWorkers: number;
  133713. private static GetDefaultNumWorkers;
  133714. private static _Default;
  133715. /**
  133716. * Default instance for the draco compression object.
  133717. */
  133718. static get Default(): DracoCompression;
  133719. /**
  133720. * Constructor
  133721. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  133722. */
  133723. constructor(numWorkers?: number);
  133724. /**
  133725. * Stop all async operations and release resources.
  133726. */
  133727. dispose(): void;
  133728. /**
  133729. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  133730. * @returns a promise that resolves when ready
  133731. */
  133732. whenReadyAsync(): Promise<void>;
  133733. /**
  133734. * Decode Draco compressed mesh data to vertex data.
  133735. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  133736. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  133737. * @returns A promise that resolves with the decoded vertex data
  133738. */
  133739. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  133740. [kind: string]: number;
  133741. }): Promise<VertexData>;
  133742. }
  133743. }
  133744. declare module BABYLON {
  133745. /**
  133746. * Class for building Constructive Solid Geometry
  133747. */
  133748. export class CSG {
  133749. private polygons;
  133750. /**
  133751. * The world matrix
  133752. */
  133753. matrix: Matrix;
  133754. /**
  133755. * Stores the position
  133756. */
  133757. position: Vector3;
  133758. /**
  133759. * Stores the rotation
  133760. */
  133761. rotation: Vector3;
  133762. /**
  133763. * Stores the rotation quaternion
  133764. */
  133765. rotationQuaternion: Nullable<Quaternion>;
  133766. /**
  133767. * Stores the scaling vector
  133768. */
  133769. scaling: Vector3;
  133770. /**
  133771. * Convert the Mesh to CSG
  133772. * @param mesh The Mesh to convert to CSG
  133773. * @returns A new CSG from the Mesh
  133774. */
  133775. static FromMesh(mesh: Mesh): CSG;
  133776. /**
  133777. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  133778. * @param polygons Polygons used to construct a CSG solid
  133779. */
  133780. private static FromPolygons;
  133781. /**
  133782. * Clones, or makes a deep copy, of the CSG
  133783. * @returns A new CSG
  133784. */
  133785. clone(): CSG;
  133786. /**
  133787. * Unions this CSG with another CSG
  133788. * @param csg The CSG to union against this CSG
  133789. * @returns The unioned CSG
  133790. */
  133791. union(csg: CSG): CSG;
  133792. /**
  133793. * Unions this CSG with another CSG in place
  133794. * @param csg The CSG to union against this CSG
  133795. */
  133796. unionInPlace(csg: CSG): void;
  133797. /**
  133798. * Subtracts this CSG with another CSG
  133799. * @param csg The CSG to subtract against this CSG
  133800. * @returns A new CSG
  133801. */
  133802. subtract(csg: CSG): CSG;
  133803. /**
  133804. * Subtracts this CSG with another CSG in place
  133805. * @param csg The CSG to subtact against this CSG
  133806. */
  133807. subtractInPlace(csg: CSG): void;
  133808. /**
  133809. * Intersect this CSG with another CSG
  133810. * @param csg The CSG to intersect against this CSG
  133811. * @returns A new CSG
  133812. */
  133813. intersect(csg: CSG): CSG;
  133814. /**
  133815. * Intersects this CSG with another CSG in place
  133816. * @param csg The CSG to intersect against this CSG
  133817. */
  133818. intersectInPlace(csg: CSG): void;
  133819. /**
  133820. * Return a new CSG solid with solid and empty space switched. This solid is
  133821. * not modified.
  133822. * @returns A new CSG solid with solid and empty space switched
  133823. */
  133824. inverse(): CSG;
  133825. /**
  133826. * Inverses the CSG in place
  133827. */
  133828. inverseInPlace(): void;
  133829. /**
  133830. * This is used to keep meshes transformations so they can be restored
  133831. * when we build back a Babylon Mesh
  133832. * NB : All CSG operations are performed in world coordinates
  133833. * @param csg The CSG to copy the transform attributes from
  133834. * @returns This CSG
  133835. */
  133836. copyTransformAttributes(csg: CSG): CSG;
  133837. /**
  133838. * Build Raw mesh from CSG
  133839. * Coordinates here are in world space
  133840. * @param name The name of the mesh geometry
  133841. * @param scene The Scene
  133842. * @param keepSubMeshes Specifies if the submeshes should be kept
  133843. * @returns A new Mesh
  133844. */
  133845. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  133846. /**
  133847. * Build Mesh from CSG taking material and transforms into account
  133848. * @param name The name of the Mesh
  133849. * @param material The material of the Mesh
  133850. * @param scene The Scene
  133851. * @param keepSubMeshes Specifies if submeshes should be kept
  133852. * @returns The new Mesh
  133853. */
  133854. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  133855. }
  133856. }
  133857. declare module BABYLON {
  133858. /**
  133859. * Class used to create a trail following a mesh
  133860. */
  133861. export class TrailMesh extends Mesh {
  133862. private _generator;
  133863. private _autoStart;
  133864. private _running;
  133865. private _diameter;
  133866. private _length;
  133867. private _sectionPolygonPointsCount;
  133868. private _sectionVectors;
  133869. private _sectionNormalVectors;
  133870. private _beforeRenderObserver;
  133871. /**
  133872. * @constructor
  133873. * @param name The value used by scene.getMeshByName() to do a lookup.
  133874. * @param generator The mesh or transform node to generate a trail.
  133875. * @param scene The scene to add this mesh to.
  133876. * @param diameter Diameter of trailing mesh. Default is 1.
  133877. * @param length Length of trailing mesh. Default is 60.
  133878. * @param autoStart Automatically start trailing mesh. Default true.
  133879. */
  133880. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  133881. /**
  133882. * "TrailMesh"
  133883. * @returns "TrailMesh"
  133884. */
  133885. getClassName(): string;
  133886. private _createMesh;
  133887. /**
  133888. * Start trailing mesh.
  133889. */
  133890. start(): void;
  133891. /**
  133892. * Stop trailing mesh.
  133893. */
  133894. stop(): void;
  133895. /**
  133896. * Update trailing mesh geometry.
  133897. */
  133898. update(): void;
  133899. /**
  133900. * Returns a new TrailMesh object.
  133901. * @param name is a string, the name given to the new mesh
  133902. * @param newGenerator use new generator object for cloned trail mesh
  133903. * @returns a new mesh
  133904. */
  133905. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  133906. /**
  133907. * Serializes this trail mesh
  133908. * @param serializationObject object to write serialization to
  133909. */
  133910. serialize(serializationObject: any): void;
  133911. /**
  133912. * Parses a serialized trail mesh
  133913. * @param parsedMesh the serialized mesh
  133914. * @param scene the scene to create the trail mesh in
  133915. * @returns the created trail mesh
  133916. */
  133917. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  133918. }
  133919. }
  133920. declare module BABYLON {
  133921. /**
  133922. * Class containing static functions to help procedurally build meshes
  133923. */
  133924. export class TiledBoxBuilder {
  133925. /**
  133926. * Creates a box mesh
  133927. * 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)
  133928. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  133929. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133930. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133931. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133932. * @param name defines the name of the mesh
  133933. * @param options defines the options used to create the mesh
  133934. * @param scene defines the hosting scene
  133935. * @returns the box mesh
  133936. */
  133937. static CreateTiledBox(name: string, options: {
  133938. pattern?: number;
  133939. width?: number;
  133940. height?: number;
  133941. depth?: number;
  133942. tileSize?: number;
  133943. tileWidth?: number;
  133944. tileHeight?: number;
  133945. alignHorizontal?: number;
  133946. alignVertical?: number;
  133947. faceUV?: Vector4[];
  133948. faceColors?: Color4[];
  133949. sideOrientation?: number;
  133950. updatable?: boolean;
  133951. }, scene?: Nullable<Scene>): Mesh;
  133952. }
  133953. }
  133954. declare module BABYLON {
  133955. /**
  133956. * Class containing static functions to help procedurally build meshes
  133957. */
  133958. export class TorusKnotBuilder {
  133959. /**
  133960. * Creates a torus knot mesh
  133961. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  133962. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  133963. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  133964. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  133965. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133966. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133967. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  133968. * @param name defines the name of the mesh
  133969. * @param options defines the options used to create the mesh
  133970. * @param scene defines the hosting scene
  133971. * @returns the torus knot mesh
  133972. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  133973. */
  133974. static CreateTorusKnot(name: string, options: {
  133975. radius?: number;
  133976. tube?: number;
  133977. radialSegments?: number;
  133978. tubularSegments?: number;
  133979. p?: number;
  133980. q?: number;
  133981. updatable?: boolean;
  133982. sideOrientation?: number;
  133983. frontUVs?: Vector4;
  133984. backUVs?: Vector4;
  133985. }, scene: any): Mesh;
  133986. }
  133987. }
  133988. declare module BABYLON {
  133989. /**
  133990. * Polygon
  133991. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  133992. */
  133993. export class Polygon {
  133994. /**
  133995. * Creates a rectangle
  133996. * @param xmin bottom X coord
  133997. * @param ymin bottom Y coord
  133998. * @param xmax top X coord
  133999. * @param ymax top Y coord
  134000. * @returns points that make the resulting rectation
  134001. */
  134002. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  134003. /**
  134004. * Creates a circle
  134005. * @param radius radius of circle
  134006. * @param cx scale in x
  134007. * @param cy scale in y
  134008. * @param numberOfSides number of sides that make up the circle
  134009. * @returns points that make the resulting circle
  134010. */
  134011. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  134012. /**
  134013. * Creates a polygon from input string
  134014. * @param input Input polygon data
  134015. * @returns the parsed points
  134016. */
  134017. static Parse(input: string): Vector2[];
  134018. /**
  134019. * Starts building a polygon from x and y coordinates
  134020. * @param x x coordinate
  134021. * @param y y coordinate
  134022. * @returns the started path2
  134023. */
  134024. static StartingAt(x: number, y: number): Path2;
  134025. }
  134026. /**
  134027. * Builds a polygon
  134028. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  134029. */
  134030. export class PolygonMeshBuilder {
  134031. private _points;
  134032. private _outlinepoints;
  134033. private _holes;
  134034. private _name;
  134035. private _scene;
  134036. private _epoints;
  134037. private _eholes;
  134038. private _addToepoint;
  134039. /**
  134040. * Babylon reference to the earcut plugin.
  134041. */
  134042. bjsEarcut: any;
  134043. /**
  134044. * Creates a PolygonMeshBuilder
  134045. * @param name name of the builder
  134046. * @param contours Path of the polygon
  134047. * @param scene scene to add to when creating the mesh
  134048. * @param earcutInjection can be used to inject your own earcut reference
  134049. */
  134050. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  134051. /**
  134052. * Adds a whole within the polygon
  134053. * @param hole Array of points defining the hole
  134054. * @returns this
  134055. */
  134056. addHole(hole: Vector2[]): PolygonMeshBuilder;
  134057. /**
  134058. * Creates the polygon
  134059. * @param updatable If the mesh should be updatable
  134060. * @param depth The depth of the mesh created
  134061. * @returns the created mesh
  134062. */
  134063. build(updatable?: boolean, depth?: number): Mesh;
  134064. /**
  134065. * Creates the polygon
  134066. * @param depth The depth of the mesh created
  134067. * @returns the created VertexData
  134068. */
  134069. buildVertexData(depth?: number): VertexData;
  134070. /**
  134071. * Adds a side to the polygon
  134072. * @param positions points that make the polygon
  134073. * @param normals normals of the polygon
  134074. * @param uvs uvs of the polygon
  134075. * @param indices indices of the polygon
  134076. * @param bounds bounds of the polygon
  134077. * @param points points of the polygon
  134078. * @param depth depth of the polygon
  134079. * @param flip flip of the polygon
  134080. */
  134081. private addSide;
  134082. }
  134083. }
  134084. declare module BABYLON {
  134085. /**
  134086. * Class containing static functions to help procedurally build meshes
  134087. */
  134088. export class PolygonBuilder {
  134089. /**
  134090. * Creates a polygon mesh
  134091. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  134092. * * 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
  134093. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  134094. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134095. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  134096. * * Remember you can only change the shape positions, not their number when updating a polygon
  134097. * @param name defines the name of the mesh
  134098. * @param options defines the options used to create the mesh
  134099. * @param scene defines the hosting scene
  134100. * @param earcutInjection can be used to inject your own earcut reference
  134101. * @returns the polygon mesh
  134102. */
  134103. static CreatePolygon(name: string, options: {
  134104. shape: Vector3[];
  134105. holes?: Vector3[][];
  134106. depth?: number;
  134107. faceUV?: Vector4[];
  134108. faceColors?: Color4[];
  134109. updatable?: boolean;
  134110. sideOrientation?: number;
  134111. frontUVs?: Vector4;
  134112. backUVs?: Vector4;
  134113. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134114. /**
  134115. * Creates an extruded polygon mesh, with depth in the Y direction.
  134116. * * 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)
  134117. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134118. * @param name defines the name of the mesh
  134119. * @param options defines the options used to create the mesh
  134120. * @param scene defines the hosting scene
  134121. * @param earcutInjection can be used to inject your own earcut reference
  134122. * @returns the polygon mesh
  134123. */
  134124. static ExtrudePolygon(name: string, options: {
  134125. shape: Vector3[];
  134126. holes?: Vector3[][];
  134127. depth?: number;
  134128. faceUV?: Vector4[];
  134129. faceColors?: Color4[];
  134130. updatable?: boolean;
  134131. sideOrientation?: number;
  134132. frontUVs?: Vector4;
  134133. backUVs?: Vector4;
  134134. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134135. }
  134136. }
  134137. declare module BABYLON {
  134138. /**
  134139. * Class containing static functions to help procedurally build meshes
  134140. */
  134141. export class LatheBuilder {
  134142. /**
  134143. * Creates lathe mesh.
  134144. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  134145. * * 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
  134146. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  134147. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  134148. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  134149. * * 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
  134150. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  134151. * * 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
  134152. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134153. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134154. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134155. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134156. * @param name defines the name of the mesh
  134157. * @param options defines the options used to create the mesh
  134158. * @param scene defines the hosting scene
  134159. * @returns the lathe mesh
  134160. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  134161. */
  134162. static CreateLathe(name: string, options: {
  134163. shape: Vector3[];
  134164. radius?: number;
  134165. tessellation?: number;
  134166. clip?: number;
  134167. arc?: number;
  134168. closed?: boolean;
  134169. updatable?: boolean;
  134170. sideOrientation?: number;
  134171. frontUVs?: Vector4;
  134172. backUVs?: Vector4;
  134173. cap?: number;
  134174. invertUV?: boolean;
  134175. }, scene?: Nullable<Scene>): Mesh;
  134176. }
  134177. }
  134178. declare module BABYLON {
  134179. /**
  134180. * Class containing static functions to help procedurally build meshes
  134181. */
  134182. export class TiledPlaneBuilder {
  134183. /**
  134184. * Creates a tiled plane mesh
  134185. * * The parameter `pattern` will, depending on value, do nothing or
  134186. * * * flip (reflect about central vertical) alternate tiles across and up
  134187. * * * flip every tile on alternate rows
  134188. * * * rotate (180 degs) alternate tiles across and up
  134189. * * * rotate every tile on alternate rows
  134190. * * * flip and rotate alternate tiles across and up
  134191. * * * flip and rotate every tile on alternate rows
  134192. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  134193. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  134194. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134195. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  134196. * * 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)
  134197. * * 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)
  134198. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  134199. * @param name defines the name of the mesh
  134200. * @param options defines the options used to create the mesh
  134201. * @param scene defines the hosting scene
  134202. * @returns the box mesh
  134203. */
  134204. static CreateTiledPlane(name: string, options: {
  134205. pattern?: number;
  134206. tileSize?: number;
  134207. tileWidth?: number;
  134208. tileHeight?: number;
  134209. size?: number;
  134210. width?: number;
  134211. height?: number;
  134212. alignHorizontal?: number;
  134213. alignVertical?: number;
  134214. sideOrientation?: number;
  134215. frontUVs?: Vector4;
  134216. backUVs?: Vector4;
  134217. updatable?: boolean;
  134218. }, scene?: Nullable<Scene>): Mesh;
  134219. }
  134220. }
  134221. declare module BABYLON {
  134222. /**
  134223. * Class containing static functions to help procedurally build meshes
  134224. */
  134225. export class TubeBuilder {
  134226. /**
  134227. * Creates a tube mesh.
  134228. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134229. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  134230. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  134231. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  134232. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  134233. * * 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)
  134234. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  134235. * * 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
  134236. * * 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
  134237. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134238. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134239. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134240. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134241. * @param name defines the name of the mesh
  134242. * @param options defines the options used to create the mesh
  134243. * @param scene defines the hosting scene
  134244. * @returns the tube mesh
  134245. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134246. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  134247. */
  134248. static CreateTube(name: string, options: {
  134249. path: Vector3[];
  134250. radius?: number;
  134251. tessellation?: number;
  134252. radiusFunction?: {
  134253. (i: number, distance: number): number;
  134254. };
  134255. cap?: number;
  134256. arc?: number;
  134257. updatable?: boolean;
  134258. sideOrientation?: number;
  134259. frontUVs?: Vector4;
  134260. backUVs?: Vector4;
  134261. instance?: Mesh;
  134262. invertUV?: boolean;
  134263. }, scene?: Nullable<Scene>): Mesh;
  134264. }
  134265. }
  134266. declare module BABYLON {
  134267. /**
  134268. * Class containing static functions to help procedurally build meshes
  134269. */
  134270. export class IcoSphereBuilder {
  134271. /**
  134272. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  134273. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  134274. * * 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`)
  134275. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  134276. * * 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
  134277. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134278. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134279. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134280. * @param name defines the name of the mesh
  134281. * @param options defines the options used to create the mesh
  134282. * @param scene defines the hosting scene
  134283. * @returns the icosahedron mesh
  134284. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  134285. */
  134286. static CreateIcoSphere(name: string, options: {
  134287. radius?: number;
  134288. radiusX?: number;
  134289. radiusY?: number;
  134290. radiusZ?: number;
  134291. flat?: boolean;
  134292. subdivisions?: number;
  134293. sideOrientation?: number;
  134294. frontUVs?: Vector4;
  134295. backUVs?: Vector4;
  134296. updatable?: boolean;
  134297. }, scene?: Nullable<Scene>): Mesh;
  134298. }
  134299. }
  134300. declare module BABYLON {
  134301. /**
  134302. * Class containing static functions to help procedurally build meshes
  134303. */
  134304. export class DecalBuilder {
  134305. /**
  134306. * Creates a decal mesh.
  134307. * 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
  134308. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  134309. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  134310. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  134311. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  134312. * @param name defines the name of the mesh
  134313. * @param sourceMesh defines the mesh where the decal must be applied
  134314. * @param options defines the options used to create the mesh
  134315. * @param scene defines the hosting scene
  134316. * @returns the decal mesh
  134317. * @see https://doc.babylonjs.com/how_to/decals
  134318. */
  134319. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  134320. position?: Vector3;
  134321. normal?: Vector3;
  134322. size?: Vector3;
  134323. angle?: number;
  134324. }): Mesh;
  134325. }
  134326. }
  134327. declare module BABYLON {
  134328. /**
  134329. * Class containing static functions to help procedurally build meshes
  134330. */
  134331. export class MeshBuilder {
  134332. /**
  134333. * Creates a box mesh
  134334. * * The parameter `size` sets the size (float) of each box side (default 1)
  134335. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  134336. * * 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)
  134337. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134338. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134339. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  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. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  134342. * @param name defines the name of the mesh
  134343. * @param options defines the options used to create the mesh
  134344. * @param scene defines the hosting scene
  134345. * @returns the box mesh
  134346. */
  134347. static CreateBox(name: string, options: {
  134348. size?: number;
  134349. width?: number;
  134350. height?: number;
  134351. depth?: number;
  134352. faceUV?: Vector4[];
  134353. faceColors?: Color4[];
  134354. sideOrientation?: number;
  134355. frontUVs?: Vector4;
  134356. backUVs?: Vector4;
  134357. updatable?: boolean;
  134358. }, scene?: Nullable<Scene>): Mesh;
  134359. /**
  134360. * Creates a tiled box mesh
  134361. * * faceTiles sets the pattern, tile size and number of tiles for a face
  134362. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134363. * @param name defines the name of the mesh
  134364. * @param options defines the options used to create the mesh
  134365. * @param scene defines the hosting scene
  134366. * @returns the tiled box mesh
  134367. */
  134368. static CreateTiledBox(name: string, options: {
  134369. pattern?: number;
  134370. size?: number;
  134371. width?: number;
  134372. height?: number;
  134373. depth: number;
  134374. tileSize?: number;
  134375. tileWidth?: number;
  134376. tileHeight?: number;
  134377. faceUV?: Vector4[];
  134378. faceColors?: Color4[];
  134379. alignHorizontal?: number;
  134380. alignVertical?: number;
  134381. sideOrientation?: number;
  134382. updatable?: boolean;
  134383. }, scene?: Nullable<Scene>): Mesh;
  134384. /**
  134385. * Creates a sphere mesh
  134386. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  134387. * * 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`)
  134388. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  134389. * * 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
  134390. * * 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)
  134391. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134392. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134393. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134394. * @param name defines the name of the mesh
  134395. * @param options defines the options used to create the mesh
  134396. * @param scene defines the hosting scene
  134397. * @returns the sphere mesh
  134398. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  134399. */
  134400. static CreateSphere(name: string, options: {
  134401. segments?: number;
  134402. diameter?: number;
  134403. diameterX?: number;
  134404. diameterY?: number;
  134405. diameterZ?: number;
  134406. arc?: number;
  134407. slice?: number;
  134408. sideOrientation?: number;
  134409. frontUVs?: Vector4;
  134410. backUVs?: Vector4;
  134411. updatable?: boolean;
  134412. }, scene?: Nullable<Scene>): Mesh;
  134413. /**
  134414. * Creates a plane polygonal mesh. By default, this is a disc
  134415. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  134416. * * 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
  134417. * * 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
  134418. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134419. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134420. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134421. * @param name defines the name of the mesh
  134422. * @param options defines the options used to create the mesh
  134423. * @param scene defines the hosting scene
  134424. * @returns the plane polygonal mesh
  134425. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  134426. */
  134427. static CreateDisc(name: string, options: {
  134428. radius?: number;
  134429. tessellation?: number;
  134430. arc?: number;
  134431. updatable?: boolean;
  134432. sideOrientation?: number;
  134433. frontUVs?: Vector4;
  134434. backUVs?: Vector4;
  134435. }, scene?: Nullable<Scene>): Mesh;
  134436. /**
  134437. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  134438. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  134439. * * 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`)
  134440. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  134441. * * 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
  134442. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134443. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134444. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134445. * @param name defines the name of the mesh
  134446. * @param options defines the options used to create the mesh
  134447. * @param scene defines the hosting scene
  134448. * @returns the icosahedron mesh
  134449. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  134450. */
  134451. static CreateIcoSphere(name: string, options: {
  134452. radius?: number;
  134453. radiusX?: number;
  134454. radiusY?: number;
  134455. radiusZ?: number;
  134456. flat?: boolean;
  134457. subdivisions?: number;
  134458. sideOrientation?: number;
  134459. frontUVs?: Vector4;
  134460. backUVs?: Vector4;
  134461. updatable?: boolean;
  134462. }, scene?: Nullable<Scene>): Mesh;
  134463. /**
  134464. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134465. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  134466. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  134467. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  134468. * * 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
  134469. * * 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
  134470. * * 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
  134471. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134472. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134473. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134474. * * 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
  134475. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  134476. * * 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
  134477. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  134478. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134479. * @param name defines the name of the mesh
  134480. * @param options defines the options used to create the mesh
  134481. * @param scene defines the hosting scene
  134482. * @returns the ribbon mesh
  134483. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  134484. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134485. */
  134486. static CreateRibbon(name: string, options: {
  134487. pathArray: Vector3[][];
  134488. closeArray?: boolean;
  134489. closePath?: boolean;
  134490. offset?: number;
  134491. updatable?: boolean;
  134492. sideOrientation?: number;
  134493. frontUVs?: Vector4;
  134494. backUVs?: Vector4;
  134495. instance?: Mesh;
  134496. invertUV?: boolean;
  134497. uvs?: Vector2[];
  134498. colors?: Color4[];
  134499. }, scene?: Nullable<Scene>): Mesh;
  134500. /**
  134501. * Creates a cylinder or a cone mesh
  134502. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  134503. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  134504. * * 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.
  134505. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  134506. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  134507. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  134508. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  134509. * * 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).
  134510. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  134511. * * 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).
  134512. * * 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
  134513. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  134514. * * 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
  134515. * * 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.
  134516. * * If `enclose` is false, a ring surface is one element.
  134517. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  134518. * * 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
  134519. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134520. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134521. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134522. * @param name defines the name of the mesh
  134523. * @param options defines the options used to create the mesh
  134524. * @param scene defines the hosting scene
  134525. * @returns the cylinder mesh
  134526. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  134527. */
  134528. static CreateCylinder(name: string, options: {
  134529. height?: number;
  134530. diameterTop?: number;
  134531. diameterBottom?: number;
  134532. diameter?: number;
  134533. tessellation?: number;
  134534. subdivisions?: number;
  134535. arc?: number;
  134536. faceColors?: Color4[];
  134537. faceUV?: Vector4[];
  134538. updatable?: boolean;
  134539. hasRings?: boolean;
  134540. enclose?: boolean;
  134541. cap?: number;
  134542. sideOrientation?: number;
  134543. frontUVs?: Vector4;
  134544. backUVs?: Vector4;
  134545. }, scene?: Nullable<Scene>): Mesh;
  134546. /**
  134547. * Creates a torus mesh
  134548. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  134549. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  134550. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  134551. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134552. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134553. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134554. * @param name defines the name of the mesh
  134555. * @param options defines the options used to create the mesh
  134556. * @param scene defines the hosting scene
  134557. * @returns the torus mesh
  134558. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  134559. */
  134560. static CreateTorus(name: string, options: {
  134561. diameter?: number;
  134562. thickness?: number;
  134563. tessellation?: number;
  134564. updatable?: boolean;
  134565. sideOrientation?: number;
  134566. frontUVs?: Vector4;
  134567. backUVs?: Vector4;
  134568. }, scene?: Nullable<Scene>): Mesh;
  134569. /**
  134570. * Creates a torus knot mesh
  134571. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  134572. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  134573. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  134574. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  134575. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134576. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134577. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134578. * @param name defines the name of the mesh
  134579. * @param options defines the options used to create the mesh
  134580. * @param scene defines the hosting scene
  134581. * @returns the torus knot mesh
  134582. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  134583. */
  134584. static CreateTorusKnot(name: string, options: {
  134585. radius?: number;
  134586. tube?: number;
  134587. radialSegments?: number;
  134588. tubularSegments?: number;
  134589. p?: number;
  134590. q?: number;
  134591. updatable?: boolean;
  134592. sideOrientation?: number;
  134593. frontUVs?: Vector4;
  134594. backUVs?: Vector4;
  134595. }, scene?: Nullable<Scene>): Mesh;
  134596. /**
  134597. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  134598. * * 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
  134599. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  134600. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  134601. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  134602. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  134603. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  134604. * * 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
  134605. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  134606. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134607. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  134608. * @param name defines the name of the new line system
  134609. * @param options defines the options used to create the line system
  134610. * @param scene defines the hosting scene
  134611. * @returns a new line system mesh
  134612. */
  134613. static CreateLineSystem(name: string, options: {
  134614. lines: Vector3[][];
  134615. updatable?: boolean;
  134616. instance?: Nullable<LinesMesh>;
  134617. colors?: Nullable<Color4[][]>;
  134618. useVertexAlpha?: boolean;
  134619. }, scene: Nullable<Scene>): LinesMesh;
  134620. /**
  134621. * Creates a line mesh
  134622. * 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
  134623. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  134624. * * The parameter `points` is an array successive Vector3
  134625. * * 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
  134626. * * The optional parameter `colors` is an array of successive Color4, one per line point
  134627. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  134628. * * When updating an instance, remember that only point positions can change, not the number of points
  134629. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134630. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  134631. * @param name defines the name of the new line system
  134632. * @param options defines the options used to create the line system
  134633. * @param scene defines the hosting scene
  134634. * @returns a new line mesh
  134635. */
  134636. static CreateLines(name: string, options: {
  134637. points: Vector3[];
  134638. updatable?: boolean;
  134639. instance?: Nullable<LinesMesh>;
  134640. colors?: Color4[];
  134641. useVertexAlpha?: boolean;
  134642. }, scene?: Nullable<Scene>): LinesMesh;
  134643. /**
  134644. * Creates a dashed line mesh
  134645. * * 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
  134646. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  134647. * * The parameter `points` is an array successive Vector3
  134648. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  134649. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  134650. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  134651. * * 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
  134652. * * When updating an instance, remember that only point positions can change, not the number of points
  134653. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134654. * @param name defines the name of the mesh
  134655. * @param options defines the options used to create the mesh
  134656. * @param scene defines the hosting scene
  134657. * @returns the dashed line mesh
  134658. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  134659. */
  134660. static CreateDashedLines(name: string, options: {
  134661. points: Vector3[];
  134662. dashSize?: number;
  134663. gapSize?: number;
  134664. dashNb?: number;
  134665. updatable?: boolean;
  134666. instance?: LinesMesh;
  134667. }, scene?: Nullable<Scene>): LinesMesh;
  134668. /**
  134669. * 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.
  134670. * * 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.
  134671. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  134672. * * 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.
  134673. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  134674. * * 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
  134675. * * 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
  134676. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  134677. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134678. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134679. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  134680. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134681. * @param name defines the name of the mesh
  134682. * @param options defines the options used to create the mesh
  134683. * @param scene defines the hosting scene
  134684. * @returns the extruded shape mesh
  134685. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134686. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  134687. */
  134688. static ExtrudeShape(name: string, options: {
  134689. shape: Vector3[];
  134690. path: Vector3[];
  134691. scale?: number;
  134692. rotation?: number;
  134693. cap?: number;
  134694. updatable?: boolean;
  134695. sideOrientation?: number;
  134696. frontUVs?: Vector4;
  134697. backUVs?: Vector4;
  134698. instance?: Mesh;
  134699. invertUV?: boolean;
  134700. }, scene?: Nullable<Scene>): Mesh;
  134701. /**
  134702. * Creates an custom extruded shape mesh.
  134703. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  134704. * * 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.
  134705. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  134706. * * 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
  134707. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  134708. * * 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
  134709. * * It must returns a float value that will be the scale value applied to the shape on each path point
  134710. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  134711. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  134712. * * 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
  134713. * * 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
  134714. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  134715. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134716. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134717. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134718. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134719. * @param name defines the name of the mesh
  134720. * @param options defines the options used to create the mesh
  134721. * @param scene defines the hosting scene
  134722. * @returns the custom extruded shape mesh
  134723. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  134724. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134725. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  134726. */
  134727. static ExtrudeShapeCustom(name: string, options: {
  134728. shape: Vector3[];
  134729. path: Vector3[];
  134730. scaleFunction?: any;
  134731. rotationFunction?: any;
  134732. ribbonCloseArray?: boolean;
  134733. ribbonClosePath?: boolean;
  134734. cap?: number;
  134735. updatable?: boolean;
  134736. sideOrientation?: number;
  134737. frontUVs?: Vector4;
  134738. backUVs?: Vector4;
  134739. instance?: Mesh;
  134740. invertUV?: boolean;
  134741. }, scene?: Nullable<Scene>): Mesh;
  134742. /**
  134743. * Creates lathe mesh.
  134744. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  134745. * * 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
  134746. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  134747. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  134748. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  134749. * * 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
  134750. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  134751. * * 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
  134752. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134753. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134754. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134755. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134756. * @param name defines the name of the mesh
  134757. * @param options defines the options used to create the mesh
  134758. * @param scene defines the hosting scene
  134759. * @returns the lathe mesh
  134760. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  134761. */
  134762. static CreateLathe(name: string, options: {
  134763. shape: Vector3[];
  134764. radius?: number;
  134765. tessellation?: number;
  134766. clip?: number;
  134767. arc?: number;
  134768. closed?: boolean;
  134769. updatable?: boolean;
  134770. sideOrientation?: number;
  134771. frontUVs?: Vector4;
  134772. backUVs?: Vector4;
  134773. cap?: number;
  134774. invertUV?: boolean;
  134775. }, scene?: Nullable<Scene>): Mesh;
  134776. /**
  134777. * Creates a tiled plane mesh
  134778. * * You can set a limited pattern arrangement with the tiles
  134779. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134780. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134781. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134782. * @param name defines the name of the mesh
  134783. * @param options defines the options used to create the mesh
  134784. * @param scene defines the hosting scene
  134785. * @returns the plane mesh
  134786. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  134787. */
  134788. static CreateTiledPlane(name: string, options: {
  134789. pattern?: number;
  134790. tileSize?: number;
  134791. tileWidth?: number;
  134792. tileHeight?: number;
  134793. size?: number;
  134794. width?: number;
  134795. height?: number;
  134796. alignHorizontal?: number;
  134797. alignVertical?: number;
  134798. sideOrientation?: number;
  134799. frontUVs?: Vector4;
  134800. backUVs?: Vector4;
  134801. updatable?: boolean;
  134802. }, scene?: Nullable<Scene>): Mesh;
  134803. /**
  134804. * Creates a plane mesh
  134805. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  134806. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  134807. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  134808. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134809. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134810. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134811. * @param name defines the name of the mesh
  134812. * @param options defines the options used to create the mesh
  134813. * @param scene defines the hosting scene
  134814. * @returns the plane mesh
  134815. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  134816. */
  134817. static CreatePlane(name: string, options: {
  134818. size?: number;
  134819. width?: number;
  134820. height?: number;
  134821. sideOrientation?: number;
  134822. frontUVs?: Vector4;
  134823. backUVs?: Vector4;
  134824. updatable?: boolean;
  134825. sourcePlane?: Plane;
  134826. }, scene?: Nullable<Scene>): Mesh;
  134827. /**
  134828. * Creates a ground mesh
  134829. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  134830. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  134831. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134832. * @param name defines the name of the mesh
  134833. * @param options defines the options used to create the mesh
  134834. * @param scene defines the hosting scene
  134835. * @returns the ground mesh
  134836. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  134837. */
  134838. static CreateGround(name: string, options: {
  134839. width?: number;
  134840. height?: number;
  134841. subdivisions?: number;
  134842. subdivisionsX?: number;
  134843. subdivisionsY?: number;
  134844. updatable?: boolean;
  134845. }, scene?: Nullable<Scene>): Mesh;
  134846. /**
  134847. * Creates a tiled ground mesh
  134848. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  134849. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  134850. * * 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
  134851. * * 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
  134852. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134853. * @param name defines the name of the mesh
  134854. * @param options defines the options used to create the mesh
  134855. * @param scene defines the hosting scene
  134856. * @returns the tiled ground mesh
  134857. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  134858. */
  134859. static CreateTiledGround(name: string, options: {
  134860. xmin: number;
  134861. zmin: number;
  134862. xmax: number;
  134863. zmax: number;
  134864. subdivisions?: {
  134865. w: number;
  134866. h: number;
  134867. };
  134868. precision?: {
  134869. w: number;
  134870. h: number;
  134871. };
  134872. updatable?: boolean;
  134873. }, scene?: Nullable<Scene>): Mesh;
  134874. /**
  134875. * Creates a ground mesh from a height map
  134876. * * The parameter `url` sets the URL of the height map image resource.
  134877. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  134878. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  134879. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  134880. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  134881. * * 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.
  134882. * * 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).
  134883. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  134884. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134885. * @param name defines the name of the mesh
  134886. * @param url defines the url to the height map
  134887. * @param options defines the options used to create the mesh
  134888. * @param scene defines the hosting scene
  134889. * @returns the ground mesh
  134890. * @see https://doc.babylonjs.com/babylon101/height_map
  134891. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  134892. */
  134893. static CreateGroundFromHeightMap(name: string, url: string, options: {
  134894. width?: number;
  134895. height?: number;
  134896. subdivisions?: number;
  134897. minHeight?: number;
  134898. maxHeight?: number;
  134899. colorFilter?: Color3;
  134900. alphaFilter?: number;
  134901. updatable?: boolean;
  134902. onReady?: (mesh: GroundMesh) => void;
  134903. }, scene?: Nullable<Scene>): GroundMesh;
  134904. /**
  134905. * Creates a polygon mesh
  134906. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  134907. * * 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
  134908. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  134909. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134910. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  134911. * * Remember you can only change the shape positions, not their number when updating a polygon
  134912. * @param name defines the name of the mesh
  134913. * @param options defines the options used to create the mesh
  134914. * @param scene defines the hosting scene
  134915. * @param earcutInjection can be used to inject your own earcut reference
  134916. * @returns the polygon mesh
  134917. */
  134918. static CreatePolygon(name: string, options: {
  134919. shape: Vector3[];
  134920. holes?: Vector3[][];
  134921. depth?: number;
  134922. faceUV?: Vector4[];
  134923. faceColors?: Color4[];
  134924. updatable?: boolean;
  134925. sideOrientation?: number;
  134926. frontUVs?: Vector4;
  134927. backUVs?: Vector4;
  134928. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134929. /**
  134930. * Creates an extruded polygon mesh, with depth in the Y direction.
  134931. * * 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)
  134932. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134933. * @param name defines the name of the mesh
  134934. * @param options defines the options used to create the mesh
  134935. * @param scene defines the hosting scene
  134936. * @param earcutInjection can be used to inject your own earcut reference
  134937. * @returns the polygon mesh
  134938. */
  134939. static ExtrudePolygon(name: string, options: {
  134940. shape: Vector3[];
  134941. holes?: Vector3[][];
  134942. depth?: number;
  134943. faceUV?: Vector4[];
  134944. faceColors?: Color4[];
  134945. updatable?: boolean;
  134946. sideOrientation?: number;
  134947. frontUVs?: Vector4;
  134948. backUVs?: Vector4;
  134949. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134950. /**
  134951. * Creates a tube mesh.
  134952. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134953. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  134954. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  134955. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  134956. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  134957. * * 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)
  134958. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  134959. * * 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
  134960. * * 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
  134961. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134962. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134963. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134964. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134965. * @param name defines the name of the mesh
  134966. * @param options defines the options used to create the mesh
  134967. * @param scene defines the hosting scene
  134968. * @returns the tube mesh
  134969. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134970. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  134971. */
  134972. static CreateTube(name: string, options: {
  134973. path: Vector3[];
  134974. radius?: number;
  134975. tessellation?: number;
  134976. radiusFunction?: {
  134977. (i: number, distance: number): number;
  134978. };
  134979. cap?: number;
  134980. arc?: number;
  134981. updatable?: boolean;
  134982. sideOrientation?: number;
  134983. frontUVs?: Vector4;
  134984. backUVs?: Vector4;
  134985. instance?: Mesh;
  134986. invertUV?: boolean;
  134987. }, scene?: Nullable<Scene>): Mesh;
  134988. /**
  134989. * Creates a polyhedron mesh
  134990. * * 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
  134991. * * The parameter `size` (positive float, default 1) sets the polygon size
  134992. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  134993. * * 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`
  134994. * * 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
  134995. * * 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)`)
  134996. * * 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
  134997. * * 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
  134998. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134999. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135000. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135001. * @param name defines the name of the mesh
  135002. * @param options defines the options used to create the mesh
  135003. * @param scene defines the hosting scene
  135004. * @returns the polyhedron mesh
  135005. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  135006. */
  135007. static CreatePolyhedron(name: string, options: {
  135008. type?: number;
  135009. size?: number;
  135010. sizeX?: number;
  135011. sizeY?: number;
  135012. sizeZ?: number;
  135013. custom?: any;
  135014. faceUV?: Vector4[];
  135015. faceColors?: Color4[];
  135016. flat?: boolean;
  135017. updatable?: boolean;
  135018. sideOrientation?: number;
  135019. frontUVs?: Vector4;
  135020. backUVs?: Vector4;
  135021. }, scene?: Nullable<Scene>): Mesh;
  135022. /**
  135023. * Creates a decal mesh.
  135024. * 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
  135025. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  135026. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  135027. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  135028. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  135029. * @param name defines the name of the mesh
  135030. * @param sourceMesh defines the mesh where the decal must be applied
  135031. * @param options defines the options used to create the mesh
  135032. * @param scene defines the hosting scene
  135033. * @returns the decal mesh
  135034. * @see https://doc.babylonjs.com/how_to/decals
  135035. */
  135036. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  135037. position?: Vector3;
  135038. normal?: Vector3;
  135039. size?: Vector3;
  135040. angle?: number;
  135041. }): Mesh;
  135042. }
  135043. }
  135044. declare module BABYLON {
  135045. /**
  135046. * A simplifier interface for future simplification implementations
  135047. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135048. */
  135049. export interface ISimplifier {
  135050. /**
  135051. * Simplification of a given mesh according to the given settings.
  135052. * Since this requires computation, it is assumed that the function runs async.
  135053. * @param settings The settings of the simplification, including quality and distance
  135054. * @param successCallback A callback that will be called after the mesh was simplified.
  135055. * @param errorCallback in case of an error, this callback will be called. optional.
  135056. */
  135057. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  135058. }
  135059. /**
  135060. * Expected simplification settings.
  135061. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  135062. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135063. */
  135064. export interface ISimplificationSettings {
  135065. /**
  135066. * Gets or sets the expected quality
  135067. */
  135068. quality: number;
  135069. /**
  135070. * Gets or sets the distance when this optimized version should be used
  135071. */
  135072. distance: number;
  135073. /**
  135074. * Gets an already optimized mesh
  135075. */
  135076. optimizeMesh?: boolean;
  135077. }
  135078. /**
  135079. * Class used to specify simplification options
  135080. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135081. */
  135082. export class SimplificationSettings implements ISimplificationSettings {
  135083. /** expected quality */
  135084. quality: number;
  135085. /** distance when this optimized version should be used */
  135086. distance: number;
  135087. /** already optimized mesh */
  135088. optimizeMesh?: boolean | undefined;
  135089. /**
  135090. * Creates a SimplificationSettings
  135091. * @param quality expected quality
  135092. * @param distance distance when this optimized version should be used
  135093. * @param optimizeMesh already optimized mesh
  135094. */
  135095. constructor(
  135096. /** expected quality */
  135097. quality: number,
  135098. /** distance when this optimized version should be used */
  135099. distance: number,
  135100. /** already optimized mesh */
  135101. optimizeMesh?: boolean | undefined);
  135102. }
  135103. /**
  135104. * Interface used to define a simplification task
  135105. */
  135106. export interface ISimplificationTask {
  135107. /**
  135108. * Array of settings
  135109. */
  135110. settings: Array<ISimplificationSettings>;
  135111. /**
  135112. * Simplification type
  135113. */
  135114. simplificationType: SimplificationType;
  135115. /**
  135116. * Mesh to simplify
  135117. */
  135118. mesh: Mesh;
  135119. /**
  135120. * Callback called on success
  135121. */
  135122. successCallback?: () => void;
  135123. /**
  135124. * Defines if parallel processing can be used
  135125. */
  135126. parallelProcessing: boolean;
  135127. }
  135128. /**
  135129. * Queue used to order the simplification tasks
  135130. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135131. */
  135132. export class SimplificationQueue {
  135133. private _simplificationArray;
  135134. /**
  135135. * Gets a boolean indicating that the process is still running
  135136. */
  135137. running: boolean;
  135138. /**
  135139. * Creates a new queue
  135140. */
  135141. constructor();
  135142. /**
  135143. * Adds a new simplification task
  135144. * @param task defines a task to add
  135145. */
  135146. addTask(task: ISimplificationTask): void;
  135147. /**
  135148. * Execute next task
  135149. */
  135150. executeNext(): void;
  135151. /**
  135152. * Execute a simplification task
  135153. * @param task defines the task to run
  135154. */
  135155. runSimplification(task: ISimplificationTask): void;
  135156. private getSimplifier;
  135157. }
  135158. /**
  135159. * The implemented types of simplification
  135160. * At the moment only Quadratic Error Decimation is implemented
  135161. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135162. */
  135163. export enum SimplificationType {
  135164. /** Quadratic error decimation */
  135165. QUADRATIC = 0
  135166. }
  135167. }
  135168. declare module BABYLON {
  135169. interface Scene {
  135170. /** @hidden (Backing field) */
  135171. _simplificationQueue: SimplificationQueue;
  135172. /**
  135173. * Gets or sets the simplification queue attached to the scene
  135174. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135175. */
  135176. simplificationQueue: SimplificationQueue;
  135177. }
  135178. interface Mesh {
  135179. /**
  135180. * Simplify the mesh according to the given array of settings.
  135181. * Function will return immediately and will simplify async
  135182. * @param settings a collection of simplification settings
  135183. * @param parallelProcessing should all levels calculate parallel or one after the other
  135184. * @param simplificationType the type of simplification to run
  135185. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  135186. * @returns the current mesh
  135187. */
  135188. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  135189. }
  135190. /**
  135191. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  135192. * created in a scene
  135193. */
  135194. export class SimplicationQueueSceneComponent implements ISceneComponent {
  135195. /**
  135196. * The component name helpfull to identify the component in the list of scene components.
  135197. */
  135198. readonly name: string;
  135199. /**
  135200. * The scene the component belongs to.
  135201. */
  135202. scene: Scene;
  135203. /**
  135204. * Creates a new instance of the component for the given scene
  135205. * @param scene Defines the scene to register the component in
  135206. */
  135207. constructor(scene: Scene);
  135208. /**
  135209. * Registers the component in a given scene
  135210. */
  135211. register(): void;
  135212. /**
  135213. * Rebuilds the elements related to this component in case of
  135214. * context lost for instance.
  135215. */
  135216. rebuild(): void;
  135217. /**
  135218. * Disposes the component and the associated ressources
  135219. */
  135220. dispose(): void;
  135221. private _beforeCameraUpdate;
  135222. }
  135223. }
  135224. declare module BABYLON {
  135225. /**
  135226. * Navigation plugin interface to add navigation constrained by a navigation mesh
  135227. */
  135228. export interface INavigationEnginePlugin {
  135229. /**
  135230. * plugin name
  135231. */
  135232. name: string;
  135233. /**
  135234. * Creates a navigation mesh
  135235. * @param meshes array of all the geometry used to compute the navigatio mesh
  135236. * @param parameters bunch of parameters used to filter geometry
  135237. */
  135238. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  135239. /**
  135240. * Create a navigation mesh debug mesh
  135241. * @param scene is where the mesh will be added
  135242. * @returns debug display mesh
  135243. */
  135244. createDebugNavMesh(scene: Scene): Mesh;
  135245. /**
  135246. * Get a navigation mesh constrained position, closest to the parameter position
  135247. * @param position world position
  135248. * @returns the closest point to position constrained by the navigation mesh
  135249. */
  135250. getClosestPoint(position: Vector3): Vector3;
  135251. /**
  135252. * Get a navigation mesh constrained position, within a particular radius
  135253. * @param position world position
  135254. * @param maxRadius the maximum distance to the constrained world position
  135255. * @returns the closest point to position constrained by the navigation mesh
  135256. */
  135257. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  135258. /**
  135259. * Compute the final position from a segment made of destination-position
  135260. * @param position world position
  135261. * @param destination world position
  135262. * @returns the resulting point along the navmesh
  135263. */
  135264. moveAlong(position: Vector3, destination: Vector3): Vector3;
  135265. /**
  135266. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  135267. * @param start world position
  135268. * @param end world position
  135269. * @returns array containing world position composing the path
  135270. */
  135271. computePath(start: Vector3, end: Vector3): Vector3[];
  135272. /**
  135273. * If this plugin is supported
  135274. * @returns true if plugin is supported
  135275. */
  135276. isSupported(): boolean;
  135277. /**
  135278. * Create a new Crowd so you can add agents
  135279. * @param maxAgents the maximum agent count in the crowd
  135280. * @param maxAgentRadius the maximum radius an agent can have
  135281. * @param scene to attach the crowd to
  135282. * @returns the crowd you can add agents to
  135283. */
  135284. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  135285. /**
  135286. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135287. * The queries will try to find a solution within those bounds
  135288. * default is (1,1,1)
  135289. * @param extent x,y,z value that define the extent around the queries point of reference
  135290. */
  135291. setDefaultQueryExtent(extent: Vector3): void;
  135292. /**
  135293. * Get the Bounding box extent specified by setDefaultQueryExtent
  135294. * @returns the box extent values
  135295. */
  135296. getDefaultQueryExtent(): Vector3;
  135297. /**
  135298. * Release all resources
  135299. */
  135300. dispose(): void;
  135301. }
  135302. /**
  135303. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  135304. */
  135305. export interface ICrowd {
  135306. /**
  135307. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  135308. * You can attach anything to that node. The node position is updated in the scene update tick.
  135309. * @param pos world position that will be constrained by the navigation mesh
  135310. * @param parameters agent parameters
  135311. * @param transform hooked to the agent that will be update by the scene
  135312. * @returns agent index
  135313. */
  135314. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  135315. /**
  135316. * Returns the agent position in world space
  135317. * @param index agent index returned by addAgent
  135318. * @returns world space position
  135319. */
  135320. getAgentPosition(index: number): Vector3;
  135321. /**
  135322. * Gets the agent velocity in world space
  135323. * @param index agent index returned by addAgent
  135324. * @returns world space velocity
  135325. */
  135326. getAgentVelocity(index: number): Vector3;
  135327. /**
  135328. * remove a particular agent previously created
  135329. * @param index agent index returned by addAgent
  135330. */
  135331. removeAgent(index: number): void;
  135332. /**
  135333. * get the list of all agents attached to this crowd
  135334. * @returns list of agent indices
  135335. */
  135336. getAgents(): number[];
  135337. /**
  135338. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  135339. * @param deltaTime in seconds
  135340. */
  135341. update(deltaTime: number): void;
  135342. /**
  135343. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  135344. * @param index agent index returned by addAgent
  135345. * @param destination targeted world position
  135346. */
  135347. agentGoto(index: number, destination: Vector3): void;
  135348. /**
  135349. * Teleport the agent to a new position
  135350. * @param index agent index returned by addAgent
  135351. * @param destination targeted world position
  135352. */
  135353. agentTeleport(index: number, destination: Vector3): void;
  135354. /**
  135355. * Update agent parameters
  135356. * @param index agent index returned by addAgent
  135357. * @param parameters agent parameters
  135358. */
  135359. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  135360. /**
  135361. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135362. * The queries will try to find a solution within those bounds
  135363. * default is (1,1,1)
  135364. * @param extent x,y,z value that define the extent around the queries point of reference
  135365. */
  135366. setDefaultQueryExtent(extent: Vector3): void;
  135367. /**
  135368. * Get the Bounding box extent specified by setDefaultQueryExtent
  135369. * @returns the box extent values
  135370. */
  135371. getDefaultQueryExtent(): Vector3;
  135372. /**
  135373. * Release all resources
  135374. */
  135375. dispose(): void;
  135376. }
  135377. /**
  135378. * Configures an agent
  135379. */
  135380. export interface IAgentParameters {
  135381. /**
  135382. * Agent radius. [Limit: >= 0]
  135383. */
  135384. radius: number;
  135385. /**
  135386. * Agent height. [Limit: > 0]
  135387. */
  135388. height: number;
  135389. /**
  135390. * Maximum allowed acceleration. [Limit: >= 0]
  135391. */
  135392. maxAcceleration: number;
  135393. /**
  135394. * Maximum allowed speed. [Limit: >= 0]
  135395. */
  135396. maxSpeed: number;
  135397. /**
  135398. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  135399. */
  135400. collisionQueryRange: number;
  135401. /**
  135402. * The path visibility optimization range. [Limit: > 0]
  135403. */
  135404. pathOptimizationRange: number;
  135405. /**
  135406. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  135407. */
  135408. separationWeight: number;
  135409. }
  135410. /**
  135411. * Configures the navigation mesh creation
  135412. */
  135413. export interface INavMeshParameters {
  135414. /**
  135415. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  135416. */
  135417. cs: number;
  135418. /**
  135419. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  135420. */
  135421. ch: number;
  135422. /**
  135423. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  135424. */
  135425. walkableSlopeAngle: number;
  135426. /**
  135427. * Minimum floor to 'ceiling' height that will still allow the floor area to
  135428. * be considered walkable. [Limit: >= 3] [Units: vx]
  135429. */
  135430. walkableHeight: number;
  135431. /**
  135432. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  135433. */
  135434. walkableClimb: number;
  135435. /**
  135436. * The distance to erode/shrink the walkable area of the heightfield away from
  135437. * obstructions. [Limit: >=0] [Units: vx]
  135438. */
  135439. walkableRadius: number;
  135440. /**
  135441. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  135442. */
  135443. maxEdgeLen: number;
  135444. /**
  135445. * The maximum distance a simplfied contour's border edges should deviate
  135446. * the original raw contour. [Limit: >=0] [Units: vx]
  135447. */
  135448. maxSimplificationError: number;
  135449. /**
  135450. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  135451. */
  135452. minRegionArea: number;
  135453. /**
  135454. * Any regions with a span count smaller than this value will, if possible,
  135455. * be merged with larger regions. [Limit: >=0] [Units: vx]
  135456. */
  135457. mergeRegionArea: number;
  135458. /**
  135459. * The maximum number of vertices allowed for polygons generated during the
  135460. * contour to polygon conversion process. [Limit: >= 3]
  135461. */
  135462. maxVertsPerPoly: number;
  135463. /**
  135464. * Sets the sampling distance to use when generating the detail mesh.
  135465. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  135466. */
  135467. detailSampleDist: number;
  135468. /**
  135469. * The maximum distance the detail mesh surface should deviate from heightfield
  135470. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  135471. */
  135472. detailSampleMaxError: number;
  135473. }
  135474. }
  135475. declare module BABYLON {
  135476. /**
  135477. * RecastJS navigation plugin
  135478. */
  135479. export class RecastJSPlugin implements INavigationEnginePlugin {
  135480. /**
  135481. * Reference to the Recast library
  135482. */
  135483. bjsRECAST: any;
  135484. /**
  135485. * plugin name
  135486. */
  135487. name: string;
  135488. /**
  135489. * the first navmesh created. We might extend this to support multiple navmeshes
  135490. */
  135491. navMesh: any;
  135492. /**
  135493. * Initializes the recastJS plugin
  135494. * @param recastInjection can be used to inject your own recast reference
  135495. */
  135496. constructor(recastInjection?: any);
  135497. /**
  135498. * Creates a navigation mesh
  135499. * @param meshes array of all the geometry used to compute the navigatio mesh
  135500. * @param parameters bunch of parameters used to filter geometry
  135501. */
  135502. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  135503. /**
  135504. * Create a navigation mesh debug mesh
  135505. * @param scene is where the mesh will be added
  135506. * @returns debug display mesh
  135507. */
  135508. createDebugNavMesh(scene: Scene): Mesh;
  135509. /**
  135510. * Get a navigation mesh constrained position, closest to the parameter position
  135511. * @param position world position
  135512. * @returns the closest point to position constrained by the navigation mesh
  135513. */
  135514. getClosestPoint(position: Vector3): Vector3;
  135515. /**
  135516. * Get a navigation mesh constrained position, within a particular radius
  135517. * @param position world position
  135518. * @param maxRadius the maximum distance to the constrained world position
  135519. * @returns the closest point to position constrained by the navigation mesh
  135520. */
  135521. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  135522. /**
  135523. * Compute the final position from a segment made of destination-position
  135524. * @param position world position
  135525. * @param destination world position
  135526. * @returns the resulting point along the navmesh
  135527. */
  135528. moveAlong(position: Vector3, destination: Vector3): Vector3;
  135529. /**
  135530. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  135531. * @param start world position
  135532. * @param end world position
  135533. * @returns array containing world position composing the path
  135534. */
  135535. computePath(start: Vector3, end: Vector3): Vector3[];
  135536. /**
  135537. * Create a new Crowd so you can add agents
  135538. * @param maxAgents the maximum agent count in the crowd
  135539. * @param maxAgentRadius the maximum radius an agent can have
  135540. * @param scene to attach the crowd to
  135541. * @returns the crowd you can add agents to
  135542. */
  135543. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  135544. /**
  135545. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135546. * The queries will try to find a solution within those bounds
  135547. * default is (1,1,1)
  135548. * @param extent x,y,z value that define the extent around the queries point of reference
  135549. */
  135550. setDefaultQueryExtent(extent: Vector3): void;
  135551. /**
  135552. * Get the Bounding box extent specified by setDefaultQueryExtent
  135553. * @returns the box extent values
  135554. */
  135555. getDefaultQueryExtent(): Vector3;
  135556. /**
  135557. * Disposes
  135558. */
  135559. dispose(): void;
  135560. /**
  135561. * If this plugin is supported
  135562. * @returns true if plugin is supported
  135563. */
  135564. isSupported(): boolean;
  135565. }
  135566. /**
  135567. * Recast detour crowd implementation
  135568. */
  135569. export class RecastJSCrowd implements ICrowd {
  135570. /**
  135571. * Recast/detour plugin
  135572. */
  135573. bjsRECASTPlugin: RecastJSPlugin;
  135574. /**
  135575. * Link to the detour crowd
  135576. */
  135577. recastCrowd: any;
  135578. /**
  135579. * One transform per agent
  135580. */
  135581. transforms: TransformNode[];
  135582. /**
  135583. * All agents created
  135584. */
  135585. agents: number[];
  135586. /**
  135587. * Link to the scene is kept to unregister the crowd from the scene
  135588. */
  135589. private _scene;
  135590. /**
  135591. * Observer for crowd updates
  135592. */
  135593. private _onBeforeAnimationsObserver;
  135594. /**
  135595. * Constructor
  135596. * @param plugin recastJS plugin
  135597. * @param maxAgents the maximum agent count in the crowd
  135598. * @param maxAgentRadius the maximum radius an agent can have
  135599. * @param scene to attach the crowd to
  135600. * @returns the crowd you can add agents to
  135601. */
  135602. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  135603. /**
  135604. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  135605. * You can attach anything to that node. The node position is updated in the scene update tick.
  135606. * @param pos world position that will be constrained by the navigation mesh
  135607. * @param parameters agent parameters
  135608. * @param transform hooked to the agent that will be update by the scene
  135609. * @returns agent index
  135610. */
  135611. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  135612. /**
  135613. * Returns the agent position in world space
  135614. * @param index agent index returned by addAgent
  135615. * @returns world space position
  135616. */
  135617. getAgentPosition(index: number): Vector3;
  135618. /**
  135619. * Returns the agent velocity in world space
  135620. * @param index agent index returned by addAgent
  135621. * @returns world space velocity
  135622. */
  135623. getAgentVelocity(index: number): Vector3;
  135624. /**
  135625. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  135626. * @param index agent index returned by addAgent
  135627. * @param destination targeted world position
  135628. */
  135629. agentGoto(index: number, destination: Vector3): void;
  135630. /**
  135631. * Teleport the agent to a new position
  135632. * @param index agent index returned by addAgent
  135633. * @param destination targeted world position
  135634. */
  135635. agentTeleport(index: number, destination: Vector3): void;
  135636. /**
  135637. * Update agent parameters
  135638. * @param index agent index returned by addAgent
  135639. * @param parameters agent parameters
  135640. */
  135641. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  135642. /**
  135643. * remove a particular agent previously created
  135644. * @param index agent index returned by addAgent
  135645. */
  135646. removeAgent(index: number): void;
  135647. /**
  135648. * get the list of all agents attached to this crowd
  135649. * @returns list of agent indices
  135650. */
  135651. getAgents(): number[];
  135652. /**
  135653. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  135654. * @param deltaTime in seconds
  135655. */
  135656. update(deltaTime: number): void;
  135657. /**
  135658. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135659. * The queries will try to find a solution within those bounds
  135660. * default is (1,1,1)
  135661. * @param extent x,y,z value that define the extent around the queries point of reference
  135662. */
  135663. setDefaultQueryExtent(extent: Vector3): void;
  135664. /**
  135665. * Get the Bounding box extent specified by setDefaultQueryExtent
  135666. * @returns the box extent values
  135667. */
  135668. getDefaultQueryExtent(): Vector3;
  135669. /**
  135670. * Release all resources
  135671. */
  135672. dispose(): void;
  135673. }
  135674. }
  135675. declare module BABYLON {
  135676. /**
  135677. * Class used to enable access to IndexedDB
  135678. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  135679. */
  135680. export class Database implements IOfflineProvider {
  135681. private _callbackManifestChecked;
  135682. private _currentSceneUrl;
  135683. private _db;
  135684. private _enableSceneOffline;
  135685. private _enableTexturesOffline;
  135686. private _manifestVersionFound;
  135687. private _mustUpdateRessources;
  135688. private _hasReachedQuota;
  135689. private _isSupported;
  135690. private _idbFactory;
  135691. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  135692. private static IsUASupportingBlobStorage;
  135693. /**
  135694. * Gets a boolean indicating if Database storate is enabled (off by default)
  135695. */
  135696. static IDBStorageEnabled: boolean;
  135697. /**
  135698. * Gets a boolean indicating if scene must be saved in the database
  135699. */
  135700. get enableSceneOffline(): boolean;
  135701. /**
  135702. * Gets a boolean indicating if textures must be saved in the database
  135703. */
  135704. get enableTexturesOffline(): boolean;
  135705. /**
  135706. * Creates a new Database
  135707. * @param urlToScene defines the url to load the scene
  135708. * @param callbackManifestChecked defines the callback to use when manifest is checked
  135709. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  135710. */
  135711. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  135712. private static _ParseURL;
  135713. private static _ReturnFullUrlLocation;
  135714. private _checkManifestFile;
  135715. /**
  135716. * Open the database and make it available
  135717. * @param successCallback defines the callback to call on success
  135718. * @param errorCallback defines the callback to call on error
  135719. */
  135720. open(successCallback: () => void, errorCallback: () => void): void;
  135721. /**
  135722. * Loads an image from the database
  135723. * @param url defines the url to load from
  135724. * @param image defines the target DOM image
  135725. */
  135726. loadImage(url: string, image: HTMLImageElement): void;
  135727. private _loadImageFromDBAsync;
  135728. private _saveImageIntoDBAsync;
  135729. private _checkVersionFromDB;
  135730. private _loadVersionFromDBAsync;
  135731. private _saveVersionIntoDBAsync;
  135732. /**
  135733. * Loads a file from database
  135734. * @param url defines the URL to load from
  135735. * @param sceneLoaded defines a callback to call on success
  135736. * @param progressCallBack defines a callback to call when progress changed
  135737. * @param errorCallback defines a callback to call on error
  135738. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  135739. */
  135740. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  135741. private _loadFileAsync;
  135742. private _saveFileAsync;
  135743. /**
  135744. * Validates if xhr data is correct
  135745. * @param xhr defines the request to validate
  135746. * @param dataType defines the expected data type
  135747. * @returns true if data is correct
  135748. */
  135749. private static _ValidateXHRData;
  135750. }
  135751. }
  135752. declare module BABYLON {
  135753. /** @hidden */
  135754. export var gpuUpdateParticlesPixelShader: {
  135755. name: string;
  135756. shader: string;
  135757. };
  135758. }
  135759. declare module BABYLON {
  135760. /** @hidden */
  135761. export var gpuUpdateParticlesVertexShader: {
  135762. name: string;
  135763. shader: string;
  135764. };
  135765. }
  135766. declare module BABYLON {
  135767. /** @hidden */
  135768. export var clipPlaneFragmentDeclaration2: {
  135769. name: string;
  135770. shader: string;
  135771. };
  135772. }
  135773. declare module BABYLON {
  135774. /** @hidden */
  135775. export var gpuRenderParticlesPixelShader: {
  135776. name: string;
  135777. shader: string;
  135778. };
  135779. }
  135780. declare module BABYLON {
  135781. /** @hidden */
  135782. export var clipPlaneVertexDeclaration2: {
  135783. name: string;
  135784. shader: string;
  135785. };
  135786. }
  135787. declare module BABYLON {
  135788. /** @hidden */
  135789. export var gpuRenderParticlesVertexShader: {
  135790. name: string;
  135791. shader: string;
  135792. };
  135793. }
  135794. declare module BABYLON {
  135795. /**
  135796. * This represents a GPU particle system in Babylon
  135797. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  135798. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  135799. */
  135800. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  135801. /**
  135802. * The layer mask we are rendering the particles through.
  135803. */
  135804. layerMask: number;
  135805. private _capacity;
  135806. private _activeCount;
  135807. private _currentActiveCount;
  135808. private _accumulatedCount;
  135809. private _renderEffect;
  135810. private _updateEffect;
  135811. private _buffer0;
  135812. private _buffer1;
  135813. private _spriteBuffer;
  135814. private _updateVAO;
  135815. private _renderVAO;
  135816. private _targetIndex;
  135817. private _sourceBuffer;
  135818. private _targetBuffer;
  135819. private _engine;
  135820. private _currentRenderId;
  135821. private _started;
  135822. private _stopped;
  135823. private _timeDelta;
  135824. private _randomTexture;
  135825. private _randomTexture2;
  135826. private _attributesStrideSize;
  135827. private _updateEffectOptions;
  135828. private _randomTextureSize;
  135829. private _actualFrame;
  135830. private readonly _rawTextureWidth;
  135831. /**
  135832. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  135833. */
  135834. static get IsSupported(): boolean;
  135835. /**
  135836. * An event triggered when the system is disposed.
  135837. */
  135838. onDisposeObservable: Observable<GPUParticleSystem>;
  135839. /**
  135840. * Gets the maximum number of particles active at the same time.
  135841. * @returns The max number of active particles.
  135842. */
  135843. getCapacity(): number;
  135844. /**
  135845. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  135846. * to override the particles.
  135847. */
  135848. forceDepthWrite: boolean;
  135849. /**
  135850. * Gets or set the number of active particles
  135851. */
  135852. get activeParticleCount(): number;
  135853. set activeParticleCount(value: number);
  135854. private _preWarmDone;
  135855. /**
  135856. * Is this system ready to be used/rendered
  135857. * @return true if the system is ready
  135858. */
  135859. isReady(): boolean;
  135860. /**
  135861. * Gets if the system has been started. (Note: this will still be true after stop is called)
  135862. * @returns True if it has been started, otherwise false.
  135863. */
  135864. isStarted(): boolean;
  135865. /**
  135866. * Starts the particle system and begins to emit
  135867. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  135868. */
  135869. start(delay?: number): void;
  135870. /**
  135871. * Stops the particle system.
  135872. */
  135873. stop(): void;
  135874. /**
  135875. * Remove all active particles
  135876. */
  135877. reset(): void;
  135878. /**
  135879. * Returns the string "GPUParticleSystem"
  135880. * @returns a string containing the class name
  135881. */
  135882. getClassName(): string;
  135883. private _colorGradientsTexture;
  135884. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  135885. /**
  135886. * Adds a new color gradient
  135887. * @param gradient defines the gradient to use (between 0 and 1)
  135888. * @param color1 defines the color to affect to the specified gradient
  135889. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  135890. * @returns the current particle system
  135891. */
  135892. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  135893. /**
  135894. * Remove a specific color gradient
  135895. * @param gradient defines the gradient to remove
  135896. * @returns the current particle system
  135897. */
  135898. removeColorGradient(gradient: number): GPUParticleSystem;
  135899. private _angularSpeedGradientsTexture;
  135900. private _sizeGradientsTexture;
  135901. private _velocityGradientsTexture;
  135902. private _limitVelocityGradientsTexture;
  135903. private _dragGradientsTexture;
  135904. private _addFactorGradient;
  135905. /**
  135906. * Adds a new size gradient
  135907. * @param gradient defines the gradient to use (between 0 and 1)
  135908. * @param factor defines the size factor to affect to the specified gradient
  135909. * @returns the current particle system
  135910. */
  135911. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  135912. /**
  135913. * Remove a specific size gradient
  135914. * @param gradient defines the gradient to remove
  135915. * @returns the current particle system
  135916. */
  135917. removeSizeGradient(gradient: number): GPUParticleSystem;
  135918. /**
  135919. * Adds a new angular speed gradient
  135920. * @param gradient defines the gradient to use (between 0 and 1)
  135921. * @param factor defines the angular speed to affect to the specified gradient
  135922. * @returns the current particle system
  135923. */
  135924. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  135925. /**
  135926. * Remove a specific angular speed gradient
  135927. * @param gradient defines the gradient to remove
  135928. * @returns the current particle system
  135929. */
  135930. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  135931. /**
  135932. * Adds a new velocity gradient
  135933. * @param gradient defines the gradient to use (between 0 and 1)
  135934. * @param factor defines the velocity to affect to the specified gradient
  135935. * @returns the current particle system
  135936. */
  135937. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  135938. /**
  135939. * Remove a specific velocity gradient
  135940. * @param gradient defines the gradient to remove
  135941. * @returns the current particle system
  135942. */
  135943. removeVelocityGradient(gradient: number): GPUParticleSystem;
  135944. /**
  135945. * Adds a new limit velocity gradient
  135946. * @param gradient defines the gradient to use (between 0 and 1)
  135947. * @param factor defines the limit velocity value to affect to the specified gradient
  135948. * @returns the current particle system
  135949. */
  135950. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  135951. /**
  135952. * Remove a specific limit velocity gradient
  135953. * @param gradient defines the gradient to remove
  135954. * @returns the current particle system
  135955. */
  135956. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  135957. /**
  135958. * Adds a new drag gradient
  135959. * @param gradient defines the gradient to use (between 0 and 1)
  135960. * @param factor defines the drag value to affect to the specified gradient
  135961. * @returns the current particle system
  135962. */
  135963. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  135964. /**
  135965. * Remove a specific drag gradient
  135966. * @param gradient defines the gradient to remove
  135967. * @returns the current particle system
  135968. */
  135969. removeDragGradient(gradient: number): GPUParticleSystem;
  135970. /**
  135971. * Not supported by GPUParticleSystem
  135972. * @param gradient defines the gradient to use (between 0 and 1)
  135973. * @param factor defines the emit rate value to affect to the specified gradient
  135974. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  135975. * @returns the current particle system
  135976. */
  135977. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  135978. /**
  135979. * Not supported by GPUParticleSystem
  135980. * @param gradient defines the gradient to remove
  135981. * @returns the current particle system
  135982. */
  135983. removeEmitRateGradient(gradient: number): IParticleSystem;
  135984. /**
  135985. * Not supported by GPUParticleSystem
  135986. * @param gradient defines the gradient to use (between 0 and 1)
  135987. * @param factor defines the start size value to affect to the specified gradient
  135988. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  135989. * @returns the current particle system
  135990. */
  135991. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  135992. /**
  135993. * Not supported by GPUParticleSystem
  135994. * @param gradient defines the gradient to remove
  135995. * @returns the current particle system
  135996. */
  135997. removeStartSizeGradient(gradient: number): IParticleSystem;
  135998. /**
  135999. * Not supported by GPUParticleSystem
  136000. * @param gradient defines the gradient to use (between 0 and 1)
  136001. * @param min defines the color remap minimal range
  136002. * @param max defines the color remap maximal range
  136003. * @returns the current particle system
  136004. */
  136005. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  136006. /**
  136007. * Not supported by GPUParticleSystem
  136008. * @param gradient defines the gradient to remove
  136009. * @returns the current particle system
  136010. */
  136011. removeColorRemapGradient(): IParticleSystem;
  136012. /**
  136013. * Not supported by GPUParticleSystem
  136014. * @param gradient defines the gradient to use (between 0 and 1)
  136015. * @param min defines the alpha remap minimal range
  136016. * @param max defines the alpha remap maximal range
  136017. * @returns the current particle system
  136018. */
  136019. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  136020. /**
  136021. * Not supported by GPUParticleSystem
  136022. * @param gradient defines the gradient to remove
  136023. * @returns the current particle system
  136024. */
  136025. removeAlphaRemapGradient(): IParticleSystem;
  136026. /**
  136027. * Not supported by GPUParticleSystem
  136028. * @param gradient defines the gradient to use (between 0 and 1)
  136029. * @param color defines the color to affect to the specified gradient
  136030. * @returns the current particle system
  136031. */
  136032. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  136033. /**
  136034. * Not supported by GPUParticleSystem
  136035. * @param gradient defines the gradient to remove
  136036. * @returns the current particle system
  136037. */
  136038. removeRampGradient(): IParticleSystem;
  136039. /**
  136040. * Not supported by GPUParticleSystem
  136041. * @returns the list of ramp gradients
  136042. */
  136043. getRampGradients(): Nullable<Array<Color3Gradient>>;
  136044. /**
  136045. * Not supported by GPUParticleSystem
  136046. * Gets or sets a boolean indicating that ramp gradients must be used
  136047. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  136048. */
  136049. get useRampGradients(): boolean;
  136050. set useRampGradients(value: boolean);
  136051. /**
  136052. * Not supported by GPUParticleSystem
  136053. * @param gradient defines the gradient to use (between 0 and 1)
  136054. * @param factor defines the life time factor to affect to the specified gradient
  136055. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  136056. * @returns the current particle system
  136057. */
  136058. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  136059. /**
  136060. * Not supported by GPUParticleSystem
  136061. * @param gradient defines the gradient to remove
  136062. * @returns the current particle system
  136063. */
  136064. removeLifeTimeGradient(gradient: number): IParticleSystem;
  136065. /**
  136066. * Instantiates a GPU particle system.
  136067. * 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.
  136068. * @param name The name of the particle system
  136069. * @param options The options used to create the system
  136070. * @param scene The scene the particle system belongs to
  136071. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  136072. */
  136073. constructor(name: string, options: Partial<{
  136074. capacity: number;
  136075. randomTextureSize: number;
  136076. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  136077. protected _reset(): void;
  136078. private _createUpdateVAO;
  136079. private _createRenderVAO;
  136080. private _initialize;
  136081. /** @hidden */
  136082. _recreateUpdateEffect(): void;
  136083. /** @hidden */
  136084. _recreateRenderEffect(): void;
  136085. /**
  136086. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  136087. * @param preWarm defines if we are in the pre-warmimg phase
  136088. */
  136089. animate(preWarm?: boolean): void;
  136090. private _createFactorGradientTexture;
  136091. private _createSizeGradientTexture;
  136092. private _createAngularSpeedGradientTexture;
  136093. private _createVelocityGradientTexture;
  136094. private _createLimitVelocityGradientTexture;
  136095. private _createDragGradientTexture;
  136096. private _createColorGradientTexture;
  136097. /**
  136098. * Renders the particle system in its current state
  136099. * @param preWarm defines if the system should only update the particles but not render them
  136100. * @returns the current number of particles
  136101. */
  136102. render(preWarm?: boolean): number;
  136103. /**
  136104. * Rebuilds the particle system
  136105. */
  136106. rebuild(): void;
  136107. private _releaseBuffers;
  136108. private _releaseVAOs;
  136109. /**
  136110. * Disposes the particle system and free the associated resources
  136111. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  136112. */
  136113. dispose(disposeTexture?: boolean): void;
  136114. /**
  136115. * Clones the particle system.
  136116. * @param name The name of the cloned object
  136117. * @param newEmitter The new emitter to use
  136118. * @returns the cloned particle system
  136119. */
  136120. clone(name: string, newEmitter: any): GPUParticleSystem;
  136121. /**
  136122. * Serializes the particle system to a JSON object.
  136123. * @returns the JSON object
  136124. */
  136125. serialize(): any;
  136126. /**
  136127. * Parses a JSON object to create a GPU particle system.
  136128. * @param parsedParticleSystem The JSON object to parse
  136129. * @param scene The scene to create the particle system in
  136130. * @param rootUrl The root url to use to load external dependencies like texture
  136131. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  136132. * @returns the parsed GPU particle system
  136133. */
  136134. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  136135. }
  136136. }
  136137. declare module BABYLON {
  136138. /**
  136139. * Represents a set of particle systems working together to create a specific effect
  136140. */
  136141. export class ParticleSystemSet implements IDisposable {
  136142. /**
  136143. * Gets or sets base Assets URL
  136144. */
  136145. static BaseAssetsUrl: string;
  136146. private _emitterCreationOptions;
  136147. private _emitterNode;
  136148. /**
  136149. * Gets the particle system list
  136150. */
  136151. systems: IParticleSystem[];
  136152. /**
  136153. * Gets the emitter node used with this set
  136154. */
  136155. get emitterNode(): Nullable<TransformNode>;
  136156. /**
  136157. * Creates a new emitter mesh as a sphere
  136158. * @param options defines the options used to create the sphere
  136159. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  136160. * @param scene defines the hosting scene
  136161. */
  136162. setEmitterAsSphere(options: {
  136163. diameter: number;
  136164. segments: number;
  136165. color: Color3;
  136166. }, renderingGroupId: number, scene: Scene): void;
  136167. /**
  136168. * Starts all particle systems of the set
  136169. * @param emitter defines an optional mesh to use as emitter for the particle systems
  136170. */
  136171. start(emitter?: AbstractMesh): void;
  136172. /**
  136173. * Release all associated resources
  136174. */
  136175. dispose(): void;
  136176. /**
  136177. * Serialize the set into a JSON compatible object
  136178. * @returns a JSON compatible representation of the set
  136179. */
  136180. serialize(): any;
  136181. /**
  136182. * Parse a new ParticleSystemSet from a serialized source
  136183. * @param data defines a JSON compatible representation of the set
  136184. * @param scene defines the hosting scene
  136185. * @param gpu defines if we want GPU particles or CPU particles
  136186. * @returns a new ParticleSystemSet
  136187. */
  136188. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  136189. }
  136190. }
  136191. declare module BABYLON {
  136192. /**
  136193. * This class is made for on one-liner static method to help creating particle system set.
  136194. */
  136195. export class ParticleHelper {
  136196. /**
  136197. * Gets or sets base Assets URL
  136198. */
  136199. static BaseAssetsUrl: string;
  136200. /**
  136201. * Create a default particle system that you can tweak
  136202. * @param emitter defines the emitter to use
  136203. * @param capacity defines the system capacity (default is 500 particles)
  136204. * @param scene defines the hosting scene
  136205. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  136206. * @returns the new Particle system
  136207. */
  136208. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  136209. /**
  136210. * This is the main static method (one-liner) of this helper to create different particle systems
  136211. * @param type This string represents the type to the particle system to create
  136212. * @param scene The scene where the particle system should live
  136213. * @param gpu If the system will use gpu
  136214. * @returns the ParticleSystemSet created
  136215. */
  136216. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  136217. /**
  136218. * Static function used to export a particle system to a ParticleSystemSet variable.
  136219. * Please note that the emitter shape is not exported
  136220. * @param systems defines the particle systems to export
  136221. * @returns the created particle system set
  136222. */
  136223. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  136224. }
  136225. }
  136226. declare module BABYLON {
  136227. interface Engine {
  136228. /**
  136229. * Create an effect to use with particle systems.
  136230. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  136231. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  136232. * @param uniformsNames defines a list of attribute names
  136233. * @param samplers defines an array of string used to represent textures
  136234. * @param defines defines the string containing the defines to use to compile the shaders
  136235. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  136236. * @param onCompiled defines a function to call when the effect creation is successful
  136237. * @param onError defines a function to call when the effect creation has failed
  136238. * @returns the new Effect
  136239. */
  136240. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  136241. }
  136242. interface Mesh {
  136243. /**
  136244. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  136245. * @returns an array of IParticleSystem
  136246. */
  136247. getEmittedParticleSystems(): IParticleSystem[];
  136248. /**
  136249. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  136250. * @returns an array of IParticleSystem
  136251. */
  136252. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  136253. }
  136254. /**
  136255. * @hidden
  136256. */
  136257. export var _IDoNeedToBeInTheBuild: number;
  136258. }
  136259. declare module BABYLON {
  136260. /** Defines the 4 color options */
  136261. export enum PointColor {
  136262. /** color value */
  136263. Color = 2,
  136264. /** uv value */
  136265. UV = 1,
  136266. /** random value */
  136267. Random = 0,
  136268. /** stated value */
  136269. Stated = 3
  136270. }
  136271. /**
  136272. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  136273. * 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.
  136274. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  136275. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  136276. *
  136277. * Full documentation here : TO BE ENTERED
  136278. */
  136279. export class PointsCloudSystem implements IDisposable {
  136280. /**
  136281. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  136282. * Example : var p = SPS.particles[i];
  136283. */
  136284. particles: CloudPoint[];
  136285. /**
  136286. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  136287. */
  136288. nbParticles: number;
  136289. /**
  136290. * This a counter for your own usage. It's not set by any SPS functions.
  136291. */
  136292. counter: number;
  136293. /**
  136294. * The PCS name. This name is also given to the underlying mesh.
  136295. */
  136296. name: string;
  136297. /**
  136298. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  136299. */
  136300. mesh: Mesh;
  136301. /**
  136302. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  136303. * Please read :
  136304. */
  136305. vars: any;
  136306. /**
  136307. * @hidden
  136308. */
  136309. _size: number;
  136310. private _scene;
  136311. private _promises;
  136312. private _positions;
  136313. private _indices;
  136314. private _normals;
  136315. private _colors;
  136316. private _uvs;
  136317. private _indices32;
  136318. private _positions32;
  136319. private _colors32;
  136320. private _uvs32;
  136321. private _updatable;
  136322. private _isVisibilityBoxLocked;
  136323. private _alwaysVisible;
  136324. private _groups;
  136325. private _groupCounter;
  136326. private _computeParticleColor;
  136327. private _computeParticleTexture;
  136328. private _computeParticleRotation;
  136329. private _computeBoundingBox;
  136330. private _isReady;
  136331. /**
  136332. * Creates a PCS (Points Cloud System) object
  136333. * @param name (String) is the PCS name, this will be the underlying mesh name
  136334. * @param pointSize (number) is the size for each point
  136335. * @param scene (Scene) is the scene in which the PCS is added
  136336. * @param options defines the options of the PCS e.g.
  136337. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  136338. */
  136339. constructor(name: string, pointSize: number, scene: Scene, options?: {
  136340. updatable?: boolean;
  136341. });
  136342. /**
  136343. * Builds the PCS underlying mesh. Returns a standard Mesh.
  136344. * If no points were added to the PCS, the returned mesh is just a single point.
  136345. * @returns a promise for the created mesh
  136346. */
  136347. buildMeshAsync(): Promise<Mesh>;
  136348. /**
  136349. * @hidden
  136350. */
  136351. private _buildMesh;
  136352. private _addParticle;
  136353. private _randomUnitVector;
  136354. private _getColorIndicesForCoord;
  136355. private _setPointsColorOrUV;
  136356. private _colorFromTexture;
  136357. private _calculateDensity;
  136358. /**
  136359. * Adds points to the PCS in random positions within a unit sphere
  136360. * @param nb (positive integer) the number of particles to be created from this model
  136361. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  136362. * @returns the number of groups in the system
  136363. */
  136364. addPoints(nb: number, pointFunction?: any): number;
  136365. /**
  136366. * Adds points to the PCS from the surface of the model shape
  136367. * @param mesh is any Mesh object that will be used as a surface model for the points
  136368. * @param nb (positive integer) the number of particles to be created from this model
  136369. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  136370. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  136371. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  136372. * @returns the number of groups in the system
  136373. */
  136374. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  136375. /**
  136376. * Adds points to the PCS inside the model shape
  136377. * @param mesh is any Mesh object that will be used as a surface model for the points
  136378. * @param nb (positive integer) the number of particles to be created from this model
  136379. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  136380. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  136381. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  136382. * @returns the number of groups in the system
  136383. */
  136384. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  136385. /**
  136386. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  136387. * This method calls `updateParticle()` for each particle of the SPS.
  136388. * For an animated SPS, it is usually called within the render loop.
  136389. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  136390. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  136391. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  136392. * @returns the PCS.
  136393. */
  136394. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  136395. /**
  136396. * Disposes the PCS.
  136397. */
  136398. dispose(): void;
  136399. /**
  136400. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  136401. * doc :
  136402. * @returns the PCS.
  136403. */
  136404. refreshVisibleSize(): PointsCloudSystem;
  136405. /**
  136406. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  136407. * @param size the size (float) of the visibility box
  136408. * note : this doesn't lock the PCS mesh bounding box.
  136409. * doc :
  136410. */
  136411. setVisibilityBox(size: number): void;
  136412. /**
  136413. * Gets whether the PCS is always visible or not
  136414. * doc :
  136415. */
  136416. get isAlwaysVisible(): boolean;
  136417. /**
  136418. * Sets the PCS as always visible or not
  136419. * doc :
  136420. */
  136421. set isAlwaysVisible(val: boolean);
  136422. /**
  136423. * Tells to `setParticles()` to compute the particle rotations or not
  136424. * Default value : false. The PCS is faster when it's set to false
  136425. * Note : particle rotations are only applied to parent particles
  136426. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  136427. */
  136428. set computeParticleRotation(val: boolean);
  136429. /**
  136430. * Tells to `setParticles()` to compute the particle colors or not.
  136431. * Default value : true. The PCS is faster when it's set to false.
  136432. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  136433. */
  136434. set computeParticleColor(val: boolean);
  136435. set computeParticleTexture(val: boolean);
  136436. /**
  136437. * Gets if `setParticles()` computes the particle colors or not.
  136438. * Default value : false. The PCS is faster when it's set to false.
  136439. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  136440. */
  136441. get computeParticleColor(): boolean;
  136442. /**
  136443. * Gets if `setParticles()` computes the particle textures or not.
  136444. * Default value : false. The PCS is faster when it's set to false.
  136445. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  136446. */
  136447. get computeParticleTexture(): boolean;
  136448. /**
  136449. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  136450. */
  136451. set computeBoundingBox(val: boolean);
  136452. /**
  136453. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  136454. */
  136455. get computeBoundingBox(): boolean;
  136456. /**
  136457. * This function does nothing. It may be overwritten to set all the particle first values.
  136458. * The PCS doesn't call this function, you may have to call it by your own.
  136459. * doc :
  136460. */
  136461. initParticles(): void;
  136462. /**
  136463. * This function does nothing. It may be overwritten to recycle a particle
  136464. * The PCS doesn't call this function, you can to call it
  136465. * doc :
  136466. * @param particle The particle to recycle
  136467. * @returns the recycled particle
  136468. */
  136469. recycleParticle(particle: CloudPoint): CloudPoint;
  136470. /**
  136471. * Updates a particle : this function should be overwritten by the user.
  136472. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  136473. * doc :
  136474. * @example : just set a particle position or velocity and recycle conditions
  136475. * @param particle The particle to update
  136476. * @returns the updated particle
  136477. */
  136478. updateParticle(particle: CloudPoint): CloudPoint;
  136479. /**
  136480. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  136481. * This does nothing and may be overwritten by the user.
  136482. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  136483. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  136484. * @param update the boolean update value actually passed to setParticles()
  136485. */
  136486. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  136487. /**
  136488. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  136489. * This will be passed three parameters.
  136490. * This does nothing and may be overwritten by the user.
  136491. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  136492. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  136493. * @param update the boolean update value actually passed to setParticles()
  136494. */
  136495. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  136496. }
  136497. }
  136498. declare module BABYLON {
  136499. /**
  136500. * Represents one particle of a points cloud system.
  136501. */
  136502. export class CloudPoint {
  136503. /**
  136504. * particle global index
  136505. */
  136506. idx: number;
  136507. /**
  136508. * The color of the particle
  136509. */
  136510. color: Nullable<Color4>;
  136511. /**
  136512. * The world space position of the particle.
  136513. */
  136514. position: Vector3;
  136515. /**
  136516. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  136517. */
  136518. rotation: Vector3;
  136519. /**
  136520. * The world space rotation quaternion of the particle.
  136521. */
  136522. rotationQuaternion: Nullable<Quaternion>;
  136523. /**
  136524. * The uv of the particle.
  136525. */
  136526. uv: Nullable<Vector2>;
  136527. /**
  136528. * The current speed of the particle.
  136529. */
  136530. velocity: Vector3;
  136531. /**
  136532. * The pivot point in the particle local space.
  136533. */
  136534. pivot: Vector3;
  136535. /**
  136536. * Must the particle be translated from its pivot point in its local space ?
  136537. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  136538. * Default : false
  136539. */
  136540. translateFromPivot: boolean;
  136541. /**
  136542. * Index of this particle in the global "positions" array (Internal use)
  136543. * @hidden
  136544. */
  136545. _pos: number;
  136546. /**
  136547. * @hidden Index of this particle in the global "indices" array (Internal use)
  136548. */
  136549. _ind: number;
  136550. /**
  136551. * Group this particle belongs to
  136552. */
  136553. _group: PointsGroup;
  136554. /**
  136555. * Group id of this particle
  136556. */
  136557. groupId: number;
  136558. /**
  136559. * Index of the particle in its group id (Internal use)
  136560. */
  136561. idxInGroup: number;
  136562. /**
  136563. * @hidden Particle BoundingInfo object (Internal use)
  136564. */
  136565. _boundingInfo: BoundingInfo;
  136566. /**
  136567. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  136568. */
  136569. _pcs: PointsCloudSystem;
  136570. /**
  136571. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  136572. */
  136573. _stillInvisible: boolean;
  136574. /**
  136575. * @hidden Last computed particle rotation matrix
  136576. */
  136577. _rotationMatrix: number[];
  136578. /**
  136579. * Parent particle Id, if any.
  136580. * Default null.
  136581. */
  136582. parentId: Nullable<number>;
  136583. /**
  136584. * @hidden Internal global position in the PCS.
  136585. */
  136586. _globalPosition: Vector3;
  136587. /**
  136588. * Creates a Point Cloud object.
  136589. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  136590. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  136591. * @param group (PointsGroup) is the group the particle belongs to
  136592. * @param groupId (integer) is the group identifier in the PCS.
  136593. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  136594. * @param pcs defines the PCS it is associated to
  136595. */
  136596. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  136597. /**
  136598. * get point size
  136599. */
  136600. get size(): Vector3;
  136601. /**
  136602. * Set point size
  136603. */
  136604. set size(scale: Vector3);
  136605. /**
  136606. * Legacy support, changed quaternion to rotationQuaternion
  136607. */
  136608. get quaternion(): Nullable<Quaternion>;
  136609. /**
  136610. * Legacy support, changed quaternion to rotationQuaternion
  136611. */
  136612. set quaternion(q: Nullable<Quaternion>);
  136613. /**
  136614. * Returns a boolean. True if the particle intersects a mesh, else false
  136615. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  136616. * @param target is the object (point or mesh) what the intersection is computed against
  136617. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  136618. * @returns true if it intersects
  136619. */
  136620. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  136621. /**
  136622. * get the rotation matrix of the particle
  136623. * @hidden
  136624. */
  136625. getRotationMatrix(m: Matrix): void;
  136626. }
  136627. /**
  136628. * Represents a group of points in a points cloud system
  136629. * * PCS internal tool, don't use it manually.
  136630. */
  136631. export class PointsGroup {
  136632. /**
  136633. * The group id
  136634. * @hidden
  136635. */
  136636. groupID: number;
  136637. /**
  136638. * image data for group (internal use)
  136639. * @hidden
  136640. */
  136641. _groupImageData: Nullable<ArrayBufferView>;
  136642. /**
  136643. * Image Width (internal use)
  136644. * @hidden
  136645. */
  136646. _groupImgWidth: number;
  136647. /**
  136648. * Image Height (internal use)
  136649. * @hidden
  136650. */
  136651. _groupImgHeight: number;
  136652. /**
  136653. * Custom position function (internal use)
  136654. * @hidden
  136655. */
  136656. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  136657. /**
  136658. * density per facet for surface points
  136659. * @hidden
  136660. */
  136661. _groupDensity: number[];
  136662. /**
  136663. * Only when points are colored by texture carries pointer to texture list array
  136664. * @hidden
  136665. */
  136666. _textureNb: number;
  136667. /**
  136668. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  136669. * PCS internal tool, don't use it manually.
  136670. * @hidden
  136671. */
  136672. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  136673. }
  136674. }
  136675. declare module BABYLON {
  136676. interface Scene {
  136677. /** @hidden (Backing field) */
  136678. _physicsEngine: Nullable<IPhysicsEngine>;
  136679. /** @hidden */
  136680. _physicsTimeAccumulator: number;
  136681. /**
  136682. * Gets the current physics engine
  136683. * @returns a IPhysicsEngine or null if none attached
  136684. */
  136685. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  136686. /**
  136687. * Enables physics to the current scene
  136688. * @param gravity defines the scene's gravity for the physics engine
  136689. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  136690. * @return a boolean indicating if the physics engine was initialized
  136691. */
  136692. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  136693. /**
  136694. * Disables and disposes the physics engine associated with the scene
  136695. */
  136696. disablePhysicsEngine(): void;
  136697. /**
  136698. * Gets a boolean indicating if there is an active physics engine
  136699. * @returns a boolean indicating if there is an active physics engine
  136700. */
  136701. isPhysicsEnabled(): boolean;
  136702. /**
  136703. * Deletes a physics compound impostor
  136704. * @param compound defines the compound to delete
  136705. */
  136706. deleteCompoundImpostor(compound: any): void;
  136707. /**
  136708. * An event triggered when physic simulation is about to be run
  136709. */
  136710. onBeforePhysicsObservable: Observable<Scene>;
  136711. /**
  136712. * An event triggered when physic simulation has been done
  136713. */
  136714. onAfterPhysicsObservable: Observable<Scene>;
  136715. }
  136716. interface AbstractMesh {
  136717. /** @hidden */
  136718. _physicsImpostor: Nullable<PhysicsImpostor>;
  136719. /**
  136720. * Gets or sets impostor used for physic simulation
  136721. * @see http://doc.babylonjs.com/features/physics_engine
  136722. */
  136723. physicsImpostor: Nullable<PhysicsImpostor>;
  136724. /**
  136725. * Gets the current physics impostor
  136726. * @see http://doc.babylonjs.com/features/physics_engine
  136727. * @returns a physics impostor or null
  136728. */
  136729. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  136730. /** Apply a physic impulse to the mesh
  136731. * @param force defines the force to apply
  136732. * @param contactPoint defines where to apply the force
  136733. * @returns the current mesh
  136734. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  136735. */
  136736. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  136737. /**
  136738. * Creates a physic joint between two meshes
  136739. * @param otherMesh defines the other mesh to use
  136740. * @param pivot1 defines the pivot to use on this mesh
  136741. * @param pivot2 defines the pivot to use on the other mesh
  136742. * @param options defines additional options (can be plugin dependent)
  136743. * @returns the current mesh
  136744. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  136745. */
  136746. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  136747. /** @hidden */
  136748. _disposePhysicsObserver: Nullable<Observer<Node>>;
  136749. }
  136750. /**
  136751. * Defines the physics engine scene component responsible to manage a physics engine
  136752. */
  136753. export class PhysicsEngineSceneComponent implements ISceneComponent {
  136754. /**
  136755. * The component name helpful to identify the component in the list of scene components.
  136756. */
  136757. readonly name: string;
  136758. /**
  136759. * The scene the component belongs to.
  136760. */
  136761. scene: Scene;
  136762. /**
  136763. * Creates a new instance of the component for the given scene
  136764. * @param scene Defines the scene to register the component in
  136765. */
  136766. constructor(scene: Scene);
  136767. /**
  136768. * Registers the component in a given scene
  136769. */
  136770. register(): void;
  136771. /**
  136772. * Rebuilds the elements related to this component in case of
  136773. * context lost for instance.
  136774. */
  136775. rebuild(): void;
  136776. /**
  136777. * Disposes the component and the associated ressources
  136778. */
  136779. dispose(): void;
  136780. }
  136781. }
  136782. declare module BABYLON {
  136783. /**
  136784. * A helper for physics simulations
  136785. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136786. */
  136787. export class PhysicsHelper {
  136788. private _scene;
  136789. private _physicsEngine;
  136790. /**
  136791. * Initializes the Physics helper
  136792. * @param scene Babylon.js scene
  136793. */
  136794. constructor(scene: Scene);
  136795. /**
  136796. * Applies a radial explosion impulse
  136797. * @param origin the origin of the explosion
  136798. * @param radiusOrEventOptions the radius or the options of radial explosion
  136799. * @param strength the explosion strength
  136800. * @param falloff possible options: Constant & Linear. Defaults to Constant
  136801. * @returns A physics radial explosion event, or null
  136802. */
  136803. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  136804. /**
  136805. * Applies a radial explosion force
  136806. * @param origin the origin of the explosion
  136807. * @param radiusOrEventOptions the radius or the options of radial explosion
  136808. * @param strength the explosion strength
  136809. * @param falloff possible options: Constant & Linear. Defaults to Constant
  136810. * @returns A physics radial explosion event, or null
  136811. */
  136812. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  136813. /**
  136814. * Creates a gravitational field
  136815. * @param origin the origin of the explosion
  136816. * @param radiusOrEventOptions the radius or the options of radial explosion
  136817. * @param strength the explosion strength
  136818. * @param falloff possible options: Constant & Linear. Defaults to Constant
  136819. * @returns A physics gravitational field event, or null
  136820. */
  136821. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  136822. /**
  136823. * Creates a physics updraft event
  136824. * @param origin the origin of the updraft
  136825. * @param radiusOrEventOptions the radius or the options of the updraft
  136826. * @param strength the strength of the updraft
  136827. * @param height the height of the updraft
  136828. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  136829. * @returns A physics updraft event, or null
  136830. */
  136831. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  136832. /**
  136833. * Creates a physics vortex event
  136834. * @param origin the of the vortex
  136835. * @param radiusOrEventOptions the radius or the options of the vortex
  136836. * @param strength the strength of the vortex
  136837. * @param height the height of the vortex
  136838. * @returns a Physics vortex event, or null
  136839. * A physics vortex event or null
  136840. */
  136841. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  136842. }
  136843. /**
  136844. * Represents a physics radial explosion event
  136845. */
  136846. class PhysicsRadialExplosionEvent {
  136847. private _scene;
  136848. private _options;
  136849. private _sphere;
  136850. private _dataFetched;
  136851. /**
  136852. * Initializes a radial explosioin event
  136853. * @param _scene BabylonJS scene
  136854. * @param _options The options for the vortex event
  136855. */
  136856. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  136857. /**
  136858. * Returns the data related to the radial explosion event (sphere).
  136859. * @returns The radial explosion event data
  136860. */
  136861. getData(): PhysicsRadialExplosionEventData;
  136862. /**
  136863. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  136864. * @param impostor A physics imposter
  136865. * @param origin the origin of the explosion
  136866. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  136867. */
  136868. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  136869. /**
  136870. * Triggers affecterd impostors callbacks
  136871. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  136872. */
  136873. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  136874. /**
  136875. * Disposes the sphere.
  136876. * @param force Specifies if the sphere should be disposed by force
  136877. */
  136878. dispose(force?: boolean): void;
  136879. /*** Helpers ***/
  136880. private _prepareSphere;
  136881. private _intersectsWithSphere;
  136882. }
  136883. /**
  136884. * Represents a gravitational field event
  136885. */
  136886. class PhysicsGravitationalFieldEvent {
  136887. private _physicsHelper;
  136888. private _scene;
  136889. private _origin;
  136890. private _options;
  136891. private _tickCallback;
  136892. private _sphere;
  136893. private _dataFetched;
  136894. /**
  136895. * Initializes the physics gravitational field event
  136896. * @param _physicsHelper A physics helper
  136897. * @param _scene BabylonJS scene
  136898. * @param _origin The origin position of the gravitational field event
  136899. * @param _options The options for the vortex event
  136900. */
  136901. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  136902. /**
  136903. * Returns the data related to the gravitational field event (sphere).
  136904. * @returns A gravitational field event
  136905. */
  136906. getData(): PhysicsGravitationalFieldEventData;
  136907. /**
  136908. * Enables the gravitational field.
  136909. */
  136910. enable(): void;
  136911. /**
  136912. * Disables the gravitational field.
  136913. */
  136914. disable(): void;
  136915. /**
  136916. * Disposes the sphere.
  136917. * @param force The force to dispose from the gravitational field event
  136918. */
  136919. dispose(force?: boolean): void;
  136920. private _tick;
  136921. }
  136922. /**
  136923. * Represents a physics updraft event
  136924. */
  136925. class PhysicsUpdraftEvent {
  136926. private _scene;
  136927. private _origin;
  136928. private _options;
  136929. private _physicsEngine;
  136930. private _originTop;
  136931. private _originDirection;
  136932. private _tickCallback;
  136933. private _cylinder;
  136934. private _cylinderPosition;
  136935. private _dataFetched;
  136936. /**
  136937. * Initializes the physics updraft event
  136938. * @param _scene BabylonJS scene
  136939. * @param _origin The origin position of the updraft
  136940. * @param _options The options for the updraft event
  136941. */
  136942. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  136943. /**
  136944. * Returns the data related to the updraft event (cylinder).
  136945. * @returns A physics updraft event
  136946. */
  136947. getData(): PhysicsUpdraftEventData;
  136948. /**
  136949. * Enables the updraft.
  136950. */
  136951. enable(): void;
  136952. /**
  136953. * Disables the updraft.
  136954. */
  136955. disable(): void;
  136956. /**
  136957. * Disposes the cylinder.
  136958. * @param force Specifies if the updraft should be disposed by force
  136959. */
  136960. dispose(force?: boolean): void;
  136961. private getImpostorHitData;
  136962. private _tick;
  136963. /*** Helpers ***/
  136964. private _prepareCylinder;
  136965. private _intersectsWithCylinder;
  136966. }
  136967. /**
  136968. * Represents a physics vortex event
  136969. */
  136970. class PhysicsVortexEvent {
  136971. private _scene;
  136972. private _origin;
  136973. private _options;
  136974. private _physicsEngine;
  136975. private _originTop;
  136976. private _tickCallback;
  136977. private _cylinder;
  136978. private _cylinderPosition;
  136979. private _dataFetched;
  136980. /**
  136981. * Initializes the physics vortex event
  136982. * @param _scene The BabylonJS scene
  136983. * @param _origin The origin position of the vortex
  136984. * @param _options The options for the vortex event
  136985. */
  136986. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  136987. /**
  136988. * Returns the data related to the vortex event (cylinder).
  136989. * @returns The physics vortex event data
  136990. */
  136991. getData(): PhysicsVortexEventData;
  136992. /**
  136993. * Enables the vortex.
  136994. */
  136995. enable(): void;
  136996. /**
  136997. * Disables the cortex.
  136998. */
  136999. disable(): void;
  137000. /**
  137001. * Disposes the sphere.
  137002. * @param force
  137003. */
  137004. dispose(force?: boolean): void;
  137005. private getImpostorHitData;
  137006. private _tick;
  137007. /*** Helpers ***/
  137008. private _prepareCylinder;
  137009. private _intersectsWithCylinder;
  137010. }
  137011. /**
  137012. * Options fot the radial explosion event
  137013. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137014. */
  137015. export class PhysicsRadialExplosionEventOptions {
  137016. /**
  137017. * The radius of the sphere for the radial explosion.
  137018. */
  137019. radius: number;
  137020. /**
  137021. * The strenth of the explosion.
  137022. */
  137023. strength: number;
  137024. /**
  137025. * The strenght of the force in correspondence to the distance of the affected object
  137026. */
  137027. falloff: PhysicsRadialImpulseFalloff;
  137028. /**
  137029. * Sphere options for the radial explosion.
  137030. */
  137031. sphere: {
  137032. segments: number;
  137033. diameter: number;
  137034. };
  137035. /**
  137036. * Sphere options for the radial explosion.
  137037. */
  137038. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  137039. }
  137040. /**
  137041. * Options fot the updraft event
  137042. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137043. */
  137044. export class PhysicsUpdraftEventOptions {
  137045. /**
  137046. * The radius of the cylinder for the vortex
  137047. */
  137048. radius: number;
  137049. /**
  137050. * The strenth of the updraft.
  137051. */
  137052. strength: number;
  137053. /**
  137054. * The height of the cylinder for the updraft.
  137055. */
  137056. height: number;
  137057. /**
  137058. * The mode for the the updraft.
  137059. */
  137060. updraftMode: PhysicsUpdraftMode;
  137061. }
  137062. /**
  137063. * Options fot the vortex event
  137064. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137065. */
  137066. export class PhysicsVortexEventOptions {
  137067. /**
  137068. * The radius of the cylinder for the vortex
  137069. */
  137070. radius: number;
  137071. /**
  137072. * The strenth of the vortex.
  137073. */
  137074. strength: number;
  137075. /**
  137076. * The height of the cylinder for the vortex.
  137077. */
  137078. height: number;
  137079. /**
  137080. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  137081. */
  137082. centripetalForceThreshold: number;
  137083. /**
  137084. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  137085. */
  137086. centripetalForceMultiplier: number;
  137087. /**
  137088. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  137089. */
  137090. centrifugalForceMultiplier: number;
  137091. /**
  137092. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  137093. */
  137094. updraftForceMultiplier: number;
  137095. }
  137096. /**
  137097. * The strenght of the force in correspondence to the distance of the affected object
  137098. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137099. */
  137100. export enum PhysicsRadialImpulseFalloff {
  137101. /** Defines that impulse is constant in strength across it's whole radius */
  137102. Constant = 0,
  137103. /** Defines that impulse gets weaker if it's further from the origin */
  137104. Linear = 1
  137105. }
  137106. /**
  137107. * The strength of the force in correspondence to the distance of the affected object
  137108. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137109. */
  137110. export enum PhysicsUpdraftMode {
  137111. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  137112. Center = 0,
  137113. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  137114. Perpendicular = 1
  137115. }
  137116. /**
  137117. * Interface for a physics hit data
  137118. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137119. */
  137120. export interface PhysicsHitData {
  137121. /**
  137122. * The force applied at the contact point
  137123. */
  137124. force: Vector3;
  137125. /**
  137126. * The contact point
  137127. */
  137128. contactPoint: Vector3;
  137129. /**
  137130. * The distance from the origin to the contact point
  137131. */
  137132. distanceFromOrigin: number;
  137133. }
  137134. /**
  137135. * Interface for radial explosion event data
  137136. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137137. */
  137138. export interface PhysicsRadialExplosionEventData {
  137139. /**
  137140. * A sphere used for the radial explosion event
  137141. */
  137142. sphere: Mesh;
  137143. }
  137144. /**
  137145. * Interface for gravitational field event data
  137146. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137147. */
  137148. export interface PhysicsGravitationalFieldEventData {
  137149. /**
  137150. * A sphere mesh used for the gravitational field event
  137151. */
  137152. sphere: Mesh;
  137153. }
  137154. /**
  137155. * Interface for updraft event data
  137156. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137157. */
  137158. export interface PhysicsUpdraftEventData {
  137159. /**
  137160. * A cylinder used for the updraft event
  137161. */
  137162. cylinder: Mesh;
  137163. }
  137164. /**
  137165. * Interface for vortex event data
  137166. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137167. */
  137168. export interface PhysicsVortexEventData {
  137169. /**
  137170. * A cylinder used for the vortex event
  137171. */
  137172. cylinder: Mesh;
  137173. }
  137174. /**
  137175. * Interface for an affected physics impostor
  137176. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137177. */
  137178. export interface PhysicsAffectedImpostorWithData {
  137179. /**
  137180. * The impostor affected by the effect
  137181. */
  137182. impostor: PhysicsImpostor;
  137183. /**
  137184. * The data about the hit/horce from the explosion
  137185. */
  137186. hitData: PhysicsHitData;
  137187. }
  137188. }
  137189. declare module BABYLON {
  137190. /** @hidden */
  137191. export var blackAndWhitePixelShader: {
  137192. name: string;
  137193. shader: string;
  137194. };
  137195. }
  137196. declare module BABYLON {
  137197. /**
  137198. * Post process used to render in black and white
  137199. */
  137200. export class BlackAndWhitePostProcess extends PostProcess {
  137201. /**
  137202. * Linear about to convert he result to black and white (default: 1)
  137203. */
  137204. degree: number;
  137205. /**
  137206. * Creates a black and white post process
  137207. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  137208. * @param name The name of the effect.
  137209. * @param options The required width/height ratio to downsize to before computing the render pass.
  137210. * @param camera The camera to apply the render pass to.
  137211. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137212. * @param engine The engine which the post process will be applied. (default: current engine)
  137213. * @param reusable If the post process can be reused on the same frame. (default: false)
  137214. */
  137215. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137216. }
  137217. }
  137218. declare module BABYLON {
  137219. /**
  137220. * This represents a set of one or more post processes in Babylon.
  137221. * A post process can be used to apply a shader to a texture after it is rendered.
  137222. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  137223. */
  137224. export class PostProcessRenderEffect {
  137225. private _postProcesses;
  137226. private _getPostProcesses;
  137227. private _singleInstance;
  137228. private _cameras;
  137229. private _indicesForCamera;
  137230. /**
  137231. * Name of the effect
  137232. * @hidden
  137233. */
  137234. _name: string;
  137235. /**
  137236. * Instantiates a post process render effect.
  137237. * A post process can be used to apply a shader to a texture after it is rendered.
  137238. * @param engine The engine the effect is tied to
  137239. * @param name The name of the effect
  137240. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  137241. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  137242. */
  137243. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  137244. /**
  137245. * Checks if all the post processes in the effect are supported.
  137246. */
  137247. get isSupported(): boolean;
  137248. /**
  137249. * Updates the current state of the effect
  137250. * @hidden
  137251. */
  137252. _update(): void;
  137253. /**
  137254. * Attaches the effect on cameras
  137255. * @param cameras The camera to attach to.
  137256. * @hidden
  137257. */
  137258. _attachCameras(cameras: Camera): void;
  137259. /**
  137260. * Attaches the effect on cameras
  137261. * @param cameras The camera to attach to.
  137262. * @hidden
  137263. */
  137264. _attachCameras(cameras: Camera[]): void;
  137265. /**
  137266. * Detaches the effect on cameras
  137267. * @param cameras The camera to detatch from.
  137268. * @hidden
  137269. */
  137270. _detachCameras(cameras: Camera): void;
  137271. /**
  137272. * Detatches the effect on cameras
  137273. * @param cameras The camera to detatch from.
  137274. * @hidden
  137275. */
  137276. _detachCameras(cameras: Camera[]): void;
  137277. /**
  137278. * Enables the effect on given cameras
  137279. * @param cameras The camera to enable.
  137280. * @hidden
  137281. */
  137282. _enable(cameras: Camera): void;
  137283. /**
  137284. * Enables the effect on given cameras
  137285. * @param cameras The camera to enable.
  137286. * @hidden
  137287. */
  137288. _enable(cameras: Nullable<Camera[]>): void;
  137289. /**
  137290. * Disables the effect on the given cameras
  137291. * @param cameras The camera to disable.
  137292. * @hidden
  137293. */
  137294. _disable(cameras: Camera): void;
  137295. /**
  137296. * Disables the effect on the given cameras
  137297. * @param cameras The camera to disable.
  137298. * @hidden
  137299. */
  137300. _disable(cameras: Nullable<Camera[]>): void;
  137301. /**
  137302. * Gets a list of the post processes contained in the effect.
  137303. * @param camera The camera to get the post processes on.
  137304. * @returns The list of the post processes in the effect.
  137305. */
  137306. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  137307. }
  137308. }
  137309. declare module BABYLON {
  137310. /** @hidden */
  137311. export var extractHighlightsPixelShader: {
  137312. name: string;
  137313. shader: string;
  137314. };
  137315. }
  137316. declare module BABYLON {
  137317. /**
  137318. * 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.
  137319. */
  137320. export class ExtractHighlightsPostProcess extends PostProcess {
  137321. /**
  137322. * The luminance threshold, pixels below this value will be set to black.
  137323. */
  137324. threshold: number;
  137325. /** @hidden */
  137326. _exposure: number;
  137327. /**
  137328. * Post process which has the input texture to be used when performing highlight extraction
  137329. * @hidden
  137330. */
  137331. _inputPostProcess: Nullable<PostProcess>;
  137332. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137333. }
  137334. }
  137335. declare module BABYLON {
  137336. /** @hidden */
  137337. export var bloomMergePixelShader: {
  137338. name: string;
  137339. shader: string;
  137340. };
  137341. }
  137342. declare module BABYLON {
  137343. /**
  137344. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  137345. */
  137346. export class BloomMergePostProcess extends PostProcess {
  137347. /** Weight of the bloom to be added to the original input. */
  137348. weight: number;
  137349. /**
  137350. * Creates a new instance of @see BloomMergePostProcess
  137351. * @param name The name of the effect.
  137352. * @param originalFromInput Post process which's input will be used for the merge.
  137353. * @param blurred Blurred highlights post process which's output will be used.
  137354. * @param weight Weight of the bloom to be added to the original input.
  137355. * @param options The required width/height ratio to downsize to before computing the render pass.
  137356. * @param camera The camera to apply the render pass to.
  137357. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137358. * @param engine The engine which the post process will be applied. (default: current engine)
  137359. * @param reusable If the post process can be reused on the same frame. (default: false)
  137360. * @param textureType Type of textures used when performing the post process. (default: 0)
  137361. * @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)
  137362. */
  137363. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  137364. /** Weight of the bloom to be added to the original input. */
  137365. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137366. }
  137367. }
  137368. declare module BABYLON {
  137369. /**
  137370. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  137371. */
  137372. export class BloomEffect extends PostProcessRenderEffect {
  137373. private bloomScale;
  137374. /**
  137375. * @hidden Internal
  137376. */
  137377. _effects: Array<PostProcess>;
  137378. /**
  137379. * @hidden Internal
  137380. */
  137381. _downscale: ExtractHighlightsPostProcess;
  137382. private _blurX;
  137383. private _blurY;
  137384. private _merge;
  137385. /**
  137386. * The luminance threshold to find bright areas of the image to bloom.
  137387. */
  137388. get threshold(): number;
  137389. set threshold(value: number);
  137390. /**
  137391. * The strength of the bloom.
  137392. */
  137393. get weight(): number;
  137394. set weight(value: number);
  137395. /**
  137396. * Specifies the size of the bloom blur kernel, relative to the final output size
  137397. */
  137398. get kernel(): number;
  137399. set kernel(value: number);
  137400. /**
  137401. * Creates a new instance of @see BloomEffect
  137402. * @param scene The scene the effect belongs to.
  137403. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  137404. * @param bloomKernel The size of the kernel to be used when applying the blur.
  137405. * @param bloomWeight The the strength of bloom.
  137406. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  137407. * @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)
  137408. */
  137409. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  137410. /**
  137411. * Disposes each of the internal effects for a given camera.
  137412. * @param camera The camera to dispose the effect on.
  137413. */
  137414. disposeEffects(camera: Camera): void;
  137415. /**
  137416. * @hidden Internal
  137417. */
  137418. _updateEffects(): void;
  137419. /**
  137420. * Internal
  137421. * @returns if all the contained post processes are ready.
  137422. * @hidden
  137423. */
  137424. _isReady(): boolean;
  137425. }
  137426. }
  137427. declare module BABYLON {
  137428. /** @hidden */
  137429. export var chromaticAberrationPixelShader: {
  137430. name: string;
  137431. shader: string;
  137432. };
  137433. }
  137434. declare module BABYLON {
  137435. /**
  137436. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  137437. */
  137438. export class ChromaticAberrationPostProcess extends PostProcess {
  137439. /**
  137440. * The amount of seperation of rgb channels (default: 30)
  137441. */
  137442. aberrationAmount: number;
  137443. /**
  137444. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  137445. */
  137446. radialIntensity: number;
  137447. /**
  137448. * 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))
  137449. */
  137450. direction: Vector2;
  137451. /**
  137452. * 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))
  137453. */
  137454. centerPosition: Vector2;
  137455. /**
  137456. * Creates a new instance ChromaticAberrationPostProcess
  137457. * @param name The name of the effect.
  137458. * @param screenWidth The width of the screen to apply the effect on.
  137459. * @param screenHeight The height of the screen to apply the effect on.
  137460. * @param options The required width/height ratio to downsize to before computing the render pass.
  137461. * @param camera The camera to apply the render pass to.
  137462. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137463. * @param engine The engine which the post process will be applied. (default: current engine)
  137464. * @param reusable If the post process can be reused on the same frame. (default: false)
  137465. * @param textureType Type of textures used when performing the post process. (default: 0)
  137466. * @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)
  137467. */
  137468. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137469. }
  137470. }
  137471. declare module BABYLON {
  137472. /** @hidden */
  137473. export var circleOfConfusionPixelShader: {
  137474. name: string;
  137475. shader: string;
  137476. };
  137477. }
  137478. declare module BABYLON {
  137479. /**
  137480. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  137481. */
  137482. export class CircleOfConfusionPostProcess extends PostProcess {
  137483. /**
  137484. * 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.
  137485. */
  137486. lensSize: number;
  137487. /**
  137488. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  137489. */
  137490. fStop: number;
  137491. /**
  137492. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  137493. */
  137494. focusDistance: number;
  137495. /**
  137496. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  137497. */
  137498. focalLength: number;
  137499. private _depthTexture;
  137500. /**
  137501. * Creates a new instance CircleOfConfusionPostProcess
  137502. * @param name The name of the effect.
  137503. * @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.
  137504. * @param options The required width/height ratio to downsize to before computing the render pass.
  137505. * @param camera The camera to apply the render pass to.
  137506. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137507. * @param engine The engine which the post process will be applied. (default: current engine)
  137508. * @param reusable If the post process can be reused on the same frame. (default: false)
  137509. * @param textureType Type of textures used when performing the post process. (default: 0)
  137510. * @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)
  137511. */
  137512. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137513. /**
  137514. * 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.
  137515. */
  137516. set depthTexture(value: RenderTargetTexture);
  137517. }
  137518. }
  137519. declare module BABYLON {
  137520. /** @hidden */
  137521. export var colorCorrectionPixelShader: {
  137522. name: string;
  137523. shader: string;
  137524. };
  137525. }
  137526. declare module BABYLON {
  137527. /**
  137528. *
  137529. * This post-process allows the modification of rendered colors by using
  137530. * a 'look-up table' (LUT). This effect is also called Color Grading.
  137531. *
  137532. * The object needs to be provided an url to a texture containing the color
  137533. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  137534. * Use an image editing software to tweak the LUT to match your needs.
  137535. *
  137536. * For an example of a color LUT, see here:
  137537. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  137538. * For explanations on color grading, see here:
  137539. * @see http://udn.epicgames.com/Three/ColorGrading.html
  137540. *
  137541. */
  137542. export class ColorCorrectionPostProcess extends PostProcess {
  137543. private _colorTableTexture;
  137544. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137545. }
  137546. }
  137547. declare module BABYLON {
  137548. /** @hidden */
  137549. export var convolutionPixelShader: {
  137550. name: string;
  137551. shader: string;
  137552. };
  137553. }
  137554. declare module BABYLON {
  137555. /**
  137556. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  137557. * input texture to perform effects such as edge detection or sharpening
  137558. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  137559. */
  137560. export class ConvolutionPostProcess extends PostProcess {
  137561. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  137562. kernel: number[];
  137563. /**
  137564. * Creates a new instance ConvolutionPostProcess
  137565. * @param name The name of the effect.
  137566. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  137567. * @param options The required width/height ratio to downsize to before computing the render pass.
  137568. * @param camera The camera to apply the render pass to.
  137569. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137570. * @param engine The engine which the post process will be applied. (default: current engine)
  137571. * @param reusable If the post process can be reused on the same frame. (default: false)
  137572. * @param textureType Type of textures used when performing the post process. (default: 0)
  137573. */
  137574. constructor(name: string,
  137575. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  137576. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  137577. /**
  137578. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137579. */
  137580. static EdgeDetect0Kernel: number[];
  137581. /**
  137582. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137583. */
  137584. static EdgeDetect1Kernel: number[];
  137585. /**
  137586. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137587. */
  137588. static EdgeDetect2Kernel: number[];
  137589. /**
  137590. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137591. */
  137592. static SharpenKernel: number[];
  137593. /**
  137594. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137595. */
  137596. static EmbossKernel: number[];
  137597. /**
  137598. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137599. */
  137600. static GaussianKernel: number[];
  137601. }
  137602. }
  137603. declare module BABYLON {
  137604. /**
  137605. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  137606. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  137607. * based on samples that have a large difference in distance than the center pixel.
  137608. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  137609. */
  137610. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  137611. direction: Vector2;
  137612. /**
  137613. * Creates a new instance CircleOfConfusionPostProcess
  137614. * @param name The name of the effect.
  137615. * @param scene The scene the effect belongs to.
  137616. * @param direction The direction the blur should be applied.
  137617. * @param kernel The size of the kernel used to blur.
  137618. * @param options The required width/height ratio to downsize to before computing the render pass.
  137619. * @param camera The camera to apply the render pass to.
  137620. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  137621. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  137622. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137623. * @param engine The engine which the post process will be applied. (default: current engine)
  137624. * @param reusable If the post process can be reused on the same frame. (default: false)
  137625. * @param textureType Type of textures used when performing the post process. (default: 0)
  137626. * @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)
  137627. */
  137628. 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);
  137629. }
  137630. }
  137631. declare module BABYLON {
  137632. /** @hidden */
  137633. export var depthOfFieldMergePixelShader: {
  137634. name: string;
  137635. shader: string;
  137636. };
  137637. }
  137638. declare module BABYLON {
  137639. /**
  137640. * Options to be set when merging outputs from the default pipeline.
  137641. */
  137642. export class DepthOfFieldMergePostProcessOptions {
  137643. /**
  137644. * The original image to merge on top of
  137645. */
  137646. originalFromInput: PostProcess;
  137647. /**
  137648. * Parameters to perform the merge of the depth of field effect
  137649. */
  137650. depthOfField?: {
  137651. circleOfConfusion: PostProcess;
  137652. blurSteps: Array<PostProcess>;
  137653. };
  137654. /**
  137655. * Parameters to perform the merge of bloom effect
  137656. */
  137657. bloom?: {
  137658. blurred: PostProcess;
  137659. weight: number;
  137660. };
  137661. }
  137662. /**
  137663. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  137664. */
  137665. export class DepthOfFieldMergePostProcess extends PostProcess {
  137666. private blurSteps;
  137667. /**
  137668. * Creates a new instance of DepthOfFieldMergePostProcess
  137669. * @param name The name of the effect.
  137670. * @param originalFromInput Post process which's input will be used for the merge.
  137671. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  137672. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  137673. * @param options The required width/height ratio to downsize to before computing the render pass.
  137674. * @param camera The camera to apply the render pass to.
  137675. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137676. * @param engine The engine which the post process will be applied. (default: current engine)
  137677. * @param reusable If the post process can be reused on the same frame. (default: false)
  137678. * @param textureType Type of textures used when performing the post process. (default: 0)
  137679. * @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)
  137680. */
  137681. 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);
  137682. /**
  137683. * Updates the effect with the current post process compile time values and recompiles the shader.
  137684. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  137685. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  137686. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  137687. * @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
  137688. * @param onCompiled Called when the shader has been compiled.
  137689. * @param onError Called if there is an error when compiling a shader.
  137690. */
  137691. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  137692. }
  137693. }
  137694. declare module BABYLON {
  137695. /**
  137696. * Specifies the level of max blur that should be applied when using the depth of field effect
  137697. */
  137698. export enum DepthOfFieldEffectBlurLevel {
  137699. /**
  137700. * Subtle blur
  137701. */
  137702. Low = 0,
  137703. /**
  137704. * Medium blur
  137705. */
  137706. Medium = 1,
  137707. /**
  137708. * Large blur
  137709. */
  137710. High = 2
  137711. }
  137712. /**
  137713. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  137714. */
  137715. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  137716. private _circleOfConfusion;
  137717. /**
  137718. * @hidden Internal, blurs from high to low
  137719. */
  137720. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  137721. private _depthOfFieldBlurY;
  137722. private _dofMerge;
  137723. /**
  137724. * @hidden Internal post processes in depth of field effect
  137725. */
  137726. _effects: Array<PostProcess>;
  137727. /**
  137728. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  137729. */
  137730. set focalLength(value: number);
  137731. get focalLength(): number;
  137732. /**
  137733. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  137734. */
  137735. set fStop(value: number);
  137736. get fStop(): number;
  137737. /**
  137738. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  137739. */
  137740. set focusDistance(value: number);
  137741. get focusDistance(): number;
  137742. /**
  137743. * 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.
  137744. */
  137745. set lensSize(value: number);
  137746. get lensSize(): number;
  137747. /**
  137748. * Creates a new instance DepthOfFieldEffect
  137749. * @param scene The scene the effect belongs to.
  137750. * @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.
  137751. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  137752. * @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)
  137753. */
  137754. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  137755. /**
  137756. * Get the current class name of the current effet
  137757. * @returns "DepthOfFieldEffect"
  137758. */
  137759. getClassName(): string;
  137760. /**
  137761. * 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.
  137762. */
  137763. set depthTexture(value: RenderTargetTexture);
  137764. /**
  137765. * Disposes each of the internal effects for a given camera.
  137766. * @param camera The camera to dispose the effect on.
  137767. */
  137768. disposeEffects(camera: Camera): void;
  137769. /**
  137770. * @hidden Internal
  137771. */
  137772. _updateEffects(): void;
  137773. /**
  137774. * Internal
  137775. * @returns if all the contained post processes are ready.
  137776. * @hidden
  137777. */
  137778. _isReady(): boolean;
  137779. }
  137780. }
  137781. declare module BABYLON {
  137782. /** @hidden */
  137783. export var displayPassPixelShader: {
  137784. name: string;
  137785. shader: string;
  137786. };
  137787. }
  137788. declare module BABYLON {
  137789. /**
  137790. * DisplayPassPostProcess which produces an output the same as it's input
  137791. */
  137792. export class DisplayPassPostProcess extends PostProcess {
  137793. /**
  137794. * Creates the DisplayPassPostProcess
  137795. * @param name The name of the effect.
  137796. * @param options The required width/height ratio to downsize to before computing the render pass.
  137797. * @param camera The camera to apply the render pass to.
  137798. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137799. * @param engine The engine which the post process will be applied. (default: current engine)
  137800. * @param reusable If the post process can be reused on the same frame. (default: false)
  137801. */
  137802. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137803. }
  137804. }
  137805. declare module BABYLON {
  137806. /** @hidden */
  137807. export var filterPixelShader: {
  137808. name: string;
  137809. shader: string;
  137810. };
  137811. }
  137812. declare module BABYLON {
  137813. /**
  137814. * Applies a kernel filter to the image
  137815. */
  137816. export class FilterPostProcess extends PostProcess {
  137817. /** The matrix to be applied to the image */
  137818. kernelMatrix: Matrix;
  137819. /**
  137820. *
  137821. * @param name The name of the effect.
  137822. * @param kernelMatrix The matrix to be applied to the image
  137823. * @param options The required width/height ratio to downsize to before computing the render pass.
  137824. * @param camera The camera to apply the render pass to.
  137825. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137826. * @param engine The engine which the post process will be applied. (default: current engine)
  137827. * @param reusable If the post process can be reused on the same frame. (default: false)
  137828. */
  137829. constructor(name: string,
  137830. /** The matrix to be applied to the image */
  137831. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137832. }
  137833. }
  137834. declare module BABYLON {
  137835. /** @hidden */
  137836. export var fxaaPixelShader: {
  137837. name: string;
  137838. shader: string;
  137839. };
  137840. }
  137841. declare module BABYLON {
  137842. /** @hidden */
  137843. export var fxaaVertexShader: {
  137844. name: string;
  137845. shader: string;
  137846. };
  137847. }
  137848. declare module BABYLON {
  137849. /**
  137850. * Fxaa post process
  137851. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  137852. */
  137853. export class FxaaPostProcess extends PostProcess {
  137854. /** @hidden */
  137855. texelWidth: number;
  137856. /** @hidden */
  137857. texelHeight: number;
  137858. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  137859. private _getDefines;
  137860. }
  137861. }
  137862. declare module BABYLON {
  137863. /** @hidden */
  137864. export var grainPixelShader: {
  137865. name: string;
  137866. shader: string;
  137867. };
  137868. }
  137869. declare module BABYLON {
  137870. /**
  137871. * The GrainPostProcess adds noise to the image at mid luminance levels
  137872. */
  137873. export class GrainPostProcess extends PostProcess {
  137874. /**
  137875. * The intensity of the grain added (default: 30)
  137876. */
  137877. intensity: number;
  137878. /**
  137879. * If the grain should be randomized on every frame
  137880. */
  137881. animated: boolean;
  137882. /**
  137883. * Creates a new instance of @see GrainPostProcess
  137884. * @param name The name of the effect.
  137885. * @param options The required width/height ratio to downsize to before computing the render pass.
  137886. * @param camera The camera to apply the render pass to.
  137887. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137888. * @param engine The engine which the post process will be applied. (default: current engine)
  137889. * @param reusable If the post process can be reused on the same frame. (default: false)
  137890. * @param textureType Type of textures used when performing the post process. (default: 0)
  137891. * @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)
  137892. */
  137893. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137894. }
  137895. }
  137896. declare module BABYLON {
  137897. /** @hidden */
  137898. export var highlightsPixelShader: {
  137899. name: string;
  137900. shader: string;
  137901. };
  137902. }
  137903. declare module BABYLON {
  137904. /**
  137905. * Extracts highlights from the image
  137906. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  137907. */
  137908. export class HighlightsPostProcess extends PostProcess {
  137909. /**
  137910. * Extracts highlights from the image
  137911. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  137912. * @param name The name of the effect.
  137913. * @param options The required width/height ratio to downsize to before computing the render pass.
  137914. * @param camera The camera to apply the render pass to.
  137915. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137916. * @param engine The engine which the post process will be applied. (default: current engine)
  137917. * @param reusable If the post process can be reused on the same frame. (default: false)
  137918. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  137919. */
  137920. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  137921. }
  137922. }
  137923. declare module BABYLON {
  137924. /** @hidden */
  137925. export var mrtFragmentDeclaration: {
  137926. name: string;
  137927. shader: string;
  137928. };
  137929. }
  137930. declare module BABYLON {
  137931. /** @hidden */
  137932. export var geometryPixelShader: {
  137933. name: string;
  137934. shader: string;
  137935. };
  137936. }
  137937. declare module BABYLON {
  137938. /** @hidden */
  137939. export var geometryVertexShader: {
  137940. name: string;
  137941. shader: string;
  137942. };
  137943. }
  137944. declare module BABYLON {
  137945. /** @hidden */
  137946. interface ISavedTransformationMatrix {
  137947. world: Matrix;
  137948. viewProjection: Matrix;
  137949. }
  137950. /**
  137951. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  137952. */
  137953. export class GeometryBufferRenderer {
  137954. /**
  137955. * Constant used to retrieve the position texture index in the G-Buffer textures array
  137956. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  137957. */
  137958. static readonly POSITION_TEXTURE_TYPE: number;
  137959. /**
  137960. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  137961. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  137962. */
  137963. static readonly VELOCITY_TEXTURE_TYPE: number;
  137964. /**
  137965. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  137966. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  137967. */
  137968. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  137969. /**
  137970. * Dictionary used to store the previous transformation matrices of each rendered mesh
  137971. * in order to compute objects velocities when enableVelocity is set to "true"
  137972. * @hidden
  137973. */
  137974. _previousTransformationMatrices: {
  137975. [index: number]: ISavedTransformationMatrix;
  137976. };
  137977. /**
  137978. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  137979. * in order to compute objects velocities when enableVelocity is set to "true"
  137980. * @hidden
  137981. */
  137982. _previousBonesTransformationMatrices: {
  137983. [index: number]: Float32Array;
  137984. };
  137985. /**
  137986. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  137987. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  137988. */
  137989. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  137990. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  137991. renderTransparentMeshes: boolean;
  137992. private _scene;
  137993. private _multiRenderTarget;
  137994. private _ratio;
  137995. private _enablePosition;
  137996. private _enableVelocity;
  137997. private _enableReflectivity;
  137998. private _positionIndex;
  137999. private _velocityIndex;
  138000. private _reflectivityIndex;
  138001. protected _effect: Effect;
  138002. protected _cachedDefines: string;
  138003. /**
  138004. * Set the render list (meshes to be rendered) used in the G buffer.
  138005. */
  138006. set renderList(meshes: Mesh[]);
  138007. /**
  138008. * Gets wether or not G buffer are supported by the running hardware.
  138009. * This requires draw buffer supports
  138010. */
  138011. get isSupported(): boolean;
  138012. /**
  138013. * Returns the index of the given texture type in the G-Buffer textures array
  138014. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  138015. * @returns the index of the given texture type in the G-Buffer textures array
  138016. */
  138017. getTextureIndex(textureType: number): number;
  138018. /**
  138019. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  138020. */
  138021. get enablePosition(): boolean;
  138022. /**
  138023. * Sets whether or not objects positions are enabled for the G buffer.
  138024. */
  138025. set enablePosition(enable: boolean);
  138026. /**
  138027. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  138028. */
  138029. get enableVelocity(): boolean;
  138030. /**
  138031. * Sets wether or not objects velocities are enabled for the G buffer.
  138032. */
  138033. set enableVelocity(enable: boolean);
  138034. /**
  138035. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  138036. */
  138037. get enableReflectivity(): boolean;
  138038. /**
  138039. * Sets wether or not objects roughness are enabled for the G buffer.
  138040. */
  138041. set enableReflectivity(enable: boolean);
  138042. /**
  138043. * Gets the scene associated with the buffer.
  138044. */
  138045. get scene(): Scene;
  138046. /**
  138047. * Gets the ratio used by the buffer during its creation.
  138048. * How big is the buffer related to the main canvas.
  138049. */
  138050. get ratio(): number;
  138051. /** @hidden */
  138052. static _SceneComponentInitialization: (scene: Scene) => void;
  138053. /**
  138054. * Creates a new G Buffer for the scene
  138055. * @param scene The scene the buffer belongs to
  138056. * @param ratio How big is the buffer related to the main canvas.
  138057. */
  138058. constructor(scene: Scene, ratio?: number);
  138059. /**
  138060. * Checks wether everything is ready to render a submesh to the G buffer.
  138061. * @param subMesh the submesh to check readiness for
  138062. * @param useInstances is the mesh drawn using instance or not
  138063. * @returns true if ready otherwise false
  138064. */
  138065. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  138066. /**
  138067. * Gets the current underlying G Buffer.
  138068. * @returns the buffer
  138069. */
  138070. getGBuffer(): MultiRenderTarget;
  138071. /**
  138072. * Gets the number of samples used to render the buffer (anti aliasing).
  138073. */
  138074. get samples(): number;
  138075. /**
  138076. * Sets the number of samples used to render the buffer (anti aliasing).
  138077. */
  138078. set samples(value: number);
  138079. /**
  138080. * Disposes the renderer and frees up associated resources.
  138081. */
  138082. dispose(): void;
  138083. protected _createRenderTargets(): void;
  138084. private _copyBonesTransformationMatrices;
  138085. }
  138086. }
  138087. declare module BABYLON {
  138088. interface Scene {
  138089. /** @hidden (Backing field) */
  138090. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  138091. /**
  138092. * Gets or Sets the current geometry buffer associated to the scene.
  138093. */
  138094. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  138095. /**
  138096. * Enables a GeometryBufferRender and associates it with the scene
  138097. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  138098. * @returns the GeometryBufferRenderer
  138099. */
  138100. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  138101. /**
  138102. * Disables the GeometryBufferRender associated with the scene
  138103. */
  138104. disableGeometryBufferRenderer(): void;
  138105. }
  138106. /**
  138107. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  138108. * in several rendering techniques.
  138109. */
  138110. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  138111. /**
  138112. * The component name helpful to identify the component in the list of scene components.
  138113. */
  138114. readonly name: string;
  138115. /**
  138116. * The scene the component belongs to.
  138117. */
  138118. scene: Scene;
  138119. /**
  138120. * Creates a new instance of the component for the given scene
  138121. * @param scene Defines the scene to register the component in
  138122. */
  138123. constructor(scene: Scene);
  138124. /**
  138125. * Registers the component in a given scene
  138126. */
  138127. register(): void;
  138128. /**
  138129. * Rebuilds the elements related to this component in case of
  138130. * context lost for instance.
  138131. */
  138132. rebuild(): void;
  138133. /**
  138134. * Disposes the component and the associated ressources
  138135. */
  138136. dispose(): void;
  138137. private _gatherRenderTargets;
  138138. }
  138139. }
  138140. declare module BABYLON {
  138141. /** @hidden */
  138142. export var motionBlurPixelShader: {
  138143. name: string;
  138144. shader: string;
  138145. };
  138146. }
  138147. declare module BABYLON {
  138148. /**
  138149. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  138150. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  138151. * As an example, all you have to do is to create the post-process:
  138152. * var mb = new BABYLON.MotionBlurPostProcess(
  138153. * 'mb', // The name of the effect.
  138154. * scene, // The scene containing the objects to blur according to their velocity.
  138155. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  138156. * camera // The camera to apply the render pass to.
  138157. * );
  138158. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  138159. */
  138160. export class MotionBlurPostProcess extends PostProcess {
  138161. /**
  138162. * Defines how much the image is blurred by the movement. Default value is equal to 1
  138163. */
  138164. motionStrength: number;
  138165. /**
  138166. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  138167. */
  138168. get motionBlurSamples(): number;
  138169. /**
  138170. * Sets the number of iterations to be used for motion blur quality
  138171. */
  138172. set motionBlurSamples(samples: number);
  138173. private _motionBlurSamples;
  138174. private _geometryBufferRenderer;
  138175. /**
  138176. * Creates a new instance MotionBlurPostProcess
  138177. * @param name The name of the effect.
  138178. * @param scene The scene containing the objects to blur according to their velocity.
  138179. * @param options The required width/height ratio to downsize to before computing the render pass.
  138180. * @param camera The camera to apply the render pass to.
  138181. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138182. * @param engine The engine which the post process will be applied. (default: current engine)
  138183. * @param reusable If the post process can be reused on the same frame. (default: false)
  138184. * @param textureType Type of textures used when performing the post process. (default: 0)
  138185. * @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)
  138186. */
  138187. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138188. /**
  138189. * Excludes the given skinned mesh from computing bones velocities.
  138190. * 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.
  138191. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  138192. */
  138193. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  138194. /**
  138195. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  138196. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  138197. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  138198. */
  138199. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  138200. /**
  138201. * Disposes the post process.
  138202. * @param camera The camera to dispose the post process on.
  138203. */
  138204. dispose(camera?: Camera): void;
  138205. }
  138206. }
  138207. declare module BABYLON {
  138208. /** @hidden */
  138209. export var refractionPixelShader: {
  138210. name: string;
  138211. shader: string;
  138212. };
  138213. }
  138214. declare module BABYLON {
  138215. /**
  138216. * Post process which applies a refractin texture
  138217. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  138218. */
  138219. export class RefractionPostProcess extends PostProcess {
  138220. /** the base color of the refraction (used to taint the rendering) */
  138221. color: Color3;
  138222. /** simulated refraction depth */
  138223. depth: number;
  138224. /** the coefficient of the base color (0 to remove base color tainting) */
  138225. colorLevel: number;
  138226. private _refTexture;
  138227. private _ownRefractionTexture;
  138228. /**
  138229. * Gets or sets the refraction texture
  138230. * Please note that you are responsible for disposing the texture if you set it manually
  138231. */
  138232. get refractionTexture(): Texture;
  138233. set refractionTexture(value: Texture);
  138234. /**
  138235. * Initializes the RefractionPostProcess
  138236. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  138237. * @param name The name of the effect.
  138238. * @param refractionTextureUrl Url of the refraction texture to use
  138239. * @param color the base color of the refraction (used to taint the rendering)
  138240. * @param depth simulated refraction depth
  138241. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  138242. * @param camera The camera to apply the render pass to.
  138243. * @param options The required width/height ratio to downsize to before computing the render pass.
  138244. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138245. * @param engine The engine which the post process will be applied. (default: current engine)
  138246. * @param reusable If the post process can be reused on the same frame. (default: false)
  138247. */
  138248. constructor(name: string, refractionTextureUrl: string,
  138249. /** the base color of the refraction (used to taint the rendering) */
  138250. color: Color3,
  138251. /** simulated refraction depth */
  138252. depth: number,
  138253. /** the coefficient of the base color (0 to remove base color tainting) */
  138254. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  138255. /**
  138256. * Disposes of the post process
  138257. * @param camera Camera to dispose post process on
  138258. */
  138259. dispose(camera: Camera): void;
  138260. }
  138261. }
  138262. declare module BABYLON {
  138263. /** @hidden */
  138264. export var sharpenPixelShader: {
  138265. name: string;
  138266. shader: string;
  138267. };
  138268. }
  138269. declare module BABYLON {
  138270. /**
  138271. * The SharpenPostProcess applies a sharpen kernel to every pixel
  138272. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  138273. */
  138274. export class SharpenPostProcess extends PostProcess {
  138275. /**
  138276. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  138277. */
  138278. colorAmount: number;
  138279. /**
  138280. * How much sharpness should be applied (default: 0.3)
  138281. */
  138282. edgeAmount: number;
  138283. /**
  138284. * Creates a new instance ConvolutionPostProcess
  138285. * @param name The name of the effect.
  138286. * @param options The required width/height ratio to downsize to before computing the render pass.
  138287. * @param camera The camera to apply the render pass to.
  138288. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138289. * @param engine The engine which the post process will be applied. (default: current engine)
  138290. * @param reusable If the post process can be reused on the same frame. (default: false)
  138291. * @param textureType Type of textures used when performing the post process. (default: 0)
  138292. * @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)
  138293. */
  138294. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138295. }
  138296. }
  138297. declare module BABYLON {
  138298. /**
  138299. * PostProcessRenderPipeline
  138300. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138301. */
  138302. export class PostProcessRenderPipeline {
  138303. private engine;
  138304. private _renderEffects;
  138305. private _renderEffectsForIsolatedPass;
  138306. /**
  138307. * List of inspectable custom properties (used by the Inspector)
  138308. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  138309. */
  138310. inspectableCustomProperties: IInspectable[];
  138311. /**
  138312. * @hidden
  138313. */
  138314. protected _cameras: Camera[];
  138315. /** @hidden */
  138316. _name: string;
  138317. /**
  138318. * Gets pipeline name
  138319. */
  138320. get name(): string;
  138321. /** Gets the list of attached cameras */
  138322. get cameras(): Camera[];
  138323. /**
  138324. * Initializes a PostProcessRenderPipeline
  138325. * @param engine engine to add the pipeline to
  138326. * @param name name of the pipeline
  138327. */
  138328. constructor(engine: Engine, name: string);
  138329. /**
  138330. * Gets the class name
  138331. * @returns "PostProcessRenderPipeline"
  138332. */
  138333. getClassName(): string;
  138334. /**
  138335. * If all the render effects in the pipeline are supported
  138336. */
  138337. get isSupported(): boolean;
  138338. /**
  138339. * Adds an effect to the pipeline
  138340. * @param renderEffect the effect to add
  138341. */
  138342. addEffect(renderEffect: PostProcessRenderEffect): void;
  138343. /** @hidden */
  138344. _rebuild(): void;
  138345. /** @hidden */
  138346. _enableEffect(renderEffectName: string, cameras: Camera): void;
  138347. /** @hidden */
  138348. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  138349. /** @hidden */
  138350. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  138351. /** @hidden */
  138352. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  138353. /** @hidden */
  138354. _attachCameras(cameras: Camera, unique: boolean): void;
  138355. /** @hidden */
  138356. _attachCameras(cameras: Camera[], unique: boolean): void;
  138357. /** @hidden */
  138358. _detachCameras(cameras: Camera): void;
  138359. /** @hidden */
  138360. _detachCameras(cameras: Nullable<Camera[]>): void;
  138361. /** @hidden */
  138362. _update(): void;
  138363. /** @hidden */
  138364. _reset(): void;
  138365. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  138366. /**
  138367. * Disposes of the pipeline
  138368. */
  138369. dispose(): void;
  138370. }
  138371. }
  138372. declare module BABYLON {
  138373. /**
  138374. * PostProcessRenderPipelineManager class
  138375. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138376. */
  138377. export class PostProcessRenderPipelineManager {
  138378. private _renderPipelines;
  138379. /**
  138380. * Initializes a PostProcessRenderPipelineManager
  138381. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138382. */
  138383. constructor();
  138384. /**
  138385. * Gets the list of supported render pipelines
  138386. */
  138387. get supportedPipelines(): PostProcessRenderPipeline[];
  138388. /**
  138389. * Adds a pipeline to the manager
  138390. * @param renderPipeline The pipeline to add
  138391. */
  138392. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  138393. /**
  138394. * Attaches a camera to the pipeline
  138395. * @param renderPipelineName The name of the pipeline to attach to
  138396. * @param cameras the camera to attach
  138397. * @param unique if the camera can be attached multiple times to the pipeline
  138398. */
  138399. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  138400. /**
  138401. * Detaches a camera from the pipeline
  138402. * @param renderPipelineName The name of the pipeline to detach from
  138403. * @param cameras the camera to detach
  138404. */
  138405. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  138406. /**
  138407. * Enables an effect by name on a pipeline
  138408. * @param renderPipelineName the name of the pipeline to enable the effect in
  138409. * @param renderEffectName the name of the effect to enable
  138410. * @param cameras the cameras that the effect should be enabled on
  138411. */
  138412. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  138413. /**
  138414. * Disables an effect by name on a pipeline
  138415. * @param renderPipelineName the name of the pipeline to disable the effect in
  138416. * @param renderEffectName the name of the effect to disable
  138417. * @param cameras the cameras that the effect should be disabled on
  138418. */
  138419. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  138420. /**
  138421. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  138422. */
  138423. update(): void;
  138424. /** @hidden */
  138425. _rebuild(): void;
  138426. /**
  138427. * Disposes of the manager and pipelines
  138428. */
  138429. dispose(): void;
  138430. }
  138431. }
  138432. declare module BABYLON {
  138433. interface Scene {
  138434. /** @hidden (Backing field) */
  138435. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  138436. /**
  138437. * Gets the postprocess render pipeline manager
  138438. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138439. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  138440. */
  138441. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  138442. }
  138443. /**
  138444. * Defines the Render Pipeline scene component responsible to rendering pipelines
  138445. */
  138446. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  138447. /**
  138448. * The component name helpfull to identify the component in the list of scene components.
  138449. */
  138450. readonly name: string;
  138451. /**
  138452. * The scene the component belongs to.
  138453. */
  138454. scene: Scene;
  138455. /**
  138456. * Creates a new instance of the component for the given scene
  138457. * @param scene Defines the scene to register the component in
  138458. */
  138459. constructor(scene: Scene);
  138460. /**
  138461. * Registers the component in a given scene
  138462. */
  138463. register(): void;
  138464. /**
  138465. * Rebuilds the elements related to this component in case of
  138466. * context lost for instance.
  138467. */
  138468. rebuild(): void;
  138469. /**
  138470. * Disposes the component and the associated ressources
  138471. */
  138472. dispose(): void;
  138473. private _gatherRenderTargets;
  138474. }
  138475. }
  138476. declare module BABYLON {
  138477. /**
  138478. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  138479. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  138480. */
  138481. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  138482. private _scene;
  138483. private _camerasToBeAttached;
  138484. /**
  138485. * ID of the sharpen post process,
  138486. */
  138487. private readonly SharpenPostProcessId;
  138488. /**
  138489. * @ignore
  138490. * ID of the image processing post process;
  138491. */
  138492. readonly ImageProcessingPostProcessId: string;
  138493. /**
  138494. * @ignore
  138495. * ID of the Fast Approximate Anti-Aliasing post process;
  138496. */
  138497. readonly FxaaPostProcessId: string;
  138498. /**
  138499. * ID of the chromatic aberration post process,
  138500. */
  138501. private readonly ChromaticAberrationPostProcessId;
  138502. /**
  138503. * ID of the grain post process
  138504. */
  138505. private readonly GrainPostProcessId;
  138506. /**
  138507. * Sharpen post process which will apply a sharpen convolution to enhance edges
  138508. */
  138509. sharpen: SharpenPostProcess;
  138510. private _sharpenEffect;
  138511. private bloom;
  138512. /**
  138513. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  138514. */
  138515. depthOfField: DepthOfFieldEffect;
  138516. /**
  138517. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  138518. */
  138519. fxaa: FxaaPostProcess;
  138520. /**
  138521. * Image post processing pass used to perform operations such as tone mapping or color grading.
  138522. */
  138523. imageProcessing: ImageProcessingPostProcess;
  138524. /**
  138525. * Chromatic aberration post process which will shift rgb colors in the image
  138526. */
  138527. chromaticAberration: ChromaticAberrationPostProcess;
  138528. private _chromaticAberrationEffect;
  138529. /**
  138530. * Grain post process which add noise to the image
  138531. */
  138532. grain: GrainPostProcess;
  138533. private _grainEffect;
  138534. /**
  138535. * Glow post process which adds a glow to emissive areas of the image
  138536. */
  138537. private _glowLayer;
  138538. /**
  138539. * Animations which can be used to tweak settings over a period of time
  138540. */
  138541. animations: Animation[];
  138542. private _imageProcessingConfigurationObserver;
  138543. private _sharpenEnabled;
  138544. private _bloomEnabled;
  138545. private _depthOfFieldEnabled;
  138546. private _depthOfFieldBlurLevel;
  138547. private _fxaaEnabled;
  138548. private _imageProcessingEnabled;
  138549. private _defaultPipelineTextureType;
  138550. private _bloomScale;
  138551. private _chromaticAberrationEnabled;
  138552. private _grainEnabled;
  138553. private _buildAllowed;
  138554. /**
  138555. * Gets active scene
  138556. */
  138557. get scene(): Scene;
  138558. /**
  138559. * Enable or disable the sharpen process from the pipeline
  138560. */
  138561. set sharpenEnabled(enabled: boolean);
  138562. get sharpenEnabled(): boolean;
  138563. private _resizeObserver;
  138564. private _hardwareScaleLevel;
  138565. private _bloomKernel;
  138566. /**
  138567. * Specifies the size of the bloom blur kernel, relative to the final output size
  138568. */
  138569. get bloomKernel(): number;
  138570. set bloomKernel(value: number);
  138571. /**
  138572. * Specifies the weight of the bloom in the final rendering
  138573. */
  138574. private _bloomWeight;
  138575. /**
  138576. * Specifies the luma threshold for the area that will be blurred by the bloom
  138577. */
  138578. private _bloomThreshold;
  138579. private _hdr;
  138580. /**
  138581. * The strength of the bloom.
  138582. */
  138583. set bloomWeight(value: number);
  138584. get bloomWeight(): number;
  138585. /**
  138586. * The strength of the bloom.
  138587. */
  138588. set bloomThreshold(value: number);
  138589. get bloomThreshold(): number;
  138590. /**
  138591. * The scale of the bloom, lower value will provide better performance.
  138592. */
  138593. set bloomScale(value: number);
  138594. get bloomScale(): number;
  138595. /**
  138596. * Enable or disable the bloom from the pipeline
  138597. */
  138598. set bloomEnabled(enabled: boolean);
  138599. get bloomEnabled(): boolean;
  138600. private _rebuildBloom;
  138601. /**
  138602. * If the depth of field is enabled.
  138603. */
  138604. get depthOfFieldEnabled(): boolean;
  138605. set depthOfFieldEnabled(enabled: boolean);
  138606. /**
  138607. * Blur level of the depth of field effect. (Higher blur will effect performance)
  138608. */
  138609. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  138610. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  138611. /**
  138612. * If the anti aliasing is enabled.
  138613. */
  138614. set fxaaEnabled(enabled: boolean);
  138615. get fxaaEnabled(): boolean;
  138616. private _samples;
  138617. /**
  138618. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  138619. */
  138620. set samples(sampleCount: number);
  138621. get samples(): number;
  138622. /**
  138623. * If image processing is enabled.
  138624. */
  138625. set imageProcessingEnabled(enabled: boolean);
  138626. get imageProcessingEnabled(): boolean;
  138627. /**
  138628. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  138629. */
  138630. set glowLayerEnabled(enabled: boolean);
  138631. get glowLayerEnabled(): boolean;
  138632. /**
  138633. * Gets the glow layer (or null if not defined)
  138634. */
  138635. get glowLayer(): Nullable<GlowLayer>;
  138636. /**
  138637. * Enable or disable the chromaticAberration process from the pipeline
  138638. */
  138639. set chromaticAberrationEnabled(enabled: boolean);
  138640. get chromaticAberrationEnabled(): boolean;
  138641. /**
  138642. * Enable or disable the grain process from the pipeline
  138643. */
  138644. set grainEnabled(enabled: boolean);
  138645. get grainEnabled(): boolean;
  138646. /**
  138647. * @constructor
  138648. * @param name - The rendering pipeline name (default: "")
  138649. * @param hdr - If high dynamic range textures should be used (default: true)
  138650. * @param scene - The scene linked to this pipeline (default: the last created scene)
  138651. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  138652. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  138653. */
  138654. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  138655. /**
  138656. * Get the class name
  138657. * @returns "DefaultRenderingPipeline"
  138658. */
  138659. getClassName(): string;
  138660. /**
  138661. * Force the compilation of the entire pipeline.
  138662. */
  138663. prepare(): void;
  138664. private _hasCleared;
  138665. private _prevPostProcess;
  138666. private _prevPrevPostProcess;
  138667. private _setAutoClearAndTextureSharing;
  138668. private _depthOfFieldSceneObserver;
  138669. private _buildPipeline;
  138670. private _disposePostProcesses;
  138671. /**
  138672. * Adds a camera to the pipeline
  138673. * @param camera the camera to be added
  138674. */
  138675. addCamera(camera: Camera): void;
  138676. /**
  138677. * Removes a camera from the pipeline
  138678. * @param camera the camera to remove
  138679. */
  138680. removeCamera(camera: Camera): void;
  138681. /**
  138682. * Dispose of the pipeline and stop all post processes
  138683. */
  138684. dispose(): void;
  138685. /**
  138686. * Serialize the rendering pipeline (Used when exporting)
  138687. * @returns the serialized object
  138688. */
  138689. serialize(): any;
  138690. /**
  138691. * Parse the serialized pipeline
  138692. * @param source Source pipeline.
  138693. * @param scene The scene to load the pipeline to.
  138694. * @param rootUrl The URL of the serialized pipeline.
  138695. * @returns An instantiated pipeline from the serialized object.
  138696. */
  138697. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  138698. }
  138699. }
  138700. declare module BABYLON {
  138701. /** @hidden */
  138702. export var lensHighlightsPixelShader: {
  138703. name: string;
  138704. shader: string;
  138705. };
  138706. }
  138707. declare module BABYLON {
  138708. /** @hidden */
  138709. export var depthOfFieldPixelShader: {
  138710. name: string;
  138711. shader: string;
  138712. };
  138713. }
  138714. declare module BABYLON {
  138715. /**
  138716. * BABYLON.JS Chromatic Aberration GLSL Shader
  138717. * Author: Olivier Guyot
  138718. * Separates very slightly R, G and B colors on the edges of the screen
  138719. * Inspired by Francois Tarlier & Martins Upitis
  138720. */
  138721. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  138722. /**
  138723. * @ignore
  138724. * The chromatic aberration PostProcess id in the pipeline
  138725. */
  138726. LensChromaticAberrationEffect: string;
  138727. /**
  138728. * @ignore
  138729. * The highlights enhancing PostProcess id in the pipeline
  138730. */
  138731. HighlightsEnhancingEffect: string;
  138732. /**
  138733. * @ignore
  138734. * The depth-of-field PostProcess id in the pipeline
  138735. */
  138736. LensDepthOfFieldEffect: string;
  138737. private _scene;
  138738. private _depthTexture;
  138739. private _grainTexture;
  138740. private _chromaticAberrationPostProcess;
  138741. private _highlightsPostProcess;
  138742. private _depthOfFieldPostProcess;
  138743. private _edgeBlur;
  138744. private _grainAmount;
  138745. private _chromaticAberration;
  138746. private _distortion;
  138747. private _highlightsGain;
  138748. private _highlightsThreshold;
  138749. private _dofDistance;
  138750. private _dofAperture;
  138751. private _dofDarken;
  138752. private _dofPentagon;
  138753. private _blurNoise;
  138754. /**
  138755. * @constructor
  138756. *
  138757. * Effect parameters are as follow:
  138758. * {
  138759. * chromatic_aberration: number; // from 0 to x (1 for realism)
  138760. * edge_blur: number; // from 0 to x (1 for realism)
  138761. * distortion: number; // from 0 to x (1 for realism)
  138762. * grain_amount: number; // from 0 to 1
  138763. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  138764. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  138765. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  138766. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  138767. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  138768. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  138769. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  138770. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  138771. * }
  138772. * Note: if an effect parameter is unset, effect is disabled
  138773. *
  138774. * @param name The rendering pipeline name
  138775. * @param parameters - An object containing all parameters (see above)
  138776. * @param scene The scene linked to this pipeline
  138777. * @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)
  138778. * @param cameras The array of cameras that the rendering pipeline will be attached to
  138779. */
  138780. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  138781. /**
  138782. * Get the class name
  138783. * @returns "LensRenderingPipeline"
  138784. */
  138785. getClassName(): string;
  138786. /**
  138787. * Gets associated scene
  138788. */
  138789. get scene(): Scene;
  138790. /**
  138791. * Gets or sets the edge blur
  138792. */
  138793. get edgeBlur(): number;
  138794. set edgeBlur(value: number);
  138795. /**
  138796. * Gets or sets the grain amount
  138797. */
  138798. get grainAmount(): number;
  138799. set grainAmount(value: number);
  138800. /**
  138801. * Gets or sets the chromatic aberration amount
  138802. */
  138803. get chromaticAberration(): number;
  138804. set chromaticAberration(value: number);
  138805. /**
  138806. * Gets or sets the depth of field aperture
  138807. */
  138808. get dofAperture(): number;
  138809. set dofAperture(value: number);
  138810. /**
  138811. * Gets or sets the edge distortion
  138812. */
  138813. get edgeDistortion(): number;
  138814. set edgeDistortion(value: number);
  138815. /**
  138816. * Gets or sets the depth of field distortion
  138817. */
  138818. get dofDistortion(): number;
  138819. set dofDistortion(value: number);
  138820. /**
  138821. * Gets or sets the darken out of focus amount
  138822. */
  138823. get darkenOutOfFocus(): number;
  138824. set darkenOutOfFocus(value: number);
  138825. /**
  138826. * Gets or sets a boolean indicating if blur noise is enabled
  138827. */
  138828. get blurNoise(): boolean;
  138829. set blurNoise(value: boolean);
  138830. /**
  138831. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  138832. */
  138833. get pentagonBokeh(): boolean;
  138834. set pentagonBokeh(value: boolean);
  138835. /**
  138836. * Gets or sets the highlight grain amount
  138837. */
  138838. get highlightsGain(): number;
  138839. set highlightsGain(value: number);
  138840. /**
  138841. * Gets or sets the highlight threshold
  138842. */
  138843. get highlightsThreshold(): number;
  138844. set highlightsThreshold(value: number);
  138845. /**
  138846. * Sets the amount of blur at the edges
  138847. * @param amount blur amount
  138848. */
  138849. setEdgeBlur(amount: number): void;
  138850. /**
  138851. * Sets edge blur to 0
  138852. */
  138853. disableEdgeBlur(): void;
  138854. /**
  138855. * Sets the amout of grain
  138856. * @param amount Amount of grain
  138857. */
  138858. setGrainAmount(amount: number): void;
  138859. /**
  138860. * Set grain amount to 0
  138861. */
  138862. disableGrain(): void;
  138863. /**
  138864. * Sets the chromatic aberration amount
  138865. * @param amount amount of chromatic aberration
  138866. */
  138867. setChromaticAberration(amount: number): void;
  138868. /**
  138869. * Sets chromatic aberration amount to 0
  138870. */
  138871. disableChromaticAberration(): void;
  138872. /**
  138873. * Sets the EdgeDistortion amount
  138874. * @param amount amount of EdgeDistortion
  138875. */
  138876. setEdgeDistortion(amount: number): void;
  138877. /**
  138878. * Sets edge distortion to 0
  138879. */
  138880. disableEdgeDistortion(): void;
  138881. /**
  138882. * Sets the FocusDistance amount
  138883. * @param amount amount of FocusDistance
  138884. */
  138885. setFocusDistance(amount: number): void;
  138886. /**
  138887. * Disables depth of field
  138888. */
  138889. disableDepthOfField(): void;
  138890. /**
  138891. * Sets the Aperture amount
  138892. * @param amount amount of Aperture
  138893. */
  138894. setAperture(amount: number): void;
  138895. /**
  138896. * Sets the DarkenOutOfFocus amount
  138897. * @param amount amount of DarkenOutOfFocus
  138898. */
  138899. setDarkenOutOfFocus(amount: number): void;
  138900. private _pentagonBokehIsEnabled;
  138901. /**
  138902. * Creates a pentagon bokeh effect
  138903. */
  138904. enablePentagonBokeh(): void;
  138905. /**
  138906. * Disables the pentagon bokeh effect
  138907. */
  138908. disablePentagonBokeh(): void;
  138909. /**
  138910. * Enables noise blur
  138911. */
  138912. enableNoiseBlur(): void;
  138913. /**
  138914. * Disables noise blur
  138915. */
  138916. disableNoiseBlur(): void;
  138917. /**
  138918. * Sets the HighlightsGain amount
  138919. * @param amount amount of HighlightsGain
  138920. */
  138921. setHighlightsGain(amount: number): void;
  138922. /**
  138923. * Sets the HighlightsThreshold amount
  138924. * @param amount amount of HighlightsThreshold
  138925. */
  138926. setHighlightsThreshold(amount: number): void;
  138927. /**
  138928. * Disables highlights
  138929. */
  138930. disableHighlights(): void;
  138931. /**
  138932. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  138933. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  138934. */
  138935. dispose(disableDepthRender?: boolean): void;
  138936. private _createChromaticAberrationPostProcess;
  138937. private _createHighlightsPostProcess;
  138938. private _createDepthOfFieldPostProcess;
  138939. private _createGrainTexture;
  138940. }
  138941. }
  138942. declare module BABYLON {
  138943. /** @hidden */
  138944. export var ssao2PixelShader: {
  138945. name: string;
  138946. shader: string;
  138947. };
  138948. }
  138949. declare module BABYLON {
  138950. /** @hidden */
  138951. export var ssaoCombinePixelShader: {
  138952. name: string;
  138953. shader: string;
  138954. };
  138955. }
  138956. declare module BABYLON {
  138957. /**
  138958. * Render pipeline to produce ssao effect
  138959. */
  138960. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  138961. /**
  138962. * @ignore
  138963. * The PassPostProcess id in the pipeline that contains the original scene color
  138964. */
  138965. SSAOOriginalSceneColorEffect: string;
  138966. /**
  138967. * @ignore
  138968. * The SSAO PostProcess id in the pipeline
  138969. */
  138970. SSAORenderEffect: string;
  138971. /**
  138972. * @ignore
  138973. * The horizontal blur PostProcess id in the pipeline
  138974. */
  138975. SSAOBlurHRenderEffect: string;
  138976. /**
  138977. * @ignore
  138978. * The vertical blur PostProcess id in the pipeline
  138979. */
  138980. SSAOBlurVRenderEffect: string;
  138981. /**
  138982. * @ignore
  138983. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  138984. */
  138985. SSAOCombineRenderEffect: string;
  138986. /**
  138987. * The output strength of the SSAO post-process. Default value is 1.0.
  138988. */
  138989. totalStrength: number;
  138990. /**
  138991. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  138992. */
  138993. maxZ: number;
  138994. /**
  138995. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  138996. */
  138997. minZAspect: number;
  138998. private _samples;
  138999. /**
  139000. * Number of samples used for the SSAO calculations. Default value is 8
  139001. */
  139002. set samples(n: number);
  139003. get samples(): number;
  139004. private _textureSamples;
  139005. /**
  139006. * Number of samples to use for antialiasing
  139007. */
  139008. set textureSamples(n: number);
  139009. get textureSamples(): number;
  139010. /**
  139011. * Ratio object used for SSAO ratio and blur ratio
  139012. */
  139013. private _ratio;
  139014. /**
  139015. * Dynamically generated sphere sampler.
  139016. */
  139017. private _sampleSphere;
  139018. /**
  139019. * Blur filter offsets
  139020. */
  139021. private _samplerOffsets;
  139022. private _expensiveBlur;
  139023. /**
  139024. * If bilateral blur should be used
  139025. */
  139026. set expensiveBlur(b: boolean);
  139027. get expensiveBlur(): boolean;
  139028. /**
  139029. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  139030. */
  139031. radius: number;
  139032. /**
  139033. * The base color of the SSAO post-process
  139034. * The final result is "base + ssao" between [0, 1]
  139035. */
  139036. base: number;
  139037. /**
  139038. * Support test.
  139039. */
  139040. static get IsSupported(): boolean;
  139041. private _scene;
  139042. private _depthTexture;
  139043. private _normalTexture;
  139044. private _randomTexture;
  139045. private _originalColorPostProcess;
  139046. private _ssaoPostProcess;
  139047. private _blurHPostProcess;
  139048. private _blurVPostProcess;
  139049. private _ssaoCombinePostProcess;
  139050. /**
  139051. * Gets active scene
  139052. */
  139053. get scene(): Scene;
  139054. /**
  139055. * @constructor
  139056. * @param name The rendering pipeline name
  139057. * @param scene The scene linked to this pipeline
  139058. * @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 }
  139059. * @param cameras The array of cameras that the rendering pipeline will be attached to
  139060. */
  139061. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  139062. /**
  139063. * Get the class name
  139064. * @returns "SSAO2RenderingPipeline"
  139065. */
  139066. getClassName(): string;
  139067. /**
  139068. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  139069. */
  139070. dispose(disableGeometryBufferRenderer?: boolean): void;
  139071. private _createBlurPostProcess;
  139072. /** @hidden */
  139073. _rebuild(): void;
  139074. private _bits;
  139075. private _radicalInverse_VdC;
  139076. private _hammersley;
  139077. private _hemisphereSample_uniform;
  139078. private _generateHemisphere;
  139079. private _createSSAOPostProcess;
  139080. private _createSSAOCombinePostProcess;
  139081. private _createRandomTexture;
  139082. /**
  139083. * Serialize the rendering pipeline (Used when exporting)
  139084. * @returns the serialized object
  139085. */
  139086. serialize(): any;
  139087. /**
  139088. * Parse the serialized pipeline
  139089. * @param source Source pipeline.
  139090. * @param scene The scene to load the pipeline to.
  139091. * @param rootUrl The URL of the serialized pipeline.
  139092. * @returns An instantiated pipeline from the serialized object.
  139093. */
  139094. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  139095. }
  139096. }
  139097. declare module BABYLON {
  139098. /** @hidden */
  139099. export var ssaoPixelShader: {
  139100. name: string;
  139101. shader: string;
  139102. };
  139103. }
  139104. declare module BABYLON {
  139105. /**
  139106. * Render pipeline to produce ssao effect
  139107. */
  139108. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  139109. /**
  139110. * @ignore
  139111. * The PassPostProcess id in the pipeline that contains the original scene color
  139112. */
  139113. SSAOOriginalSceneColorEffect: string;
  139114. /**
  139115. * @ignore
  139116. * The SSAO PostProcess id in the pipeline
  139117. */
  139118. SSAORenderEffect: string;
  139119. /**
  139120. * @ignore
  139121. * The horizontal blur PostProcess id in the pipeline
  139122. */
  139123. SSAOBlurHRenderEffect: string;
  139124. /**
  139125. * @ignore
  139126. * The vertical blur PostProcess id in the pipeline
  139127. */
  139128. SSAOBlurVRenderEffect: string;
  139129. /**
  139130. * @ignore
  139131. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  139132. */
  139133. SSAOCombineRenderEffect: string;
  139134. /**
  139135. * The output strength of the SSAO post-process. Default value is 1.0.
  139136. */
  139137. totalStrength: number;
  139138. /**
  139139. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  139140. */
  139141. radius: number;
  139142. /**
  139143. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  139144. * Must not be equal to fallOff and superior to fallOff.
  139145. * Default value is 0.0075
  139146. */
  139147. area: number;
  139148. /**
  139149. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  139150. * Must not be equal to area and inferior to area.
  139151. * Default value is 0.000001
  139152. */
  139153. fallOff: number;
  139154. /**
  139155. * The base color of the SSAO post-process
  139156. * The final result is "base + ssao" between [0, 1]
  139157. */
  139158. base: number;
  139159. private _scene;
  139160. private _depthTexture;
  139161. private _randomTexture;
  139162. private _originalColorPostProcess;
  139163. private _ssaoPostProcess;
  139164. private _blurHPostProcess;
  139165. private _blurVPostProcess;
  139166. private _ssaoCombinePostProcess;
  139167. private _firstUpdate;
  139168. /**
  139169. * Gets active scene
  139170. */
  139171. get scene(): Scene;
  139172. /**
  139173. * @constructor
  139174. * @param name - The rendering pipeline name
  139175. * @param scene - The scene linked to this pipeline
  139176. * @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 }
  139177. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  139178. */
  139179. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  139180. /**
  139181. * Get the class name
  139182. * @returns "SSAORenderingPipeline"
  139183. */
  139184. getClassName(): string;
  139185. /**
  139186. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  139187. */
  139188. dispose(disableDepthRender?: boolean): void;
  139189. private _createBlurPostProcess;
  139190. /** @hidden */
  139191. _rebuild(): void;
  139192. private _createSSAOPostProcess;
  139193. private _createSSAOCombinePostProcess;
  139194. private _createRandomTexture;
  139195. }
  139196. }
  139197. declare module BABYLON {
  139198. /** @hidden */
  139199. export var screenSpaceReflectionPixelShader: {
  139200. name: string;
  139201. shader: string;
  139202. };
  139203. }
  139204. declare module BABYLON {
  139205. /**
  139206. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  139207. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  139208. */
  139209. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  139210. /**
  139211. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  139212. */
  139213. threshold: number;
  139214. /**
  139215. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  139216. */
  139217. strength: number;
  139218. /**
  139219. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  139220. */
  139221. reflectionSpecularFalloffExponent: number;
  139222. /**
  139223. * 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]
  139224. */
  139225. step: number;
  139226. /**
  139227. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  139228. */
  139229. roughnessFactor: number;
  139230. private _geometryBufferRenderer;
  139231. private _enableSmoothReflections;
  139232. private _reflectionSamples;
  139233. private _smoothSteps;
  139234. /**
  139235. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  139236. * @param name The name of the effect.
  139237. * @param scene The scene containing the objects to calculate reflections.
  139238. * @param options The required width/height ratio to downsize to before computing the render pass.
  139239. * @param camera The camera to apply the render pass to.
  139240. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139241. * @param engine The engine which the post process will be applied. (default: current engine)
  139242. * @param reusable If the post process can be reused on the same frame. (default: false)
  139243. * @param textureType Type of textures used when performing the post process. (default: 0)
  139244. * @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)
  139245. */
  139246. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139247. /**
  139248. * Gets wether or not smoothing reflections is enabled.
  139249. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  139250. */
  139251. get enableSmoothReflections(): boolean;
  139252. /**
  139253. * Sets wether or not smoothing reflections is enabled.
  139254. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  139255. */
  139256. set enableSmoothReflections(enabled: boolean);
  139257. /**
  139258. * Gets the number of samples taken while computing reflections. More samples count is high,
  139259. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  139260. */
  139261. get reflectionSamples(): number;
  139262. /**
  139263. * Sets the number of samples taken while computing reflections. More samples count is high,
  139264. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  139265. */
  139266. set reflectionSamples(samples: number);
  139267. /**
  139268. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  139269. * more the post-process will require GPU power and can generate a drop in FPS.
  139270. * Default value (5.0) work pretty well in all cases but can be adjusted.
  139271. */
  139272. get smoothSteps(): number;
  139273. set smoothSteps(steps: number);
  139274. private _updateEffectDefines;
  139275. }
  139276. }
  139277. declare module BABYLON {
  139278. /** @hidden */
  139279. export var standardPixelShader: {
  139280. name: string;
  139281. shader: string;
  139282. };
  139283. }
  139284. declare module BABYLON {
  139285. /**
  139286. * Standard rendering pipeline
  139287. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  139288. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  139289. */
  139290. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  139291. /**
  139292. * Public members
  139293. */
  139294. /**
  139295. * Post-process which contains the original scene color before the pipeline applies all the effects
  139296. */
  139297. originalPostProcess: Nullable<PostProcess>;
  139298. /**
  139299. * Post-process used to down scale an image x4
  139300. */
  139301. downSampleX4PostProcess: Nullable<PostProcess>;
  139302. /**
  139303. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  139304. */
  139305. brightPassPostProcess: Nullable<PostProcess>;
  139306. /**
  139307. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  139308. */
  139309. blurHPostProcesses: PostProcess[];
  139310. /**
  139311. * Post-process array storing all the vertical blur post-processes used by the pipeline
  139312. */
  139313. blurVPostProcesses: PostProcess[];
  139314. /**
  139315. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  139316. */
  139317. textureAdderPostProcess: Nullable<PostProcess>;
  139318. /**
  139319. * Post-process used to create volumetric lighting effect
  139320. */
  139321. volumetricLightPostProcess: Nullable<PostProcess>;
  139322. /**
  139323. * Post-process used to smooth the previous volumetric light post-process on the X axis
  139324. */
  139325. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  139326. /**
  139327. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  139328. */
  139329. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  139330. /**
  139331. * Post-process used to merge the volumetric light effect and the real scene color
  139332. */
  139333. volumetricLightMergePostProces: Nullable<PostProcess>;
  139334. /**
  139335. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  139336. */
  139337. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  139338. /**
  139339. * Base post-process used to calculate the average luminance of the final image for HDR
  139340. */
  139341. luminancePostProcess: Nullable<PostProcess>;
  139342. /**
  139343. * Post-processes used to create down sample post-processes in order to get
  139344. * the average luminance of the final image for HDR
  139345. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  139346. */
  139347. luminanceDownSamplePostProcesses: PostProcess[];
  139348. /**
  139349. * Post-process used to create a HDR effect (light adaptation)
  139350. */
  139351. hdrPostProcess: Nullable<PostProcess>;
  139352. /**
  139353. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  139354. */
  139355. textureAdderFinalPostProcess: Nullable<PostProcess>;
  139356. /**
  139357. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  139358. */
  139359. lensFlareFinalPostProcess: Nullable<PostProcess>;
  139360. /**
  139361. * Post-process used to merge the final HDR post-process and the real scene color
  139362. */
  139363. hdrFinalPostProcess: Nullable<PostProcess>;
  139364. /**
  139365. * Post-process used to create a lens flare effect
  139366. */
  139367. lensFlarePostProcess: Nullable<PostProcess>;
  139368. /**
  139369. * Post-process that merges the result of the lens flare post-process and the real scene color
  139370. */
  139371. lensFlareComposePostProcess: Nullable<PostProcess>;
  139372. /**
  139373. * Post-process used to create a motion blur effect
  139374. */
  139375. motionBlurPostProcess: Nullable<PostProcess>;
  139376. /**
  139377. * Post-process used to create a depth of field effect
  139378. */
  139379. depthOfFieldPostProcess: Nullable<PostProcess>;
  139380. /**
  139381. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  139382. */
  139383. fxaaPostProcess: Nullable<FxaaPostProcess>;
  139384. /**
  139385. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  139386. */
  139387. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  139388. /**
  139389. * Represents the brightness threshold in order to configure the illuminated surfaces
  139390. */
  139391. brightThreshold: number;
  139392. /**
  139393. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  139394. */
  139395. blurWidth: number;
  139396. /**
  139397. * Sets if the blur for highlighted surfaces must be only horizontal
  139398. */
  139399. horizontalBlur: boolean;
  139400. /**
  139401. * Gets the overall exposure used by the pipeline
  139402. */
  139403. get exposure(): number;
  139404. /**
  139405. * Sets the overall exposure used by the pipeline
  139406. */
  139407. set exposure(value: number);
  139408. /**
  139409. * Texture used typically to simulate "dirty" on camera lens
  139410. */
  139411. lensTexture: Nullable<Texture>;
  139412. /**
  139413. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  139414. */
  139415. volumetricLightCoefficient: number;
  139416. /**
  139417. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  139418. */
  139419. volumetricLightPower: number;
  139420. /**
  139421. * Used the set the blur intensity to smooth the volumetric lights
  139422. */
  139423. volumetricLightBlurScale: number;
  139424. /**
  139425. * Light (spot or directional) used to generate the volumetric lights rays
  139426. * The source light must have a shadow generate so the pipeline can get its
  139427. * depth map
  139428. */
  139429. sourceLight: Nullable<SpotLight | DirectionalLight>;
  139430. /**
  139431. * For eye adaptation, represents the minimum luminance the eye can see
  139432. */
  139433. hdrMinimumLuminance: number;
  139434. /**
  139435. * For eye adaptation, represents the decrease luminance speed
  139436. */
  139437. hdrDecreaseRate: number;
  139438. /**
  139439. * For eye adaptation, represents the increase luminance speed
  139440. */
  139441. hdrIncreaseRate: number;
  139442. /**
  139443. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  139444. */
  139445. get hdrAutoExposure(): boolean;
  139446. /**
  139447. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  139448. */
  139449. set hdrAutoExposure(value: boolean);
  139450. /**
  139451. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  139452. */
  139453. lensColorTexture: Nullable<Texture>;
  139454. /**
  139455. * The overall strengh for the lens flare effect
  139456. */
  139457. lensFlareStrength: number;
  139458. /**
  139459. * Dispersion coefficient for lens flare ghosts
  139460. */
  139461. lensFlareGhostDispersal: number;
  139462. /**
  139463. * Main lens flare halo width
  139464. */
  139465. lensFlareHaloWidth: number;
  139466. /**
  139467. * Based on the lens distortion effect, defines how much the lens flare result
  139468. * is distorted
  139469. */
  139470. lensFlareDistortionStrength: number;
  139471. /**
  139472. * Configures the blur intensity used for for lens flare (halo)
  139473. */
  139474. lensFlareBlurWidth: number;
  139475. /**
  139476. * Lens star texture must be used to simulate rays on the flares and is available
  139477. * in the documentation
  139478. */
  139479. lensStarTexture: Nullable<Texture>;
  139480. /**
  139481. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  139482. * flare effect by taking account of the dirt texture
  139483. */
  139484. lensFlareDirtTexture: Nullable<Texture>;
  139485. /**
  139486. * Represents the focal length for the depth of field effect
  139487. */
  139488. depthOfFieldDistance: number;
  139489. /**
  139490. * Represents the blur intensity for the blurred part of the depth of field effect
  139491. */
  139492. depthOfFieldBlurWidth: number;
  139493. /**
  139494. * Gets how much the image is blurred by the movement while using the motion blur post-process
  139495. */
  139496. get motionStrength(): number;
  139497. /**
  139498. * Sets how much the image is blurred by the movement while using the motion blur post-process
  139499. */
  139500. set motionStrength(strength: number);
  139501. /**
  139502. * Gets wether or not the motion blur post-process is object based or screen based.
  139503. */
  139504. get objectBasedMotionBlur(): boolean;
  139505. /**
  139506. * Sets wether or not the motion blur post-process should be object based or screen based
  139507. */
  139508. set objectBasedMotionBlur(value: boolean);
  139509. /**
  139510. * List of animations for the pipeline (IAnimatable implementation)
  139511. */
  139512. animations: Animation[];
  139513. /**
  139514. * Private members
  139515. */
  139516. private _scene;
  139517. private _currentDepthOfFieldSource;
  139518. private _basePostProcess;
  139519. private _fixedExposure;
  139520. private _currentExposure;
  139521. private _hdrAutoExposure;
  139522. private _hdrCurrentLuminance;
  139523. private _motionStrength;
  139524. private _isObjectBasedMotionBlur;
  139525. private _floatTextureType;
  139526. private _camerasToBeAttached;
  139527. private _ratio;
  139528. private _bloomEnabled;
  139529. private _depthOfFieldEnabled;
  139530. private _vlsEnabled;
  139531. private _lensFlareEnabled;
  139532. private _hdrEnabled;
  139533. private _motionBlurEnabled;
  139534. private _fxaaEnabled;
  139535. private _screenSpaceReflectionsEnabled;
  139536. private _motionBlurSamples;
  139537. private _volumetricLightStepsCount;
  139538. private _samples;
  139539. /**
  139540. * @ignore
  139541. * Specifies if the bloom pipeline is enabled
  139542. */
  139543. get BloomEnabled(): boolean;
  139544. set BloomEnabled(enabled: boolean);
  139545. /**
  139546. * @ignore
  139547. * Specifies if the depth of field pipeline is enabed
  139548. */
  139549. get DepthOfFieldEnabled(): boolean;
  139550. set DepthOfFieldEnabled(enabled: boolean);
  139551. /**
  139552. * @ignore
  139553. * Specifies if the lens flare pipeline is enabed
  139554. */
  139555. get LensFlareEnabled(): boolean;
  139556. set LensFlareEnabled(enabled: boolean);
  139557. /**
  139558. * @ignore
  139559. * Specifies if the HDR pipeline is enabled
  139560. */
  139561. get HDREnabled(): boolean;
  139562. set HDREnabled(enabled: boolean);
  139563. /**
  139564. * @ignore
  139565. * Specifies if the volumetric lights scattering effect is enabled
  139566. */
  139567. get VLSEnabled(): boolean;
  139568. set VLSEnabled(enabled: boolean);
  139569. /**
  139570. * @ignore
  139571. * Specifies if the motion blur effect is enabled
  139572. */
  139573. get MotionBlurEnabled(): boolean;
  139574. set MotionBlurEnabled(enabled: boolean);
  139575. /**
  139576. * Specifies if anti-aliasing is enabled
  139577. */
  139578. get fxaaEnabled(): boolean;
  139579. set fxaaEnabled(enabled: boolean);
  139580. /**
  139581. * Specifies if screen space reflections are enabled.
  139582. */
  139583. get screenSpaceReflectionsEnabled(): boolean;
  139584. set screenSpaceReflectionsEnabled(enabled: boolean);
  139585. /**
  139586. * Specifies the number of steps used to calculate the volumetric lights
  139587. * Typically in interval [50, 200]
  139588. */
  139589. get volumetricLightStepsCount(): number;
  139590. set volumetricLightStepsCount(count: number);
  139591. /**
  139592. * Specifies the number of samples used for the motion blur effect
  139593. * Typically in interval [16, 64]
  139594. */
  139595. get motionBlurSamples(): number;
  139596. set motionBlurSamples(samples: number);
  139597. /**
  139598. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  139599. */
  139600. get samples(): number;
  139601. set samples(sampleCount: number);
  139602. /**
  139603. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  139604. * @constructor
  139605. * @param name The rendering pipeline name
  139606. * @param scene The scene linked to this pipeline
  139607. * @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)
  139608. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  139609. * @param cameras The array of cameras that the rendering pipeline will be attached to
  139610. */
  139611. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  139612. private _buildPipeline;
  139613. private _createDownSampleX4PostProcess;
  139614. private _createBrightPassPostProcess;
  139615. private _createBlurPostProcesses;
  139616. private _createTextureAdderPostProcess;
  139617. private _createVolumetricLightPostProcess;
  139618. private _createLuminancePostProcesses;
  139619. private _createHdrPostProcess;
  139620. private _createLensFlarePostProcess;
  139621. private _createDepthOfFieldPostProcess;
  139622. private _createMotionBlurPostProcess;
  139623. private _getDepthTexture;
  139624. private _disposePostProcesses;
  139625. /**
  139626. * Dispose of the pipeline and stop all post processes
  139627. */
  139628. dispose(): void;
  139629. /**
  139630. * Serialize the rendering pipeline (Used when exporting)
  139631. * @returns the serialized object
  139632. */
  139633. serialize(): any;
  139634. /**
  139635. * Parse the serialized pipeline
  139636. * @param source Source pipeline.
  139637. * @param scene The scene to load the pipeline to.
  139638. * @param rootUrl The URL of the serialized pipeline.
  139639. * @returns An instantiated pipeline from the serialized object.
  139640. */
  139641. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  139642. /**
  139643. * Luminance steps
  139644. */
  139645. static LuminanceSteps: number;
  139646. }
  139647. }
  139648. declare module BABYLON {
  139649. /** @hidden */
  139650. export var tonemapPixelShader: {
  139651. name: string;
  139652. shader: string;
  139653. };
  139654. }
  139655. declare module BABYLON {
  139656. /** Defines operator used for tonemapping */
  139657. export enum TonemappingOperator {
  139658. /** Hable */
  139659. Hable = 0,
  139660. /** Reinhard */
  139661. Reinhard = 1,
  139662. /** HejiDawson */
  139663. HejiDawson = 2,
  139664. /** Photographic */
  139665. Photographic = 3
  139666. }
  139667. /**
  139668. * Defines a post process to apply tone mapping
  139669. */
  139670. export class TonemapPostProcess extends PostProcess {
  139671. private _operator;
  139672. /** Defines the required exposure adjustement */
  139673. exposureAdjustment: number;
  139674. /**
  139675. * Creates a new TonemapPostProcess
  139676. * @param name defines the name of the postprocess
  139677. * @param _operator defines the operator to use
  139678. * @param exposureAdjustment defines the required exposure adjustement
  139679. * @param camera defines the camera to use (can be null)
  139680. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  139681. * @param engine defines the hosting engine (can be ignore if camera is set)
  139682. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  139683. */
  139684. constructor(name: string, _operator: TonemappingOperator,
  139685. /** Defines the required exposure adjustement */
  139686. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  139687. }
  139688. }
  139689. declare module BABYLON {
  139690. /** @hidden */
  139691. export var volumetricLightScatteringPixelShader: {
  139692. name: string;
  139693. shader: string;
  139694. };
  139695. }
  139696. declare module BABYLON {
  139697. /** @hidden */
  139698. export var volumetricLightScatteringPassVertexShader: {
  139699. name: string;
  139700. shader: string;
  139701. };
  139702. }
  139703. declare module BABYLON {
  139704. /** @hidden */
  139705. export var volumetricLightScatteringPassPixelShader: {
  139706. name: string;
  139707. shader: string;
  139708. };
  139709. }
  139710. declare module BABYLON {
  139711. /**
  139712. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  139713. */
  139714. export class VolumetricLightScatteringPostProcess extends PostProcess {
  139715. private _volumetricLightScatteringPass;
  139716. private _volumetricLightScatteringRTT;
  139717. private _viewPort;
  139718. private _screenCoordinates;
  139719. private _cachedDefines;
  139720. /**
  139721. * If not undefined, the mesh position is computed from the attached node position
  139722. */
  139723. attachedNode: {
  139724. position: Vector3;
  139725. };
  139726. /**
  139727. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  139728. */
  139729. customMeshPosition: Vector3;
  139730. /**
  139731. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  139732. */
  139733. useCustomMeshPosition: boolean;
  139734. /**
  139735. * If the post-process should inverse the light scattering direction
  139736. */
  139737. invert: boolean;
  139738. /**
  139739. * The internal mesh used by the post-process
  139740. */
  139741. mesh: Mesh;
  139742. /**
  139743. * @hidden
  139744. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  139745. */
  139746. get useDiffuseColor(): boolean;
  139747. set useDiffuseColor(useDiffuseColor: boolean);
  139748. /**
  139749. * Array containing the excluded meshes not rendered in the internal pass
  139750. */
  139751. excludedMeshes: AbstractMesh[];
  139752. /**
  139753. * Controls the overall intensity of the post-process
  139754. */
  139755. exposure: number;
  139756. /**
  139757. * Dissipates each sample's contribution in range [0, 1]
  139758. */
  139759. decay: number;
  139760. /**
  139761. * Controls the overall intensity of each sample
  139762. */
  139763. weight: number;
  139764. /**
  139765. * Controls the density of each sample
  139766. */
  139767. density: number;
  139768. /**
  139769. * @constructor
  139770. * @param name The post-process name
  139771. * @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)
  139772. * @param camera The camera that the post-process will be attached to
  139773. * @param mesh The mesh used to create the light scattering
  139774. * @param samples The post-process quality, default 100
  139775. * @param samplingModeThe post-process filtering mode
  139776. * @param engine The babylon engine
  139777. * @param reusable If the post-process is reusable
  139778. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  139779. */
  139780. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  139781. /**
  139782. * Returns the string "VolumetricLightScatteringPostProcess"
  139783. * @returns "VolumetricLightScatteringPostProcess"
  139784. */
  139785. getClassName(): string;
  139786. private _isReady;
  139787. /**
  139788. * Sets the new light position for light scattering effect
  139789. * @param position The new custom light position
  139790. */
  139791. setCustomMeshPosition(position: Vector3): void;
  139792. /**
  139793. * Returns the light position for light scattering effect
  139794. * @return Vector3 The custom light position
  139795. */
  139796. getCustomMeshPosition(): Vector3;
  139797. /**
  139798. * Disposes the internal assets and detaches the post-process from the camera
  139799. */
  139800. dispose(camera: Camera): void;
  139801. /**
  139802. * Returns the render target texture used by the post-process
  139803. * @return the render target texture used by the post-process
  139804. */
  139805. getPass(): RenderTargetTexture;
  139806. private _meshExcluded;
  139807. private _createPass;
  139808. private _updateMeshScreenCoordinates;
  139809. /**
  139810. * Creates a default mesh for the Volumeric Light Scattering post-process
  139811. * @param name The mesh name
  139812. * @param scene The scene where to create the mesh
  139813. * @return the default mesh
  139814. */
  139815. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  139816. }
  139817. }
  139818. declare module BABYLON {
  139819. interface Scene {
  139820. /** @hidden (Backing field) */
  139821. _boundingBoxRenderer: BoundingBoxRenderer;
  139822. /** @hidden (Backing field) */
  139823. _forceShowBoundingBoxes: boolean;
  139824. /**
  139825. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  139826. */
  139827. forceShowBoundingBoxes: boolean;
  139828. /**
  139829. * Gets the bounding box renderer associated with the scene
  139830. * @returns a BoundingBoxRenderer
  139831. */
  139832. getBoundingBoxRenderer(): BoundingBoxRenderer;
  139833. }
  139834. interface AbstractMesh {
  139835. /** @hidden (Backing field) */
  139836. _showBoundingBox: boolean;
  139837. /**
  139838. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  139839. */
  139840. showBoundingBox: boolean;
  139841. }
  139842. /**
  139843. * Component responsible of rendering the bounding box of the meshes in a scene.
  139844. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  139845. */
  139846. export class BoundingBoxRenderer implements ISceneComponent {
  139847. /**
  139848. * The component name helpfull to identify the component in the list of scene components.
  139849. */
  139850. readonly name: string;
  139851. /**
  139852. * The scene the component belongs to.
  139853. */
  139854. scene: Scene;
  139855. /**
  139856. * Color of the bounding box lines placed in front of an object
  139857. */
  139858. frontColor: Color3;
  139859. /**
  139860. * Color of the bounding box lines placed behind an object
  139861. */
  139862. backColor: Color3;
  139863. /**
  139864. * Defines if the renderer should show the back lines or not
  139865. */
  139866. showBackLines: boolean;
  139867. /**
  139868. * @hidden
  139869. */
  139870. renderList: SmartArray<BoundingBox>;
  139871. private _colorShader;
  139872. private _vertexBuffers;
  139873. private _indexBuffer;
  139874. private _fillIndexBuffer;
  139875. private _fillIndexData;
  139876. /**
  139877. * Instantiates a new bounding box renderer in a scene.
  139878. * @param scene the scene the renderer renders in
  139879. */
  139880. constructor(scene: Scene);
  139881. /**
  139882. * Registers the component in a given scene
  139883. */
  139884. register(): void;
  139885. private _evaluateSubMesh;
  139886. private _activeMesh;
  139887. private _prepareRessources;
  139888. private _createIndexBuffer;
  139889. /**
  139890. * Rebuilds the elements related to this component in case of
  139891. * context lost for instance.
  139892. */
  139893. rebuild(): void;
  139894. /**
  139895. * @hidden
  139896. */
  139897. reset(): void;
  139898. /**
  139899. * Render the bounding boxes of a specific rendering group
  139900. * @param renderingGroupId defines the rendering group to render
  139901. */
  139902. render(renderingGroupId: number): void;
  139903. /**
  139904. * In case of occlusion queries, we can render the occlusion bounding box through this method
  139905. * @param mesh Define the mesh to render the occlusion bounding box for
  139906. */
  139907. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  139908. /**
  139909. * Dispose and release the resources attached to this renderer.
  139910. */
  139911. dispose(): void;
  139912. }
  139913. }
  139914. declare module BABYLON {
  139915. interface Scene {
  139916. /** @hidden (Backing field) */
  139917. _depthRenderer: {
  139918. [id: string]: DepthRenderer;
  139919. };
  139920. /**
  139921. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  139922. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  139923. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  139924. * @returns the created depth renderer
  139925. */
  139926. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  139927. /**
  139928. * Disables a depth renderer for a given camera
  139929. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  139930. */
  139931. disableDepthRenderer(camera?: Nullable<Camera>): void;
  139932. }
  139933. /**
  139934. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  139935. * in several rendering techniques.
  139936. */
  139937. export class DepthRendererSceneComponent implements ISceneComponent {
  139938. /**
  139939. * The component name helpfull to identify the component in the list of scene components.
  139940. */
  139941. readonly name: string;
  139942. /**
  139943. * The scene the component belongs to.
  139944. */
  139945. scene: Scene;
  139946. /**
  139947. * Creates a new instance of the component for the given scene
  139948. * @param scene Defines the scene to register the component in
  139949. */
  139950. constructor(scene: Scene);
  139951. /**
  139952. * Registers the component in a given scene
  139953. */
  139954. register(): void;
  139955. /**
  139956. * Rebuilds the elements related to this component in case of
  139957. * context lost for instance.
  139958. */
  139959. rebuild(): void;
  139960. /**
  139961. * Disposes the component and the associated ressources
  139962. */
  139963. dispose(): void;
  139964. private _gatherRenderTargets;
  139965. private _gatherActiveCameraRenderTargets;
  139966. }
  139967. }
  139968. declare module BABYLON {
  139969. /** @hidden */
  139970. export var outlinePixelShader: {
  139971. name: string;
  139972. shader: string;
  139973. };
  139974. }
  139975. declare module BABYLON {
  139976. /** @hidden */
  139977. export var outlineVertexShader: {
  139978. name: string;
  139979. shader: string;
  139980. };
  139981. }
  139982. declare module BABYLON {
  139983. interface Scene {
  139984. /** @hidden */
  139985. _outlineRenderer: OutlineRenderer;
  139986. /**
  139987. * Gets the outline renderer associated with the scene
  139988. * @returns a OutlineRenderer
  139989. */
  139990. getOutlineRenderer(): OutlineRenderer;
  139991. }
  139992. interface AbstractMesh {
  139993. /** @hidden (Backing field) */
  139994. _renderOutline: boolean;
  139995. /**
  139996. * Gets or sets a boolean indicating if the outline must be rendered as well
  139997. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  139998. */
  139999. renderOutline: boolean;
  140000. /** @hidden (Backing field) */
  140001. _renderOverlay: boolean;
  140002. /**
  140003. * Gets or sets a boolean indicating if the overlay must be rendered as well
  140004. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  140005. */
  140006. renderOverlay: boolean;
  140007. }
  140008. /**
  140009. * This class is responsible to draw bothe outline/overlay of meshes.
  140010. * It should not be used directly but through the available method on mesh.
  140011. */
  140012. export class OutlineRenderer implements ISceneComponent {
  140013. /**
  140014. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  140015. */
  140016. private static _StencilReference;
  140017. /**
  140018. * The name of the component. Each component must have a unique name.
  140019. */
  140020. name: string;
  140021. /**
  140022. * The scene the component belongs to.
  140023. */
  140024. scene: Scene;
  140025. /**
  140026. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  140027. */
  140028. zOffset: number;
  140029. private _engine;
  140030. private _effect;
  140031. private _cachedDefines;
  140032. private _savedDepthWrite;
  140033. /**
  140034. * Instantiates a new outline renderer. (There could be only one per scene).
  140035. * @param scene Defines the scene it belongs to
  140036. */
  140037. constructor(scene: Scene);
  140038. /**
  140039. * Register the component to one instance of a scene.
  140040. */
  140041. register(): void;
  140042. /**
  140043. * Rebuilds the elements related to this component in case of
  140044. * context lost for instance.
  140045. */
  140046. rebuild(): void;
  140047. /**
  140048. * Disposes the component and the associated ressources.
  140049. */
  140050. dispose(): void;
  140051. /**
  140052. * Renders the outline in the canvas.
  140053. * @param subMesh Defines the sumesh to render
  140054. * @param batch Defines the batch of meshes in case of instances
  140055. * @param useOverlay Defines if the rendering is for the overlay or the outline
  140056. */
  140057. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  140058. /**
  140059. * Returns whether or not the outline renderer is ready for a given submesh.
  140060. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  140061. * @param subMesh Defines the submesh to check readyness for
  140062. * @param useInstances Defines wheter wee are trying to render instances or not
  140063. * @returns true if ready otherwise false
  140064. */
  140065. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  140066. private _beforeRenderingMesh;
  140067. private _afterRenderingMesh;
  140068. }
  140069. }
  140070. declare module BABYLON {
  140071. /**
  140072. * Defines the basic options interface of a Sprite Frame Source Size.
  140073. */
  140074. export interface ISpriteJSONSpriteSourceSize {
  140075. /**
  140076. * number of the original width of the Frame
  140077. */
  140078. w: number;
  140079. /**
  140080. * number of the original height of the Frame
  140081. */
  140082. h: number;
  140083. }
  140084. /**
  140085. * Defines the basic options interface of a Sprite Frame Data.
  140086. */
  140087. export interface ISpriteJSONSpriteFrameData {
  140088. /**
  140089. * number of the x offset of the Frame
  140090. */
  140091. x: number;
  140092. /**
  140093. * number of the y offset of the Frame
  140094. */
  140095. y: number;
  140096. /**
  140097. * number of the width of the Frame
  140098. */
  140099. w: number;
  140100. /**
  140101. * number of the height of the Frame
  140102. */
  140103. h: number;
  140104. }
  140105. /**
  140106. * Defines the basic options interface of a JSON Sprite.
  140107. */
  140108. export interface ISpriteJSONSprite {
  140109. /**
  140110. * string name of the Frame
  140111. */
  140112. filename: string;
  140113. /**
  140114. * ISpriteJSONSpriteFrame basic object of the frame data
  140115. */
  140116. frame: ISpriteJSONSpriteFrameData;
  140117. /**
  140118. * boolean to flag is the frame was rotated.
  140119. */
  140120. rotated: boolean;
  140121. /**
  140122. * boolean to flag is the frame was trimmed.
  140123. */
  140124. trimmed: boolean;
  140125. /**
  140126. * ISpriteJSONSpriteFrame basic object of the source data
  140127. */
  140128. spriteSourceSize: ISpriteJSONSpriteFrameData;
  140129. /**
  140130. * ISpriteJSONSpriteFrame basic object of the source data
  140131. */
  140132. sourceSize: ISpriteJSONSpriteSourceSize;
  140133. }
  140134. /**
  140135. * Defines the basic options interface of a JSON atlas.
  140136. */
  140137. export interface ISpriteJSONAtlas {
  140138. /**
  140139. * Array of objects that contain the frame data.
  140140. */
  140141. frames: Array<ISpriteJSONSprite>;
  140142. /**
  140143. * object basic object containing the sprite meta data.
  140144. */
  140145. meta?: object;
  140146. }
  140147. }
  140148. declare module BABYLON {
  140149. /** @hidden */
  140150. export var spriteMapPixelShader: {
  140151. name: string;
  140152. shader: string;
  140153. };
  140154. }
  140155. declare module BABYLON {
  140156. /** @hidden */
  140157. export var spriteMapVertexShader: {
  140158. name: string;
  140159. shader: string;
  140160. };
  140161. }
  140162. declare module BABYLON {
  140163. /**
  140164. * Defines the basic options interface of a SpriteMap
  140165. */
  140166. export interface ISpriteMapOptions {
  140167. /**
  140168. * Vector2 of the number of cells in the grid.
  140169. */
  140170. stageSize?: Vector2;
  140171. /**
  140172. * Vector2 of the size of the output plane in World Units.
  140173. */
  140174. outputSize?: Vector2;
  140175. /**
  140176. * Vector3 of the position of the output plane in World Units.
  140177. */
  140178. outputPosition?: Vector3;
  140179. /**
  140180. * Vector3 of the rotation of the output plane.
  140181. */
  140182. outputRotation?: Vector3;
  140183. /**
  140184. * number of layers that the system will reserve in resources.
  140185. */
  140186. layerCount?: number;
  140187. /**
  140188. * number of max animation frames a single cell will reserve in resources.
  140189. */
  140190. maxAnimationFrames?: number;
  140191. /**
  140192. * number cell index of the base tile when the system compiles.
  140193. */
  140194. baseTile?: number;
  140195. /**
  140196. * boolean flip the sprite after its been repositioned by the framing data.
  140197. */
  140198. flipU?: boolean;
  140199. /**
  140200. * Vector3 scalar of the global RGB values of the SpriteMap.
  140201. */
  140202. colorMultiply?: Vector3;
  140203. }
  140204. /**
  140205. * Defines the IDisposable interface in order to be cleanable from resources.
  140206. */
  140207. export interface ISpriteMap extends IDisposable {
  140208. /**
  140209. * String name of the SpriteMap.
  140210. */
  140211. name: string;
  140212. /**
  140213. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  140214. */
  140215. atlasJSON: ISpriteJSONAtlas;
  140216. /**
  140217. * Texture of the SpriteMap.
  140218. */
  140219. spriteSheet: Texture;
  140220. /**
  140221. * The parameters to initialize the SpriteMap with.
  140222. */
  140223. options: ISpriteMapOptions;
  140224. }
  140225. /**
  140226. * Class used to manage a grid restricted sprite deployment on an Output plane.
  140227. */
  140228. export class SpriteMap implements ISpriteMap {
  140229. /** The Name of the spriteMap */
  140230. name: string;
  140231. /** The JSON file with the frame and meta data */
  140232. atlasJSON: ISpriteJSONAtlas;
  140233. /** The systems Sprite Sheet Texture */
  140234. spriteSheet: Texture;
  140235. /** Arguments passed with the Constructor */
  140236. options: ISpriteMapOptions;
  140237. /** Public Sprite Storage array, parsed from atlasJSON */
  140238. sprites: Array<ISpriteJSONSprite>;
  140239. /** Returns the Number of Sprites in the System */
  140240. get spriteCount(): number;
  140241. /** Returns the Position of Output Plane*/
  140242. get position(): Vector3;
  140243. /** Returns the Position of Output Plane*/
  140244. set position(v: Vector3);
  140245. /** Returns the Rotation of Output Plane*/
  140246. get rotation(): Vector3;
  140247. /** Returns the Rotation of Output Plane*/
  140248. set rotation(v: Vector3);
  140249. /** Sets the AnimationMap*/
  140250. get animationMap(): RawTexture;
  140251. /** Sets the AnimationMap*/
  140252. set animationMap(v: RawTexture);
  140253. /** Scene that the SpriteMap was created in */
  140254. private _scene;
  140255. /** Texture Buffer of Float32 that holds tile frame data*/
  140256. private _frameMap;
  140257. /** Texture Buffers of Float32 that holds tileMap data*/
  140258. private _tileMaps;
  140259. /** Texture Buffer of Float32 that holds Animation Data*/
  140260. private _animationMap;
  140261. /** Custom ShaderMaterial Central to the System*/
  140262. private _material;
  140263. /** Custom ShaderMaterial Central to the System*/
  140264. private _output;
  140265. /** Systems Time Ticker*/
  140266. private _time;
  140267. /**
  140268. * Creates a new SpriteMap
  140269. * @param name defines the SpriteMaps Name
  140270. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  140271. * @param spriteSheet is the Texture that the Sprites are on.
  140272. * @param options a basic deployment configuration
  140273. * @param scene The Scene that the map is deployed on
  140274. */
  140275. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  140276. /**
  140277. * Returns tileID location
  140278. * @returns Vector2 the cell position ID
  140279. */
  140280. getTileID(): Vector2;
  140281. /**
  140282. * Gets the UV location of the mouse over the SpriteMap.
  140283. * @returns Vector2 the UV position of the mouse interaction
  140284. */
  140285. getMousePosition(): Vector2;
  140286. /**
  140287. * Creates the "frame" texture Buffer
  140288. * -------------------------------------
  140289. * Structure of frames
  140290. * "filename": "Falling-Water-2.png",
  140291. * "frame": {"x":69,"y":103,"w":24,"h":32},
  140292. * "rotated": true,
  140293. * "trimmed": true,
  140294. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  140295. * "sourceSize": {"w":32,"h":32}
  140296. * @returns RawTexture of the frameMap
  140297. */
  140298. private _createFrameBuffer;
  140299. /**
  140300. * Creates the tileMap texture Buffer
  140301. * @param buffer normally and array of numbers, or a false to generate from scratch
  140302. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  140303. * @returns RawTexture of the tileMap
  140304. */
  140305. private _createTileBuffer;
  140306. /**
  140307. * Modifies the data of the tileMaps
  140308. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  140309. * @param pos is the iVector2 Coordinates of the Tile
  140310. * @param tile The SpriteIndex of the new Tile
  140311. */
  140312. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  140313. /**
  140314. * Creates the animationMap texture Buffer
  140315. * @param buffer normally and array of numbers, or a false to generate from scratch
  140316. * @returns RawTexture of the animationMap
  140317. */
  140318. private _createTileAnimationBuffer;
  140319. /**
  140320. * Modifies the data of the animationMap
  140321. * @param cellID is the Index of the Sprite
  140322. * @param _frame is the target Animation frame
  140323. * @param toCell is the Target Index of the next frame of the animation
  140324. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  140325. * @param speed is a global scalar of the time variable on the map.
  140326. */
  140327. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  140328. /**
  140329. * Exports the .tilemaps file
  140330. */
  140331. saveTileMaps(): void;
  140332. /**
  140333. * Imports the .tilemaps file
  140334. * @param url of the .tilemaps file
  140335. */
  140336. loadTileMaps(url: string): void;
  140337. /**
  140338. * Release associated resources
  140339. */
  140340. dispose(): void;
  140341. }
  140342. }
  140343. declare module BABYLON {
  140344. /**
  140345. * Class used to manage multiple sprites of different sizes on the same spritesheet
  140346. * @see http://doc.babylonjs.com/babylon101/sprites
  140347. */
  140348. export class SpritePackedManager extends SpriteManager {
  140349. /** defines the packed manager's name */
  140350. name: string;
  140351. /**
  140352. * Creates a new sprite manager from a packed sprite sheet
  140353. * @param name defines the manager's name
  140354. * @param imgUrl defines the sprite sheet url
  140355. * @param capacity defines the maximum allowed number of sprites
  140356. * @param scene defines the hosting scene
  140357. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  140358. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  140359. * @param samplingMode defines the smapling mode to use with spritesheet
  140360. * @param fromPacked set to true; do not alter
  140361. */
  140362. constructor(
  140363. /** defines the packed manager's name */
  140364. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  140365. }
  140366. }
  140367. declare module BABYLON {
  140368. /**
  140369. * Defines the list of states available for a task inside a AssetsManager
  140370. */
  140371. export enum AssetTaskState {
  140372. /**
  140373. * Initialization
  140374. */
  140375. INIT = 0,
  140376. /**
  140377. * Running
  140378. */
  140379. RUNNING = 1,
  140380. /**
  140381. * Done
  140382. */
  140383. DONE = 2,
  140384. /**
  140385. * Error
  140386. */
  140387. ERROR = 3
  140388. }
  140389. /**
  140390. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  140391. */
  140392. export abstract class AbstractAssetTask {
  140393. /**
  140394. * Task name
  140395. */ name: string;
  140396. /**
  140397. * Callback called when the task is successful
  140398. */
  140399. onSuccess: (task: any) => void;
  140400. /**
  140401. * Callback called when the task is not successful
  140402. */
  140403. onError: (task: any, message?: string, exception?: any) => void;
  140404. /**
  140405. * Creates a new AssetsManager
  140406. * @param name defines the name of the task
  140407. */
  140408. constructor(
  140409. /**
  140410. * Task name
  140411. */ name: string);
  140412. private _isCompleted;
  140413. private _taskState;
  140414. private _errorObject;
  140415. /**
  140416. * Get if the task is completed
  140417. */
  140418. get isCompleted(): boolean;
  140419. /**
  140420. * Gets the current state of the task
  140421. */
  140422. get taskState(): AssetTaskState;
  140423. /**
  140424. * Gets the current error object (if task is in error)
  140425. */
  140426. get errorObject(): {
  140427. message?: string;
  140428. exception?: any;
  140429. };
  140430. /**
  140431. * Internal only
  140432. * @hidden
  140433. */
  140434. _setErrorObject(message?: string, exception?: any): void;
  140435. /**
  140436. * Execute the current task
  140437. * @param scene defines the scene where you want your assets to be loaded
  140438. * @param onSuccess is a callback called when the task is successfully executed
  140439. * @param onError is a callback called if an error occurs
  140440. */
  140441. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140442. /**
  140443. * Execute the current task
  140444. * @param scene defines the scene where you want your assets to be loaded
  140445. * @param onSuccess is a callback called when the task is successfully executed
  140446. * @param onError is a callback called if an error occurs
  140447. */
  140448. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140449. /**
  140450. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  140451. * This can be used with failed tasks that have the reason for failure fixed.
  140452. */
  140453. reset(): void;
  140454. private onErrorCallback;
  140455. private onDoneCallback;
  140456. }
  140457. /**
  140458. * Define the interface used by progress events raised during assets loading
  140459. */
  140460. export interface IAssetsProgressEvent {
  140461. /**
  140462. * Defines the number of remaining tasks to process
  140463. */
  140464. remainingCount: number;
  140465. /**
  140466. * Defines the total number of tasks
  140467. */
  140468. totalCount: number;
  140469. /**
  140470. * Defines the task that was just processed
  140471. */
  140472. task: AbstractAssetTask;
  140473. }
  140474. /**
  140475. * Class used to share progress information about assets loading
  140476. */
  140477. export class AssetsProgressEvent implements IAssetsProgressEvent {
  140478. /**
  140479. * Defines the number of remaining tasks to process
  140480. */
  140481. remainingCount: number;
  140482. /**
  140483. * Defines the total number of tasks
  140484. */
  140485. totalCount: number;
  140486. /**
  140487. * Defines the task that was just processed
  140488. */
  140489. task: AbstractAssetTask;
  140490. /**
  140491. * Creates a AssetsProgressEvent
  140492. * @param remainingCount defines the number of remaining tasks to process
  140493. * @param totalCount defines the total number of tasks
  140494. * @param task defines the task that was just processed
  140495. */
  140496. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  140497. }
  140498. /**
  140499. * Define a task used by AssetsManager to load meshes
  140500. */
  140501. export class MeshAssetTask extends AbstractAssetTask {
  140502. /**
  140503. * Defines the name of the task
  140504. */
  140505. name: string;
  140506. /**
  140507. * Defines the list of mesh's names you want to load
  140508. */
  140509. meshesNames: any;
  140510. /**
  140511. * Defines the root url to use as a base to load your meshes and associated resources
  140512. */
  140513. rootUrl: string;
  140514. /**
  140515. * Defines the filename of the scene to load from
  140516. */
  140517. sceneFilename: string;
  140518. /**
  140519. * Gets the list of loaded meshes
  140520. */
  140521. loadedMeshes: Array<AbstractMesh>;
  140522. /**
  140523. * Gets the list of loaded particle systems
  140524. */
  140525. loadedParticleSystems: Array<IParticleSystem>;
  140526. /**
  140527. * Gets the list of loaded skeletons
  140528. */
  140529. loadedSkeletons: Array<Skeleton>;
  140530. /**
  140531. * Gets the list of loaded animation groups
  140532. */
  140533. loadedAnimationGroups: Array<AnimationGroup>;
  140534. /**
  140535. * Callback called when the task is successful
  140536. */
  140537. onSuccess: (task: MeshAssetTask) => void;
  140538. /**
  140539. * Callback called when the task is successful
  140540. */
  140541. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  140542. /**
  140543. * Creates a new MeshAssetTask
  140544. * @param name defines the name of the task
  140545. * @param meshesNames defines the list of mesh's names you want to load
  140546. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  140547. * @param sceneFilename defines the filename of the scene to load from
  140548. */
  140549. constructor(
  140550. /**
  140551. * Defines the name of the task
  140552. */
  140553. name: string,
  140554. /**
  140555. * Defines the list of mesh's names you want to load
  140556. */
  140557. meshesNames: any,
  140558. /**
  140559. * Defines the root url to use as a base to load your meshes and associated resources
  140560. */
  140561. rootUrl: string,
  140562. /**
  140563. * Defines the filename of the scene to load from
  140564. */
  140565. sceneFilename: string);
  140566. /**
  140567. * Execute the current task
  140568. * @param scene defines the scene where you want your assets to be loaded
  140569. * @param onSuccess is a callback called when the task is successfully executed
  140570. * @param onError is a callback called if an error occurs
  140571. */
  140572. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140573. }
  140574. /**
  140575. * Define a task used by AssetsManager to load text content
  140576. */
  140577. export class TextFileAssetTask extends AbstractAssetTask {
  140578. /**
  140579. * Defines the name of the task
  140580. */
  140581. name: string;
  140582. /**
  140583. * Defines the location of the file to load
  140584. */
  140585. url: string;
  140586. /**
  140587. * Gets the loaded text string
  140588. */
  140589. text: string;
  140590. /**
  140591. * Callback called when the task is successful
  140592. */
  140593. onSuccess: (task: TextFileAssetTask) => void;
  140594. /**
  140595. * Callback called when the task is successful
  140596. */
  140597. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  140598. /**
  140599. * Creates a new TextFileAssetTask object
  140600. * @param name defines the name of the task
  140601. * @param url defines the location of the file to load
  140602. */
  140603. constructor(
  140604. /**
  140605. * Defines the name of the task
  140606. */
  140607. name: string,
  140608. /**
  140609. * Defines the location of the file to load
  140610. */
  140611. url: string);
  140612. /**
  140613. * Execute the current task
  140614. * @param scene defines the scene where you want your assets to be loaded
  140615. * @param onSuccess is a callback called when the task is successfully executed
  140616. * @param onError is a callback called if an error occurs
  140617. */
  140618. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140619. }
  140620. /**
  140621. * Define a task used by AssetsManager to load binary data
  140622. */
  140623. export class BinaryFileAssetTask extends AbstractAssetTask {
  140624. /**
  140625. * Defines the name of the task
  140626. */
  140627. name: string;
  140628. /**
  140629. * Defines the location of the file to load
  140630. */
  140631. url: string;
  140632. /**
  140633. * Gets the lodaded data (as an array buffer)
  140634. */
  140635. data: ArrayBuffer;
  140636. /**
  140637. * Callback called when the task is successful
  140638. */
  140639. onSuccess: (task: BinaryFileAssetTask) => void;
  140640. /**
  140641. * Callback called when the task is successful
  140642. */
  140643. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  140644. /**
  140645. * Creates a new BinaryFileAssetTask object
  140646. * @param name defines the name of the new task
  140647. * @param url defines the location of the file to load
  140648. */
  140649. constructor(
  140650. /**
  140651. * Defines the name of the task
  140652. */
  140653. name: string,
  140654. /**
  140655. * Defines the location of the file to load
  140656. */
  140657. url: string);
  140658. /**
  140659. * Execute the current task
  140660. * @param scene defines the scene where you want your assets to be loaded
  140661. * @param onSuccess is a callback called when the task is successfully executed
  140662. * @param onError is a callback called if an error occurs
  140663. */
  140664. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140665. }
  140666. /**
  140667. * Define a task used by AssetsManager to load images
  140668. */
  140669. export class ImageAssetTask extends AbstractAssetTask {
  140670. /**
  140671. * Defines the name of the task
  140672. */
  140673. name: string;
  140674. /**
  140675. * Defines the location of the image to load
  140676. */
  140677. url: string;
  140678. /**
  140679. * Gets the loaded images
  140680. */
  140681. image: HTMLImageElement;
  140682. /**
  140683. * Callback called when the task is successful
  140684. */
  140685. onSuccess: (task: ImageAssetTask) => void;
  140686. /**
  140687. * Callback called when the task is successful
  140688. */
  140689. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  140690. /**
  140691. * Creates a new ImageAssetTask
  140692. * @param name defines the name of the task
  140693. * @param url defines the location of the image to load
  140694. */
  140695. constructor(
  140696. /**
  140697. * Defines the name of the task
  140698. */
  140699. name: string,
  140700. /**
  140701. * Defines the location of the image to load
  140702. */
  140703. url: string);
  140704. /**
  140705. * Execute the current task
  140706. * @param scene defines the scene where you want your assets to be loaded
  140707. * @param onSuccess is a callback called when the task is successfully executed
  140708. * @param onError is a callback called if an error occurs
  140709. */
  140710. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140711. }
  140712. /**
  140713. * Defines the interface used by texture loading tasks
  140714. */
  140715. export interface ITextureAssetTask<TEX extends BaseTexture> {
  140716. /**
  140717. * Gets the loaded texture
  140718. */
  140719. texture: TEX;
  140720. }
  140721. /**
  140722. * Define a task used by AssetsManager to load 2D textures
  140723. */
  140724. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  140725. /**
  140726. * Defines the name of the task
  140727. */
  140728. name: string;
  140729. /**
  140730. * Defines the location of the file to load
  140731. */
  140732. url: string;
  140733. /**
  140734. * Defines if mipmap should not be generated (default is false)
  140735. */
  140736. noMipmap?: boolean | undefined;
  140737. /**
  140738. * Defines if texture must be inverted on Y axis (default is false)
  140739. */
  140740. invertY?: boolean | undefined;
  140741. /**
  140742. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140743. */
  140744. samplingMode: number;
  140745. /**
  140746. * Gets the loaded texture
  140747. */
  140748. texture: Texture;
  140749. /**
  140750. * Callback called when the task is successful
  140751. */
  140752. onSuccess: (task: TextureAssetTask) => void;
  140753. /**
  140754. * Callback called when the task is successful
  140755. */
  140756. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  140757. /**
  140758. * Creates a new TextureAssetTask object
  140759. * @param name defines the name of the task
  140760. * @param url defines the location of the file to load
  140761. * @param noMipmap defines if mipmap should not be generated (default is false)
  140762. * @param invertY defines if texture must be inverted on Y axis (default is false)
  140763. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140764. */
  140765. constructor(
  140766. /**
  140767. * Defines the name of the task
  140768. */
  140769. name: string,
  140770. /**
  140771. * Defines the location of the file to load
  140772. */
  140773. url: string,
  140774. /**
  140775. * Defines if mipmap should not be generated (default is false)
  140776. */
  140777. noMipmap?: boolean | undefined,
  140778. /**
  140779. * Defines if texture must be inverted on Y axis (default is false)
  140780. */
  140781. invertY?: boolean | undefined,
  140782. /**
  140783. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140784. */
  140785. samplingMode?: number);
  140786. /**
  140787. * Execute the current task
  140788. * @param scene defines the scene where you want your assets to be loaded
  140789. * @param onSuccess is a callback called when the task is successfully executed
  140790. * @param onError is a callback called if an error occurs
  140791. */
  140792. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140793. }
  140794. /**
  140795. * Define a task used by AssetsManager to load cube textures
  140796. */
  140797. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  140798. /**
  140799. * Defines the name of the task
  140800. */
  140801. name: string;
  140802. /**
  140803. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  140804. */
  140805. url: string;
  140806. /**
  140807. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  140808. */
  140809. extensions?: string[] | undefined;
  140810. /**
  140811. * Defines if mipmaps should not be generated (default is false)
  140812. */
  140813. noMipmap?: boolean | undefined;
  140814. /**
  140815. * Defines the explicit list of files (undefined by default)
  140816. */
  140817. files?: string[] | undefined;
  140818. /**
  140819. * Gets the loaded texture
  140820. */
  140821. texture: CubeTexture;
  140822. /**
  140823. * Callback called when the task is successful
  140824. */
  140825. onSuccess: (task: CubeTextureAssetTask) => void;
  140826. /**
  140827. * Callback called when the task is successful
  140828. */
  140829. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  140830. /**
  140831. * Creates a new CubeTextureAssetTask
  140832. * @param name defines the name of the task
  140833. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  140834. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  140835. * @param noMipmap defines if mipmaps should not be generated (default is false)
  140836. * @param files defines the explicit list of files (undefined by default)
  140837. */
  140838. constructor(
  140839. /**
  140840. * Defines the name of the task
  140841. */
  140842. name: string,
  140843. /**
  140844. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  140845. */
  140846. url: string,
  140847. /**
  140848. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  140849. */
  140850. extensions?: string[] | undefined,
  140851. /**
  140852. * Defines if mipmaps should not be generated (default is false)
  140853. */
  140854. noMipmap?: boolean | undefined,
  140855. /**
  140856. * Defines the explicit list of files (undefined by default)
  140857. */
  140858. files?: string[] | undefined);
  140859. /**
  140860. * Execute the current task
  140861. * @param scene defines the scene where you want your assets to be loaded
  140862. * @param onSuccess is a callback called when the task is successfully executed
  140863. * @param onError is a callback called if an error occurs
  140864. */
  140865. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140866. }
  140867. /**
  140868. * Define a task used by AssetsManager to load HDR cube textures
  140869. */
  140870. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  140871. /**
  140872. * Defines the name of the task
  140873. */
  140874. name: string;
  140875. /**
  140876. * Defines the location of the file to load
  140877. */
  140878. url: string;
  140879. /**
  140880. * Defines the desired size (the more it increases the longer the generation will be)
  140881. */
  140882. size: number;
  140883. /**
  140884. * Defines if mipmaps should not be generated (default is false)
  140885. */
  140886. noMipmap: boolean;
  140887. /**
  140888. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  140889. */
  140890. generateHarmonics: boolean;
  140891. /**
  140892. * 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)
  140893. */
  140894. gammaSpace: boolean;
  140895. /**
  140896. * Internal Use Only
  140897. */
  140898. reserved: boolean;
  140899. /**
  140900. * Gets the loaded texture
  140901. */
  140902. texture: HDRCubeTexture;
  140903. /**
  140904. * Callback called when the task is successful
  140905. */
  140906. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  140907. /**
  140908. * Callback called when the task is successful
  140909. */
  140910. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  140911. /**
  140912. * Creates a new HDRCubeTextureAssetTask object
  140913. * @param name defines the name of the task
  140914. * @param url defines the location of the file to load
  140915. * @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.
  140916. * @param noMipmap defines if mipmaps should not be generated (default is false)
  140917. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  140918. * @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)
  140919. * @param reserved Internal use only
  140920. */
  140921. constructor(
  140922. /**
  140923. * Defines the name of the task
  140924. */
  140925. name: string,
  140926. /**
  140927. * Defines the location of the file to load
  140928. */
  140929. url: string,
  140930. /**
  140931. * Defines the desired size (the more it increases the longer the generation will be)
  140932. */
  140933. size: number,
  140934. /**
  140935. * Defines if mipmaps should not be generated (default is false)
  140936. */
  140937. noMipmap?: boolean,
  140938. /**
  140939. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  140940. */
  140941. generateHarmonics?: boolean,
  140942. /**
  140943. * 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)
  140944. */
  140945. gammaSpace?: boolean,
  140946. /**
  140947. * Internal Use Only
  140948. */
  140949. reserved?: boolean);
  140950. /**
  140951. * Execute the current task
  140952. * @param scene defines the scene where you want your assets to be loaded
  140953. * @param onSuccess is a callback called when the task is successfully executed
  140954. * @param onError is a callback called if an error occurs
  140955. */
  140956. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140957. }
  140958. /**
  140959. * Define a task used by AssetsManager to load Equirectangular cube textures
  140960. */
  140961. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  140962. /**
  140963. * Defines the name of the task
  140964. */
  140965. name: string;
  140966. /**
  140967. * Defines the location of the file to load
  140968. */
  140969. url: string;
  140970. /**
  140971. * Defines the desired size (the more it increases the longer the generation will be)
  140972. */
  140973. size: number;
  140974. /**
  140975. * Defines if mipmaps should not be generated (default is false)
  140976. */
  140977. noMipmap: boolean;
  140978. /**
  140979. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  140980. * but the standard material would require them in Gamma space) (default is true)
  140981. */
  140982. gammaSpace: boolean;
  140983. /**
  140984. * Gets the loaded texture
  140985. */
  140986. texture: EquiRectangularCubeTexture;
  140987. /**
  140988. * Callback called when the task is successful
  140989. */
  140990. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  140991. /**
  140992. * Callback called when the task is successful
  140993. */
  140994. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  140995. /**
  140996. * Creates a new EquiRectangularCubeTextureAssetTask object
  140997. * @param name defines the name of the task
  140998. * @param url defines the location of the file to load
  140999. * @param size defines the desired size (the more it increases the longer the generation will be)
  141000. * If the size is omitted this implies you are using a preprocessed cubemap.
  141001. * @param noMipmap defines if mipmaps should not be generated (default is false)
  141002. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  141003. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  141004. * (default is true)
  141005. */
  141006. constructor(
  141007. /**
  141008. * Defines the name of the task
  141009. */
  141010. name: string,
  141011. /**
  141012. * Defines the location of the file to load
  141013. */
  141014. url: string,
  141015. /**
  141016. * Defines the desired size (the more it increases the longer the generation will be)
  141017. */
  141018. size: number,
  141019. /**
  141020. * Defines if mipmaps should not be generated (default is false)
  141021. */
  141022. noMipmap?: boolean,
  141023. /**
  141024. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  141025. * but the standard material would require them in Gamma space) (default is true)
  141026. */
  141027. gammaSpace?: boolean);
  141028. /**
  141029. * Execute the current task
  141030. * @param scene defines the scene where you want your assets to be loaded
  141031. * @param onSuccess is a callback called when the task is successfully executed
  141032. * @param onError is a callback called if an error occurs
  141033. */
  141034. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  141035. }
  141036. /**
  141037. * This class can be used to easily import assets into a scene
  141038. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  141039. */
  141040. export class AssetsManager {
  141041. private _scene;
  141042. private _isLoading;
  141043. protected _tasks: AbstractAssetTask[];
  141044. protected _waitingTasksCount: number;
  141045. protected _totalTasksCount: number;
  141046. /**
  141047. * Callback called when all tasks are processed
  141048. */
  141049. onFinish: (tasks: AbstractAssetTask[]) => void;
  141050. /**
  141051. * Callback called when a task is successful
  141052. */
  141053. onTaskSuccess: (task: AbstractAssetTask) => void;
  141054. /**
  141055. * Callback called when a task had an error
  141056. */
  141057. onTaskError: (task: AbstractAssetTask) => void;
  141058. /**
  141059. * Callback called when a task is done (whatever the result is)
  141060. */
  141061. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  141062. /**
  141063. * Observable called when all tasks are processed
  141064. */
  141065. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  141066. /**
  141067. * Observable called when a task had an error
  141068. */
  141069. onTaskErrorObservable: Observable<AbstractAssetTask>;
  141070. /**
  141071. * Observable called when all tasks were executed
  141072. */
  141073. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  141074. /**
  141075. * Observable called when a task is done (whatever the result is)
  141076. */
  141077. onProgressObservable: Observable<IAssetsProgressEvent>;
  141078. /**
  141079. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  141080. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  141081. */
  141082. useDefaultLoadingScreen: boolean;
  141083. /**
  141084. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  141085. * when all assets have been downloaded.
  141086. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  141087. */
  141088. autoHideLoadingUI: boolean;
  141089. /**
  141090. * Creates a new AssetsManager
  141091. * @param scene defines the scene to work on
  141092. */
  141093. constructor(scene: Scene);
  141094. /**
  141095. * Add a MeshAssetTask to the list of active tasks
  141096. * @param taskName defines the name of the new task
  141097. * @param meshesNames defines the name of meshes to load
  141098. * @param rootUrl defines the root url to use to locate files
  141099. * @param sceneFilename defines the filename of the scene file
  141100. * @returns a new MeshAssetTask object
  141101. */
  141102. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  141103. /**
  141104. * Add a TextFileAssetTask to the list of active tasks
  141105. * @param taskName defines the name of the new task
  141106. * @param url defines the url of the file to load
  141107. * @returns a new TextFileAssetTask object
  141108. */
  141109. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  141110. /**
  141111. * Add a BinaryFileAssetTask to the list of active tasks
  141112. * @param taskName defines the name of the new task
  141113. * @param url defines the url of the file to load
  141114. * @returns a new BinaryFileAssetTask object
  141115. */
  141116. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  141117. /**
  141118. * Add a ImageAssetTask to the list of active tasks
  141119. * @param taskName defines the name of the new task
  141120. * @param url defines the url of the file to load
  141121. * @returns a new ImageAssetTask object
  141122. */
  141123. addImageTask(taskName: string, url: string): ImageAssetTask;
  141124. /**
  141125. * Add a TextureAssetTask to the list of active tasks
  141126. * @param taskName defines the name of the new task
  141127. * @param url defines the url of the file to load
  141128. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141129. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  141130. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  141131. * @returns a new TextureAssetTask object
  141132. */
  141133. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  141134. /**
  141135. * Add a CubeTextureAssetTask to the list of active tasks
  141136. * @param taskName defines the name of the new task
  141137. * @param url defines the url of the file to load
  141138. * @param extensions defines the extension to use to load the cube map (can be null)
  141139. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141140. * @param files defines the list of files to load (can be null)
  141141. * @returns a new CubeTextureAssetTask object
  141142. */
  141143. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  141144. /**
  141145. *
  141146. * Add a HDRCubeTextureAssetTask to the list of active tasks
  141147. * @param taskName defines the name of the new task
  141148. * @param url defines the url of the file to load
  141149. * @param size defines the size you want for the cubemap (can be null)
  141150. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141151. * @param generateHarmonics defines if you want to automatically generate (true by default)
  141152. * @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)
  141153. * @param reserved Internal use only
  141154. * @returns a new HDRCubeTextureAssetTask object
  141155. */
  141156. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  141157. /**
  141158. *
  141159. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  141160. * @param taskName defines the name of the new task
  141161. * @param url defines the url of the file to load
  141162. * @param size defines the size you want for the cubemap (can be null)
  141163. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141164. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  141165. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  141166. * @returns a new EquiRectangularCubeTextureAssetTask object
  141167. */
  141168. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  141169. /**
  141170. * Remove a task from the assets manager.
  141171. * @param task the task to remove
  141172. */
  141173. removeTask(task: AbstractAssetTask): void;
  141174. private _decreaseWaitingTasksCount;
  141175. private _runTask;
  141176. /**
  141177. * Reset the AssetsManager and remove all tasks
  141178. * @return the current instance of the AssetsManager
  141179. */
  141180. reset(): AssetsManager;
  141181. /**
  141182. * Start the loading process
  141183. * @return the current instance of the AssetsManager
  141184. */
  141185. load(): AssetsManager;
  141186. /**
  141187. * Start the loading process as an async operation
  141188. * @return a promise returning the list of failed tasks
  141189. */
  141190. loadAsync(): Promise<void>;
  141191. }
  141192. }
  141193. declare module BABYLON {
  141194. /**
  141195. * Wrapper class for promise with external resolve and reject.
  141196. */
  141197. export class Deferred<T> {
  141198. /**
  141199. * The promise associated with this deferred object.
  141200. */
  141201. readonly promise: Promise<T>;
  141202. private _resolve;
  141203. private _reject;
  141204. /**
  141205. * The resolve method of the promise associated with this deferred object.
  141206. */
  141207. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  141208. /**
  141209. * The reject method of the promise associated with this deferred object.
  141210. */
  141211. get reject(): (reason?: any) => void;
  141212. /**
  141213. * Constructor for this deferred object.
  141214. */
  141215. constructor();
  141216. }
  141217. }
  141218. declare module BABYLON {
  141219. /**
  141220. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  141221. */
  141222. export class MeshExploder {
  141223. private _centerMesh;
  141224. private _meshes;
  141225. private _meshesOrigins;
  141226. private _toCenterVectors;
  141227. private _scaledDirection;
  141228. private _newPosition;
  141229. private _centerPosition;
  141230. /**
  141231. * Explodes meshes from a center mesh.
  141232. * @param meshes The meshes to explode.
  141233. * @param centerMesh The mesh to be center of explosion.
  141234. */
  141235. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  141236. private _setCenterMesh;
  141237. /**
  141238. * Get class name
  141239. * @returns "MeshExploder"
  141240. */
  141241. getClassName(): string;
  141242. /**
  141243. * "Exploded meshes"
  141244. * @returns Array of meshes with the centerMesh at index 0.
  141245. */
  141246. getMeshes(): Array<Mesh>;
  141247. /**
  141248. * Explodes meshes giving a specific direction
  141249. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  141250. */
  141251. explode(direction?: number): void;
  141252. }
  141253. }
  141254. declare module BABYLON {
  141255. /**
  141256. * Class used to help managing file picking and drag'n'drop
  141257. */
  141258. export class FilesInput {
  141259. /**
  141260. * List of files ready to be loaded
  141261. */
  141262. static get FilesToLoad(): {
  141263. [key: string]: File;
  141264. };
  141265. /**
  141266. * Callback called when a file is processed
  141267. */
  141268. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  141269. private _engine;
  141270. private _currentScene;
  141271. private _sceneLoadedCallback;
  141272. private _progressCallback;
  141273. private _additionalRenderLoopLogicCallback;
  141274. private _textureLoadingCallback;
  141275. private _startingProcessingFilesCallback;
  141276. private _onReloadCallback;
  141277. private _errorCallback;
  141278. private _elementToMonitor;
  141279. private _sceneFileToLoad;
  141280. private _filesToLoad;
  141281. /**
  141282. * Creates a new FilesInput
  141283. * @param engine defines the rendering engine
  141284. * @param scene defines the hosting scene
  141285. * @param sceneLoadedCallback callback called when scene is loaded
  141286. * @param progressCallback callback called to track progress
  141287. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  141288. * @param textureLoadingCallback callback called when a texture is loading
  141289. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  141290. * @param onReloadCallback callback called when a reload is requested
  141291. * @param errorCallback callback call if an error occurs
  141292. */
  141293. 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);
  141294. private _dragEnterHandler;
  141295. private _dragOverHandler;
  141296. private _dropHandler;
  141297. /**
  141298. * Calls this function to listen to drag'n'drop events on a specific DOM element
  141299. * @param elementToMonitor defines the DOM element to track
  141300. */
  141301. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  141302. /**
  141303. * Release all associated resources
  141304. */
  141305. dispose(): void;
  141306. private renderFunction;
  141307. private drag;
  141308. private drop;
  141309. private _traverseFolder;
  141310. private _processFiles;
  141311. /**
  141312. * Load files from a drop event
  141313. * @param event defines the drop event to use as source
  141314. */
  141315. loadFiles(event: any): void;
  141316. private _processReload;
  141317. /**
  141318. * Reload the current scene from the loaded files
  141319. */
  141320. reload(): void;
  141321. }
  141322. }
  141323. declare module BABYLON {
  141324. /**
  141325. * Defines the root class used to create scene optimization to use with SceneOptimizer
  141326. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141327. */
  141328. export class SceneOptimization {
  141329. /**
  141330. * Defines the priority of this optimization (0 by default which means first in the list)
  141331. */
  141332. priority: number;
  141333. /**
  141334. * Gets a string describing the action executed by the current optimization
  141335. * @returns description string
  141336. */
  141337. getDescription(): string;
  141338. /**
  141339. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141340. * @param scene defines the current scene where to apply this optimization
  141341. * @param optimizer defines the current optimizer
  141342. * @returns true if everything that can be done was applied
  141343. */
  141344. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141345. /**
  141346. * Creates the SceneOptimization object
  141347. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141348. * @param desc defines the description associated with the optimization
  141349. */
  141350. constructor(
  141351. /**
  141352. * Defines the priority of this optimization (0 by default which means first in the list)
  141353. */
  141354. priority?: number);
  141355. }
  141356. /**
  141357. * Defines an optimization used to reduce the size of render target textures
  141358. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141359. */
  141360. export class TextureOptimization extends SceneOptimization {
  141361. /**
  141362. * Defines the priority of this optimization (0 by default which means first in the list)
  141363. */
  141364. priority: number;
  141365. /**
  141366. * 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
  141367. */
  141368. maximumSize: number;
  141369. /**
  141370. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141371. */
  141372. step: number;
  141373. /**
  141374. * Gets a string describing the action executed by the current optimization
  141375. * @returns description string
  141376. */
  141377. getDescription(): string;
  141378. /**
  141379. * Creates the TextureOptimization object
  141380. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141381. * @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
  141382. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141383. */
  141384. constructor(
  141385. /**
  141386. * Defines the priority of this optimization (0 by default which means first in the list)
  141387. */
  141388. priority?: number,
  141389. /**
  141390. * 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
  141391. */
  141392. maximumSize?: number,
  141393. /**
  141394. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141395. */
  141396. step?: number);
  141397. /**
  141398. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141399. * @param scene defines the current scene where to apply this optimization
  141400. * @param optimizer defines the current optimizer
  141401. * @returns true if everything that can be done was applied
  141402. */
  141403. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141404. }
  141405. /**
  141406. * Defines an optimization used to increase or decrease the rendering resolution
  141407. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141408. */
  141409. export class HardwareScalingOptimization extends SceneOptimization {
  141410. /**
  141411. * Defines the priority of this optimization (0 by default which means first in the list)
  141412. */
  141413. priority: number;
  141414. /**
  141415. * Defines the maximum scale to use (2 by default)
  141416. */
  141417. maximumScale: number;
  141418. /**
  141419. * Defines the step to use between two passes (0.5 by default)
  141420. */
  141421. step: number;
  141422. private _currentScale;
  141423. private _directionOffset;
  141424. /**
  141425. * Gets a string describing the action executed by the current optimization
  141426. * @return description string
  141427. */
  141428. getDescription(): string;
  141429. /**
  141430. * Creates the HardwareScalingOptimization object
  141431. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141432. * @param maximumScale defines the maximum scale to use (2 by default)
  141433. * @param step defines the step to use between two passes (0.5 by default)
  141434. */
  141435. constructor(
  141436. /**
  141437. * Defines the priority of this optimization (0 by default which means first in the list)
  141438. */
  141439. priority?: number,
  141440. /**
  141441. * Defines the maximum scale to use (2 by default)
  141442. */
  141443. maximumScale?: number,
  141444. /**
  141445. * Defines the step to use between two passes (0.5 by default)
  141446. */
  141447. step?: number);
  141448. /**
  141449. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141450. * @param scene defines the current scene where to apply this optimization
  141451. * @param optimizer defines the current optimizer
  141452. * @returns true if everything that can be done was applied
  141453. */
  141454. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141455. }
  141456. /**
  141457. * Defines an optimization used to remove shadows
  141458. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141459. */
  141460. export class ShadowsOptimization extends SceneOptimization {
  141461. /**
  141462. * Gets a string describing the action executed by the current optimization
  141463. * @return description string
  141464. */
  141465. getDescription(): string;
  141466. /**
  141467. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141468. * @param scene defines the current scene where to apply this optimization
  141469. * @param optimizer defines the current optimizer
  141470. * @returns true if everything that can be done was applied
  141471. */
  141472. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141473. }
  141474. /**
  141475. * Defines an optimization used to turn post-processes off
  141476. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141477. */
  141478. export class PostProcessesOptimization extends SceneOptimization {
  141479. /**
  141480. * Gets a string describing the action executed by the current optimization
  141481. * @return description string
  141482. */
  141483. getDescription(): string;
  141484. /**
  141485. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141486. * @param scene defines the current scene where to apply this optimization
  141487. * @param optimizer defines the current optimizer
  141488. * @returns true if everything that can be done was applied
  141489. */
  141490. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141491. }
  141492. /**
  141493. * Defines an optimization used to turn lens flares off
  141494. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141495. */
  141496. export class LensFlaresOptimization extends SceneOptimization {
  141497. /**
  141498. * Gets a string describing the action executed by the current optimization
  141499. * @return description string
  141500. */
  141501. getDescription(): string;
  141502. /**
  141503. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141504. * @param scene defines the current scene where to apply this optimization
  141505. * @param optimizer defines the current optimizer
  141506. * @returns true if everything that can be done was applied
  141507. */
  141508. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141509. }
  141510. /**
  141511. * Defines an optimization based on user defined callback.
  141512. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141513. */
  141514. export class CustomOptimization extends SceneOptimization {
  141515. /**
  141516. * Callback called to apply the custom optimization.
  141517. */
  141518. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  141519. /**
  141520. * Callback called to get custom description
  141521. */
  141522. onGetDescription: () => string;
  141523. /**
  141524. * Gets a string describing the action executed by the current optimization
  141525. * @returns description string
  141526. */
  141527. getDescription(): string;
  141528. /**
  141529. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141530. * @param scene defines the current scene where to apply this optimization
  141531. * @param optimizer defines the current optimizer
  141532. * @returns true if everything that can be done was applied
  141533. */
  141534. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141535. }
  141536. /**
  141537. * Defines an optimization used to turn particles off
  141538. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141539. */
  141540. export class ParticlesOptimization extends SceneOptimization {
  141541. /**
  141542. * Gets a string describing the action executed by the current optimization
  141543. * @return description string
  141544. */
  141545. getDescription(): string;
  141546. /**
  141547. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141548. * @param scene defines the current scene where to apply this optimization
  141549. * @param optimizer defines the current optimizer
  141550. * @returns true if everything that can be done was applied
  141551. */
  141552. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141553. }
  141554. /**
  141555. * Defines an optimization used to turn render targets off
  141556. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141557. */
  141558. export class RenderTargetsOptimization extends SceneOptimization {
  141559. /**
  141560. * Gets a string describing the action executed by the current optimization
  141561. * @return description string
  141562. */
  141563. getDescription(): string;
  141564. /**
  141565. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141566. * @param scene defines the current scene where to apply this optimization
  141567. * @param optimizer defines the current optimizer
  141568. * @returns true if everything that can be done was applied
  141569. */
  141570. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141571. }
  141572. /**
  141573. * Defines an optimization used to merge meshes with compatible materials
  141574. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141575. */
  141576. export class MergeMeshesOptimization extends SceneOptimization {
  141577. private static _UpdateSelectionTree;
  141578. /**
  141579. * Gets or sets a boolean which defines if optimization octree has to be updated
  141580. */
  141581. static get UpdateSelectionTree(): boolean;
  141582. /**
  141583. * Gets or sets a boolean which defines if optimization octree has to be updated
  141584. */
  141585. static set UpdateSelectionTree(value: boolean);
  141586. /**
  141587. * Gets a string describing the action executed by the current optimization
  141588. * @return description string
  141589. */
  141590. getDescription(): string;
  141591. private _canBeMerged;
  141592. /**
  141593. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141594. * @param scene defines the current scene where to apply this optimization
  141595. * @param optimizer defines the current optimizer
  141596. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  141597. * @returns true if everything that can be done was applied
  141598. */
  141599. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  141600. }
  141601. /**
  141602. * Defines a list of options used by SceneOptimizer
  141603. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141604. */
  141605. export class SceneOptimizerOptions {
  141606. /**
  141607. * Defines the target frame rate to reach (60 by default)
  141608. */
  141609. targetFrameRate: number;
  141610. /**
  141611. * Defines the interval between two checkes (2000ms by default)
  141612. */
  141613. trackerDuration: number;
  141614. /**
  141615. * Gets the list of optimizations to apply
  141616. */
  141617. optimizations: SceneOptimization[];
  141618. /**
  141619. * Creates a new list of options used by SceneOptimizer
  141620. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  141621. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  141622. */
  141623. constructor(
  141624. /**
  141625. * Defines the target frame rate to reach (60 by default)
  141626. */
  141627. targetFrameRate?: number,
  141628. /**
  141629. * Defines the interval between two checkes (2000ms by default)
  141630. */
  141631. trackerDuration?: number);
  141632. /**
  141633. * Add a new optimization
  141634. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  141635. * @returns the current SceneOptimizerOptions
  141636. */
  141637. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  141638. /**
  141639. * Add a new custom optimization
  141640. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  141641. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  141642. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141643. * @returns the current SceneOptimizerOptions
  141644. */
  141645. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  141646. /**
  141647. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  141648. * @param targetFrameRate defines the target frame rate (60 by default)
  141649. * @returns a SceneOptimizerOptions object
  141650. */
  141651. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141652. /**
  141653. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  141654. * @param targetFrameRate defines the target frame rate (60 by default)
  141655. * @returns a SceneOptimizerOptions object
  141656. */
  141657. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141658. /**
  141659. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  141660. * @param targetFrameRate defines the target frame rate (60 by default)
  141661. * @returns a SceneOptimizerOptions object
  141662. */
  141663. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141664. }
  141665. /**
  141666. * Class used to run optimizations in order to reach a target frame rate
  141667. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141668. */
  141669. export class SceneOptimizer implements IDisposable {
  141670. private _isRunning;
  141671. private _options;
  141672. private _scene;
  141673. private _currentPriorityLevel;
  141674. private _targetFrameRate;
  141675. private _trackerDuration;
  141676. private _currentFrameRate;
  141677. private _sceneDisposeObserver;
  141678. private _improvementMode;
  141679. /**
  141680. * Defines an observable called when the optimizer reaches the target frame rate
  141681. */
  141682. onSuccessObservable: Observable<SceneOptimizer>;
  141683. /**
  141684. * Defines an observable called when the optimizer enables an optimization
  141685. */
  141686. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  141687. /**
  141688. * Defines an observable called when the optimizer is not able to reach the target frame rate
  141689. */
  141690. onFailureObservable: Observable<SceneOptimizer>;
  141691. /**
  141692. * Gets a boolean indicating if the optimizer is in improvement mode
  141693. */
  141694. get isInImprovementMode(): boolean;
  141695. /**
  141696. * Gets the current priority level (0 at start)
  141697. */
  141698. get currentPriorityLevel(): number;
  141699. /**
  141700. * Gets the current frame rate checked by the SceneOptimizer
  141701. */
  141702. get currentFrameRate(): number;
  141703. /**
  141704. * Gets or sets the current target frame rate (60 by default)
  141705. */
  141706. get targetFrameRate(): number;
  141707. /**
  141708. * Gets or sets the current target frame rate (60 by default)
  141709. */
  141710. set targetFrameRate(value: number);
  141711. /**
  141712. * Gets or sets the current interval between two checks (every 2000ms by default)
  141713. */
  141714. get trackerDuration(): number;
  141715. /**
  141716. * Gets or sets the current interval between two checks (every 2000ms by default)
  141717. */
  141718. set trackerDuration(value: number);
  141719. /**
  141720. * Gets the list of active optimizations
  141721. */
  141722. get optimizations(): SceneOptimization[];
  141723. /**
  141724. * Creates a new SceneOptimizer
  141725. * @param scene defines the scene to work on
  141726. * @param options defines the options to use with the SceneOptimizer
  141727. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  141728. * @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)
  141729. */
  141730. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  141731. /**
  141732. * Stops the current optimizer
  141733. */
  141734. stop(): void;
  141735. /**
  141736. * Reset the optimizer to initial step (current priority level = 0)
  141737. */
  141738. reset(): void;
  141739. /**
  141740. * Start the optimizer. By default it will try to reach a specific framerate
  141741. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  141742. */
  141743. start(): void;
  141744. private _checkCurrentState;
  141745. /**
  141746. * Release all resources
  141747. */
  141748. dispose(): void;
  141749. /**
  141750. * Helper function to create a SceneOptimizer with one single line of code
  141751. * @param scene defines the scene to work on
  141752. * @param options defines the options to use with the SceneOptimizer
  141753. * @param onSuccess defines a callback to call on success
  141754. * @param onFailure defines a callback to call on failure
  141755. * @returns the new SceneOptimizer object
  141756. */
  141757. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  141758. }
  141759. }
  141760. declare module BABYLON {
  141761. /**
  141762. * Class used to serialize a scene into a string
  141763. */
  141764. export class SceneSerializer {
  141765. /**
  141766. * Clear cache used by a previous serialization
  141767. */
  141768. static ClearCache(): void;
  141769. /**
  141770. * Serialize a scene into a JSON compatible object
  141771. * @param scene defines the scene to serialize
  141772. * @returns a JSON compatible object
  141773. */
  141774. static Serialize(scene: Scene): any;
  141775. /**
  141776. * Serialize a mesh into a JSON compatible object
  141777. * @param toSerialize defines the mesh to serialize
  141778. * @param withParents defines if parents must be serialized as well
  141779. * @param withChildren defines if children must be serialized as well
  141780. * @returns a JSON compatible object
  141781. */
  141782. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  141783. }
  141784. }
  141785. declare module BABYLON {
  141786. /**
  141787. * Class used to host texture specific utilities
  141788. */
  141789. export class TextureTools {
  141790. /**
  141791. * Uses the GPU to create a copy texture rescaled at a given size
  141792. * @param texture Texture to copy from
  141793. * @param width defines the desired width
  141794. * @param height defines the desired height
  141795. * @param useBilinearMode defines if bilinear mode has to be used
  141796. * @return the generated texture
  141797. */
  141798. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  141799. }
  141800. }
  141801. declare module BABYLON {
  141802. /**
  141803. * This represents the different options available for the video capture.
  141804. */
  141805. export interface VideoRecorderOptions {
  141806. /** Defines the mime type of the video. */
  141807. mimeType: string;
  141808. /** Defines the FPS the video should be recorded at. */
  141809. fps: number;
  141810. /** Defines the chunk size for the recording data. */
  141811. recordChunckSize: number;
  141812. /** The audio tracks to attach to the recording. */
  141813. audioTracks?: MediaStreamTrack[];
  141814. }
  141815. /**
  141816. * This can help with recording videos from BabylonJS.
  141817. * This is based on the available WebRTC functionalities of the browser.
  141818. *
  141819. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  141820. */
  141821. export class VideoRecorder {
  141822. private static readonly _defaultOptions;
  141823. /**
  141824. * Returns whether or not the VideoRecorder is available in your browser.
  141825. * @param engine Defines the Babylon Engine.
  141826. * @returns true if supported otherwise false.
  141827. */
  141828. static IsSupported(engine: Engine): boolean;
  141829. private readonly _options;
  141830. private _canvas;
  141831. private _mediaRecorder;
  141832. private _recordedChunks;
  141833. private _fileName;
  141834. private _resolve;
  141835. private _reject;
  141836. /**
  141837. * True when a recording is already in progress.
  141838. */
  141839. get isRecording(): boolean;
  141840. /**
  141841. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  141842. * @param engine Defines the BabylonJS Engine you wish to record.
  141843. * @param options Defines options that can be used to customize the capture.
  141844. */
  141845. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  141846. /**
  141847. * Stops the current recording before the default capture timeout passed in the startRecording function.
  141848. */
  141849. stopRecording(): void;
  141850. /**
  141851. * Starts recording the canvas for a max duration specified in parameters.
  141852. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  141853. * If null no automatic download will start and you can rely on the promise to get the data back.
  141854. * @param maxDuration Defines the maximum recording time in seconds.
  141855. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  141856. * @return A promise callback at the end of the recording with the video data in Blob.
  141857. */
  141858. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  141859. /**
  141860. * Releases internal resources used during the recording.
  141861. */
  141862. dispose(): void;
  141863. private _handleDataAvailable;
  141864. private _handleError;
  141865. private _handleStop;
  141866. }
  141867. }
  141868. declare module BABYLON {
  141869. /**
  141870. * Class containing a set of static utilities functions for screenshots
  141871. */
  141872. export class ScreenshotTools {
  141873. /**
  141874. * Captures a screenshot of the current rendering
  141875. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141876. * @param engine defines the rendering engine
  141877. * @param camera defines the source camera
  141878. * @param size This parameter can be set to a single number or to an object with the
  141879. * following (optional) properties: precision, width, height. If a single number is passed,
  141880. * it will be used for both width and height. If an object is passed, the screenshot size
  141881. * will be derived from the parameters. The precision property is a multiplier allowing
  141882. * rendering at a higher or lower resolution
  141883. * @param successCallback defines the callback receives a single parameter which contains the
  141884. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  141885. * src parameter of an <img> to display it
  141886. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  141887. * Check your browser for supported MIME types
  141888. */
  141889. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  141890. /**
  141891. * Captures a screenshot of the current rendering
  141892. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141893. * @param engine defines the rendering engine
  141894. * @param camera defines the source camera
  141895. * @param size This parameter can be set to a single number or to an object with the
  141896. * following (optional) properties: precision, width, height. If a single number is passed,
  141897. * it will be used for both width and height. If an object is passed, the screenshot size
  141898. * will be derived from the parameters. The precision property is a multiplier allowing
  141899. * rendering at a higher or lower resolution
  141900. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  141901. * Check your browser for supported MIME types
  141902. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  141903. * to the src parameter of an <img> to display it
  141904. */
  141905. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  141906. /**
  141907. * Generates an image screenshot from the specified camera.
  141908. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141909. * @param engine The engine to use for rendering
  141910. * @param camera The camera to use for rendering
  141911. * @param size This parameter can be set to a single number or to an object with the
  141912. * following (optional) properties: precision, width, height. If a single number is passed,
  141913. * it will be used for both width and height. If an object is passed, the screenshot size
  141914. * will be derived from the parameters. The precision property is a multiplier allowing
  141915. * rendering at a higher or lower resolution
  141916. * @param successCallback The callback receives a single parameter which contains the
  141917. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  141918. * src parameter of an <img> to display it
  141919. * @param mimeType The MIME type of the screenshot image (default: image/png).
  141920. * Check your browser for supported MIME types
  141921. * @param samples Texture samples (default: 1)
  141922. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  141923. * @param fileName A name for for the downloaded file.
  141924. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  141925. */
  141926. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  141927. /**
  141928. * Generates an image screenshot from the specified camera.
  141929. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141930. * @param engine The engine to use for rendering
  141931. * @param camera The camera to use for rendering
  141932. * @param size This parameter can be set to a single number or to an object with the
  141933. * following (optional) properties: precision, width, height. If a single number is passed,
  141934. * it will be used for both width and height. If an object is passed, the screenshot size
  141935. * will be derived from the parameters. The precision property is a multiplier allowing
  141936. * rendering at a higher or lower resolution
  141937. * @param mimeType The MIME type of the screenshot image (default: image/png).
  141938. * Check your browser for supported MIME types
  141939. * @param samples Texture samples (default: 1)
  141940. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  141941. * @param fileName A name for for the downloaded file.
  141942. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  141943. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  141944. * to the src parameter of an <img> to display it
  141945. */
  141946. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  141947. /**
  141948. * Gets height and width for screenshot size
  141949. * @private
  141950. */
  141951. private static _getScreenshotSize;
  141952. }
  141953. }
  141954. declare module BABYLON {
  141955. /**
  141956. * Interface for a data buffer
  141957. */
  141958. export interface IDataBuffer {
  141959. /**
  141960. * Reads bytes from the data buffer.
  141961. * @param byteOffset The byte offset to read
  141962. * @param byteLength The byte length to read
  141963. * @returns A promise that resolves when the bytes are read
  141964. */
  141965. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  141966. /**
  141967. * The byte length of the buffer.
  141968. */
  141969. readonly byteLength: number;
  141970. }
  141971. /**
  141972. * Utility class for reading from a data buffer
  141973. */
  141974. export class DataReader {
  141975. /**
  141976. * The data buffer associated with this data reader.
  141977. */
  141978. readonly buffer: IDataBuffer;
  141979. /**
  141980. * The current byte offset from the beginning of the data buffer.
  141981. */
  141982. byteOffset: number;
  141983. private _dataView;
  141984. private _dataByteOffset;
  141985. /**
  141986. * Constructor
  141987. * @param buffer The buffer to read
  141988. */
  141989. constructor(buffer: IDataBuffer);
  141990. /**
  141991. * Loads the given byte length.
  141992. * @param byteLength The byte length to load
  141993. * @returns A promise that resolves when the load is complete
  141994. */
  141995. loadAsync(byteLength: number): Promise<void>;
  141996. /**
  141997. * Read a unsigned 32-bit integer from the currently loaded data range.
  141998. * @returns The 32-bit integer read
  141999. */
  142000. readUint32(): number;
  142001. /**
  142002. * Read a byte array from the currently loaded data range.
  142003. * @param byteLength The byte length to read
  142004. * @returns The byte array read
  142005. */
  142006. readUint8Array(byteLength: number): Uint8Array;
  142007. /**
  142008. * Read a string from the currently loaded data range.
  142009. * @param byteLength The byte length to read
  142010. * @returns The string read
  142011. */
  142012. readString(byteLength: number): string;
  142013. /**
  142014. * Skips the given byte length the currently loaded data range.
  142015. * @param byteLength The byte length to skip
  142016. */
  142017. skipBytes(byteLength: number): void;
  142018. }
  142019. }
  142020. declare module BABYLON {
  142021. /**
  142022. * Options used for hit testing
  142023. */
  142024. export interface IWebXRHitTestOptions {
  142025. /**
  142026. * Only test when user interacted with the scene. Default - hit test every frame
  142027. */
  142028. testOnPointerDownOnly?: boolean;
  142029. /**
  142030. * The node to use to transform the local results to world coordinates
  142031. */
  142032. worldParentNode?: TransformNode;
  142033. }
  142034. /**
  142035. * Interface defining the babylon result of raycasting/hit-test
  142036. */
  142037. export interface IWebXRHitResult {
  142038. /**
  142039. * The native hit test result
  142040. */
  142041. xrHitResult: XRHitResult;
  142042. /**
  142043. * Transformation matrix that can be applied to a node that will put it in the hit point location
  142044. */
  142045. transformationMatrix: Matrix;
  142046. }
  142047. /**
  142048. * The currently-working hit-test module.
  142049. * Hit test (or raycasting) is used to interact with the real world.
  142050. * For further information read here - https://github.com/immersive-web/hit-test
  142051. */
  142052. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  142053. /**
  142054. * options to use when constructing this feature
  142055. */
  142056. readonly options: IWebXRHitTestOptions;
  142057. /**
  142058. * The module's name
  142059. */
  142060. static readonly Name: string;
  142061. /**
  142062. * The (Babylon) version of this module.
  142063. * This is an integer representing the implementation version.
  142064. * This number does not correspond to the webxr specs version
  142065. */
  142066. static readonly Version: number;
  142067. /**
  142068. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  142069. * @param event the (select) event to use to select with
  142070. * @param referenceSpace the reference space to use for this hit test
  142071. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  142072. */
  142073. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  142074. /**
  142075. * execute a hit test with an XR Ray
  142076. *
  142077. * @param xrSession a native xrSession that will execute this hit test
  142078. * @param xrRay the ray (position and direction) to use for raycasting
  142079. * @param referenceSpace native XR reference space to use for the hit-test
  142080. * @param filter filter function that will filter the results
  142081. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  142082. */
  142083. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  142084. /**
  142085. * Triggered when new babylon (transformed) hit test results are available
  142086. */
  142087. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  142088. private _onSelectEnabled;
  142089. /**
  142090. * Creates a new instance of the (legacy version) hit test feature
  142091. * @param _xrSessionManager an instance of WebXRSessionManager
  142092. * @param options options to use when constructing this feature
  142093. */
  142094. constructor(_xrSessionManager: WebXRSessionManager,
  142095. /**
  142096. * options to use when constructing this feature
  142097. */
  142098. options?: IWebXRHitTestOptions);
  142099. /**
  142100. * Populated with the last native XR Hit Results
  142101. */
  142102. lastNativeXRHitResults: XRHitResult[];
  142103. /**
  142104. * attach this feature
  142105. * Will usually be called by the features manager
  142106. *
  142107. * @returns true if successful.
  142108. */
  142109. attach(): boolean;
  142110. /**
  142111. * detach this feature.
  142112. * Will usually be called by the features manager
  142113. *
  142114. * @returns true if successful.
  142115. */
  142116. detach(): boolean;
  142117. private _onHitTestResults;
  142118. private _origin;
  142119. private _direction;
  142120. private _mat;
  142121. protected _onXRFrame(frame: XRFrame): void;
  142122. private _onSelect;
  142123. /**
  142124. * Dispose this feature and all of the resources attached
  142125. */
  142126. dispose(): void;
  142127. }
  142128. }
  142129. declare module BABYLON {
  142130. /**
  142131. * Options used in the plane detector module
  142132. */
  142133. export interface IWebXRPlaneDetectorOptions {
  142134. /**
  142135. * The node to use to transform the local results to world coordinates
  142136. */
  142137. worldParentNode?: TransformNode;
  142138. }
  142139. /**
  142140. * A babylon interface for a webxr plane.
  142141. * A Plane is actually a polygon, built from N points in space
  142142. *
  142143. * Supported in chrome 79, not supported in canary 81 ATM
  142144. */
  142145. export interface IWebXRPlane {
  142146. /**
  142147. * a babylon-assigned ID for this polygon
  142148. */
  142149. id: number;
  142150. /**
  142151. * the native xr-plane object
  142152. */
  142153. xrPlane: XRPlane;
  142154. /**
  142155. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  142156. */
  142157. polygonDefinition: Array<Vector3>;
  142158. /**
  142159. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  142160. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  142161. */
  142162. transformationMatrix: Matrix;
  142163. }
  142164. /**
  142165. * The plane detector is used to detect planes in the real world when in AR
  142166. * For more information see https://github.com/immersive-web/real-world-geometry/
  142167. */
  142168. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  142169. private _options;
  142170. /**
  142171. * The module's name
  142172. */
  142173. static readonly Name: string;
  142174. /**
  142175. * The (Babylon) version of this module.
  142176. * This is an integer representing the implementation version.
  142177. * This number does not correspond to the webxr specs version
  142178. */
  142179. static readonly Version: number;
  142180. /**
  142181. * Observers registered here will be executed when a new plane was added to the session
  142182. */
  142183. onPlaneAddedObservable: Observable<IWebXRPlane>;
  142184. /**
  142185. * Observers registered here will be executed when a plane is no longer detected in the session
  142186. */
  142187. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  142188. /**
  142189. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  142190. * This can execute N times every frame
  142191. */
  142192. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  142193. private _enabled;
  142194. private _detectedPlanes;
  142195. private _lastFrameDetected;
  142196. /**
  142197. * construct a new Plane Detector
  142198. * @param _xrSessionManager an instance of xr Session manager
  142199. * @param _options configuration to use when constructing this feature
  142200. */
  142201. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  142202. private _init;
  142203. protected _onXRFrame(frame: XRFrame): void;
  142204. /**
  142205. * Dispose this feature and all of the resources attached
  142206. */
  142207. dispose(): void;
  142208. private _updatePlaneWithXRPlane;
  142209. /**
  142210. * avoiding using Array.find for global support.
  142211. * @param xrPlane the plane to find in the array
  142212. */
  142213. private findIndexInPlaneArray;
  142214. }
  142215. }
  142216. declare module BABYLON {
  142217. /**
  142218. * Configuration options of the anchor system
  142219. */
  142220. export interface IWebXRAnchorSystemOptions {
  142221. /**
  142222. * a node that will be used to convert local to world coordinates
  142223. */
  142224. worldParentNode?: TransformNode;
  142225. /**
  142226. * should the anchor system use plane detection.
  142227. * If set to true, the plane-detection feature should be set using setPlaneDetector
  142228. */
  142229. usePlaneDetection?: boolean;
  142230. /**
  142231. * Should a new anchor be added every time a select event is triggered
  142232. */
  142233. addAnchorOnSelect?: boolean;
  142234. }
  142235. /**
  142236. * A babylon container for an XR Anchor
  142237. */
  142238. export interface IWebXRAnchor {
  142239. /**
  142240. * A babylon-assigned ID for this anchor
  142241. */
  142242. id: number;
  142243. /**
  142244. * The native anchor object
  142245. */
  142246. xrAnchor: XRAnchor;
  142247. /**
  142248. * Transformation matrix to apply to an object attached to this anchor
  142249. */
  142250. transformationMatrix: Matrix;
  142251. }
  142252. /**
  142253. * An implementation of the anchor system of WebXR.
  142254. * Note that the current documented implementation is not available in any browser. Future implementations
  142255. * will use the frame to create an anchor and not the session or a detected plane
  142256. * For further information see https://github.com/immersive-web/anchors/
  142257. */
  142258. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  142259. private _options;
  142260. /**
  142261. * The module's name
  142262. */
  142263. static readonly Name: string;
  142264. /**
  142265. * The (Babylon) version of this module.
  142266. * This is an integer representing the implementation version.
  142267. * This number does not correspond to the webxr specs version
  142268. */
  142269. static readonly Version: number;
  142270. /**
  142271. * Observers registered here will be executed when a new anchor was added to the session
  142272. */
  142273. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  142274. /**
  142275. * Observers registered here will be executed when an existing anchor updates
  142276. * This can execute N times every frame
  142277. */
  142278. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  142279. /**
  142280. * Observers registered here will be executed when an anchor was removed from the session
  142281. */
  142282. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  142283. private _planeDetector;
  142284. private _hitTestModule;
  142285. private _enabled;
  142286. private _trackedAnchors;
  142287. private _lastFrameDetected;
  142288. /**
  142289. * constructs a new anchor system
  142290. * @param _xrSessionManager an instance of WebXRSessionManager
  142291. * @param _options configuration object for this feature
  142292. */
  142293. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  142294. /**
  142295. * set the plane detector to use in order to create anchors from frames
  142296. * @param planeDetector the plane-detector module to use
  142297. * @param enable enable plane-anchors. default is true
  142298. */
  142299. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  142300. /**
  142301. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  142302. * @param hitTestModule the hit-test module to use.
  142303. */
  142304. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  142305. /**
  142306. * attach this feature
  142307. * Will usually be called by the features manager
  142308. *
  142309. * @returns true if successful.
  142310. */
  142311. attach(): boolean;
  142312. /**
  142313. * detach this feature.
  142314. * Will usually be called by the features manager
  142315. *
  142316. * @returns true if successful.
  142317. */
  142318. detach(): boolean;
  142319. /**
  142320. * Dispose this feature and all of the resources attached
  142321. */
  142322. dispose(): void;
  142323. protected _onXRFrame(frame: XRFrame): void;
  142324. private _onSelect;
  142325. /**
  142326. * Add anchor at a specific XR point.
  142327. *
  142328. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  142329. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  142330. * @returns a promise the fulfills when the anchor was created
  142331. */
  142332. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  142333. private _updateAnchorWithXRFrame;
  142334. /**
  142335. * avoiding using Array.find for global support.
  142336. * @param xrAnchor the plane to find in the array
  142337. */
  142338. private _findIndexInAnchorArray;
  142339. }
  142340. }
  142341. declare module BABYLON {
  142342. /**
  142343. * Options interface for the background remover plugin
  142344. */
  142345. export interface IWebXRBackgroundRemoverOptions {
  142346. /**
  142347. * don't disable the environment helper
  142348. */
  142349. ignoreEnvironmentHelper?: boolean;
  142350. /**
  142351. * flags to configure the removal of the environment helper.
  142352. * If not set, the entire background will be removed. If set, flags should be set as well.
  142353. */
  142354. environmentHelperRemovalFlags?: {
  142355. /**
  142356. * Should the skybox be removed (default false)
  142357. */
  142358. skyBox?: boolean;
  142359. /**
  142360. * Should the ground be removed (default false)
  142361. */
  142362. ground?: boolean;
  142363. };
  142364. /**
  142365. * Further background meshes to disable when entering AR
  142366. */
  142367. backgroundMeshes?: AbstractMesh[];
  142368. }
  142369. /**
  142370. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  142371. */
  142372. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  142373. /**
  142374. * read-only options to be used in this module
  142375. */
  142376. readonly options: IWebXRBackgroundRemoverOptions;
  142377. /**
  142378. * The module's name
  142379. */
  142380. static readonly Name: string;
  142381. /**
  142382. * The (Babylon) version of this module.
  142383. * This is an integer representing the implementation version.
  142384. * This number does not correspond to the webxr specs version
  142385. */
  142386. static readonly Version: number;
  142387. /**
  142388. * registered observers will be triggered when the background state changes
  142389. */
  142390. onBackgroundStateChangedObservable: Observable<boolean>;
  142391. /**
  142392. * constructs a new background remover module
  142393. * @param _xrSessionManager the session manager for this module
  142394. * @param options read-only options to be used in this module
  142395. */
  142396. constructor(_xrSessionManager: WebXRSessionManager,
  142397. /**
  142398. * read-only options to be used in this module
  142399. */
  142400. options?: IWebXRBackgroundRemoverOptions);
  142401. /**
  142402. * attach this feature
  142403. * Will usually be called by the features manager
  142404. *
  142405. * @returns true if successful.
  142406. */
  142407. attach(): boolean;
  142408. /**
  142409. * detach this feature.
  142410. * Will usually be called by the features manager
  142411. *
  142412. * @returns true if successful.
  142413. */
  142414. detach(): boolean;
  142415. private _setBackgroundState;
  142416. /**
  142417. * Dispose this feature and all of the resources attached
  142418. */
  142419. dispose(): void;
  142420. protected _onXRFrame(_xrFrame: XRFrame): void;
  142421. }
  142422. }
  142423. declare module BABYLON {
  142424. /**
  142425. * Options for the controller physics feature
  142426. */
  142427. export class IWebXRControllerPhysicsOptions {
  142428. /**
  142429. * the xr input to use with this pointer selection
  142430. */
  142431. xrInput: WebXRInput;
  142432. /**
  142433. * The physics properties of the future impostors
  142434. */
  142435. physicsProperties?: {
  142436. /**
  142437. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  142438. * Note that this requires a physics engine that supports mesh impostors!
  142439. */
  142440. useControllerMesh?: boolean;
  142441. /**
  142442. * The type of impostor to create. Default is sphere
  142443. */
  142444. impostorType?: number;
  142445. /**
  142446. * the size of the impostor. Defaults to 10cm
  142447. */
  142448. impostorSize?: number | {
  142449. width: number;
  142450. height: number;
  142451. depth: number;
  142452. };
  142453. /**
  142454. * Friction definitions
  142455. */
  142456. friction?: number;
  142457. /**
  142458. * Restitution
  142459. */
  142460. restitution?: number;
  142461. };
  142462. /**
  142463. * Should the headset get its own impostor
  142464. */
  142465. enableHeadsetImpostor?: boolean;
  142466. /**
  142467. * Optional parameters for the headset impostor
  142468. */
  142469. headsetImpostorParams?: {
  142470. /**
  142471. * The type of impostor to create. Default is sphere
  142472. */
  142473. impostorType: number;
  142474. /**
  142475. * the size of the impostor. Defaults to 10cm
  142476. */
  142477. impostorSize?: number | {
  142478. width: number;
  142479. height: number;
  142480. depth: number;
  142481. };
  142482. /**
  142483. * Friction definitions
  142484. */
  142485. friction?: number;
  142486. /**
  142487. * Restitution
  142488. */
  142489. restitution?: number;
  142490. };
  142491. }
  142492. /**
  142493. * Add physics impostor to your webxr controllers,
  142494. * including naive calculation of their linear and angular velocity
  142495. */
  142496. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  142497. private readonly _options;
  142498. /**
  142499. * The module's name
  142500. */
  142501. static readonly Name: string;
  142502. /**
  142503. * The (Babylon) version of this module.
  142504. * This is an integer representing the implementation version.
  142505. * This number does not correspond to the webxr specs version
  142506. */
  142507. static readonly Version: number;
  142508. private _lastTimestamp;
  142509. private _delta;
  142510. private _controllers;
  142511. private _headsetImpostor?;
  142512. private _headsetMesh?;
  142513. private _tmpVector;
  142514. private _tmpQuaternion;
  142515. /**
  142516. * Construct a new Controller Physics Feature
  142517. * @param _xrSessionManager the corresponding xr session manager
  142518. * @param _options options to create this feature with
  142519. */
  142520. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  142521. /**
  142522. * Update the physics properties provided in the constructor
  142523. * @param newProperties the new properties object
  142524. */
  142525. setPhysicsProperties(newProperties: {
  142526. impostorType?: number;
  142527. impostorSize?: number | {
  142528. width: number;
  142529. height: number;
  142530. depth: number;
  142531. };
  142532. friction?: number;
  142533. restitution?: number;
  142534. }): void;
  142535. /**
  142536. * Get the physics impostor of a specific controller.
  142537. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  142538. * @param controller the controller or the controller id of which to get the impostor
  142539. * @returns the impostor or null
  142540. */
  142541. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  142542. /**
  142543. * Get the headset impostor, if enabled
  142544. * @returns the impostor
  142545. */
  142546. getHeadsetImpostor(): PhysicsImpostor | undefined;
  142547. /**
  142548. * attach this feature
  142549. * Will usually be called by the features manager
  142550. *
  142551. * @returns true if successful.
  142552. */
  142553. attach(): boolean;
  142554. /**
  142555. * detach this feature.
  142556. * Will usually be called by the features manager
  142557. *
  142558. * @returns true if successful.
  142559. */
  142560. detach(): boolean;
  142561. /**
  142562. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  142563. * @param xrController the controller to add
  142564. */
  142565. addController(xrController: WebXRInputSource): void;
  142566. private _debugMode;
  142567. /**
  142568. * @hidden
  142569. * enable debugging - will show console outputs and the impostor mesh
  142570. */
  142571. _enablePhysicsDebug(): void;
  142572. private _attachController;
  142573. private _detachController;
  142574. protected _onXRFrame(_xrFrame: any): void;
  142575. }
  142576. }
  142577. declare module BABYLON {
  142578. /**
  142579. * The motion controller class for all microsoft mixed reality controllers
  142580. */
  142581. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  142582. /**
  142583. * The base url used to load the left and right controller models
  142584. */
  142585. static MODEL_BASE_URL: string;
  142586. /**
  142587. * The name of the left controller model file
  142588. */
  142589. static MODEL_LEFT_FILENAME: string;
  142590. /**
  142591. * The name of the right controller model file
  142592. */
  142593. static MODEL_RIGHT_FILENAME: string;
  142594. profileId: string;
  142595. protected readonly _mapping: {
  142596. defaultButton: {
  142597. "valueNodeName": string;
  142598. "unpressedNodeName": string;
  142599. "pressedNodeName": string;
  142600. };
  142601. defaultAxis: {
  142602. "valueNodeName": string;
  142603. "minNodeName": string;
  142604. "maxNodeName": string;
  142605. };
  142606. buttons: {
  142607. "xr-standard-trigger": {
  142608. "rootNodeName": string;
  142609. "componentProperty": string;
  142610. "states": string[];
  142611. };
  142612. "xr-standard-squeeze": {
  142613. "rootNodeName": string;
  142614. "componentProperty": string;
  142615. "states": string[];
  142616. };
  142617. "xr-standard-touchpad": {
  142618. "rootNodeName": string;
  142619. "labelAnchorNodeName": string;
  142620. "touchPointNodeName": string;
  142621. };
  142622. "xr-standard-thumbstick": {
  142623. "rootNodeName": string;
  142624. "componentProperty": string;
  142625. "states": string[];
  142626. };
  142627. };
  142628. axes: {
  142629. "xr-standard-touchpad": {
  142630. "x-axis": {
  142631. "rootNodeName": string;
  142632. };
  142633. "y-axis": {
  142634. "rootNodeName": string;
  142635. };
  142636. };
  142637. "xr-standard-thumbstick": {
  142638. "x-axis": {
  142639. "rootNodeName": string;
  142640. };
  142641. "y-axis": {
  142642. "rootNodeName": string;
  142643. };
  142644. };
  142645. };
  142646. };
  142647. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  142648. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  142649. protected _getFilenameAndPath(): {
  142650. filename: string;
  142651. path: string;
  142652. };
  142653. protected _updateModel(): void;
  142654. protected _getModelLoadingConstraints(): boolean;
  142655. protected _setRootMesh(meshes: AbstractMesh[]): void;
  142656. }
  142657. }
  142658. declare module BABYLON {
  142659. /**
  142660. * The motion controller class for oculus touch (quest, rift).
  142661. * This class supports legacy mapping as well the standard xr mapping
  142662. */
  142663. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  142664. private _forceLegacyControllers;
  142665. /**
  142666. * The base url used to load the left and right controller models
  142667. */
  142668. static MODEL_BASE_URL: string;
  142669. /**
  142670. * The name of the left controller model file
  142671. */
  142672. static MODEL_LEFT_FILENAME: string;
  142673. /**
  142674. * The name of the right controller model file
  142675. */
  142676. static MODEL_RIGHT_FILENAME: string;
  142677. /**
  142678. * Base Url for the Quest controller model.
  142679. */
  142680. static QUEST_MODEL_BASE_URL: string;
  142681. profileId: string;
  142682. private _modelRootNode;
  142683. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  142684. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  142685. protected _getFilenameAndPath(): {
  142686. filename: string;
  142687. path: string;
  142688. };
  142689. /**
  142690. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  142691. * between the touch and touch 2.
  142692. */
  142693. private _isQuest;
  142694. protected _updateModel(): void;
  142695. protected _getModelLoadingConstraints(): boolean;
  142696. protected _setRootMesh(meshes: AbstractMesh[]): void;
  142697. }
  142698. }
  142699. declare module BABYLON {
  142700. /**
  142701. * The motion controller class for the standard HTC-Vive controllers
  142702. */
  142703. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  142704. /**
  142705. * The base url used to load the left and right controller models
  142706. */
  142707. static MODEL_BASE_URL: string;
  142708. /**
  142709. * File name for the controller model.
  142710. */
  142711. static MODEL_FILENAME: string;
  142712. profileId: string;
  142713. private _modelRootNode;
  142714. /**
  142715. * Create a new Vive motion controller object
  142716. * @param scene the scene to use to create this controller
  142717. * @param gamepadObject the corresponding gamepad object
  142718. * @param handness the handness of the controller
  142719. */
  142720. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  142721. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  142722. protected _getFilenameAndPath(): {
  142723. filename: string;
  142724. path: string;
  142725. };
  142726. protected _updateModel(): void;
  142727. protected _getModelLoadingConstraints(): boolean;
  142728. protected _setRootMesh(meshes: AbstractMesh[]): void;
  142729. }
  142730. }
  142731. declare module BABYLON {
  142732. /**
  142733. * A cursor which tracks a point on a path
  142734. */
  142735. export class PathCursor {
  142736. private path;
  142737. /**
  142738. * Stores path cursor callbacks for when an onchange event is triggered
  142739. */
  142740. private _onchange;
  142741. /**
  142742. * The value of the path cursor
  142743. */
  142744. value: number;
  142745. /**
  142746. * The animation array of the path cursor
  142747. */
  142748. animations: Animation[];
  142749. /**
  142750. * Initializes the path cursor
  142751. * @param path The path to track
  142752. */
  142753. constructor(path: Path2);
  142754. /**
  142755. * Gets the cursor point on the path
  142756. * @returns A point on the path cursor at the cursor location
  142757. */
  142758. getPoint(): Vector3;
  142759. /**
  142760. * Moves the cursor ahead by the step amount
  142761. * @param step The amount to move the cursor forward
  142762. * @returns This path cursor
  142763. */
  142764. moveAhead(step?: number): PathCursor;
  142765. /**
  142766. * Moves the cursor behind by the step amount
  142767. * @param step The amount to move the cursor back
  142768. * @returns This path cursor
  142769. */
  142770. moveBack(step?: number): PathCursor;
  142771. /**
  142772. * Moves the cursor by the step amount
  142773. * If the step amount is greater than one, an exception is thrown
  142774. * @param step The amount to move the cursor
  142775. * @returns This path cursor
  142776. */
  142777. move(step: number): PathCursor;
  142778. /**
  142779. * Ensures that the value is limited between zero and one
  142780. * @returns This path cursor
  142781. */
  142782. private ensureLimits;
  142783. /**
  142784. * Runs onchange callbacks on change (used by the animation engine)
  142785. * @returns This path cursor
  142786. */
  142787. private raiseOnChange;
  142788. /**
  142789. * Executes a function on change
  142790. * @param f A path cursor onchange callback
  142791. * @returns This path cursor
  142792. */
  142793. onchange(f: (cursor: PathCursor) => void): PathCursor;
  142794. }
  142795. }
  142796. declare module BABYLON {
  142797. /** @hidden */
  142798. export var blurPixelShader: {
  142799. name: string;
  142800. shader: string;
  142801. };
  142802. }
  142803. declare module BABYLON {
  142804. /** @hidden */
  142805. export var pointCloudVertexDeclaration: {
  142806. name: string;
  142807. shader: string;
  142808. };
  142809. }
  142810. // Mixins
  142811. interface Window {
  142812. mozIndexedDB: IDBFactory;
  142813. webkitIndexedDB: IDBFactory;
  142814. msIndexedDB: IDBFactory;
  142815. webkitURL: typeof URL;
  142816. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  142817. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  142818. WebGLRenderingContext: WebGLRenderingContext;
  142819. MSGesture: MSGesture;
  142820. CANNON: any;
  142821. AudioContext: AudioContext;
  142822. webkitAudioContext: AudioContext;
  142823. PointerEvent: any;
  142824. Math: Math;
  142825. Uint8Array: Uint8ArrayConstructor;
  142826. Float32Array: Float32ArrayConstructor;
  142827. mozURL: typeof URL;
  142828. msURL: typeof URL;
  142829. VRFrameData: any; // WebVR, from specs 1.1
  142830. DracoDecoderModule: any;
  142831. setImmediate(handler: (...args: any[]) => void): number;
  142832. }
  142833. interface HTMLCanvasElement {
  142834. requestPointerLock(): void;
  142835. msRequestPointerLock?(): void;
  142836. mozRequestPointerLock?(): void;
  142837. webkitRequestPointerLock?(): void;
  142838. /** Track wether a record is in progress */
  142839. isRecording: boolean;
  142840. /** Capture Stream method defined by some browsers */
  142841. captureStream(fps?: number): MediaStream;
  142842. }
  142843. interface CanvasRenderingContext2D {
  142844. msImageSmoothingEnabled: boolean;
  142845. }
  142846. interface MouseEvent {
  142847. mozMovementX: number;
  142848. mozMovementY: number;
  142849. webkitMovementX: number;
  142850. webkitMovementY: number;
  142851. msMovementX: number;
  142852. msMovementY: number;
  142853. }
  142854. interface Navigator {
  142855. mozGetVRDevices: (any: any) => any;
  142856. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  142857. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  142858. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  142859. webkitGetGamepads(): Gamepad[];
  142860. msGetGamepads(): Gamepad[];
  142861. webkitGamepads(): Gamepad[];
  142862. }
  142863. interface HTMLVideoElement {
  142864. mozSrcObject: any;
  142865. }
  142866. interface Math {
  142867. fround(x: number): number;
  142868. imul(a: number, b: number): number;
  142869. }
  142870. interface WebGLRenderingContext {
  142871. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  142872. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  142873. vertexAttribDivisor(index: number, divisor: number): void;
  142874. createVertexArray(): any;
  142875. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  142876. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  142877. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  142878. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  142879. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  142880. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  142881. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  142882. // Queries
  142883. createQuery(): WebGLQuery;
  142884. deleteQuery(query: WebGLQuery): void;
  142885. beginQuery(target: number, query: WebGLQuery): void;
  142886. endQuery(target: number): void;
  142887. getQueryParameter(query: WebGLQuery, pname: number): any;
  142888. getQuery(target: number, pname: number): any;
  142889. MAX_SAMPLES: number;
  142890. RGBA8: number;
  142891. READ_FRAMEBUFFER: number;
  142892. DRAW_FRAMEBUFFER: number;
  142893. UNIFORM_BUFFER: number;
  142894. HALF_FLOAT_OES: number;
  142895. RGBA16F: number;
  142896. RGBA32F: number;
  142897. R32F: number;
  142898. RG32F: number;
  142899. RGB32F: number;
  142900. R16F: number;
  142901. RG16F: number;
  142902. RGB16F: number;
  142903. RED: number;
  142904. RG: number;
  142905. R8: number;
  142906. RG8: number;
  142907. UNSIGNED_INT_24_8: number;
  142908. DEPTH24_STENCIL8: number;
  142909. MIN: number;
  142910. MAX: number;
  142911. /* Multiple Render Targets */
  142912. drawBuffers(buffers: number[]): void;
  142913. readBuffer(src: number): void;
  142914. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  142915. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  142916. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  142917. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  142918. // Occlusion Query
  142919. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  142920. ANY_SAMPLES_PASSED: number;
  142921. QUERY_RESULT_AVAILABLE: number;
  142922. QUERY_RESULT: number;
  142923. }
  142924. interface WebGLProgram {
  142925. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  142926. }
  142927. interface EXT_disjoint_timer_query {
  142928. QUERY_COUNTER_BITS_EXT: number;
  142929. TIME_ELAPSED_EXT: number;
  142930. TIMESTAMP_EXT: number;
  142931. GPU_DISJOINT_EXT: number;
  142932. QUERY_RESULT_EXT: number;
  142933. QUERY_RESULT_AVAILABLE_EXT: number;
  142934. queryCounterEXT(query: WebGLQuery, target: number): void;
  142935. createQueryEXT(): WebGLQuery;
  142936. beginQueryEXT(target: number, query: WebGLQuery): void;
  142937. endQueryEXT(target: number): void;
  142938. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  142939. deleteQueryEXT(query: WebGLQuery): void;
  142940. }
  142941. interface WebGLUniformLocation {
  142942. _currentState: any;
  142943. }
  142944. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  142945. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  142946. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  142947. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  142948. interface WebGLRenderingContext {
  142949. readonly RASTERIZER_DISCARD: number;
  142950. readonly DEPTH_COMPONENT24: number;
  142951. readonly TEXTURE_3D: number;
  142952. readonly TEXTURE_2D_ARRAY: number;
  142953. readonly TEXTURE_COMPARE_FUNC: number;
  142954. readonly TEXTURE_COMPARE_MODE: number;
  142955. readonly COMPARE_REF_TO_TEXTURE: number;
  142956. readonly TEXTURE_WRAP_R: number;
  142957. readonly HALF_FLOAT: number;
  142958. readonly RGB8: number;
  142959. readonly RED_INTEGER: number;
  142960. readonly RG_INTEGER: number;
  142961. readonly RGB_INTEGER: number;
  142962. readonly RGBA_INTEGER: number;
  142963. readonly R8_SNORM: number;
  142964. readonly RG8_SNORM: number;
  142965. readonly RGB8_SNORM: number;
  142966. readonly RGBA8_SNORM: number;
  142967. readonly R8I: number;
  142968. readonly RG8I: number;
  142969. readonly RGB8I: number;
  142970. readonly RGBA8I: number;
  142971. readonly R8UI: number;
  142972. readonly RG8UI: number;
  142973. readonly RGB8UI: number;
  142974. readonly RGBA8UI: number;
  142975. readonly R16I: number;
  142976. readonly RG16I: number;
  142977. readonly RGB16I: number;
  142978. readonly RGBA16I: number;
  142979. readonly R16UI: number;
  142980. readonly RG16UI: number;
  142981. readonly RGB16UI: number;
  142982. readonly RGBA16UI: number;
  142983. readonly R32I: number;
  142984. readonly RG32I: number;
  142985. readonly RGB32I: number;
  142986. readonly RGBA32I: number;
  142987. readonly R32UI: number;
  142988. readonly RG32UI: number;
  142989. readonly RGB32UI: number;
  142990. readonly RGBA32UI: number;
  142991. readonly RGB10_A2UI: number;
  142992. readonly R11F_G11F_B10F: number;
  142993. readonly RGB9_E5: number;
  142994. readonly RGB10_A2: number;
  142995. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  142996. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  142997. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  142998. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  142999. readonly DEPTH_COMPONENT32F: number;
  143000. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  143001. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  143002. 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;
  143003. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  143004. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  143005. readonly TRANSFORM_FEEDBACK: number;
  143006. readonly INTERLEAVED_ATTRIBS: number;
  143007. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  143008. createTransformFeedback(): WebGLTransformFeedback;
  143009. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  143010. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  143011. beginTransformFeedback(primitiveMode: number): void;
  143012. endTransformFeedback(): void;
  143013. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  143014. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  143015. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  143016. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  143017. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  143018. }
  143019. interface ImageBitmap {
  143020. readonly width: number;
  143021. readonly height: number;
  143022. close(): void;
  143023. }
  143024. interface WebGLQuery extends WebGLObject {
  143025. }
  143026. declare var WebGLQuery: {
  143027. prototype: WebGLQuery;
  143028. new(): WebGLQuery;
  143029. };
  143030. interface WebGLSampler extends WebGLObject {
  143031. }
  143032. declare var WebGLSampler: {
  143033. prototype: WebGLSampler;
  143034. new(): WebGLSampler;
  143035. };
  143036. interface WebGLSync extends WebGLObject {
  143037. }
  143038. declare var WebGLSync: {
  143039. prototype: WebGLSync;
  143040. new(): WebGLSync;
  143041. };
  143042. interface WebGLTransformFeedback extends WebGLObject {
  143043. }
  143044. declare var WebGLTransformFeedback: {
  143045. prototype: WebGLTransformFeedback;
  143046. new(): WebGLTransformFeedback;
  143047. };
  143048. interface WebGLVertexArrayObject extends WebGLObject {
  143049. }
  143050. declare var WebGLVertexArrayObject: {
  143051. prototype: WebGLVertexArrayObject;
  143052. new(): WebGLVertexArrayObject;
  143053. };
  143054. // Type definitions for WebVR API
  143055. // Project: https://w3c.github.io/webvr/
  143056. // Definitions by: six a <https://github.com/lostfictions>
  143057. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  143058. interface VRDisplay extends EventTarget {
  143059. /**
  143060. * Dictionary of capabilities describing the VRDisplay.
  143061. */
  143062. readonly capabilities: VRDisplayCapabilities;
  143063. /**
  143064. * z-depth defining the far plane of the eye view frustum
  143065. * enables mapping of values in the render target depth
  143066. * attachment to scene coordinates. Initially set to 10000.0.
  143067. */
  143068. depthFar: number;
  143069. /**
  143070. * z-depth defining the near plane of the eye view frustum
  143071. * enables mapping of values in the render target depth
  143072. * attachment to scene coordinates. Initially set to 0.01.
  143073. */
  143074. depthNear: number;
  143075. /**
  143076. * An identifier for this distinct VRDisplay. Used as an
  143077. * association point in the Gamepad API.
  143078. */
  143079. readonly displayId: number;
  143080. /**
  143081. * A display name, a user-readable name identifying it.
  143082. */
  143083. readonly displayName: string;
  143084. readonly isConnected: boolean;
  143085. readonly isPresenting: boolean;
  143086. /**
  143087. * If this VRDisplay supports room-scale experiences, the optional
  143088. * stage attribute contains details on the room-scale parameters.
  143089. */
  143090. readonly stageParameters: VRStageParameters | null;
  143091. /**
  143092. * Passing the value returned by `requestAnimationFrame` to
  143093. * `cancelAnimationFrame` will unregister the callback.
  143094. * @param handle Define the hanle of the request to cancel
  143095. */
  143096. cancelAnimationFrame(handle: number): void;
  143097. /**
  143098. * Stops presenting to the VRDisplay.
  143099. * @returns a promise to know when it stopped
  143100. */
  143101. exitPresent(): Promise<void>;
  143102. /**
  143103. * Return the current VREyeParameters for the given eye.
  143104. * @param whichEye Define the eye we want the parameter for
  143105. * @returns the eye parameters
  143106. */
  143107. getEyeParameters(whichEye: string): VREyeParameters;
  143108. /**
  143109. * Populates the passed VRFrameData with the information required to render
  143110. * the current frame.
  143111. * @param frameData Define the data structure to populate
  143112. * @returns true if ok otherwise false
  143113. */
  143114. getFrameData(frameData: VRFrameData): boolean;
  143115. /**
  143116. * Get the layers currently being presented.
  143117. * @returns the list of VR layers
  143118. */
  143119. getLayers(): VRLayer[];
  143120. /**
  143121. * Return a VRPose containing the future predicted pose of the VRDisplay
  143122. * when the current frame will be presented. The value returned will not
  143123. * change until JavaScript has returned control to the browser.
  143124. *
  143125. * The VRPose will contain the position, orientation, velocity,
  143126. * and acceleration of each of these properties.
  143127. * @returns the pose object
  143128. */
  143129. getPose(): VRPose;
  143130. /**
  143131. * Return the current instantaneous pose of the VRDisplay, with no
  143132. * prediction applied.
  143133. * @returns the current instantaneous pose
  143134. */
  143135. getImmediatePose(): VRPose;
  143136. /**
  143137. * The callback passed to `requestAnimationFrame` will be called
  143138. * any time a new frame should be rendered. When the VRDisplay is
  143139. * presenting the callback will be called at the native refresh
  143140. * rate of the HMD. When not presenting this function acts
  143141. * identically to how window.requestAnimationFrame acts. Content should
  143142. * make no assumptions of frame rate or vsync behavior as the HMD runs
  143143. * asynchronously from other displays and at differing refresh rates.
  143144. * @param callback Define the eaction to run next frame
  143145. * @returns the request handle it
  143146. */
  143147. requestAnimationFrame(callback: FrameRequestCallback): number;
  143148. /**
  143149. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  143150. * Repeat calls while already presenting will update the VRLayers being displayed.
  143151. * @param layers Define the list of layer to present
  143152. * @returns a promise to know when the request has been fulfilled
  143153. */
  143154. requestPresent(layers: VRLayer[]): Promise<void>;
  143155. /**
  143156. * Reset the pose for this display, treating its current position and
  143157. * orientation as the "origin/zero" values. VRPose.position,
  143158. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  143159. * updated when calling resetPose(). This should be called in only
  143160. * sitting-space experiences.
  143161. */
  143162. resetPose(): void;
  143163. /**
  143164. * The VRLayer provided to the VRDisplay will be captured and presented
  143165. * in the HMD. Calling this function has the same effect on the source
  143166. * canvas as any other operation that uses its source image, and canvases
  143167. * created without preserveDrawingBuffer set to true will be cleared.
  143168. * @param pose Define the pose to submit
  143169. */
  143170. submitFrame(pose?: VRPose): void;
  143171. }
  143172. declare var VRDisplay: {
  143173. prototype: VRDisplay;
  143174. new(): VRDisplay;
  143175. };
  143176. interface VRLayer {
  143177. leftBounds?: number[] | Float32Array | null;
  143178. rightBounds?: number[] | Float32Array | null;
  143179. source?: HTMLCanvasElement | null;
  143180. }
  143181. interface VRDisplayCapabilities {
  143182. readonly canPresent: boolean;
  143183. readonly hasExternalDisplay: boolean;
  143184. readonly hasOrientation: boolean;
  143185. readonly hasPosition: boolean;
  143186. readonly maxLayers: number;
  143187. }
  143188. interface VREyeParameters {
  143189. /** @deprecated */
  143190. readonly fieldOfView: VRFieldOfView;
  143191. readonly offset: Float32Array;
  143192. readonly renderHeight: number;
  143193. readonly renderWidth: number;
  143194. }
  143195. interface VRFieldOfView {
  143196. readonly downDegrees: number;
  143197. readonly leftDegrees: number;
  143198. readonly rightDegrees: number;
  143199. readonly upDegrees: number;
  143200. }
  143201. interface VRFrameData {
  143202. readonly leftProjectionMatrix: Float32Array;
  143203. readonly leftViewMatrix: Float32Array;
  143204. readonly pose: VRPose;
  143205. readonly rightProjectionMatrix: Float32Array;
  143206. readonly rightViewMatrix: Float32Array;
  143207. readonly timestamp: number;
  143208. }
  143209. interface VRPose {
  143210. readonly angularAcceleration: Float32Array | null;
  143211. readonly angularVelocity: Float32Array | null;
  143212. readonly linearAcceleration: Float32Array | null;
  143213. readonly linearVelocity: Float32Array | null;
  143214. readonly orientation: Float32Array | null;
  143215. readonly position: Float32Array | null;
  143216. readonly timestamp: number;
  143217. }
  143218. interface VRStageParameters {
  143219. sittingToStandingTransform?: Float32Array;
  143220. sizeX?: number;
  143221. sizeY?: number;
  143222. }
  143223. interface Navigator {
  143224. getVRDisplays(): Promise<VRDisplay[]>;
  143225. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  143226. }
  143227. interface Window {
  143228. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  143229. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  143230. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  143231. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  143232. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  143233. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  143234. }
  143235. interface Gamepad {
  143236. readonly displayId: number;
  143237. }
  143238. type XRSessionMode =
  143239. | "inline"
  143240. | "immersive-vr"
  143241. | "immersive-ar";
  143242. type XRReferenceSpaceType =
  143243. | "viewer"
  143244. | "local"
  143245. | "local-floor"
  143246. | "bounded-floor"
  143247. | "unbounded";
  143248. type XREnvironmentBlendMode =
  143249. | "opaque"
  143250. | "additive"
  143251. | "alpha-blend";
  143252. type XRVisibilityState =
  143253. | "visible"
  143254. | "visible-blurred"
  143255. | "hidden";
  143256. type XRHandedness =
  143257. | "none"
  143258. | "left"
  143259. | "right";
  143260. type XRTargetRayMode =
  143261. | "gaze"
  143262. | "tracked-pointer"
  143263. | "screen";
  143264. type XREye =
  143265. | "none"
  143266. | "left"
  143267. | "right";
  143268. interface XRSpace extends EventTarget {
  143269. }
  143270. interface XRRenderState {
  143271. depthNear?: number;
  143272. depthFar?: number;
  143273. inlineVerticalFieldOfView?: number;
  143274. baseLayer?: XRWebGLLayer;
  143275. }
  143276. interface XRInputSource {
  143277. handedness: XRHandedness;
  143278. targetRayMode: XRTargetRayMode;
  143279. targetRaySpace: XRSpace;
  143280. gripSpace: XRSpace | undefined;
  143281. gamepad: Gamepad | undefined;
  143282. profiles: Array<string>;
  143283. }
  143284. interface XRSessionInit {
  143285. optionalFeatures?: XRReferenceSpaceType[];
  143286. requiredFeatures?: XRReferenceSpaceType[];
  143287. }
  143288. interface XRSession extends XRAnchorCreator {
  143289. addEventListener: Function;
  143290. removeEventListener: Function;
  143291. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  143292. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  143293. requestAnimationFrame: Function;
  143294. end(): Promise<void>;
  143295. renderState: XRRenderState;
  143296. inputSources: Array<XRInputSource>;
  143297. // AR hit test
  143298. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  143299. updateWorldTrackingState(options: {
  143300. planeDetectionState?: { enabled: boolean; }
  143301. }): void;
  143302. }
  143303. interface XRReferenceSpace extends XRSpace {
  143304. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  143305. onreset: any;
  143306. }
  143307. type XRPlaneSet = Set<XRPlane>;
  143308. type XRAnchorSet = Set<XRAnchor>;
  143309. interface XRFrame {
  143310. session: XRSession;
  143311. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  143312. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  143313. // Anchors
  143314. trackedAnchors?: XRAnchorSet;
  143315. // Planes
  143316. worldInformation: {
  143317. detectedPlanes?: XRPlaneSet;
  143318. };
  143319. }
  143320. interface XRViewerPose extends XRPose {
  143321. views: Array<XRView>;
  143322. }
  143323. interface XRPose {
  143324. transform: XRRigidTransform;
  143325. emulatedPosition: boolean;
  143326. }
  143327. interface XRWebGLLayerOptions {
  143328. antialias?: boolean;
  143329. depth?: boolean;
  143330. stencil?: boolean;
  143331. alpha?: boolean;
  143332. multiview?: boolean;
  143333. framebufferScaleFactor?: number;
  143334. }
  143335. declare var XRWebGLLayer: {
  143336. prototype: XRWebGLLayer;
  143337. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  143338. };
  143339. interface XRWebGLLayer {
  143340. framebuffer: WebGLFramebuffer;
  143341. framebufferWidth: number;
  143342. framebufferHeight: number;
  143343. getViewport: Function;
  143344. }
  143345. declare class XRRigidTransform {
  143346. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  143347. position: DOMPointReadOnly;
  143348. orientation: DOMPointReadOnly;
  143349. matrix: Float32Array;
  143350. inverse: XRRigidTransform;
  143351. }
  143352. interface XRView {
  143353. eye: XREye;
  143354. projectionMatrix: Float32Array;
  143355. transform: XRRigidTransform;
  143356. }
  143357. interface XRInputSourceChangeEvent {
  143358. session: XRSession;
  143359. removed: Array<XRInputSource>;
  143360. added: Array<XRInputSource>;
  143361. }
  143362. interface XRInputSourceEvent extends Event {
  143363. readonly frame: XRFrame;
  143364. readonly inputSource: XRInputSource;
  143365. }
  143366. // Experimental(er) features
  143367. declare class XRRay {
  143368. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  143369. origin: DOMPointReadOnly;
  143370. direction: DOMPointReadOnly;
  143371. matrix: Float32Array;
  143372. }
  143373. interface XRHitResult {
  143374. hitMatrix: Float32Array;
  143375. }
  143376. interface XRAnchor {
  143377. // remove?
  143378. id?: string;
  143379. anchorSpace: XRSpace;
  143380. lastChangedTime: number;
  143381. detach(): void;
  143382. }
  143383. interface XRPlane extends XRAnchorCreator {
  143384. orientation: "Horizontal" | "Vertical";
  143385. planeSpace: XRSpace;
  143386. polygon: Array<DOMPointReadOnly>;
  143387. lastChangedTime: number;
  143388. }
  143389. interface XRAnchorCreator {
  143390. // AR Anchors
  143391. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  143392. }